ntp服务器端
yum install -y ntp
修改配置文件
vim /etc/ntp.conf
注释以下行
#restrict default kod nomodify notrap nopeer noquery
设置时间服务器地址
server 互联网时间服务器域名或ip地址 iburst # iburst用于加速
centos6
chkconfig ntpd on
# 设置开机启动
service ntpd start
# 启动ntp服务
centos7
sytemctl enable ntpd
# 设置开机启动
sytemctl start ntpd
# 启动ntp服务
ntpq -p
# 查看同步状态
ntp客户端
修改配置文件
vim /etc/ntp.conf
设置时间服务器地址
server 局域网时间服务器域名或ip地址 iburst # iburst用于加速
centos6
chkconfig ntpd on
# 设置开机启动
service ntpd start
# 启动ntp服务
centos7
sytemctl enable ntpd
# 设置开机启动
sytemctl start ntpd
# 启动ntp服务
ntpq -p
# 查看同步状态
chrony服务器端
1yum install -y chrony
修改配置文件
vim /etc/chrony.conf
server 互联网时间服务器域名或ip地址 iburst # iburst用于加速
allow 0.0.0.0/0
local stratum 10
centos6
chkconfig chronyd on
# 设置开机启动
service chronyd start
# 启动ntp服务
centos7
sytemctl enable chronyd
# 设置开机启动
sytemctl start chronyd
# 启动ntp服务
ntpq -p
# 查看同步状态
chrony客户端
修改配置文件
vim /etc/chrony.conf
server 互联网时间服务器域名或ip地址 iburst # iburst用于加速
centos6
chkconfig chronyd on
# 设置开机启动
service chronyd start
# 启动ntp服务
centos7
sytemctl enable chronyd
# 设置开机启动
sytemctl start chronyd
# 启动ntp服务
ntpq -p
# 查看同步状态