第1章 ntp
1.1 ntp简介
NTP(Network Time Protocol,网络时间协议)是用来使网络中的各个计算机时间同步的一种协议。它的用途是把计算机的时钟同步到世界协调时UTC,其精度在局域网内可达0.1ms,在互联网上绝大多数的地方其精度可以达到1-50ms。
1.2 ntp服务端部署
1.2. 环境说明
使用系统:CentOS 7.4 (CentOS6自带 CentOS7需要安装的)
ip地址: 外网-10.0.0.62 内网-172.16.1.62
1.2. 安装ntp
yum -y install ntp
1.2. 修改配置文件
vim /etc/ntp.conf #添加
restrict 172.16.1.0 mask 255.255.255.0 nomodify notrap
server ntp1.aliyun.com
1.2. 启动
systemctl start ntpd #启动
systemctl status ntpd #查看状态
[root@m02 ~]# ntpstat #查看是否正常
synchronised (同步的) to NTP server (5.79.108.34) at stratum
time correct to within ms
polling server every s
1.1 客户端使用
1.3. 测试
ntpdate 172.16.1.62
ntpdate -d 172.16.1.62
1.3. 加入定时任务
echo "*/5 * * * * /usr/sbin/ntpdate 172.16.1.62 &>/dev/null" >>/var/spool/cron/root