ntpサービス/クライアント構成の詳細
今回の実験は2台のrhel 6.3を使用し、そのうち192.168.1.131はサービス側である.192.168.1.132はクライアントです.サーバ側の構成は192.168のみ許可する.1.0セグメント接続サーバによる時間同期
1.ntpサービスのインストール(クライアントとサービス側)
2、サービス側のntpを構成する(サービス側のみの構成)
3、サービス側時間同期
エラーが発生しました:ntpサービスを閉じてから時間同期を行います
ntpサービスを開始
ntpポートが開いているかどうかを確認します
4、BIOS時間とシステム時間の同期
5、クライアントとサービス側は時間同期を行う
6.クライアント書き込みとサービス側時間の同期計画
これでntpサービス構成が完了します.
1.ntpサービスのインストール(クライアントとサービス側)
# yum -y install ntp
# rpm -qa | grep ntp
fontpackages-filesystem-1.41-1.1.el6.noarch
ntpdate-4.2.6p5-5.el6.centos.4.x86_64
ntp-4.2.6p5-5.el6.centos.4.x86_64
# chkconfig ntpd on #
2、サービス側のntpを構成する(サービス側のみの構成)
# vim /etc/ntp.conf
#restrict default kod nomodify notrap nopeer noquery
#restrict -6 default kod nomodify notrap nopeer noquery
, 192.168.1.0
restrict 127.0.0.1
restrict -6 ::1
restrict 192.168.1.0 mask 255.255.255.0
server 0.centos.pool.ntp.org iburst
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburst
server 127.127.1.0 #
fudge 127.127.1.0 stratum 10 # 10 , 16
3、サービス側時間同期
# ntpdate 0.centos.pool.ntp.org
28 May 16:46:10 ntpdate[2130]: the NTP socket is in use, exiting
エラーが発生しました:ntpサービスを閉じてから時間同期を行います
# service ntpd stop
# ntpdate 0.centos.pool.ntp.org
28 May 16:47:15 ntpdate[2142]: adjust time server 182.92.12.11 offset 0.038762 sec
ntpサービスを開始
# service ntpd start
# ntpq -p #
# ntpstat #
synchronised to NTP server (182.92.12.11) at stratum 3
time correct to within 207 ms
polling server every 64 s
ntpポートが開いているかどうかを確認します
# netstat -anptu | grep 123
udp 0 0 192.168.1.131:123 0.0.0.0:* 2154/ntpd
udp 0 0 127.0.0.1:123 0.0.0.0:* 2154/ntpd
udp 0 0 0.0.0.0:123 0.0.0.0:* 2154/ntpd
udp 0 0 fe80::250:56ff:fe2e:9e3:123 :::* 2154/ntpd
udp 0 0 ::1:123 :::* 2154/ntpd
udp 0 0 :::123 :::* 2154/ntpd
4、BIOS時間とシステム時間の同期
# hwclock -r # bios
# hwclock -w # bios
5、クライアントとサービス側は時間同期を行う
# ntpdate 192.168.1.131
# date #
6.クライアント書き込みとサービス側時間の同期計画
# crontab -e
0 12 * * * /usr/sbin/ntpdate 192.168.1.131 # 12
これでntpサービス構成が完了します.