Chronyd时间同步服务
AI-摘要
切换
Tianli GPT
AI初始化中...
介绍自己
生成本文简介
推荐相关文章
前往主页
前往tianli博客
CentOS7.6 chrony配置
CentOS7.6默认安装了chrony保持系统时间与时间服务器(NTP)同步。在内网中,我们需要搭建一台时钟服务器用于统一内网的系统时间。
服务端配置
进入chrony配置文件
[root@appsrv ~]# vim /etc/chrony.conf
修改如下几行
24 # Allow NTP client access from local network.
25 allow all 允许的主机
26
27 local 不管自己的时间和NTP服务器对不对得上都把自己的时间发布给客服端
28 # Serve time even if not synchronized to a time source.
29 local stratum 10
重启chronyd服务
[root@appsrv ~]# systemctl restart chronyd
客服端配置
进入chrony配置文件
[root@storagesrv ~]# vim /etc/chrony.conf
3 #server 0.centos.pool.ntp.org iburst
4 #server 1.centos.pool.ntp.org iburst
5 #server 2.centos.pool.ntp.org iburst
6 #server 3.centos.pool.ntp.org iburst
7 server 192.168.100.100 iburst 设置ntp服务器为服务端
[root@storagesrv ~]# systemctl restart chronyd
[root@storagesrv ~]# timedatectl set-ntp yes
配置crontab(计时器)每5分钟同步一次时间。
[root@storagesrv ~]# vim /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# For details see man 4 crontabs
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
*/5 * * * * ntpdate 192.168.100.100
/usr/shin/ntpdate 是执行的命令
192.168.100.100 是ntpdate的参数
查看服务器端连接的客户端状态信息
[root@appsrv ~]# chronyc clients
查看客户端状态信息
[root@storagesrv ~]# timedatectl set-ntp yes
[root@storagesrv ~]# date
Wed Feb 21 23:57:02 CST 2024
本文是原创文章,采用 CC BY-NC-ND 4.0 协议,完整转载请注明来自 HappyLadySauce
评论
匿名评论
隐私政策
你无需删除空行,直接评论以获取最佳展示效果