Raspberry pi

라즈비안(Raspbian) 시간동기화

[혜안] 2017. 4. 23. 23:39
728x90

어느날 라즈비안(Raspbian) 로그 시간을 보니 현재시간과 1시간 이상 벌어져 있었다.


최적화 한다고 ntp를 삭제했더니 이렇게 되었나 싶어 다시 ntp 설치 시도.

그런데 아래와 같은 메시지만 출력되고 설치는 되지 않았다.

$ sudo apt-get install ntp

Reading package lists... Done

Building dependency tree       

Reading state information... Done

Package ntp is not available, but is referred to by another package.

This may mean that the package is missing, has been obsoleted, or

is only available from another source

However the following packages replace it:

  openntpd


E: Package 'ntp' has no installation candidate



ntpdate만 있으면 되지 싶어 ntpdate만 설치하려고 했는데, 역시나 설치 안됨.

$ sudo apt-get install ntpdate

Reading package lists... Done

Building dependency tree       

Reading state information... Done

Package ntpdate is not available, but is referred to by another package.

This may mean that the package is missing, has been obsoleted, or

is only available from another source


E: Package 'ntpdate' has no installation candidate


결국 openntpd를 설치해야 되는구나 싶었는데, 역시 또 설치 안됨.

$ sudo apt-get install openntpd 

Reading package lists... Done

Building dependency tree       

Reading state information... Done

Package openntpd is not available, but is referred to by another package.

This may mean that the package is missing, has been obsoleted, or

is only available from another source


E: Package 'openntpd' has no installation candidate


Googling ........

결과적으로 시간동기화 서버로 사용할게 아니라면 라즈비안(Raspbian)에 ntp는 불필요하다.

tiemdatectl 을 이용하면 된다.


아래와 같이 tiemdatectl 상태를 보면 NTP 가 disabled 되어 있다.

$ timedatectl status

      Local time: Sun 2017-04-23 22:00:56 KST

  Universal time: Sun 2017-04-23 13:00:56 UTC

        RTC time: n/a

       Time zone: Asia/Seoul (KST, +0900)

     NTP enabled: no

NTP synchronized: no

 RTC in local TZ: no

      DST active: n/a


할일은,

설정파일에서 시간동기화 서버를 지정하고, NTP를 enable 시키면 된다.

$ vi /etc/systemd/timesyncd.conf 


### 타임서버를 변경할 이유가 없다면, 주석처리만 해제하자

[Time]

Servers=0.debian.pool.ntp.org 1.debian.pool.ntp.org 2.debian.pool.ntp.org 3.debian.pool.ntp.org



그리고 NTP 활성화

$ sudo timedatectl set-ntp true


다시 상태를 보면,

$ timedatectl status

      Local time: Sun 2017-04-23 23:20:26 KST

  Universal time: Sun 2017-04-23 14:20:26 UTC

        RTC time: n/a

       Time zone: Asia/Seoul (KST, +0900)

     NTP enabled: yes

NTP synchronized: no

 RTC in local TZ: no

      DST active: n/a


그럼 이제 시간을 확인해보자.

$ date

Sun Apr 23 23:20:43 KST 2017

정확히 일치한다.

로그를 확인해보면,

$ vi /var/log/syslog

Apr 23 22:05:06 raspberrypi systemd[1]: Started Time & Date Service.

Apr 23 22:05:06 raspberrypi systemd[1]: Reloading.

Apr 23 22:05:07 raspberrypi systemd-timedated[4019]: Set NTP to enabled

Apr 23 22:05:07 raspberrypi systemd[1]: Starting Network Time Synchronization...

Apr 23 22:05:07 raspberrypi systemd[1]: Started Network Time Synchronization.

Apr 23 22:05:08 raspberrypi systemd[1]: Starting System Time Synchronized.

Apr 23 22:05:08 raspberrypi systemd[1]: Reached target System Time Synchronized.

Apr 23 22:05:08 raspberrypi systemd-timesyncd[4033]: Using NTP server 211.233.78.116:123 (0.debian.pool.ntp.org).

Apr 23 23:20:17 raspberrypi systemd[3231]: Time has been changed


시간이 훅~ 뛰어서 정상으로 돌아왔다.


728x90