Linux基础_时间同步

####4.时间同步####

 

1.服务端

yum install chrony -y ##安装服务

 

vim /etc/chrony.conf ##主配置文件

21 # Allow NTP client access from local network.

22 allow 172.25.0.0/24 ##允许谁去同步我的时间

27 # Serve time even if not synchronized to any NTP server.

28 local stratum 10 ##不去同步任何人的时间,时间同步服务器级别

 

systemctl restart chronyd

systemctl stop firewalld

 

2.客户端

vim /etc/chrony.conf

  3 server 0.rhel.pool.ntp.org iburst

  4 server 1.rhel.pool.ntp.org iburst====> server ntpserverip iburst

  5 server 2.rhel.pool.ntp.org iburst====>

  6 server 3.rhel.pool.ntp.org iburst

 

systemctl restart chronyd

测试:

[root@localhost ~]# chronyc sources -v

210 Number of sources = 1

 

  .-- Source mode  '^' = server, '=' = peer, '#' = local clock.

 / .- Source state '*' = current synced, '+' = combined , '-' = not combined,

| /   '?' = unreachable, 'x' = time may be in error, '~' = time too variable.

||                                                 .- xxxx [ yyyy ] +/- zzzz

||                                                /   xxxx = adjusted offset,

||         Log2(Polling interval) -.             |    yyyy = measured offset,

||                                  \            |    zzzz = estimated error.

||                                   |           |                         

MS Name/IP address         Stratum Poll Reach LastRx Last sample

===============================================================================

^* 172.25.0.11                  10   6   377    41   +170us[ +201us] +/-  191us

 

 

 

####5.timedatectl命令####

timedatectl status ##显示当前时间信息

set-time ##设定当前时间

set-timezone ##设定当前时区

set-local-rtc 0|1 ##设定是否使用utc时间

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值