◆案例◆ 配置NTP时间同步服务器
◆NTP-服务端配置◆
1.安装NTP
yum install -y ntp ntp-date
2.编辑NTP主配置文件
编辑配置文件,修改以下标★语句
vim /etc/ntp.conf 19 # Use public servers from the pool.ntp.org project. 20 # Please consider joining the pool (http://www.pool.ntp.org/join.html). ★ #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 #注释掉,不使用网络同步 25 ★ restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap #允许192.168.1.0/24网段来获取 ★ server 127.127.1.0 #本服务器,地址反写 ★ fudge 127.127.1.0 stratum 10 #定义权威服务器,级别10
3重启NTP服务
systemctl restart ntpd
◆NTP-客户端同步◆
1.安装NTP
yum install -y ntp ntp-date
2.NTP同步时间
ntpdate -u 192.168.1.0 #指定NTP服务器IP
3.写入crond
crontable -e */20 * * * * ntpdate –u 192.168.22.191 &>/dev/null systemctl restart crond