Time synchronization

Apt-get install chrony yum install chrony(centos)

SSH may be garbled

>vi /etc/locale.conf Change LANG= zh_cn. utf-8 to LANG= zh_cn. GBK >source /etc/locale.confCopy the code

Set up the Chrony startup service

  • Service Status:

Systemctl start chronyd.service systemctl enable chronyd.service systemctl status chronyd.service

  • Server and client chrony configuration
  1. Server configuration Configuration file Modify vi /etc/chrony. conf Configure the list of clients that can be accessed. CIDR is supported, for example, allow 192.168/16

  2. Synchronize local stratum from other NTP servers. 10 Run the chrony service systemctl restart chronyd.service

  • Client Configuration
  1. Vim /etc/chrony.conf Add the IP address of the source server ntp.aliyun.com iburst

  2. Restart the chrony service systemctl restart chronyd.service

  3. Viewing synchronization Status

    systemctl status chronyd -l

  4. Common commands

  • Viewing the time synchronization source:

$chronyc sources -v

  • Immediate manual synchronization

$chronyc -a makestep

  • Viewing the time synchronization source status:

$ chronyc sourcestats -v

  • Set the hardware time. The default hardware time is UTC.

$ timedatectl set-local-rtc 1

  • Enable NTP time synchronization:

$ timedatectl set-ntp yes

  • Calibrate the time server:

$chronyc tracking The chrony service must be restarted after /etc/chrony.conf is configured