본문 바로가기
Linux

리눅스 시간 동기화

by Yoon_estar 2024. 3. 13.
728x90
반응형

ntp

관리서버(master)에서 수행

# vi /etc/ntp.conf
----------------------------------------------------------------------------------------
restrict	default	nomodify	notrap	noquery
restrict	127.0.0.1
restrict	-6	::1
restrict	192.168.201.0	mask	255.255.255.0	nomodify	notrap
#	straum	2	server	list
server	127.127.1.0
fudge	127.127.1.0	stratum	10
server	kr.pool.ntp.org
server	time.bora.net
server	time.kornet.net
driftfile	/var/lib/ntp/drift
broadcastdelay	0.008
keys	/etc/ntp/keys
logfile	/var/log/ntp.log
# service	ntpd	restart
# systemctl	disable	chronyd
# systemctl	enable	ntpd
# ntpdate	-u	kr.pool.ntp.org
# date
# ntpq	-p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*LOCAL(0)        .LOCL.          10 l    3   64    3    0.000    0.000   0.001
 121.174.142.81  220.73.142.66    3 u   66   64    2    8.096   -0.923   0.001
 time.bora.net   90.1.14.51       2 u    1   64    3    2.621    6.897   1.122
 mail.innotab.co .INIT.          16 u   64   64    0    0.000    0.000   0.000

계산 서버(node01, node02)에서 수행

# vi /etc/ntp.conf
------------------------------------------------------------
driftfile	/var/lib/ntp/drift
restrict	default	kod	nomodify	notrap	nopeer	noquery
restrict	-6	default	kod	nomodify	notrap	nopeer	noquery
restrict	127.0.0.1
restrict	-6	::1
server	192.168.201.150		#	<관리서버	IP>
#server	kr.pool.ntp.org
#server	time.bora.net
#server	time.kornet.net
includefile	/etc/ntp/crypto/pw
keys	/etc/ntp/keys
-------------------------------------------------------------
# service	ntpd restart
# systemctl disable chronyd
# systemctl enable ntpd
# ntpdate	-u 192.168.207.101
# date
# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 master          LOCAL(0)        11 u   35   64    1    0.103    6.169   0.001
+175.193.3.234   119.205.235.196  3 u   30   64    1    3.512   -0.058   0.087
+121.174.142.81  220.73.142.66    3 u   28   64    1    8.291    2.868   0.199
 121.174.142.82  220.73.142.66    3 u   37   64    0    0.000    0.000   0.001
*106.247.248.106 17.253.68.253    2 u   25   64    1    2.484    3.298   0.173

chronyd

master server

# yum install chrony

# vi /etc/chrony.conf
---------------------------------------------
pool kr.pool.ntp.org iburst
driftfile /var/lib/chrony/drift
makestep 1.0 3
rtcsync
allow 192.168.0.0/16
keyfile /etc/chrony.keys
leapsectz right/UTC
logdir /var/log/chrony
---------------------------------------------

pool 에서 ntp 서버를 정의하고, allow 에서 client 접근 허용 네트워크 대역을 설정함.

# systemctl restart chronyd
# systemctl enable --now chronyd
# chronyc sources
---------------------------------------------
210 Number of sources = 4
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^- send.mx.cdnetworks.com        2   6    17    20   +342us[ -121us] +/-   60ms
^- dadns.cdnetworks.co.kr        2   6    17    25   -245us[ -707us] +/-   49ms
^- 106.247.248.106               2   6    17    25  +1015us[ +553us] +/-   26ms
^* ec2-13-209-84-50.ap-nort>     2   6    17    25   -307us[ -770us] +/- 5712us

# yum install ntpstat
# ntpstat
---------------------------------------------
synchronised to NTP server (13.209.84.50) at stratum 3
   time correct to within 6 ms
   polling server every 64 s
---------------------------------------------

# timedatectl status
---------------------------------------------
               Local time: 일 2023-07-30 17:17:37 KST
           Universal time: 일 2023-07-30 08:17:37 UTC
                 RTC time: 일 2023-07-30 08:17:37
                Time zone: Asia/Seoul (KST, +0900)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no
---------------------------------------------

node (계산 서버)

  • 시간 동기화 클라이언트 설정
# yum install chrony

# vi /etc/chrony.conf
------------------------------------------------------------
pool **192.168.201.70** iburst maxsources 1   <- 관리노드 IP
driftfile /var/lib/chrony/drift
makestep 1.0 3
rtcsync
allow 192.168.0.0/16
keyfile /etc/chrony.keys
leapsectz right/UTC
logdir /var/log/chrony
-------------------------------------------------------------

###
# systemctl restart chronyd
# systemctl enable --now chronyd
# chronyc sources
---------------------------------------------
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^* rocky8n00                     3   6    77     9    -31us[  -46us] +/-   33ms

# timedatectl status
---------------------------------------------
               Local time: 일 2023-07-30 17:21:07 KST
           Universal time: 일 2023-07-30 08:21:07 UTC
                 RTC time: 일 2023-07-30 08:21:07
                Time zone: Asia/Seoul (KST, +0900)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no
---------------------------------------------

관리 노드

  • 각 노드에서 동기화 확인
# date
hybrid-master 2023. 10. 17. (화) 19:18:04 KST
hybrid-node01 2023. 10. 17. (화) 19:18:04 KST
hybrid-node02 2023. 10. 17. (화) 19:18:04 KST
반응형

'Linux' 카테고리의 다른 글

리눅스 tee 명령어  (0) 2024.04.01
리눅스 우분투 설치 후 기본 설정  (0) 2024.04.01
Bonding  (0) 2024.03.13
Uptime  (0) 2024.02.27
Rsync 명령어  (1) 2024.02.27