【笔记】集群时间同步
前言
通过ntp命令,实现集群间时间同步
配置主机
修改ntp配置文件
- 为以下内容去除注释
1 | restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap |
- 为以下内容添加注释
1 | #server 0.centos.pool.ntp.org iburst |
- 文件末尾添加配置,确保NTP服务从本地时钟获取时间
1 | server 127.127.1.0 |
修改ntpd配置文件
- 添加以下内容,同步硬件时钟
1 | SYNC_HWCLOCK=yes |
重启ntp服务
1 | service ntpd restart |
设置ntp服务开机启动
1 | chkconfig ntpd on |
配置从机
- 每隔1分钟同步一次时间
1 | crontab -e |
<ip>:主机IP地址
1 | */1 * * * * /usr/sbin/ntpdate <ip> |