CentOS7.2 chrony替代ntp搭建时间服务器

chrony既可作时间服务器服务端,也可作客户端。

最近在测试chrony,发现chrony性能比ntp要好很多,且chrony配置简单、管理方便,决定记录和大家分享一下。

一、配置接口时间服务器(连接更精确时间服务器的服务器),假设IP为192.168.1.1

1.安装所需包

[plain]  view plain  copy
  1. yum install chrony -y  

2.配置chrony主配置文件如下:

[plain]  view plain  copy
  1. cat <<EOF> /etc/chrony.conf    
  2. server s2m.time.edu.cn iburst    
  3. stratumweight 0    
  4. driftfile /var/lib/chrony/drift    
  5. rtcsync    
  6. makestep 10 3    
  7. allow 192.168.1.0/24    
  8. bindcmdaddress 127.0.0.1    
  9. bindcmdaddress ::1    
  10. keyfile /etc/chrony.keys    
  11. commandkey 1    
  12. generatecommandkey    
  13. noclientlog    
  14. logchange 0.5    
  15. logdir /var/log/chrony    
  16. EOF    

3.启动chrony服务并设定开机自启

[plain]  view plain  copy
  1. systemctl enable chronyd.service    
  2. systemctl start chronyd.service   

二、配置其他服务器(类似以往装有ntpdate的服务器)

1.安装所需包

[plain]  view plain  copy
  1. yum install chrony -y  

2.配置chrony主配置文件如下:

[plain]  view plain  copy
  1. cat <<EOF> /etc/chrony.conf    
  2. server 192.168.1.1 iburst    
  3. stratumweight 0    
  4. driftfile /var/lib/chrony/drift    
  5. rtcsync    
  6. makestep 10 3    
  7. allow 192.168.1.0/24    
  8. bindcmdaddress 127.0.0.1    
  9. bindcmdaddress ::1    
  10. keyfile /etc/chrony.keys    
  11. commandkey 1    
  12. generatecommandkey    
  13. noclientlog    
  14. logchange 0.5    
  15. logdir /var/log/chrony    
  16. EOF    

3.启动chrony服务并设定开机自启

[plain]  view plain  copy
  1. systemctl enable chronyd.service    
  2. systemctl start chronyd.service   

三、验证:

1.接口服务器,执行如下:

[plain]  view plain  copy
  1. #chronyc sources  
  2. 210 Number of sources = 1  
  3. MS Name/IP address         Stratum Poll Reach LastRx Last sample  
  4. ===============================================================================  
  5. ^* ns.pku.edu.cn                 2   7   377    49    -37us[  -50us] +/-  207ms  
出现如上即为配置成功。

2.其他服务器,执行如下:

[plain]  view plain  copy
  1. #chronyc sources  
  2. 210 Number of sources = 1  
  3. MS Name/IP address         Stratum Poll Reach LastRx Last sample  
  4. ===============================================================================  
  5. ^* 192.168.1.1                 2   7   377    49    -37us[  -50us] +/-  207ms  

出现如上即为配置成功。

出处:https://blog.csdn.net/hnhuangyiyang/article/details/52711631

猜你喜欢

转载自blog.csdn.net/jackliu16/article/details/80328064