This experiment uses 2 Rhel 6.3, of which 192.168.1.131 is the service side; 192.168.1.132 is the client. Server-side configuration allows only 192.168.1.0 network segments to connect to servers for time synchronization
1. Install the NTP service (client and server side)
# yum-y Install ntp# Rpm-qa | grep ntpfontpackages-filesystem-1.41-1.1.el6.noarchntpdate-4.2.6p5-5.el6.centos.4.x86_ 64ntp-4.2.6p5-5.el6.centos.4.x86_64# chkconfig ntpd on # Configure boot auto-start
2. Configure NTP on the server (server-side configuration only)
# vim/etc/ntp.conf Two lines comment off #restrict default kod nomodify notrap nopeer noquery #restrict-6 default Kod no Modify Notrap nopeer noquery add last line, open 192.168.1.0 network segment sync restrict 127.0.0.1restrict-6:: 1restrict 192.168.1.0 Mask 255.255.255.0 set synchronization time Site Server 0.centos.pool.ntp.org iburstserver 1.centos.pool.ntp.org iburstserver 2. centos.pool.ntp.org iburstserver 3.centos.pool.ntp.org iburstserver 127.127.1.0 # local time synchronization Fudge 127.127.1.0 Stratum 10 # local time synchronization is 10th level, setting must be less than 16
3, the service side time synchronization
# ntpdate 0.centos.pool.ntp.org 16:46:10 ntpdate[2130]: The NTP socket is on use, exiting
Error: Turn off NTP service and synchronize time
# service NTPD stop# ntpdate 0.centos.pool.ntp.org28 May 16:47:15 ntpdate[2142]: Adjust time server 182.92.12.11 offset 0. 038762 sec
Turn on the NTP service
# service NTPD start# ntpq-p # view time Sync info # ntpstat # view time sync status synchronised to NTP serv ER (182.92.12.11) at stratum 3 time correct to within 207 MS polling server every
To see if the NTP port is turned on
# netstat -anptu | grep 123udp 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, the BIOS time and the system time synchronization
# hwclock-r # View current BIOS time # hwclock-w # write local time to BIOS
5, the client and the server to synchronize time
# ntpdate 192.168.1.131# Date # to see if the time is synchronized successfully
6, in the client write and service-side time synchronization plan
# CRONTAB-E 0 * * */usr/sbin/ntpdate 192.168.1.131 # daily 12 o'clock with the service side time synchronization
At this point, the NTP service configuration is complete.
An explanation of NTP service/client Configuration