当我们使用多台硬件机器部署分布式或者集群环境的时候,往往需要每太机器的时间同步,可使用NTP服务
[root@node1 ~]# yum install ntp ## 配置yum源后,在每个节点上执行安装ntp服务
每个节点都安装ntp服务后,指定一个服务节点( node1),其他作为同步节点( node2...node6),node2到node6节点与node1的时间进行同步;
[root@node1 ~]# vi /etc/ntp.conf ## 注释原有server开头的服务配置,指定server为当前节点 # Use public servers from the pool.ntp.org project. # Please consider joining the pool (http://www.pool.ntp.org/join.html). #server ntp.aliyun.com ## 注释行 server 127.127.1.0 ## 添加行 [root@node1 ~]# systemctl restart ntpd
[root@node2 ~]# vi /etc/ntp.conf ## 注释原有server开头的服务配置,指定server为node1,重启ntpd服务 # Use public servers from the pool.ntp.org project. # Please consider joining the pool (http://www.pool.ntp.org/join.html). #server ntp.aliyun.com ## 注释行 server node1 iburst ## 添加行 [root@node2 ~]# systemctl restart ntpd
所有同步节点均按照node2节点修改
配置完成后,可等待让其自动同步,也可以使用手动同步时间,在所有同步节点执行
[root@node2 ~]# ntpdate -u node1
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69985104/viewspace-2743460/ ,如需转载,请注明出处,否则将追究法律责任。