环境:
用rsync+sersync配置远程实时同步备份,两边配置完成,正常同步。后发现同步日志rsync.log时间比系统时间慢8个小时问题,如下:
系统时间信息:
[root@rsync ]# timedatectl
Local time: Wed 2020-10-28 14:38:55 CST
Universal time: Wed 2020-10-28 06:38:55 UTC
RTC time: Wed 2020-10-28 06:27:57
Time zone: Asia/Shanghai (CST, +0800)
NTP enabled: yes
NTP synchronized: no
RTC in local TZ: no
DST active: n/a
time文件:
[root@rsync 427]# ls -l /etc/localtime
lrwxrwxrwx. 1 root root 35 Oct 27 17:17 /etc/localtime -> ../usr/share/zoneinfo/Asia/Shanghai
[root@rsync 427]# date
Wed Oct 28 14:39:28 CST 2020
rsynclog日志文件信息:
2020/10/28 03:33:50 [14630] connect from sersync (192.192.101.96)
2020/10/27 19:33:50 [14630] rsync to docshare/ from rsyncuser@sersync (192.192.101.96)
2020/10/27 19:33:50 [14630] receiving file list
2020/10/27 21:02:34 [14630] sent 1906166 bytes received 157271577 bytes total size 545619813056
2020/10/28 05:03:50 [15569] connect from sersync (192.192.101.96)
2020/10/27 21:03:50 [15569] rsync to docshare/ from rsyncuser@sersync (192.192.101.96)
2020/10/27 21:03:50 [15569] receiving file list
2020/10/27 22:48:52 [15569] sent 1905998 bytes received 157271429 bytes total size 545619813056
解决办法:
修改/etc/profile文件,添加export TZ=‘CST-8'
source /etc/profile 使修改立即生效。
再查看日志时间rsync.log,显示正常,如下:
2020/10/28 14:32:53 [21159] rsyncd version 3.1.2 starting, listening on port 873
2020/10/28 14:33:07 [21170] connect from sersync (192.192.101.96)
2020/10/28 14:33:07 [21170] rsync to docshare/ from rsyncuser@sersync (192.192.101.96)
2020/10/28 14:33:07 [21170] receiving file list
再次查看timedatectl,发现有告警,不知道有没有影响,待测
[root@rsync 427]# timedatectl
Warning: Ignoring the TZ variable. Reading the system's time zone setting only.
Local time: Wed 2020-10-28 14:38:55 CST
Universal time: Wed 2020-10-28 06:38:55 UTC
RTC time: Wed 2020-10-28 06:27:57
Time zone: Asia/Shanghai (CST, +0800)
NTP enabled: yes
NTP synchronized: no
RTC in local TZ: no
DST active: n/a