NTP时间同步

步骤一:部署NTP服务

1)安装软件包
[root@proxy ~]# yum -y install chrony
[root@proxy ~]# rpm -qc chrony                        //查看配置文件列表
/etc/chrony.conf
/etc/chrony.keys
.. ..
2)修改配置文件
[root@proxy ~]# cat /etc/chrony.conf
.. ..
server 0.centos.pool.ntp.org iburst         //server用户客户端指向上层NTP服务器
allow 192.168.4.0/24                        //允许那个IP或网络访问NTP
#deny  192.168.4.1                        //拒绝那个IP或网络访问NTP
local stratum 10                            //设置NTP服务器的层数量
.. ..
4)启动NTP服务
[root@proxy ~]# systemctl  restart  chronyd
[root@proxy ~]# systemctl  enable  chronyd
5)设置防火墙
[root@proxy ~]# firewall-cmd --set-default-zone=trusted
步骤二:配置客户端

1)安装软件包
[root@client ~]# yum -y install chrony
2) 修改配置文件
[root@client ~]# vim /etc/chrony.conf
server 192.168.4.5 iburst                //设置与哪台服务器同步数据
                                        //iburst参数设置重启服务后尽快同步时间
3) 将客户端时间修改为错误的时间
[root@client ~]#  date  -s  "hour:minute"         //调整时间(小时:分钟)
[root@client ~]#  date                            //查看修改后的时间
4) 重启chrony与服务器同步时间
[root@client ~]# systemctl  restart  chronyd
5) 确认时间是否已经同步
[root@client ~]# date                            //多执行几次查看结果

 

posted @ 2018-12-26 15:48  Ray_chen  阅读(192)  评论(0编辑  收藏  举报