以下为个人测试环境仅供参考:
172.16.1.11节点:
yum install -y ntp
vi /etc/ntp.conf
##server 0.centos.pool.ntp.org iburst --注释上
##server 1.centos.pool.ntp.org iburst
##server 2.centos.pool.ntp.org iburst
##server 3.centos.pool.ntp.org iburst
server 127.127.1.0 iburst --加这个
[root@hdfs ~]# systemctl restart ntpd.service
[root@hdfs ~]# systemctl status ntpd.service
172.16.1.12节点:
[root@db2 mnt]# netstat -anptu |grep 123 --测试端口开没开
[root@db2 mnt]# vi /etc/ntp.conf
##server 0.centos.pool.ntp.org iburst --注释上
##server 1.centos.pool.ntp.org iburst
##server 2.centos.pool.ntp.org iburst
##server 3.centos.pool.ntp.org iburst
server 172.16.1.11
restrict 172.16.1.11 mask 255.255.0.0 nomodify notrap
[root@db2 mnt]# systemctl stop ntpd.service
必须关闭进程后才能同步主服务节点的时间,然后再重启,显示成功。
[root@db2 mnt]# ntpdate 172.16.1.11
systemctl restart ntpd.service
systemctl status ntpd.service
172.16.1.13节点:
[root@db2 mnt]# vi /etc/ntp.conf
##server 0.centos.pool.ntp.org iburst --注释上要不会报错
##server 1.centos.pool.ntp.org iburst
##server 2.centos.pool.ntp.org iburst
##server 3.centos.pool.ntp.org iburst
server 172.16.1.11
restrict 172.16.1.11 mask 255.255.0.0 nomodify notrap
[root@db3 ~]# systemctl stop ntpd.service
[root@db3 ~]# ntpdate 172.16.1.11
成功!!
systemctl restart ntpd.service
systemctl status ntpd.service
ntpdate -u 172.16.1.11 或不加u
同步后所有节点date检查时间同步情况。
设置开机自启:
chkconfig ntpd on