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 server configuration-ntp

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Configure ntp

Ntp is the service of network time synchronization, the accuracy of time is very important, a lot of data should know the exact time when recording. There are many sites on the Internet, and the time for matching the National time Service Center of the Chinese Academy of Sciences is generally set in China.

1. Install ntp software

[root@localhost ~] # rpm-qa | grep ntp / / check whether it is installed. This software is installed by default.

Ntpdate-4.2.6p5-1.el6.centos.i686

Fontpackages-filesystem-1.41-1.1.el6.noarch

Ntp-4.2.6p5-1.el6.centos.i686

[root@localhost ~] #

2. Configure the ntp site and modify the configuration file "/ etc/ntp.conf"

[root@localhost wj] # gedit / etc/xinetd.d/telnet

# server 0.centos.pool.ntp.org iburst

# server 1.centos.pool.ntp.org iburst

# server 2.centos.pool.ntp.org iburst

# server 3.centos.pool.ntp.org iburst / / I don't want the above

Server ntp1.aliyun.com / / Ali Cloud time Server

Server ntp2.aliyun.com

Server ntp3.aliyun.com

Server ntp4.aliyun.com

3. Modify the firewall. Ntp uses udp port 123 by default, which needs to be set in the firewall.

[root@localhost wj] # gedit / etc/sysconfig/iptables

-An INPUT-m state-- state NEW-m udp-p udp-- dport 123-j ACCEPT

[root@localhost wj] # service iptables restart

Iptables: set chain to policy ACCEPT: filter nat [OK]

Iptables: clear firewall rules: [OK]

Iptables: uninstalling module: [OK]

Iptables: apply firewall rules: [OK]

Iptables: load additional modules: nf_conntrack_ftp [OK]

4. Start the ntp service

[root@localhost wj] # service ntpd restart

Close ntpd: [OK]

Starting ntpd: [OK]

5. Check the running status of ntp

[root@localhost wj] # ntpq-p

Remote refid st t when poll reach delay offset jitter

=

120.25.115.20 10.137.53.7 2 u 4 64 1 26.132 188282. 0.000

203.107.6.88 100.107.25.114 2 u 3 64 1 83.645 188285. 0.000

6. Synchronize time, use the command ntpdate

[root@localhost wj] # ntpdate aliyun.com

16 Aug 10:07:03 ntpdate [20193]: the NTP socket is in use, exiting / / if you encounter this error, please do the following

[root@localhost wj] # lsof-iRu 123

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME

Ntpd 20187 ntp 16u IPv4 262711 0t0 UDP *: ntp

Ntpd 20187 ntp 17u IPv6 262712 0t0 UDP *: ntp

Ntpd 20187 ntp 18u IPv4 262718 0t0 UDP localhost:ntp

Ntpd 20187 ntp 19u IPv4 262719 0t0 UDP 192.168.0.119:ntp

Ntpd 20187 ntp 20u IPv6 262720 0t0 UDP localhost:ntp

Ntpd 20187 ntp 21u IPv6 262721 0t0 UDP [fe80::a00:27ff:fe14:3357]: ntp

[root@localhost wj] # kill-9 20187 / / Kill the above process

[root@localhost wj] # ntpdate 202.112.29.82

16 Aug 10:13:21 ntpdate [20212]: adjust time server 202.112.29.82 offset 0.006454 sec

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