ntp服务器(192.168.0.242 node2)(暂时没测试出来,不使用)
- 下载
yum install ntp -y
- 配置
vi /etc/ntp.conf
image.png... #restrict default nomodify notrap nopeer noquery restrict default nomodify #允许其他任意ip主机同步 ... server 127.0.0.1 # 使用本地时间 fudge 127.0.0.1 stratum 10 ... #server 0.centos.pool.ntp.org iburst #server 1.centos.pool.ntp.org iburst #server 2.centos.pool.ntp.org iburst #server 3.centos.pool.ntp.org iburst ...
- 启动服务
systemctl start ntpd
systemctl enable ntpd
- 查看
ntpq -p
image.png
ntp客户端(192.168.0.242 nod3)(暂时没测试出来,不使用)
- 下载
yum install ntp -y
- 配置
vi /etc/ntp.conf
image.png... #server 0.centos.pool.ntp.org iburst #server 1.centos.pool.ntp.org iburst #server 2.centos.pool.ntp.org iburst #server 3.centos.pool.ntp.org iburst server node2 iburst ...
- 启动服务
systemctl start ntpd
systemctl enable ntpd
- 查看
ntpq -p
image.png- 验证
- chrony服务器
- 下载:
yum install chrony
- 配置:
vi /etc/chrony.conf
image.png#server 0.centos.pool.ntp.org iburst #server 1.centos.pool.ntp.org iburst #server 2.centos.pool.ntp.org iburst #server 3.centos.pool.ntp.org iburst server ntp1.aliyun.com iburst #如果是局域网的话就不需要这个 allow 192.168.0.0/24 local stratum 10 bindcmdaddress 127.0.0.1 bindcmdaddress ::1
- 启动
systemctl enable chronyd
systemctl start chronyd
- 验证
chronyc sources -v
image.png
- chrony客户端
- 下载:
yum install chrony
- 配置:
vi /etc/chrony.conf
image.png#server 0.centos.pool.ntp.org iburst #server 1.centos.pool.ntp.org iburst #server 2.centos.pool.ntp.org iburst #server 3.centos.pool.ntp.org iburst server node2 iburst
- 启动
systemctl enable chronyd
systemctl start chronyd
- 验证
chronyc sources -v
注:MS
字段中S
为*
才算连接上
image.png- 测试
修改客户端的时间:date -s 14:00:00
然后重启chronyd:systemctl restart chronyd
就可以重新对时
通过systemctl status chronyd
,可以查看日志
image.png
网友评论