chrony时间同步 服务端 客户端 安装配置
原创内容http://www.cnblogs.com/elvi/p/7658021.html
#!/bin/sh
#运行环境 centos7
#chrony时间同步 服务端 客户端 安装配置 #安装
yum install chrony -y
cp /etc/chrony.conf{,.bak} #备份默认配置 #chrony服务配置
echo "
# #外部NTP服务#
server ntp6.aliyun.com iburst
server cn.ntp.org.cn iburst
server ntp.shu.edu.cn iburst
driftfile /var/lib/chrony/drift
driftfile /var/lib/chrony/drift
makestep 1.0
rtcsync
logdir /var/log/chrony
">/etc/chrony.conf #chrony作为内网NTP服务配置
echo "
# #外部NTP服务
server ntp6.aliyun.com iburst
server cn.ntp.org.cn iburst
server ntp.shu.edu.cn iburst
driftfile /var/lib/chrony/drift
makestep 1.0
rtcsync
# #内网
allow 10.2.1.0/
allow 172.16.11.0/
bindcmdaddress 127.0.0.1
bindcmdaddress ::
keyfile /etc/chrony.keys
commandkey
generatecommandkey
noclientlog
logchange 0.5
logdir /var/log/chrony
">/etc/chrony.conf #chrony使用内网NTP服务配置
echo "
# #内部NTP服务
server 10.2.1.10 iburst
server ntp6.aliyun.com iburst
driftfile /var/lib/chrony/drift
makestep 1.0
rtcsync
logdir /var/log/chrony
">/etc/chrony.conf #启动
systemctl start chronyd
systemctl enable chronyd #开机启动
systemctl restart chronyd
chronyc sources #查看同步源 ##查看 chronyc sources #服务端
# Number of sources =
# MS Name/IP address Stratum Poll Reach LastRx Last sample
# ===============================================================================
# ^* time6.aliyun.com -2307us[-3126us] +/- 20ms
# ^+ xk---a8.bta.net.cn +767us[ +767us] +/- 62ms
# ^- ntp.shu.edu.cn -11ms[ -11ms] +/- 419ms # # chronyc sources #客户端
# Number of sources =
# MS Name/IP address Stratum Poll Reach LastRx Last sample
# ===============================================================================
# ^* kweb.w.dev -99us[ +160us] +/- 21ms