在master,slave1,slave2上安装ntp以及ntpdate
将所有的机器的ntp都关闭掉
使用service ntp status查看三台机器的ntp状态
使用ctrl+c退出当前状态
修改ntp server (仅在master即可) 的/etc/ntp.conf
在/etc/目录下,使用crontab -e命令进入 /etc/ntp.conf
在vim中找到这一段文字,相应的地方注释掉,然后添加红框中的语句
```bash server 127.127.1.0 fudge 127.127.1.0 stratum 10
13. ![](https://strongwillpro.oss-cn-beijing.aliyuncs.com/img/20221011201002.png)
14. ![](https://strongwillpro.oss-cn-beijing.aliyuncs.com/img/20221011201343.png)
15. 这个地方去掉相应的#,然后填上
16. ```
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
然后对ntp server (master) 执行sudo service ntp start 开启服务
在slave1,slave2机器,将同步时间的命令放在crontab中(以slave1为例)
第一步,在etc路径下运行crontab -e
退出方式:ctrl + x 然后问你是否保存,按y,然后回车即可保存并退出,slave2同理修改
最后,运行sudo ntpdate master 进行同步时间的操作即可