CentOS7 时间与网络时间同步

2021年8月20日12:03:54 评论 550
首月免费体验

在做分布式集群开发时,经常会遇见集群时间节点不一致,从而造成某个节点服务进程启动失败或者通信失败。今天分享一下Centos下如何将本地集群时间和网络时间同步,这样妈妈再也不用担心我因为时间不一致而出现的失败情况。

问题描述:使用date命令查看之后,发现时间与本地时间不一致。

 

三步解决方法:

1、安装ntpdate工具

[root@slave1 ~]# yum -y install ntp ntpdate

 

安装成功!

2、设置系统时间与网络时间同步

[root@slave1 ~]# ntpdate 0.asia.pool.ntp.org

这里主要就是通过时间服务器对系统时间进行同步,所以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、将系统时间写入硬件时间

[root@slave1 ~]# hwclock --systohc

 

这里是为了防止系统重启后时间被还原,因此需要写到硬件设备中去。

This article create by XPU.Xiaxing,If you think this article is not bad, please give me a compliment, Thank u so much!

weinxin
博主微信
这是我的微信扫一扫

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: