CentOS7—时间同步(笔录)
今天在学习etcd集群搭建时遇到时间不同步错误,故做笔记记录一下,错误信息如下:
与对等端47856ed020c3771a的时钟差太大
2020-12-24 10:23:26.649584 W | rafthttp: the clock difference against peer 47856ed020c3771a is too high [4.070577968s > 1s] (prober "ROUND_TRIPPER_SNAPSHOT")
2020-12-24 10:23:31.650852 W | rafthttp: the clock difference against peer 47856ed020c3771a is too high [4.066382795s > 1s] (prober "ROUND_TRIPPER_RAFT_MESSAGE")
找到对应的节点:47856ed020c3771a ---- > 192.168.6.12:2380
1、安装ntp服务
yum -y install ntp
2、设置时间
[root@hdss7-12 etcd]# ntpdate 0.asia.pool.ntp.org
24 Dec 10:34:57 ntpdate[1879]: step time server 45.76.111.149 offset -0.783300 sec
注:
这里主要就是通过时间服务器对系统时间进行同步,所以0.asia.pool.ntp.org并不是固定的,大家可以选择time.nist.gov、time.nuri.net、0.asia.pool.ntp.org、1.asia.pool.ntp.org、2.asia.pool.ntp.org、3.asia.pool.ntp.org中任意一个,只要保证可用就OK。
3、将系统时间写入硬件时间
hwclock --systohc
4、检查ntp服务是否为开机自启
[root@hdss7-12 etcd]# systemctl list-unit-files --type service |grep ntp
ntpd.service disabled
ntpdate.service disabled
5、设置为开机自启
systemctl enable ntpd.service
systemctl enable ntpdate.service