确保主机时间与网络时间保持同步此操作示例仅供参考,实际情况请根据待容灾主机自身情况自行配置
Windows
示例操作系统:Windows2012 R2
使用Windows系统时间工具进行配置
点击桌面 Windows 图标 > 打开控制面板,选择日期和时间进行配置。设置时间自动同步到Internet
在“日期和时间”选项卡中,点击“Internet Time”。 点击“更改设置”。设置自动同步到本地时间同步服务器
如果你的主机在内网环境,需要将地址配置为您本地的时间同步服务器地址
:::tips
其中
:::
点击立即更新按钮,等待与Internet时间服务器同步
点击确认按钮即可
Linux
示例操作系统:CentOS Linux release 7.5
安装ntp
[root@node ~]# yum install -y ntp
启动ntp服务
[root@node ~]# systemctl start ntpd
[root@node ~]# systemctl enable ntpd
Created symlink from /etc/systemd/system/multi-user.target.wants/ntpd.service to /usr/lib/systemd/system/ntpd.service.
查看ntp服务
[root@node ~]# systemctl status ntpd
● ntpd.service - Network Time Service
Loaded: loaded (/usr/lib/systemd/system/ntpd.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2022-08-04 08:00:47 CST; 7h left
Main PID: 20746 (ntpd)
Tasks: 1
Memory: 768.0K
CGroup: /system.slice/ntpd.service
└─20746 /usr/sbin/ntpd -u ntp:ntp -g
Aug 04 08:00:47 node ntpd[20746]: Listen normally on 6 lo ::1 UDP 123
Aug 04 08:00:47 node ntpd[20746]: Listen normally on 7 ens33 fe80::8a83:7297:7cb8:9934 UDP 123
Aug 04 08:00:47 node ntpd[20746]: Listening on routing socket on fd #24 for interface updates
Aug 04 08:00:47 node systemd[1]: Started Network Time Service.
Aug 04 08:00:47 node ntpd[20746]: 0.0.0.0 c016 06 restart
Aug 04 08:00:47 node ntpd[20746]: 0.0.0.0 c012 02 freq_set kernel 0.000 PPM
Aug 04 08:00:47 node ntpd[20746]: 0.0.0.0 c011 01 freq_not_set
Aug 04 08:00:56 node ntpd[20746]: 0.0.0.0 c61c 0c clock_step -28798.353463 s
Aug 04 00:00:57 node ntpd[20746]: 0.0.0.0 c614 04 freq_mode
Aug 04 00:00:58 node ntpd[20746]: 0.0.0.0 c618 08 no_sys_peer
修改ntp.conf文件
请确保将 time.example.com 替换为你想要使用的实际NTP服务器地址。这个命令在修改后会直接保存文件,所以在执行前确保你对配置的修改没有问题。
# 将以server开头的行注释掉。
# 在文件的末尾添加新的NTP服务器地址。
[root@localhost ~]# sudo sed -i -e '/^server/ s/^server/#&/' -e '$ a server time.example.com iburst' /etc/ntp.conf
重启服务
[root@node ~]# systemctl restart ntpd
检查同步状态
[root@node ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
203.107.6.88 100.107.25.114 2 u 2 64 1 30.975 149.499 0.393