1.题目要求
chrony服务部署:两台机器
a: 第一台机器从阿里云同步时间
第二台机器从第一台机器同步时间
b: 第一台服务器使用系统时间作为第二台服务器的时钟源, 第一台服务器层级设置为6
2.内容
a:
第一台机子:
查看ip:
[root@hezhihao ~]# ifconfig
设置selinux:
[root@hezhihao ~]# setenforce 0
[root@hezhihao ~]# getenforce
Permissive
关闭防火墙:
[root@hezhihao ~]# systemctl stop firewalld
查看状态:
[root@hezhihao ~]# systemctl status firewalld
![](https://i-blog.csdnimg.cn/blog_migrate/439724ed8783f3a0074d77ba74a5d6cc.png)
[root@hezhihao ~]# systemctl status chronyd
![](https://i-blog.csdnimg.cn/blog_migrate/8f034c095b829a8212ac5ce947e5d4f8.png)
在/etc/chrony.conf配置阿里云
[root@hezhihao ~]# vim /etc/chrony.conf
server ntp.aliyun.com iburst,原先里边的pool使用#注释掉
![](https://i-blog.csdnimg.cn/blog_migrate/0c5b33f11c555edc2b3d5b3a54e5c9a2.png)
allow:默认情况下不允许任何ntp客户端访问,将allow前面的#注释掉
![](https://i-blog.csdnimg.cn/blog_migrate/2037ad0c0600ce895afae7dea37743a5.png)
配置完重启服务
[root@hezhihao ~]# systemctl restart chronyd
测试阿里云,确保链路链路通
[root@hezhihao ~]# ping ntp.aliyun.com
![](https://i-blog.csdnimg.cn/blog_migrate/c75df1570a534c3d540af50f05e20ca9.png)
开启网络时间同步
timedatectl set-ntp true
[root@hezhihao ~]# timedatectl set-ntp true
使用timedatectl
![](https://i-blog.csdnimg.cn/blog_migrate/66ea8b02d8623da49e608d1ad4bdce7a.png)
使用chronyc sources
![](https://i-blog.csdnimg.cn/blog_migrate/f39c9140fa022b293ca649940ead7b1e.png)
使用chronyc tracking
[root@hezhihao ~]# chronyc tracking
![](https://i-blog.csdnimg.cn/blog_migrate/fabe175845cb8d4c92b57cba925ec1f1.png)
第二台机子:
[root@hezhihao1 ~]# systemctl disable firewall
[root@hezhihao1 ~]# systemctl status chronyd
![](https://i-blog.csdnimg.cn/blog_migrate/8a2669c56457508b4d94847993ef5f99.png)
[root@hezhihao1 ~]# vim /etc/chrony.conf
![](https://i-blog.csdnimg.cn/blog_migrate/1779f9eca99514a0f973f8627e67c645.png)
[root@hezhihao1 ~]# systemctl restart chronyd
![](https://i-blog.csdnimg.cn/blog_migrate/8ebca177a940610bdb8abac26700c49b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/7f434656401b2ffe938917f38d0e9869.png)
b:
第一台机子:
配置server ip
![](https://i-blog.csdnimg.cn/blog_migrate/e18adc050ae321d53f97bd60d26bdd2e.png)
配置层数stratum
local stratum 10: 1-15-> 只是表达了距离真正时钟源比较源
![](https://i-blog.csdnimg.cn/blog_migrate/0556b81e40e02bd314aacd87a1516734.png)
[root@hezhihao ~]# systemctl restart chronyd
[root@hezhihao ~]# timedatectl set-ntp true
[root@hezhihao ~]# timedatectl status
在第二台机子查看:
![](https://i-blog.csdnimg.cn/blog_migrate/89c44f6973c784ae7caab736c130df0e.png)