环境说明
- 三台虚拟机 agent、server、state
- centos7版本为 CentOS-7-x86_64-Minimal-1810
agent端设置时区为上海时区
timedatectl set-ntp no
timedatectl list-timezones
timedatectl set-timezone Asia/Shanghai
timedatectl
#退出当前登录会话
ctrl + D
# 重新登录agent虚拟机,并查看时间是否已经修改成功
timedatectl
date
server、state端设置与agent端时间同步
yum -y install ntp ntpdate
vim /etc/ntp.conf
#编辑内容如下
restrict 127.0.0.1
restrict -6 ::1
restrict default ignore
server agent-ip
fudge agent-ip stratum 8
vi /etc/sysconfig/ntpd
OPTIONS="-g -l /var/log/ntpstats/ntpd.log"
#配置开机自启动
chkconfig ntpd on
#启动ntpd服务
service ntpd start
网友评论