본문 바로가기
Operating System/Linux & Unix

[LINUX] CentOS 8 NTP 설정

by 이미존재 2022. 10. 6.
반응형

■ CentOS 8 이후 NTP 설정

 

1. NTP 설정

 : CentOS 8 부터 rdate, ntpq 지원되지 않는다. Chrony라는 유티릴티를 권장하고 있다.

 

 1) /etc/chrony.conf config

pool 시작하는 부분을 주석처리하고 ntp 서버  등록한다.

 

#pool 2.centos.pool.ntp.org iburst

server 192.168.1.90

 

# Serve time even if not synchronized to a time source.

local stratum 10   <== 주석처리를 제거한다. 이유는 좀더 찾아봐야 

 

2) timedatectl 명령으로 기준 시간을 확인한다.

]# timedatectl

               Local time: 수 2021-01-27 03:09:49 EST

           Universal time: 수 2021-01-27 08:09:49 UTC

                 RTC time: 수 2021-01-27 08:09:50

                Time zone: America/New_York (EST, -0500)

System clock synchronized: no

              NTP service: active

          RTC in local TZ: no

 

 => time zone  Asia/Seoul 되어 있지 않으면 변경한다.

]# timedatectl set-timezone Asia/Seoul

]# timedatectl

               Local time: 수 2021-01-27 17:11:40 KST

           Universal time: 수 2021-01-27 08:11:40 UTC

                 RTC time: 수 2021-01-27 08:11:40

                Time zone: Asia/Seoul (KST, +0900)

System clock synchronized: no

              NTP service: active

          RTC in local TZ: no

 

System clock synchronized: no 일경우

[root@localhost ~]# timedatectl set-ntp yes

 

3) chronyd Enable하고 Start 한다. 이미 기동 되어 있다면 기동 한다.

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 2020-12-17 14:13:32 KST; 1 months 10 days ago

     Docs: man:chronyd(8)

           man:chrony.conf(5)

  Process: 1130 ExecStartPost=/usr/libexec/chrony-helper update-daemon (code=exited, status=0/SUCCESS)

  Process: 1030 ExecStart=/usr/sbin/chronyd $OPTIONS (code=exited, status=0/SUCCESS)

 Main PID: 1053 (chronyd)

    Tasks: 1 (limit: 101236)

   Memory: 2.9M

   CGroup: /system.slice/chronyd.service

           └─1053 /usr/sbin/chronyd

 

 1월 27 10:43:24 dbmng01 chronyd[1053]: Source 2a02:2a50:6::123 replaced with 2a01:4f9:c010:1625::1

 1월 27 11:22:15 dbmng01 chronyd[1053]: Source 2400:8902::f03c:92ff:fe7d:a163 replaced with 2400:6180:0:d0::98:c001

 1월 27 12:07:30 dbmng01 chronyd[1053]: Source 2400:6180:0:d1::866:9001 replaced with 2400:6180:0:d1::7d6:1001

 1월 27 12:43:47 dbmng01 chronyd[1053]: Source 211.233.84.186 replaced with 211.233.40.78

 1월 27 13:18:40 dbmng01 chronyd[1053]: Source 2a01:4f9:c010:1625::1 replaced with 2001:3c8:c108:ace:c0e::5

 1월 27 13:57:24 dbmng01 chronyd[1053]: Source 2400:6180:0:d0::98:c001 replaced with 2406:2000:fc:437::1001

 1월 27 14:42:04 dbmng01 chronyd[1053]: Source 2400:6180:0:d1::7d6:1001 replaced with 211.233.84.186

 1월 27 15:18:56 dbmng01 chronyd[1053]: Source 211.233.40.78 replaced with 13.209.84.50

 1월 27 15:53:25 dbmng01 chronyd[1053]: Source 2001:3c8:c108:ace:c0e::5 replaced with 2001:470:fc6f::123

 1월 27 16:32:35 dbmng01 chronyd[1053]: Source 2406:2000:fc:437::1001 replaced with 211.233.40.78

 

]# systemctl restart chronyd

 

4) 변경된 시간을 확인  동기화 상태를 확인 한다.

]# date

2021. 01. 27. (수) 17:13:12 KST

]# chronyc tracking

Reference ID    : 7F7F0101 ()

Stratum         : 10

Ref time (UTC)  : Wed Jan 27 08:14:17 2021

System time     : 0.000000000 seconds fast of NTP time

Last offset     : +0.000000000 seconds

RMS offset      : 0.000000000 seconds

Frequency       : 0.000 ppm slow

Residual freq   : +0.000 ppm

Skew            : 0.000 ppm

Root delay      : 0.000000000 seconds

Root dispersion : 0.000000000 seconds

Update interval : 0.0 seconds

Leap status     : Normal

 

]#chronyc sources

210 Number of sources = 2

MS Name/IP address         Stratum Poll Reach LastRx Last sample

===============================================================================

^* 210.98.16.101                 3  10   177   29m   +886us[ +948us] +/-   16ms

^- time.bora.net                 2   6   131    12  -7292us[-7292us] +/-  141ms

728x90

댓글