linux时间同步服务(chronyd服务)

配置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
在这里插入图片描述

一些系统时间设定的命令

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.一年中的第几周
在这里插入图片描述

timedatectl status ##显示系统时间
timedatectl set-timezone Asia/Shanghai ##更改当前时区为东八区
timedatectl set-time “2012-10-30 18:17:16” ##设定系统时间
timedatectl set-local-rtc 0 ##设定是否使用UTC时间

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值