1.安装ntp 以及ntpdate:yum –y install ntp ntpdate
2.编辑配置文件: vi /etc/ntp.conf
备注:原来有关server的一行可以全部注释或删掉,新增 server 127.127.1.0 以及fudge 127.127.1.0 stratum 10 两行
restrict 可以根据运行的ip或者ip段进行权限控制。
3. 保存配置文件::wq
4. 重启服务:systemctl restart ntpd
5.查看udp 123端口是否监听:netstat –nulp |grep 123
6.ntp 客户端 进行debug :netdate –d ntp_server_ip
这个命令非常实用,如果ntp server有问题的话,可以根据debug信息找到问题原因
7.ntp客户端进行时间同步:ntpdate ntp_server_ip