시간 동기화 설정 점검
    • PDF

    시간 동기화 설정 점검

    • PDF

    Article Summary

    VPC 환경에서 이용 가능합니다.

    네이버 클라우드 플랫폼에서는 시간 동기화를 위한 NTP 서버를 제공합니다. 시간 동기화 설정은 시스템 운영 및 관리에 중요한 영향을 미치며, 보안, 네트워크 통신, 데이터 정확성 등과 밀접한 관련이 있습니다. 가급적이면 주기적인 1회성 시간 동기화보다는 지속적으로 시간을 맞추는 데몬을 사용해 주십시오.

    CentOS, Rocky Linux

    네이버 클라우드 플랫폼에서 제공 중인 RedHat 계열의 OS에서 NTP 설정값 및 파일을 점검해 주십시오.

    참고

    CentOS 7과 Rocky Linux 8을 대상으로 설명합니다.

    1. chrony 설치 및 동작 여부를 확인해 주십시오.
      • CentOS 7
        [root@centos7 ~]# rpm -qa | grep chrony
        chrony-3.4-1.el7.x86_64
        
        [root@centos7 ~]# ps -ef|grep chronyd | grep -v grep 
        chrony     497     1  0 Mar27 ?        00:00:05 /usr/sbin/chronyd
        
      • Rocky Linux 8
        [root@rockylinux8 ~]# rpm -qa | grep chrony
        chrony-4.1-1.el8.rocky.0.1.x86_64
        
        [root@rockylinux8 ~]# ps -ef | grep chronyd | grep -v grep
        chrony       725       1  0 Jul25 ?        00:00:05 /usr/sbin/chronyd
        
    2. DHCP에서 받아온 네이버 클라우드 플랫폼 NTP 설정값을 확인해 주십시오. VPC 환경에서 제공되는 NTP 서버의 IP는 169.254.169.123169.254.169.124입니다.
      [root@centos7 ~]# cat /var/lib/dhclient/chrony.servers.eth0
      169.254.169.123 iburst
      169.254.169.124 iburst
      
      • 해당 경로에 169.254.169.123169.254.169.124가 존재하지 않으면 아래와 같이 직접 NTP 설정값을 추가하여 처리해 주십시오.
        [root@centos7 ~]# cat /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
        server 169.254.169.123
        server 169.254.169.124
        
        ... 생략 ...
        
        [root@centos7 ~]# systemctl restart chronyd.service
        
        [root@centos7 ~]# chronyc sources
        210 Number of sources = 2
        MS Name/IP address         Stratum Poll Reach LastRx Last sample              
        ===============================================================================
        ^? 169.254.169.123               3   6     3     6  -1689us[-1689us] +/-   48ms
        ^? 169.254.169.124               3   6     3     6  -1437us[-1437us] +/-   38ms
        
    3. timedatectl 명령을 수행해 시간 동기화 여부를 확인해 주십시오.
      • NTP synchronized 값 또는 System clock synchronized 값이 yes이면 정상적으로 동기화된 상태입니다.
      • CentOS 7
        [root@centos7 ~]# timedatectl
                        Local time: Fri 2023-08-18 13:57:57 KST
                    Universal time: Fri 2023-08-18 04:57:57 UTC
                          RTC time: Fri 2023-08-18 04:57:57
                         Time zone: Asia/Seoul (KST, +0900)
                       NTP enabled: yes
                  NTP synchronized: yes
                   RTC in local TZ: no
        
      • Rocky Linux 8
        [root@rockylinux8 ~]# timedatectl
                         Local time: Fri 2023-08-18 13:57:57 KST
                     Universal time: Fri 2023-08-18 04:57:57 UTC
                           RTC time: Fri 2023-08-18 04:57:57
                          Time zone: Asia/Seoul (KST, +0900)
          System clock synchronized: yes
                        NTP service: active
                    RTC in local TZ: no
        
    4. /etc/chrony.conf 파일 설정 및 내용을 확인해 주십시오. 추가적인 시간 동기화를 설정하거나, 기존 설정 정보를 변경하고 싶은 경우에 해당 파일에서 설정할 수 있습니다.
      • VPC 환경에서 제공되는 NTP 서버의 IP는 169.254.169.123169.254.169.124입니다.
      • CentOS 7
        [root@centos7 ~]# cat /etc/chrony.conf
        # Use public servers from the pool.ntp.org project.
        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
        
        ... 생략 ...
        
      • Rocky Linux 8
        • 시간 동기화 설정값에서 잘못 들어간 10.X IP 대역은 주석 처리해 주십시오.
        • DHCP 서버로부터 시간 동기화를 위한 서버 정보를 받아오기 때문에, 변경하지 않아도 시간 동기화에 문제가 되지는 않습니다.
        • 주석 처리 전
          [root@rockylinux8 ~]#  cat /etc/chrony.conf
          # These servers were defined in the installation:
          server 10.22.64.22 iburst
          server 10.22.64.38 iburst
          # Use public servers from the pool.ntp.org project.
          # Please consider joining the pool (http://www.pool.ntp.org/join.html).
          
          ... 생략 ...
          
        • 주석 처리 후
          [root@rockylinux8 ~]#  cat /etc/chrony.conf
          # These servers were defined in the installation:
          # server 10.22.64.22 iburst
          # server 10.22.64.38 iburst
          # Use public servers from the pool.ntp.org project.
          # Please consider joining the pool (http://www.pool.ntp.org/join.html).
          server 169.254.169.123
          server 169.254.169.124
          
          ... 생략 ...
          
    5. 시간 동기화 내용을 확인해 주십시오.
      [root@centos7 ~]# systemctl restart chronyd.service
      
      [root@centos7 ~]# chronyc sources -v
      
      .-- Source mode  '^' = server, '=' = peer, '#' = local clock.
      / .- Source state '*' = current synced, '+' = combined , '-' = not combined,
      | /   '?' = unreachable, 'x' = time may be in error, '~' = time too variable.
      ||                                                 .- xxxx [ yyyy ] +/- zzzz
      ||      Reachability register (octal) -.           |  xxxx = adjusted offset,
      ||      Log2(Polling interval) --.      |          |  yyyy = measured offset,
      ||                                \     |          |  zzzz = estimated error.
      ||                                 |    |           \
      MS Name/IP address         Stratum Poll Reach LastRx Last sample              
      ===============================================================================
      ^+ 169.254.169.123               3   6   377    14  +3999us[+3999us] +/-  227ms
      ^+ 169.254.169.124               3   6   377    51   +198us[ +198us] +/-   44ms
      
      

    Ubuntu

    네이버 클라우드 플랫폼에서 제공 중인 Ubuntu 계열의 OS에서 NTP 설정값 및 파일을 점검해 주십시오.

    참고

    Ubuntu 18.04, Ubuntu 20.04를 대상으로 설명합니다.

    1. systemd-timesyncd 데몬의 상태를 확인해 주십시오.
      • systemd-timesyncd 데몬이 활성화되어 있으면 부팅 시에 chronyd 서비스가 동작하지 않으므로, 반드시 비활성화해야 합니다.
      • Ubuntu 18.04: 기본적으로 systemd-timesynd.service가 'enabled' 상태입니다. chronyd 서비스를 정상적으로 사용하기 위해서 'disabled' 상태로 변경해 주십시오.
      root@ubuntu1804:~# systemctl is-enabled systemd-timesyncd.service
      enabled
      
      root@ubuntu1804:~# systemctl disable systemd-timesyncd
      Removed /etc/systemd/system/sysinit.target.wants/systemd-timesyncd.service.
      
      root@ubuntu1804:~# systemctl stop systemd-timesyncd
      
      root@ubuntu1804:~# systemctl restart chronyd
      
      root@ubuntu1804:~# systemctl is-enabled systemd-timesyncd.service
      disabled
      
      • Ubuntu 20.04
        root@ubuntu2004:~# systemctl is-enabled systemd-timesyncd.service
        masked
        
    2. chrony 설치 및 동작 여부를 확인해 주십시오.
      • Ubuntu 18.04
        root@ubuntu1804:~# dpkg -l | grep chrony
        ii  chrony                                 3.2-4ubuntu4.5                                     amd64        Versatile implementation of the Network Time Protocol  
        
        root@ubuntu1804:~# ps -ef | grep chronyd | grep -v grep
        _chrony   2149     1  0 19:27 ?        00:00:00 /usr/sbin/chronyd
        
      • Ubuntu 20.04
        root@ubuntu2004:~# dpkg -l | grep chrony
        ii  chrony                               3.5-6ubuntu6.2                        amd64        Versatile implementation of the Network Time Protocol  
        
        root@ubuntu2004:~# ps -ef | grep chronyd | grep -v grep
        _chrony      680       1  0 17:48 ?        00:00:00 /usr/sbin/chronyd -F -1
        _chrony      683     680  0 17:48 ?        00:00:00 /usr/sbin/chronyd -F -1
        
    3. DHCP에서 받아온 네이버 클라우드 플랫폼 NTP 설정값을 확인해 주십시오. VPC 환경에서 제공되는 NTP 서버의 IP는 169.254.169.123169.254.169.124입니다.
      root@ubuntu2004:~# cat /var/lib/dhcp/chrony.servers.eth0
      169.254.169.123 iburst
      169.254.169.124 iburst
      
      • 해당 경로에 169.254.169.123169.254.169.124가 존재하지 않으면 아래와 같이 직접 NTP 설정값을 추가하여 처리해 주십시오.
        root@ubuntu2004:~# cat /etc/chrony/chrony.conf
        # See http://www.pool.ntp.org/join.html for more information.
        #pool ntp.ubuntu.com        iburst maxsources 4
        #pool 0.ubuntu.pool.ntp.org iburst maxsources 1
        #pool 1.ubuntu.pool.ntp.org iburst maxsources 1
        #pool 2.ubuntu.pool.ntp.org iburst maxsources 2
        server 169.254.169.123
        server 169.254.169.124
        
        ... 생략 ...
        
        root@ubuntu2004:~# systemctl restart chronyd.service
        
        root@ubuntu2004:~# chronyc sources
        210 Number of sources = 2
        MS Name/IP address         Stratum Poll Reach LastRx Last sample              
        ===============================================================================
        ^? 169.254.169.123               3   6     1     8   +608us[ +608us] +/-   19ms
        ^? 169.254.169.124               3   6     1     8   +669us[ +669us] +/-   20ms
        
    4. timedatectl 명령을 수행해 시간 동기화 여부를 확인해 주십시오.
      • System clock synchronized 값이 yes이면, 정상적으로 동기화된 상태입니다.
      • Ubuntu 18.04
        root@ubuntu1804:~# timedatectl
                              Local time: Wed 2023-08-18 19:33:52 KST
                          Universal time: Wed 2023-08-18 10:33:52 UTC
                                RTC time: Wed 2023-08-18 10:33:53
                               Time zone: Asia/Seoul (KST, +0900)
               System clock synchronized: yes
        systemd-timesyncd.service active: no
                         RTC in local TZ: no
        
      • Ubuntu 20.04
        root@ubuntu2004:~# timedatectl
                       Local time: Wed 2023-08-18 17:40:33 KST
                   Universal time: Wed 2023-08-18 08:40:33 UTC
                         RTC time: Wed 2023-08-18 08:40:34   
                        Time zone: Asia/Seoul (KST, +0900)   
        System clock synchronized: yes                       
                      NTP service: active                    
                  RTC in local TZ: no
        
    5. /etc/chrony/chrony.conf 파일 설정 및 내용을 확인해 주십시오. 추가적인 시간 동기화를 설정하거나, 기존 설정 정보를 변경하고 싶은 경우에 해당 파일에서 설정할 수 있습니다.
      • VPC 환경에서 제공되는 NTP 서버의 IP는 169.254.169.123169.254.169.124입니다.
        root@ubuntu2004:~# cat /etc/chrony/chrony.conf
        # Use public servers from the pool.ntp.org project.
        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
        
        ... 생략 ...
        
    6. 시간 동기화 내용을 확인해 주십시오.
      root@ubuntu2004:~# chronyc sources -v
      
       .-- Source mode  '^' = server, '=' = peer, '#' = local clock.
      / .- Source state '*' = current synced, '+' = combined , '-' = not combined,
      | /   '?' = unreachable, 'x' = time may be in error, '~' = time too variable.
      ||                                                 .- xxxx [ yyyy ] +/- zzzz
      ||      Reachability register (octal) -.           |  xxxx = adjusted offset,
      ||      Log2(Polling interval) --.      |          |  yyyy = measured offset,
      ||                                \     |          |  zzzz = estimated error.
      ||                                 |    |           \
      MS Name/IP address         Stratum Poll Reach LastRx Last sample              
      ===============================================================================
      ^+ 169.254.169.123               3   6   377    14  +3999us[+3999us] +/-  227ms
      ^+ 169.254.169.124               3   6   377    51   +198us[ +198us] +/-   44ms
      

    NTP 관련 자주하는 질문

    Q. 네트워크를 통한 시간 동기화 NTP 서버 설정은 네이버 클라우드에서 제공하는 2대만 설정하면 되나요?

    네이버 클라우드에서 제공하는 NTP 서버는 고객의 다양한 환경을 고려하여 무료로 제공되는 서비스입니다.
    네트워크 환경이 외부로 접근할 수 있는 NAT나 공인 IP를 가지는 환경이라면 네이버 클라우드에서 제공하는 NTP 서버 외에도 외부 Public NTP 서버를 3대 이상 설정하는 것을 권장 드립니다.

    NTP 서버를 2대만 설정할 경우, 2대 중에 1대에서 시간 동기화가 정상 수행되지 않는 상황이 발생하면 어느 서버의 시간이 정확한 시간을 제공하고 있는지 알 수 없는 Majority(과반수) 문제가 발생하게 됩니다. 공식 NTP 설정 가이드에서도 최소 3대의 서버를 권장하며, 일반적으로 5대의 서버를 설정하는 것이 권고되고 있습니다. 자세한 내용은 공식 홈페이지에서 확인할 수 있습니다.

    Private Subnet에서 NAT 설정이 되어 있지 않아 외부 네트워크에 접근이 불가능한 경우, Bastion 서버를 외부 Public NTP 서버와 동기화를 가능하게 설정하고 해당 서버를 포함하여 최소 3대 이상의 NTP 서버를 설정하는 것을 권장 드립니다.


    이 문서가 도움이 되었습니까?

    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.