"CentOS ntp 설치"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-source +syntaxhighlight))
 
(사용자 3명의 중간 판 41개는 보이지 않습니다)
1번째 줄: 1번째 줄:
{{소문자}}
{{테스트|CentOS 6}}
{{테스트|CentOS 5.7}}
;CentOS ntp 설치


==설치 확인==
==확인==
<code>yum info ntp</code>설치 여부를 확인해 보자.
<syntaxhighlight lang='console'>
<source lang='dos'>
[root@zetawiki ~]# rpm -qa ntp
[root@localhost ~]# yum info ntp
[root@zetawiki ~]# yum list ntp
Loaded plugins: fastestmirror
... (생략)
Loading mirror speeds from cached hostfile
Available Packages
  * base: www.ftp.ne.jp
ntp.x86_64                    4.2.6p5-5.el6.centos.4                    updates
  * extras: www.ftp.ne.jp
</syntaxhighlight>
* updates: www.ftp.ne.jp
:→ updates 저장소를 통해 설치가능
Installed Packages
 
Name      : ntp
==설치==
Arch       : x86_64
<syntaxhighlight lang='console'>
Version    : 4.2.2p1
[root@zetawiki ~]# yum install ntp
Release    : 15.el5.centos
... (생략)
Size      : 2.5 M
================================================================================
Repo      : installed
  Package      Arch        Version                        Repository    Size
Summary   : Synchronizes system time using the Network Time Protocol (NTP).
================================================================================
URL        : http://www.ntp.org
Installing:
License    : distributable
  ntp          x86_64      4.2.6p5-5.el6.centos.4          updates      595 k
Description: The Network Time Protocol (NTP) is used to synchronize a computer's
Installing for dependencies:
          : time with another reference time source. The ntp package contains
ntpdate       x86_64       4.2.6p5-5.el6.centos.4          updates        77 k
          : utilities and daemons that will synchronize your computer's time to
 
          : Coordinated Universal Time (UTC) via the NTP protocol and NTP
Transaction Summary
          : servers. The ntp package includes ntpdate (a program for retrieving
================================================================================
          : the date and time from remote machines via a network) and ntpd (a
Install      2 Package(s)
          : daemon which continuously adjusts system time).
 
          :
Total download size: 672 k
          : Install the ntp package if you need tools for keeping your system's
Installed size: 1.7 M
          : time synchronized via the NTP protocol.
Is this ok [y/N]: y
</syntaxhighlight>
<syntaxhighlight lang='console'>
... (생략)
Installed:
  ntp.x86_64 0:4.2.6p5-5.el6.centos.4                                                               
 
Dependency Updated:
  ntpdate.x86_64 0:4.2.6p5-5.el6.centos.4                                                           
 
Complete!
</syntaxhighlight>


Available Packages
==확인 2==
Name      : ntp
<syntaxhighlight lang='console'>
Arch      : x86_64
[root@zetawiki ~]# rpm -qa ntp
Version    : 4.2.2p1
ntp-4.2.6p5-5.el6.centos.4.x86_64
Release    : 15.el5.centos.1
</syntaxhighlight>
Size      : 1.3 M
Repo      : updates
Summary    : Synchronizes system time using the Network Time Protocol (NTP).
URL        : http://www.ntp.org
License    : distributable
Description: The Network Time Protocol (NTP) is used to synchronize a computer's
          : time with another reference time source. The ntp package contains
          : utilities and daemons that will synchronize your computer's time to
          : Coordinated Universal Time (UTC) via the NTP protocol and NTP
          : servers. The ntp package includes ntpdate (a program for retrieving
          : the date and time from remote machines via a network) and ntpd (a
          : daemon which continuously adjusts system time).
          :
          : Install the ntp package if you need tools for keeping your system's
          : time synchronized via the NTP protocol.
</source>
ntp 4.2.2p1 (릴리즈 15.el5.centos)이 설치되어 있다. 원한다면 ntp 4.2.2p1 (릴리즈 15.el5.centos.1)로 업데이트 가능하다.


==설치 위치==
==설치 위치 확인==
<source lang='dos'>
<syntaxhighlight lang='console'>
[root@localhost ~]# whereis ntp
[root@zetawiki ~]# whereis ntp
ntp: /etc/ntp /etc/ntp.conf
ntp: /etc/ntp /etc/ntp.conf
[root@localhost ~]# whereis ntpd
[root@zetawiki ~]# which ntpq
ntpd: /sbin/ntpd /usr/sbin/ntpd /usr/share/man/man8/ntpd.8.gz
/usr/sbin/ntpq
[root@localhost ntp]# service ntpd status
[root@zetawiki ~]# which ntpdate
/usr/sbin/ntpdate
[root@zetawiki ~]# which ntpd
/usr/sbin/ntpd
[root@zetawiki ~]# service ntpd status
ntpd is stopped
ntpd is stopped
[root@localhost ~]# whereis ntpq
</syntaxhighlight>
ntpq: /usr/sbin/ntpq /usr/share/man/man8/ntpq.8.gz
[root@localhost ~]# whereis ntpdate
ntpdate: /sbin/ntpdate /usr/sbin/ntpdate /usr/share/man/man8/ntpdate.8.gz
</source>
*설정파일 ntp.conf는 /etc에 있다.
*설정파일 ntp.conf는 /etc에 있다.
*ntpq와 ntpdate는 /usr/sbin에 있다.
*ntpq, ntpdate, ntpd는 /usr/sbin에 있다.
*ntpd는 중지된 상태이다.
*ntpd는 중지된 상태이다.


==동기화 서버 설정==
==동기화 서버 설정==
{{참고|공용 ntp 서버 목록}}
{{참고|/etc/ntp.conf}}
<syntaxhighlight lang='bash'>
chkconfig ntpd on
echo driftfile /var/lib/ntp/drift > /etc/ntp.conf
echo restrict default kod nomodify notrap nopeer noquery >> /etc/ntp.conf
echo restrict -6 default kod nomodify notrap nopeer noquery >> /etc/ntp.conf
echo restrict 127.0.0.1 >> /etc/ntp.conf
echo restrict -6 ::1 >> /etc/ntp.conf
echo server 1.kr.pool.ntp.org >> /etc/ntp.conf
echo server 1.asia.pool.ntp.org >> /etc/ntp.conf
echo server 2.asia.pool.ntp.org >> /etc/ntp.conf
echo includefile /etc/ntp/crypto/pw >> /etc/ntp.conf
echo keys /etc/ntp/keys >> /etc/ntp.conf
service ntpd restart
ntpq -p
</syntaxhighlight>


==즉시 동기화==
==즉시 동기화==
;명령어
;명령어
<source lang='bash'>
<syntaxhighlight lang='bash'>
ntpdate 서버주소
ntpdate 서버주소
</source>
</syntaxhighlight>
 
;실행 예시
<syntaxhighlight lang='console'>
[root@zetawiki ~]# ntpdate time.windows.com
</syntaxhighlight>
 
==차이 보기==
;명령어
<syntaxhighlight lang='bash'>
ntpdate -d 서버주소
</syntaxhighlight>


;실행 예시
;실행 예시
<source lang='dos'>
<syntaxhighlight lang='console'>
[root@localhost ntp]# ntpdate time.windows.com
[root@zetawiki ~]# ntpdate -d time.windows.com
</source>
2 Oct 02:08:06 ntpdate[3166]: ntpdate 4.2.4p8@1.1612-o Tue Nov 29 00:09:13 UTC 2011 (1)
Looking for host time.windows.com and service ntp
host found : wwwco1test13.microsoft.com
transmit(65.55.21.21)
receive(65.55.21.21)
transmit(65.55.21.21)
receive(65.55.21.21)
transmit(65.55.21.21)
receive(65.55.21.21)
transmit(65.55.21.21)
receive(65.55.21.21)
transmit(65.55.21.21)
server 65.55.21.21, port 123
stratum 2, precision -6, leap 00, trust 000
refid [65.55.21.21], delay 0.19615, dispersion 0.00293
transmitted 4, in filter 4
reference time:    d4144c6a.71b59070  Tue, Oct  2 2012  2:07:54.444
originate timestamp: d4144c77.e83cbb72  Tue, Oct  2 2012  2:08:07.907
transmit timestamp:  d4144c77.cca0c88c  Tue, Oct  2 2012  2:08:07.799
filter delay:  0.22122  0.19688  0.19693  0.19615
        0.00000  0.00000  0.00000  0.00000
filter offset: 0.010714 0.029665 0.029863 0.030388
        0.000000 0.000000 0.000000 0.000000
delay 0.19615, dispersion 0.00293
offset 0.030388
 
2 Oct 02:08:07 ntpdate[3166]: adjust time server 65.55.21.21 offset 0.030388 sec
</syntaxhighlight>
:→ 마지막 offset 값이 양수이면 로컬서버가 늦는 것, 음수이면 로컬서버가 빠른 것.
:→ 로컬 서버가 약 0.03초 늦다.


==같이 보기==
==같이 보기==
*[[우분투 ntp 설치]]
*[[/etc/init.d/ntpd]]
*[[/etc/init.d/ntpd]]
*[[ntpq]]
*[[/etc/ntp.conf]]
*[[ntpd]]
*[[ntpdate]]
*[[ntpdate]]
*[[공용 ntp 서버 목록]]
*[[리눅스 시간 맞는지 확인]]


[[분류:리눅스]]
[[분류:리눅스]]
[[분류: /usr/sbin]]
[[분류: NTP]]

2020년 11월 2일 (월) 00:55 기준 최신판

CentOS ntp 설치

1 확인[ | ]

[root@zetawiki ~]# rpm -qa ntp
[root@zetawiki ~]# yum list ntp
... (생략)
Available Packages
ntp.x86_64                    4.2.6p5-5.el6.centos.4                     updates
→ updates 저장소를 통해 설치가능

2 설치[ | ]

[root@zetawiki ~]# yum install ntp
... (생략)
================================================================================
 Package       Arch         Version                         Repository     Size
================================================================================
Installing:
 ntp           x86_64       4.2.6p5-5.el6.centos.4          updates       595 k
Installing for dependencies:
 ntpdate       x86_64       4.2.6p5-5.el6.centos.4          updates        77 k

Transaction Summary
================================================================================
Install       2 Package(s)

Total download size: 672 k
Installed size: 1.7 M
Is this ok [y/N]: y
... (생략)
Installed:
  ntp.x86_64 0:4.2.6p5-5.el6.centos.4                                                                

Dependency Updated:
  ntpdate.x86_64 0:4.2.6p5-5.el6.centos.4                                                            

Complete!

3 확인 2[ | ]

[root@zetawiki ~]# rpm -qa ntp
ntp-4.2.6p5-5.el6.centos.4.x86_64

4 설치 위치 확인[ | ]

[root@zetawiki ~]# whereis ntp
ntp: /etc/ntp /etc/ntp.conf
[root@zetawiki ~]# which ntpq
/usr/sbin/ntpq
[root@zetawiki ~]# which ntpdate
/usr/sbin/ntpdate
[root@zetawiki ~]# which ntpd
/usr/sbin/ntpd
[root@zetawiki ~]# service ntpd status
ntpd is stopped
  • 설정파일 ntp.conf는 /etc에 있다.
  • ntpq, ntpdate, ntpd는 /usr/sbin에 있다.
  • ntpd는 중지된 상태이다.

5 동기화 서버 설정[ | ]

chkconfig ntpd on
echo driftfile /var/lib/ntp/drift > /etc/ntp.conf
echo restrict default kod nomodify notrap nopeer noquery >> /etc/ntp.conf
echo restrict -6 default kod nomodify notrap nopeer noquery >> /etc/ntp.conf
echo restrict 127.0.0.1 >> /etc/ntp.conf
echo restrict -6 ::1 >> /etc/ntp.conf
echo server 1.kr.pool.ntp.org >> /etc/ntp.conf
echo server 1.asia.pool.ntp.org >> /etc/ntp.conf
echo server 2.asia.pool.ntp.org >> /etc/ntp.conf
echo includefile /etc/ntp/crypto/pw >> /etc/ntp.conf
echo keys /etc/ntp/keys >> /etc/ntp.conf
service ntpd restart
ntpq -p

6 즉시 동기화[ | ]

명령어
ntpdate 서버주소
실행 예시
[root@zetawiki ~]# ntpdate time.windows.com

7 차이 보기[ | ]

명령어
ntpdate -d 서버주소
실행 예시
[root@zetawiki ~]# ntpdate -d time.windows.com
 2 Oct 02:08:06 ntpdate[3166]: ntpdate 4.2.4p8@1.1612-o Tue Nov 29 00:09:13 UTC 2011 (1)
Looking for host time.windows.com and service ntp
host found : wwwco1test13.microsoft.com
transmit(65.55.21.21)
receive(65.55.21.21)
transmit(65.55.21.21)
receive(65.55.21.21)
transmit(65.55.21.21)
receive(65.55.21.21)
transmit(65.55.21.21)
receive(65.55.21.21)
transmit(65.55.21.21)
server 65.55.21.21, port 123
stratum 2, precision -6, leap 00, trust 000
refid [65.55.21.21], delay 0.19615, dispersion 0.00293
transmitted 4, in filter 4
reference time:    d4144c6a.71b59070  Tue, Oct  2 2012  2:07:54.444
originate timestamp: d4144c77.e83cbb72  Tue, Oct  2 2012  2:08:07.907
transmit timestamp:  d4144c77.cca0c88c  Tue, Oct  2 2012  2:08:07.799
filter delay:  0.22122  0.19688  0.19693  0.19615 
         0.00000  0.00000  0.00000  0.00000 
filter offset: 0.010714 0.029665 0.029863 0.030388
         0.000000 0.000000 0.000000 0.000000
delay 0.19615, dispersion 0.00293
offset 0.030388

 2 Oct 02:08:07 ntpdate[3166]: adjust time server 65.55.21.21 offset 0.030388 sec
→ 마지막 offset 값이 양수이면 로컬서버가 늦는 것, 음수이면 로컬서버가 빠른 것.
→ 로컬 서버가 약 0.03초 늦다.

8 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}