top of page
  • 작성자 사진김영찬

NTP 서버 구축

자체 NTP 서버를 구축하기 위한 방법을 설명합니다.

NTP(Network Time Protocol) 서비스는 과거에는 NTP 서버를 설치했으나 최근에는 chrony 서버를 일반적으로 사용합니다.



Step1. chrony 설치

  • chrony 설치 확인

[root@tools ~]# rpm -qa | grep chrony

chrony-3.4-1.el7.x86_64 -- default로 설치되어 있음

  • chrony 설치

[root@tools ~]# yum install chrony

Step2. chronyd 설정

  • chrony 서버 설정 파일 /etc/chrony.conf 수정

[root@tools ~]# vi /etc/chrony.conf

# Use public servers from the pool.ntp.org project. # Please consider joining the pool (http://www.pool.ntp.org/join.html). server 0.centos.pool.ntp.org iburst server 1.centos.pool.ntp.org iburst server 2.centos.pool.ntp.org iburst server 3.centos.pool.ntp.org iburst

. . .

  • 시간 동기화 서버를 국내 표준시로 ntp 동기화를 하도록 설정한다. # Please consider joining the pool (http://www.pool.ntp.org/join.html). #server 0.centos.pool.ntp.org iburst #server 1.centos.pool.ntp.org iburst #server 2.centos.pool.ntp.org iburst #server 3.centos.pool.ntp.org iburst

# 대한민국 표준시로 ntp 동기화 설정 server 1.kr.pool.ntp.org iburst server 1.asis.pool.ntp.org iburst server 0.asia.pool.ntp.org iburst

  • chrony 서버인 stratum 설정을 enable 해주고, 3으로 설정 # Serve time even if not synchronized to a time source. #local stratum 10 local stratum 3

  • ntp 클라이언트가 접속 할 수 있는 네트워크를 설정 # Allow NTP client access from local network. allow 192.168.0.0/24 -- 내부 사설 네트워크 192.168.0.x의 C 클래스의 대역에서 접속 허용하도록 설정

Step3. chrony ntp 서비스 구동 및 확인

  • ntp 서비스 관련 방화벽을 허용한다. [root@tool2 ~]# firewall-cmd --add-service=ntp --permanent [root@tool2 ~]# firewall-cmd --reload

  • chronyd 서비스를 재시작해서 변경한 서비스를 적용하고 적용된 ntp source를 확인한다. [root@tools ~]# systemctl restart chronyd [root@tools ~]# chronyc sources -- ntp source와 시간차 정보 확인(Last 항목 만큼 차이) Number of sources = 2 MS Name/IP address Stratum Poll Reach LastRx Last sample =============================================================================== ^? 193.123.243.2 2 6 1 34 -150us[ -150us] +/- 47ms ^? ntp-b2.nict.go.jp 1 6 1 34 +50ms[ +50ms] +/- 70ms

Step4. 시간 동기화가 필요한 모든 host에서 NTP 클라이언트 설정(개별 host별로 설정 필요)

  • 기본적으로 ntp 클라이언트 역시 chrony 를 사용하고 설치되어 있지 않은 경우 yum 명령으로 chrony 를 설치 [root@worker2 ~]# yum install chrony

  • worker2 서버에서 기본 설정된 ntp 서버 정보를 확인해 보면 다음과 같이 출력된다. [root@worker2 ~]# chronyc sources =============================================================================== ^- 106.247.248.106 2 9 377 321 +538us[ +538us] +/- 38ms ^* ec2-13-209-84-50.ap-nort> 2 9 377 613 -2573us[-2447us] +/- 5580us ^- any.time.nl 2 10 377 153 -2388us[-2388us] +/- 49ms

  • /etc/chrony.conf 파일을 수정해서 ntp 서버를 앞서 구축한 tools 서버를 가리키도록 한다. # Use public servers from the pool.ntp.org project. # Please consider joining the pool (http://www.pool.ntp.org/join.html). #server 0.centos.pool.ntp.org iburst #server 1.centos.pool.ntp.org iburst #server 2.centos.pool.ntp.org iburst #server 3.centos.pool.ntp.org iburst server 192.168.0.159 iburst -- tools.futuresoft.co.kr

  • chronyd 서비스를 재시작하고, 연결된 ntp 서버 정보를 확인한다. [root@worker2 ~]# systemctl restart chronyd [root@worker2 ~]# chronyc sources -v =============================================================================== ^~ tools.futuresoft.co.kr 3 6 377 65 -297.6s[-297.6s] +/- 1249us

  • timedatectl 명령으로 NTP 동기화 상태를 확인(chronyc -a makestep을

[root@worker2 ~]# timedatectl NTP enabled: yes NTP synchronized: yes -- NTP 서버와 시간 동기화를 하지 않는 상태

  • chronyc 서버와 시간 동기화를 시작한다(시간 gap은 한번에 되지 않고 설정에 따라 시간이 걸려서 맞춰진다)

[root@worker2 ~]# chronyc -a makestep

[root@worker2 ~]# chronyc sources -v [root@worker2 ~]# timedatectl NTP enabled: yes NTP synchronized: no -- NTP 서버와 시간을 동기화하는중(gap이 있음)

조회수 958회댓글 0개

최근 게시물

전체 보기
bottom of page