Linux Server time synchronization configuration

Source: Internet
Author: User
Tags add time chrony

Time servers with CentOS7, other servers (Centos 6, RHEL7) Synchronize the server time

RHEL 7, CentOS 7 default network Time protocol is Chrony

This tutorial time Server service side host name: Centos7-node3 ip:192.168.231.130

Client 1 Host Name: Rhel7-node1

Client 2 host Name: Centos6-node2

Service side:

Check the status of the next Chrony service first

[Email protected] ~]# systemctl status Chronydunit Chronyd.service could not being found.

If the query does not have the service, you can install Yum

[[email protected] ~]# yum install -y chronyloaded plugins:  fastestmirrorbase                                                                                                                | 3.6 kB  00:00:00     extras                                                                                                              | 3.4 kB  00:00:00     updates                                                                                                             | 3.4 kB  00:00:00      loading mirror speeds from cached  Hostfile--------------------------------------------------------------omit part of the process--------------------------------------------- --------------------------running transaction  installing : chrony-3.2-2.el7.x86_64                                                                                                1/1   verifying  :  chrony-3.2-2.el7.x86_64                                                                                                1/1 Installed:  chrony.x86_64 0:3.2-2.el7                                                                                                                complete!

Start the Chrony service

[Email protected] ~]# systemctl start chronyd

Query status

[[Email protected] ~]# systemctl status chronyd  CHRONYD.SERVICE - NTP  client/server   Loaded: loaded  (/usr/lib/systemd/system/chronyd.service;  enabled; vendor preset: enabled)    Active: active  (running)  since  thu 2018-06-07 10:20:28 cst; 2s ago     docs: man : Chronyd (8)            man:chrony.conf (5)    process: 6031 execstartpost=/usr/libexec/chrony-helper update-daemon  (code=exited,  status=0/success)   Process: 6027 ExecStart=/usr/sbin/chronyd  $OPTIONS   (code= exited, status=0/success)  Main PID: 6029  (chronyd)    cgroup: / System.slice/chronyd.service           └─6029 /usr /sbin/chronydjun 07 10:20:28 centos7-node3 systemd[1]: starting ntp client/server ... jun 07 10:20:28 centos7-node3 chronyd[6029]: chronyd version 3.2  starting  (+cmdmon +ntp +refclock +rtc +privdrop +scfilter + ... DEBUG) jun 07 10:20:28 centos7-node3 chronyd[6029]: initial frequency - 29.914 ppmjun 07 10:20:28 centos7-node3 systemd[1]: started ntp client /server. jun 07 10:20:33 centos7-node3 chronyd[6029]: selected source  37.218.240.198jun 07 10:20:33 centos7-node3 chronyd[6029]: system clock  wrong by -3.020089 seconds, adjustment startedjun 07 10:20:30  centos7-node3 chronyd[6029]: system clock was stepped by -3.020089  Secondshint: some lines were ellipsized, uSe -l to show in full. 

Do the following configuration as a time server:

[[email protected] ~]# VIM/ETC/CHRONY.CONF25 # allow NTP Client access from local network.26 allow 192.168.231.0/2427 28 # Serve Time even if not synchronized to a time source.29 local stratum 10


Three server times, centos7-node3 for normal time


Client Configuration:

Client 1:

Delete or annotate the server 0.rhel.pool.ntp.org iburst---server 3.rhel.pool.ntp.org iburst

New \ Modify Configuration:

Server 192.168.231.130 Iburt

Allow 192.168.231.0/24

[[email protected] ~]# vim /etc/chrony.conf  1 # use public  servers from the pool.ntp.org project.    2 # please  consider joining the pool  (http://www.pool.ntp.org/join.html).     3   #server  0.rhel.pool.ntp.org iburst    4  #server  1. rhel.pool.ntp.org iburst    5  #server  2.rhel.pool.ntp.org iburst     6  #server  3.rhel.pool.ntp.org iburst    7 server  192.168.231.130 iburst    8 # ignore stratum in source  selection.    9 stratumweight 0   10     11 # record the rate at which the system clock gains/ Losses time.   12&nBsp;driftfile /var/lib/chrony/drift   13    14 # enable  kernel RTC synchronization.   15 rtcsync   16     17 # in first three updates step the system clock  instead of slew   18 # if the adjustment is  Larger than 10 seconds.   19 makestep 10 3   20     21 # Allow NTP client access from local  Network.   22 allow 192.168.231.0/24

After the modification is complete, save, restart the Chrony service to take effect

[Email protected] ~]# systemctl restart Chronyd


Client 2 Centos6-node2

CentOS 6 is NTP

Execute Ntpdate 192.168.231.130

[[email protected] ~]# ntpdate 192.168.231.130 7 June 16:59:34 ntpdate[1563]: The NTP socket is on use, exiting

If the above error occurs, stop the NTP service and then execute Ntpdate 192.168.231.130

[[Email protected] ~]# service ntpd stopshutting down ntpd: [OK][[email Protect Ed] ~]# ntpdate 192.168.231.130 7 June 17:00:19 ntpdate[1578]: Step time Server 192.168.231.130 offset-13589998.954539 sec [[Email protected] ~]# service ntpd statusntpd is stopped[[email protected] ~]# Datethu June 7 17:00:37 CST 2018

Then add time synchronization to the scheduled task

[Email protected] ~]# CRONTAB-E0-59/10 * * * */usr/sbin/ntpdate 192.168.231.130

10-minute synchronization


Now look at the next three server times are consistent








Linux Server time synchronization configuration

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.