10.安装NTP时钟同步
#查看chrony服务是否存在
systemctl status chrony
systemctl stop chronyd
systemctl disable chronyd
使用ntp服务
1. ntp服务端配置
1.1 安装启动ntp服务
date # 查看系统时间
## 安装
yum -y install net-tools # netstat
yum -y install ntp
systemctl start ntpd
systemctl status ntpd
systemctl enable ntpd
1.2 修改/etc/ntp.conf
vim /etc/ntp.conf
#注释配置
#server o.rhel.pool.ntp.org.iburst
#server 1.rhel.pool.ntp.org.iburst
#server 2.rhel.pool.ntp.org.iburst
#server 3.rhel.pool.ntp.org.iburst
#在已经注释下的配置增加一些配置
server 127.127.1.0
fudge 127.127.1.0 stratum 10
1.3 修改/etc/sysconfig/ntpd文件
vim /etc/sysconfig/ntpd
#添加内容如下,用于保证硬件时间与系统时间一致
SYNC_HWCLOCK=yes
1.4 重启ntp
systemctl restart ntpd
#查看NTP状态
ntpstat
#列出上层NTP服务器的连接状态
ntpq -p
2. ntp客户端配置
2.1. 安装,同步时间
yum -y install ntp
#同步时间ntpdate 服务端ip
ntpdate 172.21.32.198
2.2 修改/etc/ntp.conf文件
vim /etc/ntp.conf
#注释配置
#server o.rhel.pool.ntp.org.iburst
#server 1.rhel.pool.ntp.org.iburst
#server 2.rhel.pool.ntp.org.iburst
#server 3.rhel.pool.ntp.org.iburst
#在已经注释下的配置增加一些配置
#授权192.168.1.0-192.168.1.255网段上的所有机器可以从这台机器上查询和同步时间
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
restrict 172.21.30.0 mask 255.255.255.0 nomodify notrap
server 服务端ip
#server 127.127.1.0
2.3 重启ntp
systemctl restart ntpd
systemctl status ntpd