RHEL 7 时间同步设置方法


RHEL 7 时间同步设置

安装(使用YUM)
yum -y install chrony

启动(可配置到系统启动)
chronyd

配置chrony服务开机启动
在/etc/rc.d/rc.local中增加以下行:
if [ -f /usr/local/sbin/chronyd -a -f /etc/chrony.conf ]; then
/usr/local/sbin/chronyd -r -s
echo "Start chronyd"
fi

动态配置
进入命令行工具
chronyc -a

以下命令均在命令行里面输入
获取命令帮助
help

使服务在线
online

增加时间服务器
add server 10.45.13.20

配置同步策略,允许所有IP可同步
allow all

检查同步服务状态
activity

检查同步时间状态
tracking

检查同步源状态
sources

静态配置
修改/etc/chrony.conf
在原有server行下增加
server 10.45.13.20 #时间同步服务器IP地址
保存配置
然后重启同步服务
serviec chronyd restart

系统时间设置及检查
#timedatectl
Local time: 四 2015-01-22 15:42:39 CST #本地时间
Universal time: 四 2015-01-22 07:42:39 UTC
RTC time: 四 2015-01-22 07:42:40
Timezone: Asia/Shanghai (CST, +0800)
NTP enabled: yes #是否开启同步
NTP synchronized: yes #同步是否成功
RTC in local TZ: no
DST active: n/a

修改系统时间:
timedatectl set-time YYYY-MM-DD #修改年月日
timedatectl set-time HH:MM:SS #修改时间
修改系统时区:
timedatectl list-timezones #显示时区
timedatectl set-timezone time_zone #修改时区

硬件时钟查询
# hwclock
2015年01月22日 星期四 16时05分42秒 -0.896385 秒
系统时钟同步到硬件时钟
# hwclock --systohc
硬件时钟同步到系统时钟
# hwclock --hctosys

相关文档
最新文档