Get the App
SLTechnology News&Howtos  ›  Servers  › 

Centos synchronization time

Shulou Source: shulou.com Published: 2022-06-02 16:26:18 10月02日 Update

Time synchronization and Network synchronization of centos system

Generally speaking, the newly installed centos system server may have the wrong time or set the wrong time zone, so you can use NTP to synchronize from the time server.

1. Adjust the current time zone to Shanghai + 8 zone, or other time zones if you want. In the / usr/share/zoneinfo directory

Cp / usr/share/zoneinfo/Asia/Shanghai / etc/localtime

two。 Install ntpdate

Yum install-y ntpdate

3. Use ntpdate to synchronize standard time (or synchronize other time servers)

Ntpdate us.pool.ntp.org

4. Write the synchronized time into bios

Hwclock-w

5. If there is no network, you can set the time manually

Date-s 10:00:00

6. If the above synchronization is successful, you can put it in crontab.

Set the time to synchronize every ten minutes

* / 10 * ntpdate time.nist.gov

List several time servers

Us.pool.ntp.org

Time.nist.gov

Time.nuri.net

Asia.pool.ntp.org

Asia.pool.ntp.org

Asia.pool.ntp.org

Asia.pool.ntp.org

Set up your own time server

1. Install the time synchronization server ntp

Yum install-y ntp

two。 Configure ntp

Vim / etc/ntp.conf

Restrict default ignore / / does not allow modification or query of ntp by default, and does not receive special packet restrict 127.0.0.1 / / give all permissions to the local machine restrict 192.168.1.0 mask 255.255.255.0 notrap nomodify / / give the machine on the local network the right to synchronize time server time.nist.gov prefer / / set the time server Add prefer to indicate priority server 0.asia.pool.ntp.org 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/keys

3. Start ntp

/ etc/init.d/ntpd start

Chkconfig ntpd on

4. View and test

Ntpq-pn / / View synchronized server ip

Remote refid st t when poll reach delay offset jitter = 50.77.217.185 .INIT. 16U-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 0.000 * 127.127.1.0. LOCL. 10 l 18 64 377 0.000 0.000

Remote: that is, the IP or host name of the NTP host. Pay attention to the leftmost symbol. If "+" represents the upper NTP that is currently working on the clock, if it is "*", it means that it is also connected, but as a secondary online NTP host.

Refid: the address of the upper-level NTP host referenced

St: the stratum class

When: time synchronization update was done a few seconds ago

Poll: the next update is in a few seconds

Reach: the number of updates that have been requested from the upper NTP server

Delay: the time of clock delay during network transmission

Offset: the result of time compensation

Difference time between jitter:Linux system time and BIOS hardware time

Recommend the first method, although it is relatively simple to build a time server, but I do not think this is necessary. If you use someone else's time server, synchronize every 10 minutes, which can be accurate to milliseconds.

5. View the results of synchronization

Ntpstat

6. Client configuration

The installation and startup methods are the same, but the configuration of server is different. Change the configuration of server to the server 192.168.103.117 connected to the external network.

Tags: Time synchronization server service host configuration time zone system network update permissions result wrong special precise necessary upper layer representative role just Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Shulou Technology Redmi Apple Huawei