环境介绍:
系统:centos7
防火墙:关闭防火墙和selinux
软件:chrony
centos6我们一直用的ntp时间服务器,虽然到CentOS7上也可以装ntp。但是各种问题。所以建议centos7使用chrony同步工具。
服务端配置:
1.安装chrony软件
[root@server ~]# yum install chrony -y
2.修改配置文件
[root@server ~]# vim /etc/chrony.conf
server 0.centos.pool.ntp.org iburst #可以修改ntp的服务器。最好用国内的。
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburst
allow 172.19.150.0/24 #打开允许同步的IP
阿里ntp的服务器列表
time1.aliyun.com
time2.aliyun.com
time3.aliyun.com
time4.aliyun.com
time5.aliyun.com
time6.aliyun.com
time7.aliyun.com
3.启动、开机自启动、查看状态、查看同步源
[root@server ~]# systemctl start chronyd
[root@server ~]# systemctl enable chronyd
[root@server ~]# systemctl status chronyd
● chronyd.service - NTP client/server
Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor preset: enabled)
Active: active (running) since 一 2018-04-23 11:25:38 CST; 6min ago
[root@server ~]# chronyc sources
210 Number of sources = 1
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* time4.aliyun.com 2 6 17 41 +87us[+1374us] +/- 28ms
客户端配置:
1. 安装chrony
[root@client ~]# yum install chrony -y
2. 修改配置文件
[root@client ~]# vim /etc/chrony.conf
# Use public servers from the pool.ntp.org project.
# 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
server 172.19.150.105 iburst #添加server
3.启动、开机自启动、查看状态、查看同步源
[root@client ~]# date
Sat Sep 9 00:00:02 CST 2017
[root@client ~]# systemctl start chronyd
[root@client ~]# systemctl enable chronyd
[root@client ~]# systemctl status chronyd
● chronyd.service - NTP client/server
Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2017-09-09 00:00:11 CST; 7 months 13 days ago
Docs: man:chronyd(8)
[root@client ~]# date
Sat Sep 9 00:00:13 CST 2017
[root@client ~]# chronyc sources
210 Number of sources = 1
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* 172.19.150.105 3 6 17 3 +52us[ +107us] +/- 32ms
###最后一条有*号表示同步成功