NTP服务器时间同步

来源:互联网 发布:mysql存储过程语法 编辑:程序博客网 时间:2024/05/22 03:48

1. NTP服务器时间同步

⑴ vi /etc/ntp.conf

restrict 127.0.0.1

restrict -6 ::1

restrict 10.1.4.130 mask 255.255.255.0 nomodify notrap

server  127.127.1.0     # local clock

fudge   127.127.1.0 stratum 10

⑵ 启动ntp服务
#/etc/init.d/ntpd start
添加到自启动
所有节点执行如下命令,让每次系统启动的时候自动启动ntp服务:
chkconfig --level 35 ntpd on

客户端设置

[root@namenode01 ~]#vi /etc/ntp.conf

driftfile /var/lib/ntp/drift 文件里有

server 10.1.4.130

restrict 101.4.130 nomodify notrap noquery

server  127.127.1.0     # local clock

fudge   127.127.1.0 stratum 10

Npt主服务器ip要去掉,只是针对客户的而言

[root@namenode ~]# for i in {32,33,34};do scp /etc/ntp.conf root@10.1.4.1$i:/etc/ntp.conf; done

启动服务

/etc/init.d/ntpd start
添加到自启动
所有节点执行如下命令,让每次系统启动的时候自动启动ntp服务:
chkconfig --level 35 ntpd on

 

所有客户端手动同步时间

[root@namenode01 ~]#ntpdate -u manager

[root@namenode01 ~]# crontab -e

*/5 * * * * root /usr/sbin/ntpdate 10.1.4.130; /sbin/hwclock -w

[root@masternode02 ~]# service crond restart ;chkconfig --level 35 crond on

0 0
原创粉丝点击