时间:2020.04.17
环境:centos7.6.1810
目的:通过配置NTP实现多台服务器时间同步
说明:模式为1主多从 主服务主机服务器名称为node1 已配置DNS解析 网段为192.168.100.0
作者:Zhong QQ交流群:121160124 欢迎加入!
所有主机查看时区时间等相关信息并设置时区
timedatectl #
timedatectl list-timezones #
timedatectl set-timezone Asia/Shanghai # 设置时区为上海
所有主机安装ntpd服务
yum install ntp -y
主服务主机编辑配置文件ntp.conf
vim /etc/ntp.conf
# 增加以下的设置
server 127.127.1.0 iburst local clock #当外部时间不不可⽤用时,可使⽤用本地硬件时间
restrict 192.168.100.0 mask 255.255.255.0 nomodify notrap #允许同一网段主机同步时间
主服务主机启动服务查看状态
systemctl start ntpd
systemctl enable ntpd
systemctl status ntpd
ntpq -p
其它主机配置同步主服务主机时间
systemctl stop ntpd
systemctl disable ntpd
ntpdate node1 # node1为主服务主机名
其它主机配置定时任务每天同步时间
cro