Two methods of time synchronization for CentOS servers

Source: Internet
Author: User
Due to hardware, the root standard time of the machine is not equal to or greater, and the error of one month ranges from several seconds to several minutes. The time is not accurate for the server, which may cause a lot of trouble. For example, you cannot place an order or log on to a game during payment. It doesn't matter if you use a PC. just change it manually. 1. use ntpdate to update the time from the time server. if your linux system does not have the ntpdate command yuminstallntp, you do not need to configure or use it, test [root @ loc

Due to hardware, the root standard time of the machine is not equal to or greater, and the error of one month ranges from several seconds to several minutes. The time is not accurate for the server, which may cause a lot of trouble. For example, you cannot place an order or log on to a game during payment. It doesn't matter if you use a PC. just change it manually.


1. use ntpdate to update the time from the time server

If your linux system does not have the ntpdate command

yum install ntp


After the installation is complete, do not configure or test it.

[root@localhost ~]# ntpdate time.nist.gov 22 Oct 21:11:43 ntpdate[5014]: adjust time server 207.200.81.113 offset -0.018788 sec


If the above content shows that the synchronization is successful. Add the following content to the crontab.

  1. */10 * ntpdate time.nist.gov # domain name or IP address

Synchronize data every 10 minutes. Several time servers are recommended.

Time.nist.gov
Time.nuri.net
Asia.pool.ntp.org
Asia.pool.ntp.org
Asia.pool.ntp.org
Asia.pool.ntp.org

2. use ntp to build your own time server

We use other time servers to synchronize time. these time servers are authoritative. When we build our own time server, we don't need crontab to regularly run it.

1. installation time server ntp

  1. Yum install ntp

2. configure ntp

View copy print?
[Root @ localhost ~] # Cat/etc/ntp. conf | awk '{if ($0 !~ /^ $/& $0 !~ /^ #/) {Print $0} 'restrict default ignore // ntp cannot be modified or queried by default, and do not receive special packets restrict 127.0.0.1 // give the local machine all permissions restrict 192.168.1.0 mask 255.255.255.0 notrap nomodify // give the local machine the permission to synchronize time server time.nist.gov prefer // Set the time server, add prefer to indicate priority for server monitoring server 1.asia.pool.ntp.org server 2.asia.pool.ntp.org server 127.127.1.0 # local clock fudge 127.127.1.0 stratum 10 driftfile/var/lib/ntp/drift keys/etc/ntp


3. start ntp

  1. [Root @ localhost ~] #/Etc/init. d/ntpd start

4. View and test

[Root @ localhost ~] # Netstat-upnl | grep ntpd // view the time range [root @ localhost ~] # Ntpq-pn // view the synchronized server IP remote refid st t when poll reach delay offset jitter ====================== ========================================================== ========================== 50.77.217.185. INIT. 16 u-64 0 0.000 0.000 0.000 202.90.158.4. INIT. 16 u-64 0 0.000 0.000 0.000 202.71.100.89. INIT. 16 u-64 0 0.000 0.000 0.000 202.134.1.10. INIT. 16 u-64 0 0.000 0.000*127.127.1.0. LOCL. 10 l 18 64 377 0.000 0 . 000 0.001 [root @ localhost ~] # Ntpstat // synchronization result synchronised to local net at stratum 11 time correct to within 12 MS polling server every 512 s

Remote: The IP address or host name of the NTP host. Note the leftmost symbol. if it is "+", it indicates the upper-layer NTP that is currently working on the clock. if it is "*", it indicates that there are also online connections, but it is used as a secondary online NTP host.
Refid: refer to the address of the NTP host on the previous layer.
St: stratum class
When: a few seconds ago, I performed time synchronization updates.
Poll: The next update takes several seconds.
Reach: number of times that NTP servers on the upper layer have requested updates
Delay: The time delay during network transmission
Offset: the result of time compensation
Jitter: time difference between Linux system time and BIOS hardware Time

The first method is recommended. although it is relatively simple to set up a time server, I don't think this is necessary. If someone else's time server is used for synchronization every 10 minutes, it can be accurate to milliseconds.

Author: sea bottom e

Address: http://blog.51yip.com/server/1474.html


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.