ntp时间同步

公司需要ntp时间同步的操作文档,在网上看到好多的文档都不行;捣鼓了好久终于弄好了,写出来希望给后来的人一些方便

 环境server 192.168.2.50

client 192.168.2.52

在server上配置好yum

yum安装ntp

yum install ntp

修改ntp配置文件

vim /etc/ntp.conf

driftfile /var/lib/ntp/drift
restrict default nomodify notrap  (不限制任何机器对其同步时间)
restrict 127.0.0.1
restrict -6 ::1
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
server 127.127.1.0(同步本地时间)
fudge 127.127.1.0 stratum 8


重启ntp服务

service ntpd restart

netstat -tulnp|grep ntp

udp        0      0 192.168.2.58:123            0.0.0.0:*                               30234/ntpd          
udp        0      0 192.168.2.54:123            0.0.0.0:*                               30234/ntpd          
udp        0      0 169.254.232.49:123          0.0.0.0:*                               30234/ntpd          
udp        0      0 169.254.30.234:123          0.0.0.0:*                               30234/ntpd          
udp        0      0 10.10.4.52:123              0.0.0.0:*                               30234/ntpd          
udp        0      0 10.10.3.52:123              0.0.0.0:*                               30234/ntpd          
udp        0      0 10.10.2.52:123              0.0.0.0:*                               30234/ntpd          
udp        0      0 10.10.1.52:123              0.0.0.0:*                               30234/ntpd          
udp        0      0 192.168.2.52:123            0.0.0.0:*                               30234/ntpd          
udp        0      0 127.0.0.1:123               0.0.0.0:*                               30234/ntpd          
udp        0      0 0.0.0.0:123                 0.0.0.0:*                               30234/ntpd          
udp        0      0 fe80::26be:5ff:ff89:1b72:123 :::*                                    30234/ntpd          
udp        0      0 fe80::26be:5ff:ff89:1b71:123 :::*                                    30234/ntpd          
udp        0      0 fe80::202:c903:19:c011:123  :::*                                    30234/ntpd          
udp        0      0 fe80::202:c903:19:c012:123  :::*                                    30234/ntpd          
udp        0      0 fe80::ec4:7aff:fea8:b008:123 :::*                                    30234/ntpd          
udp        0      0 ::1:123                     :::*                                    30234/ntpd          
udp        0      0 :::123                      :::*                                    30234/ntpd      



客户端配置

yum install ntp

vim /etc/ntp.conf

driftfile /var/lib/ntp/drift
restrict 127.0.0.1
restrict -6 ::1
server 192.168.2.52(选择ntp服务器)
restrict 192.168.2.52 nomodify notrap noquery
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
server 127.0.0.1
fudge 127.127.1.0 stratum 8

完成后在客户端 ntpdate -u 192.168.2.52验证是否成功或者等待2-3小时后两台机器自己就会同步(具体机制不太清楚)


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值