본문 바로가기

OPS

[서버관리] 시간동기화 명령어 (ntpdate, ntpd, chronyd)

 

1. 서비스 사용 여부 확인

<ntpd>
# systemctl status ntpd

<chronyd>
# systemctl status chronyd

 

2. 시간동기화 서버 설정 (/etc/ntp.conf, /etc/chrony.conf)

<ntpd>
# vi /etc/ntp.conf

<chronyd>
# vi /etc/chrony.conf

--------------------------------------------
<동일>
#기존 서버 주석처리
#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 [시간동기화 서버 IP] iburst (동기화 시간 단축 옵션)

 

3. 시간동기화 서비스 시작

<ntpd>
# systemctl start ntpd

<chronyd>
# systemctl start chronyd

 

4. 부팅시 자동 시작 설정

<ntpd>
# systemctl enable ntpd

<chronyd>
# systemctl enable chronyd

 

5. 시간동기화 여부 확인

 

<ntpd>
# ntpq -p
# ntpstat

<chronyd>
# chronyc sources -v
# chronyc tracking

<ntpdate>
# ntpdate -d [시간동기화 서버 IP]

 

6. 시간동기화 수동

<ntpd>
# systemctl stop ntpd (ntpd 동작 시 ntpdate 안됨)
# ntpdate [시간동기화 서버 IP]
# hwclock -w (현재 시간으로 하드웨어 시간 설정)
# systemctl start ntpd (ntpd 서비스 다시 시작)

<chronyd>
# chronyc -a makestep
# hwclock -w (현재 시간으로 하드웨어 시간 설정)