配置chrony服务
集群中节点之间需要时间同步,不依赖外部的时间服务NTP,在内部搭建时间服务器。首先保证所有节点都安装了chrony,命令如下:yum install chrony -y。 在提供时间同步服务的服务端节点做如下操作:
vim /etc/chrony.conf
22 allow 192.168.211.131 ##允许哪些客户端来同步主机的时间
29 local stratum 10 ##本机不同步任何主机时间,本机作为时间源
systemctl restart chronyd.service ##重启配置文件
在需要同步服务的客户端节点做如下操作:
vim /etc/chrony.conf
3 server 192.168.211.132 iburst ##本机同步192.168.211.132主机的时间
systemctl restart chronyd.service ##重启配置文件
测试:在客户端节点执行chronyc sources -v ![在这里插入图片描述](https://img-blog.csdnimg.cn/20201106123814117.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2FzbWFydGtpbGxlcg==,size_16,color_FFFFFF,t_70#pic_center)
一些系统时间设定的命令
date ##可用man date 学习date命令
NAME
date - print or set the system date and time
SYNOPSIS
date [OPTION]… [+FORMAT]
date [-u|–utc|–universal] [MMDDhhmm[[CC]YY][.ss]]
DESCRIPTION
Display the current time in the given FORMAT, or set the system date.
Mandatory arguments to long options are mandatory for short options too.
#查看当前日期的x天前或者x天后的时间 1.从1970年1月1日 00:00:00 到目前为止经历的秒数 2.12 PM/AM 3.一年中的第几周 ![在这里插入图片描述](https://img-blog.csdnimg.cn/20201106124714663.png#pic_center)
timedatectl status ##显示系统时间
timedatectl set-timezone Asia/Shanghai ##更改当前时区为东八区
timedatectl set-time “2012-10-30 18:17:16” ##设定系统时间
timedatectl set-local-rtc 0 ##设定是否使用UTC时间
![在这里插入图片描述](https://img-blog.csdnimg.cn/20201106124813755.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2FzbWFydGtpbGxlcg==,size_16,color_FFFFFF,t_70#pic_center)
|