时间同步
程序员文章站
2022-05-31 09:29:32
...
-
安装ntp服务
yum -y install ntp
-
设置开机启动
service ntpd start chkconfig ntpd on
-
配置时间服务器
3.1 主节点: sudo vi /etc/ntp.confdriftfile /var/lib/ntp/drift restrict default kod nomodify notrap nopeer noquery restrict -6 default kod nomodify notrap nopeer noquery restrict 127.0.0.1 restrict -6 ::1 restrict 192.168.100.0 mask 255.255.255.0 nomodify notrap # 给192.168.100.0网段,子网掩码为255.255.255.0的局域网机的机器有同>步时间的权限 server ntp1.aliyun.com prefer server 127.127.1.0 # localclock includefile /etc/ntp/crypto/pw keys /etc/ntp/keys
3.2 需要同步节点:sudo vi /etc/ntp.conf
driftfile /var/lib/ntp/drift
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict -6 ::1
server 192.168.100.110 # 主节点IP
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
-
重启ntp服务,5-10分钟之后同步成功
service ntpd restart