"Gentoo DateTime HowTo"의 두 판 사이의 차이

Gentoo Korea Wiki
둘러보기로 가기 검색하러 가기
124번째 줄: 124번째 줄:
 
{{Example|코드 예제 4.2: ntpd 데몬 등록| # rc-update add ntpd default}}
 
{{Example|코드 예제 4.2: ntpd 데몬 등록| # rc-update add ntpd default}}
  
이제 시작하시죠!
+
이제 시작하시죠!<ref name="check-whether-your-settings-have-been-applied">정확한 시간이 맞춰졌는지 확인하시려면 http://time.is 에서 확인하시기 바랍니다.</ref>
  
 
{{Example|코드 예제 4.3: ntpd 시작| # /etc/init.d/ntpd start}}
 
{{Example|코드 예제 4.3: ntpd 시작| # /etc/init.d/ntpd start}}
  
정확한 시간이 맞춰졌는지 확인하시려면 http://time.is 에서 확인하시기 바랍니다.
+
== 참고 ==
 +
 
 +
<references/>

2013년 3월 24일 (일) 18:28 판

개요

한국의 한국에 대한 한국을 위한 젠투 리눅스의 날찌 시간 설정 방법입니다. (이외의 지역에서는 알아서 적절하게 설정하시기 바랍니다.)

필요한 패키지 설치

rdatenet-misc/ntp, net-misc/openntpd 등이 있지만 여기서는 rdate의 사용을 지양 하고 openntpd 의 사용을 적극 권장하는 바입니다.


코드 예제 2.1: 필요한 패키지 설치하기
emerge sys-libs/timezone-data openntpd ntp-syntax



참고: 필요한 패키지만 언급하였습니다. 기타 의존 요소 존재 여부에 대해서는 -pav 옵션을 사용하여 확인하십시오


시스템 설정

우선 다음 명령으로 시간대 존재여부를 확인합니다.


코드 예제 3.1: 존재하는 시간대 확인
# ls /usr/share/zoneinfo -a
# ls /usr/share/zoneinfo/Asia -a


다음과 같은 결과가 나타날 것입니다.

2013.03.24 18:12:46
gentoo conf.d # ls /usr/share/zoneinfo -a
.           Asia       Canada   Egypt    GB-Eire    HST       Jamaica    MST7MDT  PRC       ROK        Universal    posix
..          Atlantic   Chile    Eire     GMT        Hongkong  Japan      Mexico   PST8PDT   Singapore  W-SU         posixrules
Africa      Australia  Cuba     Etc      GMT+0      Iceland   Kwajalein  Mideast  Pacific   Turkey     WET          right
America     Brazil     EET      Europe   GMT-0      Indian    Libya      NZ       Poland    UCT        Zulu         zone.tab
Antarctica  CET        EST      Factory  GMT0       Iran      MET        NZ-CHAT  Portugal  US         iso3166.tab
Arctic      CST6CDT    EST5EDT  GB       Greenwich  Israel    MST        Navajo   ROC       UTC        localtime

2013.03.24 18:13:34
gentoo conf.d # ls /usr/share/zoneinfo/Asia -a
.          Baghdad     Chungking  Hebron       Kamchatka     Kuwait        Omsk        Riyadh88   Tbilisi        Ust-Nera
..         Bahrain     Colombo    Ho_Chi_Minh  Karachi       Macao         Oral        Riyadh89   Tehran         Vientiane
Aden       Baku        Dacca      Hong_Kong    Kashgar       Macau         Phnom_Penh  Saigon     Tel_Aviv       Vladivostok
Almaty     Bangkok     Damascus   Hovd         Kathmandu     Magadan       Pontianak   Sakhalin   Thimbu         Yakutsk
Amman      Beirut      Dhaka      Irkutsk      Katmandu      Makassar      Pyongyang   Samarkand  Thimphu        Yekaterinburg
Anadyr     Bishkek     Dili       Istanbul     Khandyga      Manila        Qatar       Seoul      Tokyo          Yerevan
Aqtau      Brunei      Dubai      Jakarta      Kolkata       Muscat        Qyzylorda   Shanghai   Ujung_Pandang
Aqtobe     Calcutta    Dushanbe   Jayapura     Krasnoyarsk   Nicosia       Rangoon     Singapore  Ulaanbaatar
Ashgabat   Choibalsan  Gaza       Jerusalem    Kuala_Lumpur  Novokuznetsk  Riyadh      Taipei     Ulan_Bator
Ashkhabad  Chongqing   Harbin     Kabul        Kuching       Novosibirsk   Riyadh87    Tashkent   Urumqi

2013.03.24 18:13:35
gentoo conf.d #

Korea는 없지만 Seoul이 있군요! 아래와 같이 시간대를 설정해줍니다.


코드 예제 3.2: 시간대 설정
# ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime


다음 명령을 내려 편집기를 통해 설정 파일을 엽니다. (emacs 신도라면 emacs로 여셔도 됩니다.)


코드 예제 3.1: 시스템 설정
# vi /etc/conf.d/hwclock


다음 설정을 참고하여 적절하게 값을 기입해 넣으십시오. CLOCK_OPTS는 설정하지 않아도 되는 것 같습니다. (.....)

# /etc/conf.d/clock

# Set CLOCK to "UTC" if your hardware clock is set to UTC (also known as
# Greenwich Mean Time).  If that clock is set to the local time, then 
# set CLOCK to "local".
# Note that if you dual boot with Windows, then you should set it to
# "local" because Windows always sets the hardware clock to local time.

CLOCK="local"

# Select the proper timezone.  For valid values, peek inside of the
# /usr/share/zoneinfo/ directory.  For example, some common values are
# "America/New_York" or "EST5EDT" or "Europe/Berlin".  If you want to
# manage /etc/localtime yourself, set this to "".

TIMEZONE="Asia/Seoul"

# If you wish to pass any other arguments to hwclock during bootup, 
# you may do so here.

CLOCK_OPTS=""

# If you want to set the Hardware Clock to the current System Time (software
# clock) during shutdown, then say "yes" here.

CLOCK_SYSTOHC="yes"


### ALPHA SPECIFIC OPTIONS ###

# If your alpha uses the SRM console, set this to "yes".
SRM="no"

# If your alpha uses the ARC console, set this to "yes".
ARC="no"

OpenNTPd 설정

OpenNTPd의 가장 큰 특징이자 장점이라면 Clock skew(시간 꼬임)를 알아서 계산해서 밀리초 단위의 보정을 자동으로 해준다는 점입니다. rdate를 여러번 호출하면서 서버에 부하를 주고 나중에 꽤 상당한(?) 시간 오차가 벌어지는 점을 감안한다면, OpenNTPd의 선택은 정말 탁월하다고 볼 수 있을지도 모릅니다.

보통 데몬의 설정은 /etc/conf.d 에서 파일을 찾아서 하지만, OpenNTPd는 무난한 프로그램들과 마찬가지로 /etc에 ntpd.conf 파일을 저장하여 설정[1]합니다. 물론 설정도 아주 쉽(?) 습니다. OpenNTPd를 설치할 때, 이미 필요한 설정파일이 마련되고, 이 상태에서 설정 값을 아래 설정 파일과 똑같이 넣으시면 됩니다.


코드 예제 4.1: /etc/ntpd.conf 편집
# vi /etc/ntpd.conf


# $OpenBSD: ntpd.conf,v 1.7 2004/07/20 17:38:35 henning Exp $
# sample ntpd configuration file, see ntpd.conf(5)

# Addresses to listen on (ntpd does not listen by default)
listen on *
#listen on 127.0.0.1
#listen on ::1

# sync to a single server
server kr.pool.ntp.org

# use a random selection of 8 public stratum 2 servers
# see http://twiki.ntp.org/bin/view/Servers/NTPPoolServers
#servers pool.ntp.org

# Choose servers announced from Debian NTP Pool
servers 0.asia.pool.ntp.org
servers 1.asia.pool.ntp.org
servers 2.asia.pool.ntp.org
servers 3.asia.pool.ntp.org

이제 설정을 다 마쳤으면, 시스템을 시작할 때마다 데몬이 동작하도록 등록합니다


코드 예제 4.2: ntpd 데몬 등록
# rc-update add ntpd default


이제 시작하시죠![2]


코드 예제 4.3: ntpd 시작
# /etc/init.d/ntpd start


참고

  1. http://en.gentoo-wiki.com/wiki/NTP
  2. 정확한 시간이 맞춰졌는지 확인하시려면 http://time.is 에서 확인하시기 바랍니다.