码迷,mamicode.com
首页 > 其他好文 > 详细

时间同步

时间:2016-10-25 11:52:15      阅读:218      评论:0      收藏:0      [点我收藏+]

标签:配置文件   服务器   access   server   服务端   


1.服务端

yum install chrony -y##安装服务

 

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

21 # Allow NTP client access from local network.

22 allow 172.25.254.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.254.2              10   6   377    41   +170us[ +201us] +/-  191us

技术分享 

 

 

 

两边都清空日志,> /var/log/messages

在服务端随意执行一条命令,在客户端便可以看到时间同步过来

 

 

 

####3timedatectl命令####

timedatectlstatus##显示当前时间信息

set-time##设定当前时间

set-timezone##设定当前时区

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


时间同步

标签:配置文件   服务器   access   server   服务端   

原文地址:http://12110904.blog.51cto.com/12100904/1865270

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!