Linux clock synchronization

Source: Internet
Author: User

1, in the Linux system, we may often encounter the host time is not synchronized this situation, it is necessary to set the host time synchronization.

Case one:
There are four server nodes, there are two master nodes (main node: 10.183.35.45; Slave node: 10.183.35.46), and the other two nodes are 10.183.35.47/10.183.35.48, and the time of the four host nodes is different.
Then we may be in the actual application will be set to one or two host time, the other main opportunity to the two host time as the benchmark to fix their time to meet the two host server time.
* Process of this case:
Now the 10.183.35.45 (primary server) and 10.183.35.46 (for the secondary server) "Set up two servers because, in case one of the host hangs, there is a standby host role" The time of the two hosts, whichever; put 10.183.35.46/47/48
Host time synchronization 10.183.35.45 host time to fix time.
Step One:
(1) For this case with a master-slave server node, we need to modify the ntp.conf configuration file,
Under the CD/ETC directory, modify the ntp.conf configuration file to add two lines of code under the configuration file:
# Cat/etc/ntp.con
Server 127.127.1.0 # Local clock (LCL)
Fudge 127.127.1.0 stratum LCL is unsynchronized

# # #以下两行代码为需要添加的代码, server 10.183.35.45prefer, primary server, server 10.183.35.46, secondary server
Server 10.183.35.45 prefer
Server 10.183.35.46
###

Driftfile/var/lib/ntp/drift/ntp.drift # path for drift file
LOGFILE/VAR/LOG/NTP # Alternate log file
Keys/etc/ntp.keys # path for keys file
Trustedkey 1 # define trusted keys
Requestkey 1 # key (7) for accessing server variables
(2) After modifying the configuration file, you will need to restart the NTP service:
# RCNTP Status
# RCNTP Stop
# RCNTP Start
Or
# RCNTP Restart
(3) Manually modify synchronization time (This command can also be applied to scenarios that require synchronization and a server time synchronization):
# ntpdate-s 10.183.35.45--This command does not work, the SNTP command can be executed
Or
# sntp-p No-r 10.183.35.45
(4) Under Monitoring and inspection:
# ntpq-p
Using this command to check the status of an NTP service and to see "reach", the value of such a keyword has been increased to 377, indicating success.

If the above steps are unsuccessful, execute the following command:
# Chkconfig-a|grep App
# chkconfig Boot.apparmor off
# Rcapparmor Stop
These three commands are executed under the server, then perform the following command check:
Ntpq-p

All of the above commands must be executed under the root user

Linux clock synchronization

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.