블로그 이미지
훅크선장

카테고리

분류 전체보기 (362)
사진이야기 (23)
펭귄컴퓨팅 (121)
컴퓨터보안 (84)
절름발이 프로그래머 (59)
하드웨어개조 (23)
멀알려줄까 (35)
홈베이킹&홈쿠킹 (2)
잡다한것들 (15)
Total
Today
Yesterday

달력

« » 2024.4
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30

공지사항

태그목록

최근에 올라온 글

사설망 내부 서버들의 시간 동기화를 위해서, ntp 서버 데몬을 사용하는 방법입니다.

먼저 시간의 기준이 되는 서버를 선정합니다. 예로 그 서버가 192.168.100.15 라고 합니다.
그리고, 각 서버들이 192.168.100.x  네트워크에 속해있다고 가정합니다.

제일 우선적으로 모든 서버에 ntp 데몬을 설치하여야 합니다.
[root@localhost ~]# yum install ntp
Loaded plugins: dellsysid, fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.tt.co.kr
 * extras: centos.tt.co.kr치
 * updates: centos.tt.co.kr
base                                                                 | 2.1 kB     00:00     
dell-omsa-indep                                                      | 1.9 kB     00:00     
dell-omsa-specific                                                   | 1.9 kB     00:00     
extras                                                               | 2.1 kB     00:00     
updates                                                              | 1.9 kB     00:00     
updates/primary_db                                                   | 588 kB     00:00     
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package ntp.x86_64 0:4.2.2p1-9.el5.centos.2.1 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

============================================================================================
 Package        Arch              Version                             Repository       Size
============================================================================================
Installing:
 ntp            x86_64            4.2.2p1-9.el5.centos.2.1            base            1.3 M

Transaction Summary
============================================================================================
Install       1 Package(s)
Upgrade       0 Package(s)

Total download size: 1.3 M
Is this ok [y/N]: y
Downloading Packages:
ntp-4.2.2p1-9.el5.centos.2.1.x86_64.rpm                              | 1.3 MB     00:00     
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : ntp                                                                  1/1 

Installed:
  ntp.x86_64 0:4.2.2p1-9.el5.centos.2.1

설치가 완료되었으면, ntp 관련 설정을 하면 됩니다.
기존에 자동으로 설치되는 /etc/ntp.conf 에서 일부만 고치면 됩니다.

사설망내에서 시간의 기준이 되는 예로 192.168.100.15 번 서버는 /etc/ntp.conf 파일에서 다음 부분만 수정하여 설정합니다.
# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
restrict 192.168.100.0 mask 255.255.255.0 nomodify notrap # 로컬 서버들이 시간 정보를 가져갈 수 있도록, 접근제한을 풀어줍니다.

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.rhel.pool.ntp.org  # 기존에 설정된 server 들을 모두 사용하지 않습니다.
#server 1.rhel.pool.ntp.org  # 오직 자체 시스템의 클럭만을 시간으로 사용합니다. (이 서버가 기준이므로,)
#server 2.rhel.pool.ntp.org

192.168.100.15 번 서버는 현재 사설망의 기준 시간이 되는 서버이므로, 오직 자체 시스템의 클럭만을 시간으로 사용합니다. 그러므로, /etc/ntp.conf 파일 내에서 server 라는 문구는 유일하게 다음 한 줄만 존재하여야 합니다.
server  127.127.1.0     # local clock

다음으로, 192.168.100.x 네트워크에 존재하는 다른 서버들은 기준 시간 서버로 192.168.100.15 서버를 사용하므로, /etc/ntp.conf 파일에서 다음 부분만 수정하여 설정합니다.

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.rhel.pool.ntp.org  # 기존에 설정된 server 들을 모두 사용하지 않습니다.
#server 1.rhel.pool.ntp.org
#server 2.rhel.pool.ntp.org
server 192.168.100.15  # 사설망내 시간 기준 서버를 지정합니다.

기준 시간 서버인 192.168.100.15 서버와 192.168.100.x 네트워크에 존재하는 다른 서버들의 설정이 다른 것은 기준 서버를 제외한 다른 서버들은 별도로 시간 정보를 다른 쪽에 줄 필요가 없기 때문입니다.( 기준 서버와 동일하게, 접근제한을 풀어줘서 또 다른 기준 시간 서버로 사용할 수도 있습니다만, 관리자의 선택에 따르면 됩니다.)

설정이 완료되었으면, ntpd 서비스를 시작시키고, 매 시스템이 시작될 때마다 구동되도록 설정합니다.
[root@localhost ~]# service ntpd start
[root@localhost ~]# chkconfig ntpd on

ntpd 서비스가 정상적으로 동작하는지를 확인합니다.
[root@localhost ~]# ps -ef |grep ntp
ntp      23483     1  0 14:24 ?        00:00:00 ntpd -u ntp:ntp -p /var/run/ntpd.pid -g
root     24326 23151  0 15:10 pts/12   00:00:00 grep ntp
[root@localhost ~]#

ntpd 서비스가 시간을 정상적으로 동기화하고 있는 여부는 다음과 같이 확인합니다.
기준 시간 서버인 192.168.100.15 서버는 동기화 정보를 자기 자신뿐이므로, 결과가 다음과 같이 나타나고,
[root@localhost ~]# ntpq -pn
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*127.127.1.0     .LOCL.          10 l   19   64  377    0.000    0.000   0.001
[root@localhost ~]#

192.168.100.x 네트워크에 존재하는 다른 서버들은 기준 시간 서버인 192.168.100.15 서버를 참조하고 있기 때문에, 다음과 같이 결과가 출력됩니다.

[root@Server1 etc]# ntpq -pn
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*192.168..100.15  LOCAL(0)        11 u   47   64  377    0.156   16.448  14.100
 127.127.1.0     .LOCL.          10 l   40   64  377    0.000    0.000   0.001
[root@Server1 etc]#


Posted by 훅크선장
, |