Linux系统时间管理——时间同步服务之chronyd
Linux系统时间管理——时间同步服务之chronyd
1.时间同步服务
服务名称:chronyd
在服务端:
vim /etc/chrony.conf
22行: allow 172.25.254/24 ##允许网络位相同的客户端来同步本机时间
29行: local stratum 10 ##本机不同步任何主机的时进,本机作为时间源(时间源的优先级为10)
![d89276b4868c7e2594d30c2d3985941a.png](https://img.php1.cn/3cd4a/1eebe/cd5/e62700fe09f8933e.webp)
systemctl restart chronyd.service ##重启服务
systemctl stop firewalld ##关闭火墙
在客户端:
vim /etc/chrony.conf
server 172.25.254.218 iburst ##本机立即同步218主机的时间(iburst 立即更改)
![0171e28ced905a92bfc17d57b5c06dec.png](https://img.php1.cn/3cd4a/1eebe/cd5/d942b7ec373849c3.webp)
![80f00feccf9ff2e75c8d3c85852b27df.png](https://img.php1.cn/3cd4a/1eebe/cd5/e88efe5b0a13a7fa.webp)
systemctl restart chronyd.service
测试:
在客户端:
[[email protected]_ssh ~]# date 11111111 ##修改客户端时间
Mon Nov 11 11:11:00 EST 2019
[[email protected]_ssh ~]#
[[email protected]_ssh ~]# chronyc sources -v
![5d5e0cf738fceb22d9a97c7c3b9554c8.png](https://img.php1.cn/3cd4a/1eebe/cd5/45a090220e38e09d.webp)
![302d25f4b233ddf7dabc347df9a049b9.png](https://img.php1.cn/3cd4a/1eebe/cd5/4283cd4bbba41b87.png)
utc时间计算方式:世界时间+时区
2.timedatectl 命令
timedatectl ##管理系统时间
timedatectl status ##显示当前时间信息
![57a62be8c90d207174e4923a2f4d9e42.png](https://img.php1.cn/3cd4a/1eebe/cd5/5287a7b3296ea13e.webp)
timedatectl set-timezone "Asia/Shanghai" ##设置当前时区,更改当前时区分为东8区
![20c5708375085d12cf8e7298041f6880.png](https://img.php1.cn/3cd4a/18ace/696/1d8e759bd3e6bbec.jpeg)
timedatectl set-time "2016-08-08 12:12" ## 设置当前时间
![1e7d0de2a162f5d8b172a141dfa4d708.png](https://img.php1.cn/3cd4a/1eebe/cd5/011ac27956d007f0.webp)
timedatectl set-local-rtc 0/1 ##设置是否使用utc时间
vim /etc/adjtime
![c7ce6815f36144e9104a3349efd006da.png](https://img.php1.cn/3cd4a/1eebe/cd5/5287a7b3296ea13e.webp)
![596d631004e7f11b397f35f721eb30ec.png](https://img.php1.cn/3cd4a/1eebe/cd5/70be2ca197098d98.webp)
timedatectl list-timezones ##查看支持的时区
![daf7ec92dd7d5fafe72a1616e0cf29e0.png](https://img.php1.cn/3cd4a/1eebe/cd5/bff2716168d1ed7b.webp)
Linux系统时间管理——时间同步服务之chronyd相关教程