服务端
1.安装chrony
$yum -y install chrony
2.备份ntp服务器配置文件
$cp /etc/chrony.conf /etc/chrony.conf.bak
3.修改配置
$cat >/etc/chrony.conf <<'EOF'
server s1a.time.edu.cn iburst
server ntp.aliyun.com iburst
#server 172.16.1.71 iburst #(同步本地时间)
driftfile /var/lib/chrony/drift
makestep 1.0 3
rtcsync
allow 172.16.1.0/24
local stratum 10
logdir /var/log/chrony
EOF
4.开机自启并启动chronyd服务
$systemctl enable chronyd
$systemctl start chronyd
5.查看端口
$netstat -antulp | grep chronyd
udp 0 0 127.0.0.1:323 0.0.0.0:* 1771/chronyd
udp 0 0 0.0.0.0:123 0.0.0.0:* 1771/chronyd
udp6 0 0 ::1:323 :::* 1771/chrony
6.查看是否同步(带*是同步成功)
$chronyc sources -v
210 Number of sources = 2
.-- Source mode '^' = server, '=' = peer, '#' = local clock.
/ .- Source state '*' = current synced, '+' = combined , '-' = not combined,
| / '?' = unreachable, 'x' = time may be in error, '~' = time too variable.
|| .- xxxx [ yyyy ] +/- zzzz
|| Reachability register (octal) -. | xxxx = adjusted offset,
|| Log2(Polling interval) --. | | yyyy = measured offset,
|| \ | | zzzz = estimated error.
|| | | \
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* 60.10.112.202.in-addr.ar> 1 10 377 948 +1431us[+1700us] +/- 21ms
客户端测试
#1.更改时间
$date -s 20190825
#2.同步测试
$ntpdate 172.16.1.*
#3.书写定时任务
$echo "*/5 * * * * /sbin/ntpdate 172.16.1.71 >/dev/null 2>&1" >> /var/spool/cron/root
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。