时间同步服务器配置

时间同步服务

多主机协作工作时,各个主机的时间同步很重要,时间不一致会造成很多重要应用的故障,如:加密协 议,日志,集群等, 利用NTP(Network Time Protocol) 协议使网络中的各个计算机时间达到同步。 目前NTP协议属于运维基础架构中必备的基本服务之一

时间同步软件实现:

ntp

chrony

ntp:

将系统时钟和世界协调时UTC同步,精度在局域网内可达0.1ms,在互联网上绝大多数的地方精度可以 达到1-50ms

项目官网:http://www.ntp.org

chrony: 实现NTP协议的的自由软件。可使系统时钟与NTP服务器,参考时钟(例如GPS接收器)以及使用手表 和键盘的手动输入进行同步。还可以作为NTPv4(RFC 5905)服务器和对等体运行,为网络中的计算机 提供时间服务。设计用于在各种条件下良好运行,包括间歇性和高度拥挤的网络连接,温度变化(计算 机时钟对温度敏感),以及不能连续运行或在虚拟机上运行的系统。

通过Internet同步的两台机器之间的典型精度在几毫秒之内,在LAN上,精度通常为几十微秒。利用硬 件时间戳或硬件参考时钟,可实现亚微秒的

#服务器端配置
[root@centos8 ~]#hostname -I
10.0.0.8 
[root@centos8 ~]#yum -y install chrony
[root@ubuntu2004 ~]#apt install chrony -y
[root@centos8 ~]#vim /etc/chrony.conf
server ntp.aliyun.com iburst
server ntp.tencent.com iburst
server ntp.ntsc.ac.cn iburst
#allow 192.168.0.0/16
allow 0.0.0.0/0  #加此行,指定允许同步的网段
# Serve time even if not synchronized to a time source.
local stratum 10 #删除此行注释,当互联网无法连接,仍然可以为客户端提供时间同步服务
[root@centos8 ~]#systemctl restart chronyd
#服务启动后会打开端口123/udp
[root@centos8 ~]#ss -ntlu
Netid             State               Recv-Q             Send-Q                 
            Local Address:Port                             Peer Address:Port     
         
udp               UNCONN              0                   0                     
                   0.0.0.0:123                                   0.0.0.0:*       
          
udp               UNCONN              0                   0                     
                 127.0.0.1:323                                   0.0.0.0:*       
          
udp               UNCONN              0                   0                     
                    [::1]:323                                     [::]:*       
          
tcp               LISTEN              0                   128                   
                   0.0.0.0:22                                    0.0.0.0:*       
          
tcp               LISTEN              0                   100                   
                 127.0.0.1:25                                    0.0.0.0:*       
          
tcp               LISTEN              0                   128                   
                      [::]:22                                       [::]:*       
          
tcp               LISTEN              0                   100                   
                    [::1]:25                                       [::]:*  
#客户端配置
[root@centos7 ~]#vim /etc/chrony.conf
server 10.0.0.8 iburst
server 10.0.0.8 iburst  #另外一台 主服务器也像上面那台那样操作,做高可用集群
[root@centos7 ~]#systemctl restart chronyd.service 
#确认同步成功
[root@centos7 ~]#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
||     Reachability register (octal) -.           | xxxx = adjusted offset,
||     Log2(Polling interval) --.     |         | yyyy = measured offset,
||                               \     |         | zzzz = estimated error.
||                                 |   |           \
MS Name/IP address         Stratum Poll Reach LastRx Last sample               
===============================================================================
^* 10.0.0.8                      3   6    77    29   -229us[-1154us] +/-   17ms

精度

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值