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

Linux sets ntp time synchronization

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

Share

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

Description of NTP clock synchronization mode

NTP has two clock synchronization methods under linux, which are direct synchronization and smooth synchronization.

Direct synchronization

Use the ntpdate command to synchronize and change the time directly. If there is a task running at 12:00 on the server, the current server time is 13:00, but 11:00 standard time, using this command may cause the task to repeat. Therefore, using ntpdate synchronization can be risky, so this command is also often used when configuring clock synchronization services to synchronize time for the first time.

Smooth synchronization

Using ntpd for clock synchronization can ensure that a time does not go through twice, and the offset of each synchronization time is not too steep, which is slow. Because of this, ntpd smooth synchronization may take a long time.

1. Install ntp

Yum install ntp

2. Set the ntp service to boot.

Systemctl restart ntp.service

3. Set up the server

3.1. Vi / etc/ntp.conf The contents are as follows: driftfile / var/lib/ntp/ntp.drift # draft file # allows other machines in the private network to synchronize time restrict 192.168.137.0 (replace with their own ip) mask 255.255.255.0 nomodify notrap# Use public servers from the pool.ntp.org project.# the most active time server in China: [http://www.pool.ntp.org/zone/cn](http://www.pool.ntp. Org/zone/cn) server 210.72.145.44 perfer # China National time receiving Center server 202.112.10.36 # 1.cn.pool.ntp.orgserver 59.124.196.83 # 0.asia.pool.ntp.org # allow update time by the upper server# allows the upper time server to actively modify the local time restrict 210.72.145.44 nomodify notrap noqueryrestrict 202.112.10.36 nomodify Notrap noqueryrestrict 59.124.196.83 nomodify notrap noquery # when an external time server is not available Using local time as time service server 127.127.1.0 # local clockfudge 127.127.1.0 stratum 10

Restart the service: service ntpd restart

3.3.View synchronization status: netstat-tlunp | grep ntp

4. Set synchronization

4.1 vim / etc/ntp.conf The content is as follows: driftfile / var/lib/ntp/ntp.drift # draft file statsdir / var/log/ntpstats/statistics loopstats peerstats clockstatsfilegen loopstats file loopstats type day enablefilegen peerstats file peerstats type day enablefilegen clockstatsfile clockstats type day enable# makes NTP Server an intranet ntp server server 192.168.137.110 (master node ip) fudge 192.168.137.110 stratum does not allow access to restrict-4 default kod notrap nomodify nopeer noqueryrestrict-6 default kod notrap from ipv4 and ipv6 clients on the public network Nomodify nopeer noquery#Local users may interrogate the ntp server more closely.restrict 127.0.0.1restrict:: 1

4.2 restart the service: service ntpd restart

4.3Manual synchronization: ntpdate-u 192.168.124.146

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