프로그래밍

[리눅스 초보 서버관리] 시간동기화 ntp 타임서버 클라이언트 설정

할랑할랑 2014. 5. 7. 15:07
반응형

[리눅스 초보 서버관리] 시간동기화 ntp 타임서버 클라이언트 설정(GNU/Linux)

시간 동기화 기준으로 잡을 ntp 서버 주소는 /etc/ntp.conf 파일에 기록한다.

[root@test]# cat /etc/ntp.conf
# For more information about this file, see the man pages
# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).
# ...생략...
server time.windows.com

ntp 데몬(daemon)은 ntpd 명령으로 띄울 수 있는데, SLEW 옵션으로 -x 을 주게 되면 서서히 시간이 변경된다.

[root@test]# ntpd -x

그리고 프로세스가 잘 떠있나 ps -ef 명령으로 확인해본다.

[root@test]# ps -ef | grep ntp | grep -v grep
root     30224     1  0 10:20 ?        00:00:00 ntpd -x

원칙적으로는 표준 시간과 시간차가 많이 나는 경우에는, 1. 해당 서버의 서비스를 모두 중단 →  2. 강제로 시간 설정(ntpdate 명령 이용) → 3. ntpd 실행의 순서로 진행해야겠으나, 이미 서비스가 운영 중이고 게다가 데이터베이스(DB, 오라클 DBMS 등...)를 운영 중인 서버라면, 무중단 상태에서 ntpd 실행 시 서버 시간이 역행하여 서비스에 문제를 일으킬 수 있으므로, 시간 역행(Time Backward) 방지하고, 시간을 서서히 맞추도록 slew 옵션(-x)을 주었다. ntpq -p 및 ntpstat 명령을 쳐보면, offset 차이가 처음엔 9000 ms 정도였으나, 3시간 정도 지난 지금은 4000 ms 정도로 서서히 줄어들고 있는 것을 확인할 수 있다.역주행 방지

[root@test]# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*xxxxxxxxxxxxx   xxx.xxx.xxx.xxx  5 u   18   64  377    0.238  -4169.9 143.066
[root@test]#
[root@test]# ntpstat
synchronised to NTP server (xxx.xxx.xxx.xxx) at stratum 6
   time correct to within 4390 ms
   polling server every 64 s

다만, 각종 매뉴얼이든 인터넷 도움말이든 다 뒤져보면, slew 옵션은 정확도 및 안정성에 문제가 있어, 공식적으로는 사용을 권장하지 않는다고 한다. (man ntpd 혹은 man xntpd 하여, / 키 누르고 SLEW 또는 slew 검색). 다른 서버(HP-UX, AIX 등)이거나, 좀 더 전문적인 수준의 내용은 man 명령으로 매뉴얼을 참고하거나, 인터넷 검색, 관련글 링크를 참고...


※ 관련글
- NTP를 이용한 시스템간 시간 동기화 (해당 글은 원 출처를 알 수 없어, 관련 링크 검색 결과를 모두 올린다.)
    - http://woong.koong.net/index.php?MenuID=4&mode=view&idx=433
    - http://hardy.tistory.com/116
    - ntp설정관련 ( http://cafe.daum.net/ds800/WYFA/35?q= )
    - http://elecfrog.tistory.com/entry/AIX-서버-시간-맞추기-NTP-서버-구성
    - http://blog.naver.com/luxury0726/120019420176
    - http://blog.naver.com/mereblue/110039653811
    - http://blog.naver.com/cyber143/20086602186
- 데일리리시큐::신뢰성 있는 로그 분석의 필수 조건, 시간동기화: http://dailysecu.com/news_view.php?article_id=3532
- Manual Pages::ntpd : http://www.nxmnpg.com/8/ntpd


※ 관련글
- 유닉스 서버 시간 서서히 맞추기(서서히 초단위 시계 조작), AIX(IBM UNIX), HP-UX(HP UNIX) 서버 관리(ntp 프로토콜 이용이 불가능할 경우) ( http://hallang.tistory.com/406 )
- [유닉스, 리눅스 서버 관리 초보] tar로 파일 묶기, 풀기 및 간단한 파일 압축(compress, uncompress)http://hallang.tistory.com/394 )
- [유닉스초보] 쉘 스크립트 날짜 계산, 유닉스 쉘에서 이틀 전, 삼일 전 날짜 구하기 (서버관리 기초) ( http://hallang.tistory.com/371 )
- [초보] vi 에디터에서 줄번호(행번호, 라인넘버) 표시 하기 ( http://hallang.tistory.com/285 )

반응형