搭建时间同步服务器
时间同步服务器
1.安装时间同步服务器的软件chrony
Cent OS7默认安装
yum install -y chrony
2.修改chrony的配置文件
vim /etc/chrony.conf
#将下边的server注释掉或删掉,这是本机器使用的时间同步服务器,我们要让本机作为时间同步服务器,因此,不需要同步别人的时间
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
allow 10.0.0/24 #打开这行的注释,且修改运行访问本台时间同步服务器的网段
local stratum 10 #打开这行注释,这台时间同步服务器的优先级别,级别越高,优先同步
3.安装ntpdate命令
yum install -y ntpdate #ntpdate命令为同步时间命令,本机作为时间同步服务器,首先时间要准确
ntpdate -u ntp1.aliyun.com #向阿里的时间时间同步服务器同步一下时间
4.开启chrony服务
systemctl start chronyd
时间同步客户端配置
1.安装时间同步服务器的软件chrony
Cent OS7默认安装
2.修改chrony的配置文件
vim /etc/chrony.conf
#将下边的server注释掉或删掉,这是本机器使用的时间同步服务器,我们要让本机作为时间同步服务器,因此,不需要同步别人的时间
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
#增加下边这行,时间同步服务器ip
server 10.0.0.143 iburst
allow 10.0.0.139 #打开这行的注释,修改ip为本机ip,意思为允许这个ip访问时间同步服务器
3.开启chrony服务
systemctl start chronyd #开启后,就会同步时间同步服务器的时间
#如果时间同步服务时间改变,需要重启客户端的时间同步服务,才能同步