Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Ntp and chronyd

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Ntp and chronyd

The disadvantages of synchronizing time immediately, affecting the execution of some scheduled tasks

First, synchronize time immediately

Method 1:

Ntpdate ntp.aliyun.com

Method 2: restart the ntp service

Method 3: restart the chrony service

Check the status of ntp and chrony

[root@textbox] # chronyc sources-v210 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 = ^ * localhost 3 6 17 2 + 62us [+ 661us] + /-88ms [root@textbox ~] # [root | @ textbox ~] # ntpq-p remote refid st t when poll reach delay offset jitter====*localhost 119.28.206.193 3u 41 64 177 0.784 1.195 3656236

3. Ntp is used to set up the server.

# Note the original ntp server The original ntp servers are all centos.org American [root@textbox ~] # sed'/ ^ server/s/ ^ / # /'/ etc/ntp.conf-i# add two aliyun [root@textbox ~] # sed'1a server ntp.aliyun.com iburst' / etc/ntp.conf-I [root@textbox ~] # sed'1a server ntp1.aliyun.com iburst' / etc/ntp.conf-i# restart service [root@textbox ~] # systemctl restart ntpd#ntp is as simple as that You can use port [root@textbox ~] # ntpq-p remote refid st t when poll reach delay offset jitter====+120.25.115.20 10.137.53.7 2 u 4 64 17 42.560-8.795 6.944 "203.107.88 100.107.25.114 2 u 4 64 17 15.542-7.021 6.460" 123 "when the server uses Udp [root@textbox ~] # ss-lutnp | grep ntpudp UNCONN 0 192.168.38.140 ntpd 123 *: * users: (("ntpd", pid=61668,fd=19)) udp UNCONN 0 0127.0.1 ss 123 *: * users: (("ntpd", pid=61668) Fd=18)) udp UNCONN 0 0 *: 123 *: * users: (("ntpd", pid=61668,fd=16)) udp UNCONN 0 0 fe80::69d0:5288:fda9:93ae%ens33:123: * users: (("ntpd", pid=61668) Fd=21)) udp UNCONN 0 0:: 1 users: (("ntpd", pid=61668,fd=20)) udp UNCONN 0 0: 123: * users: (("ntpd", pid=61668) Fd=17) # Test [root@linux5 ~] # ntpdate 192.168.38.140 5 Sep 09:17:25 ntpdate [28423]: adjust time server 192.168.38.140 offset-0.007790 sec

IV. Chrony server configuration

Set more items than ntp

[root@imooc-nginx ~] # sed'/ ^ server/s/ ^ / # /'/ etc/chrony.conf-I [root@imooc-nginx ~] # sed'1a server ntp.aliyun.com iburst' / etc/chrony.conf-I [root@imooc-nginx ~] # sed'1a server 0.cn.pool.ntp.org iburst' / etc/chrony.conf-I [root@imooc-nginx ~] # sed'1a server ntp1.aliyun.com iburst' / etc/chrony.conf- I # even if the current server is not synchronized with the specified ntp completion time Still provide service [root@imooc-nginx ~] # sed'1a local stratum 10' / etc/chrony.conf-i# which servers are allowed to synchronize [root@imooc-nginx ~] # sed'1a allow 192.168.0.0 / etc/chrony.conf-I [root@imooc-nginx ~] # systemctl restart chronyd [root@imooc-nginx ~] # systemctl enable chronyd# View chronyd status [root@imooc-nginx ~] # chronyc sources-v210 Number of sources = 3.-- 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 = ^ + 120.25.115.20 2 6 17 4 + 766us [+ 591us] + /-21ms ^-111.230.189. 17426174 + 98us [+ 98us] + /-49ms ^ * 203.107.6.88 26174-187us [- 361us] + /-16ms# Test [root@textbox] # ntpdate 192.168.38.154 5 Sep 09:33:25 ntpdate [61810]: adjust time server 192.168.38.154 offset-0.010546 sec

5. Two ways to automatically synchronize time

1. Ntpdate ntp.aliyun.com writes scheduled tasks and synchronizes them every hour.

2. All servers chrony are enabled, one of which is a time server, and the server of the other servers points to it.

VI. Setting the time zone

[root@textbox ~] # timedatectl set-timezone Asia/Shanghai

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report