linux下时钟同步ntp

ntp的server端的ip为192.168.5.21 hostname为node1

server端 cat /etc/ntp.conf

[root@node1 ~]# cat /etc/ntp.conf
driftfile /var/lib/ntp/drift
restrict default nomodify notrap nopeer noquery
restrict 127.0.0.1 
restrict ::1
restrict 192.168.5.0 mask 255.255.255.0 nomodify notrap
server 127.127.1.0
fudge 127.127.1.0 stratum 8
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
disable monitor

client端 cat /etc/ntp.conf
[root@node2 ~]# cat /etc/ntp.conf

driftfile /var/lib/ntp/drift
restrict default nomodify notrap nopeer noquery

restrict 127.0.0.1 
restrict ::1
restrict 192.168.5.21 nomodify notrap noquery

server 192.168.5.21
fudge 127.127.1.0 stratum 8

includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
disable monitor

配置好之后,在server端
systemctl start ntpd

在client端输入

[root@node2 ~]# ntpdate node1
 7 May 15:24:59 ntpdate[31244]: adjust time server 192.168.5.21 offset 0.004936 sec
 [root@node2 ~]# systemctl start ntpd
[root@node2 ~]# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 192.168.5.21    .INIT.          16 u    -   64    0    0.000    0.000   0.000

说明时钟同步OK

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值