所有服务器安装ntp(服务器启动ntpd,客户端关闭ntpd)
服务端配置
服务器关闭防火墙或者开发123端口用于同步时间使用
- yum install -y ntp
- systemctl stop firewalld
- systemctl disable firewalld
修改ntp服务端配置文件(注释掉其他server 数字 主机地址)
vi /etc/ntp.conf
添加修改
restrict 192.168.5.0 mask 255.255.255.0 nomodify notrap #运行哪个子网时间同步
server 127.127.1.0
fudge 127.127.1.0 stratun 10
service master
保存退出
开机自启动
systemctl enable ntpd
重启ntpd
systemctl restart ntpd
查看ntpd
watch ntpq -p
客户端配置
- yum install -y ntp
- systemctl disable ntpd
- systemctl stop ntpd
- ps -ef|grep ntpd
- kill -9 进程id
同步时间
crontab -e
添加
*/1 * * * * /usr/sbin/ntpdate master
保存退出