ntpd를 잘못 설치되어 ntpd가 잘 못 뜰때가 있다.
(ntp는 클러스터로 동작하는 많은 nosql에서 동기화하는데 중요한 위치를 차지한다. hbase, cassandra 등등이 예로 들 수 있다)
centos 6 기준으로 ntp를 실행한다.
$ sudo service ntpd start
실행 안됨
$ vi /var/log/message
Jan 9 23:45:28 ntpd[12521]: restrict: error in address '::' on line 10. Ignoring...
Jan 9 23:45:28 ntpd[12521]: restrict: error in address '::1' on line 16. Ignoring...
Jan 9 23:45:32 ntpd[12521]: ntpd exiting on signal 15
원인은 장비에 ipv6를 지원하지 않기 때문이다. ipv6을 사용하지 않기 때문에.. 그대로 진행해본다.
(SE와 정확한 원인을 파악하는게 좋다. 사실 ntpd를 다시 삭제하고 설치하는 것을 추천한다.. 하지만 재설치 없이 진행하는 글이 이 블로그의 목적이긴 한다.)
참고로 ntp 데몬이 종료됨을 아래 소스에서 확인할 수 있다. 참고로 signal 15는 SIGTERM이다.
https://github.com/ntp-project/ntp/blob/master/ntpd/ntpd.c#L1380
static void | |
finish_safe( | |
int sig | |
) | |
{ | |
const char *sig_desc; | |
sig_desc = NULL; | |
#ifdef HAVE_STRSIGNAL | |
sig_desc = strsignal(sig); | |
#endif | |
if (sig_desc == NULL) | |
sig_desc = ""; | |
msyslog(LOG_NOTICE, "%s exiting on signal %d (%s)", progname, | |
sig, sig_desc); | |
/* See Bug 2513 and Bug 2522 re the unlink of PIDFILE */ | |
# ifdef HAVE_DNSREGISTRATION | |
if (mdns != NULL) | |
DNSServiceRefDeallocate(mdns); | |
# endif | |
peer_cleanup(); | |
exit(0); | |
} |
두 군데를 수정한다. restrict -6 대신 -6을 없애고, restict -6 ::1을 주석 처리한다.
$ vi /etc/ntp.conf
..
#restrict -6 default kod nomodify notrap nopeer noquery
restrict default kod nomodify notrap nopeer noquery
#restrict -6 ::1
다시 데몬을 실행해본다.
$ sudo service ntpd start
실행 안됨
로그를 살펴보면 ntp 사용자가 없기 때문에 에러가 발생한다. (사실, ntpd는 ntp 계정에서 사용하도록 되어 있다.)
$ vi /var/log/message
sudo를 사용해 group과 user 계정을 추가한다.
$ sudo groupadd -g 87 ntp && sudo useradd -c "Network Time Protocol" -d /var/lib/ntp -u 87 \
-g ntp -s /bin/false ntp
데몬을 실행하면 잘 동작한다.
$ sudo service ntpd start
$ ps -ef | grep ntp
ntp 8261 1 0 23:47 ? 00:00:00 ntpd -u ntp:ntp -p /var/run/ntpd.pid -g
정상적으로 실행되는지 ntpq -p를 실행한다.
$ ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
...
'unix and linux' 카테고리의 다른 글
[shell] 10번째 이상의 매개변수 접근하기 (0) | 2017.01.10 |
---|---|
[sed] 레지스터 저장 예시 (0) | 2017.01.09 |
[shell] 중첩된 커맨드 대체 (0) | 2017.01.06 |
[shell] 여러 파일의 내용을 반복적으로 실행하기 (0) | 2017.01.06 |
[shell] 역슬래시(\) 예시 (0) | 2017.01.05 |