时间同步服务
多主机协作工作时,各个主机的时间同步很重要,时间不一致会造成很多重要应用的故障,如:加密协
议,日志,集群等, 利用NTP(Network Time Protocol) 协议使网络中的各个计算机时间达到同步。
目前NTP协议属于运维基础架构中必备的基本服务之一
时间同步软件
ntp
将系统时钟和世界协调时UTC同步,精度在局域网内可达0.1ms,在互联网上绝大多数的地方精度可以
达到1-50ms chrony
实现NTP协议的的自由软件。可使系统时钟与NTP服务器,参考时钟(例如GPS接收器)以及使用手表
和键盘的手动输入进行同步。还可以作为NTPv4(RFC 5905)服务器和对等体运行,为网络中的计算机
提供时间服务。设计用于在各种条件下良好运行,包括间歇性和高度拥挤的网络连接,温度变化(计算
机时钟对温度敏感),以及不能连续运行或在虚拟机上运行的系统。
chrony的优势
更快的同步只需要数分钟而非数小时时间,从而最大程度减少了时间和频率误差,对于并非全天
24 小时运行的虚拟计算机而言非常有用
能够更好地响应时钟频率的快速变化,对于具备不稳定时钟的虚拟机或导致时钟频率发生变化的节
能技术而言非常有用

chrony官网:https://chrony.tuxfamily.org
chrony官方文档:https://chrony.tuxfamily.org/documentation.html
chrony文件组成
rpm -ql chrony
/etc/NetworkManager/dispatcher.d/20-chrony
/etc/chrony.conf
/etc/chrony.keys
/etc/dhcp/dhclient.d/chrony.sh
/etc/logrotate.d/chrony
/etc/sysconfig/chronyd
/usr/bin/chronyc
/usr/lib/systemd/ntp-units.d/50-chronyd.list
/usr/lib/systemd/system/chrony-dnssrv@.service
/usr/lib/systemd/system/chrony-dnssrv@.timer
/usr/lib/systemd/system/chrony-wait.service
/usr/lib/systemd/system/chronyd.service
/usr/libexec/chrony-helper
/usr/sbin/chronyd
/usr/share/doc/chrony-3.4
/usr/share/doc/chrony-3.4/COPYING
/usr/share/doc/chrony-3.4/FAQ
/usr/share/doc/chrony-3.4/NEWS
/usr/share/doc/chrony-3.4/README
/usr/share/man/man1/chronyc.1.gz
/usr/share/man/man5/chrony.conf.5.gz
/usr/share/man/man8/chronyd.8.gz
/var/lib/chrony
/var/lib/chrony/drift
/var/lib/chrony/rtc
/var/log/chrony



监听端口: 323/udp,123/udp
配置文件: /etc/chrony.conf 规划如下:
10.0.0.8 充当NTP服务器
10.0.0.30 客户端
10.0.0.190 客户端
10.0.0.9 客户端
具体配置如下
# vim /etc/chrony.conf pool ntp.aliyun.com iburst #可以写阿里云的,也可以写其他的。
重启配置文件后查看
[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
|| 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
===============================================================================
^* 203.107.6.88 2 6 17 51 +411us[-2720us] +/- 37ms

我们可以看到已经同步OK,查看端口
端口是udp的323和123

ss -ntul
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port
udp UNCONN 0 0 127.0.0.1:876 *:*
udp UNCONN 0 0 *:904 *:*
udp UNCONN 0 0 *:38293 *:*
udp UNCONN 0 0 *:2049 *:*
udp UNCONN 0 0 *:20048 *:*
udp UNCONN 0 0 *:111 *:*
udp UNCONN 0 0 *:123 *:*

ss -ntulp
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port
udp UNCONN 0 0 127.0.0.1:876 *:* users:(("rpc.statd",pid=1123,fd=7))
udp UNCONN 0 0 *:904 *:* users:(("rpcbind",pid=743,fd=7))
udp UNCONN 0 0 *:38293 *:* users:(("rpc.statd",pid=1123,fd=8))
udp UNCONN 0 0 *:2049 *:*
udp UNCONN 0 0 *:20048 *:* users:(("rpc.mountd",pid=1143,fd=7))
udp UNCONN 0 0 *:111 *:* users:(("rpcbind",pid=743,fd=6))
udp UNCONN 0 0 *:123 *:* users:(("chronyd",pid=2542,fd=7))
udp UNCONN 0 0 *:50933 *:*
udp UNCONN 0 0 127.0.0.1:323 *:* users:(("chronyd",pid=2542,fd=5))
udp UNCONN 0 0 [::]:42338 [::]:*
udp UNCONN 0 0 [::]:904 [::]:*

ntpdate 10.0.0.8
17 Mar 16:40:44 ntpdate[1483]: no server suitable for synchronization found
没有找到适合同步的服务器 #设置本地网络可以同步我的ntp服务请求
#按照别人的配置往下写就好了
#allow 192.168.0.0/16
allow 10.0.0.0/24 #重启测试
# systemctl restart chronyd
#都同步OK
ntpdate 10.0.0.8
17 Mar 16:49:14 ntpdate[1502]: adjust time server 10.0.0.8 offset -0.005113 sec ntpdate 10.0.0.8
17 Mar 16:51:05 ntpdate[4147]: adjust time server 10.0.0.8 offset 0.009203 sec
ntpdate 10.0.0.8
17 Mar 17:03:52 ntpdate[1727]: adjust time server 10.0.0.8 offset 0.006905 sec
#客户端查看
chronyc
chrony version 3.4
Copyright (C) 1997-2003, 2007, 2009-2018 Richard P. Curnow and others
chrony comes with ABSOLUTELY NO WARRANTY. This is free software, and
you are welcome to redistribute it under certain conditions. See the
GNU General Public License version 2 for details. chronyc> clinets
Unrecognized command
chronyc> clients
Hostname NTP Drop Int IntL Last Cmd Drop Int Last
===============================================================================
10.0.0.190 4 0 1 - 20m 0 0 - -
10.0.0.9 4 0 1 - 1140 0 0 - -
10.0.0.30 4 0 1 - 373 0 0 - -

NTP服务器已经全部OK!!!希望对有所帮助!!!

 

最新文章

  1. 提高代码质量系列之二:重构小技巧——if篇
  2. 1-1 console的用法
  3. 14TH本周工作量及进度统计
  4. Java-->IO流模拟实现用户登录以及登录信息
  5. 标准库 - fmt/format.go 解读
  6. IOS开发常用技术网站
  7. oracle 日志学习(转载)
  8. SOA与EBS集成_Package 调用维护
  9. Thinkphp 零散知识点(caa/js路径,引入第三方类,ajax返回,session/cookie)
  10. 解决Delphi MDI 闪烁问题(使用WM_SETREDRAW锁屏后进行处理)
  11. selenium 百度登陆
  12. Java内存回收 - 落日之心的日志 - 网易博客
  13. 08机器学习实战之BP神经网络
  14. Ubuntu18.04多个版本GCC编译器的切换
  15. web中icon 图标问题
  16. 穷举法、for循环、函数、作用域、斐波那契数
  17. Linux给命令设置别名
  18. 并查集 (Union-Find Sets)及其应用
  19. 在AJAX里 使用【 JSON 】 返回数据类型 实现简单的下拉菜单数据
  20. 《web前端设计基础——HTML5、CSS3、JavaScript》 张树明版 简答题简单整理

热门文章

  1. springboot( 三)redis demo
  2. POJ 3415 Common Substrings(后缀数组 + 单调栈)题解
  3. ARM汇编指令-STMFD/LDMFD
  4. Semantic Pull Requests All In One
  5. 使用 js 实现一个简易版的动画库
  6. console.log & front-end jobs
  7. 比特币跌破3.5万美元,巨鲸们将目光瞄向SPC算力币
  8. 没想到即将上线的NGK生态应用这么厉害?!
  9. 阿里云linux安装nginx,亲测有效
  10. iOS拍个小视频