A. Installation method:
1.RPM Package Installation:
mount/dev/cdrom/media/
rpm-ivh/media/centos/ntp/-4.xxxx.rpm
2. Source code compilation and installation:
wget http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/ntp-4.2.6p4.tar.gz
TAR-ZXVF ntp-4.2xx.tar.gz-c/usr/local
CD ntp-4.2.xx
./configure--PREFIX=/USR/LOCAL/NTP--enable-all-clocks--enable-prase-clocks
Make
Make install
3.yum Installation:
Yum Install NTP
Two: Configuration
[[email protected]~]# cat/etc/ntp.conf
# For more information on this file, see the "the Man pages"
# ntp.conf (5), NTP_ACC (5), Ntp_auth (5), Ntp_clock (5), Ntp_misc (5), Ntp_mon (5).
Driftfile/var/lib/ntp/drift
# Permit time synchronization with We time source, but does not
# permit the source to a query or modify the service on this system.
Restrict default Kod nomodify notrap nopeer noquery
restrict-6 default Kod nomodify notrap nopeer noquery
# Permit All access over the loopback interface. This could
# is tightened as well, but to does so would effect some of
# the administrative functions.
Restrict 127.0.0.1
192.168.1.0 Mask 255.255.255.0 nomodify
Restrict-6:: 1
# Hosts on local network is less restricted.
#restrict 192.168.1.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 cn.pool.ntp.org
#broadcast 192.168.1.255 autokey# Broadcast Server
#broadcastclient # Broadcast Client
#broadcast 224.0.1.1 AutoKey # Multicast Server
#multicastclient 224.0.1.1 # Multicast Client
#manycastserver 239.255.254.254 # Manycast Server
#manycastclient 239.255.254.254 AutoKey # manycast Client
# undisciplined Local Clock. This was a fake driver intended for backup
# and when no outside source of synchronized time is available.
server127.127.1.0# Local Clock
#fudge127.127.1.0 Stratum 10
# Enable Public Key cryptography.
#crypto
Includefile/etc/ntp/crypto/pw
# key file containing the keys and Key identifiers used when operating
# with symmetric key cryptography.
Keys/etc/ntp/keys
# Specify the key identifiers which is trusted.
#trustedkey 4 8 42
# Specify the key identifier to use with the NTPDC utility.
#requestkey 8
# Specify the key identifier to use with the NTPQ utility.
#controlkey 8
# Enable writing of Statistics records.
#statistics clockstats cryptostats loopstats peerstats
[[email protected]~]#
[[email protected]~]# Chkconfig ntpd on
[[email protected]~]#
[[email protected]~]# vi/etc/sysconfig/ntpd
[[email protected]~]# Service ntpd Restart
Shutting down NTPD: [OK]
Starting ntpd: [OK]
[[email protected]~]#
[[email protected]~]# Netstat-ntulp |grep
Usage:grep [OPTION] ... PATTERN [FILE] ...
Try ' grep--help ' for more information.
[[email protected]~]# Netstat-ntulp |grep 123
UDP 0 0192.168.1.200: 123 0.0.0.0:* 25982/NTPD
UDP 0 0 127.0.0.1:123 0.0.0.0:* 25982/ntpd
UDP 0 0 0.0.0.0:123 0.0.0.0:* 25982/ntpd
UDP 0 0:: 1:123:::* 25982/ntpd
UDP 0 0::: 123:::* 25982/ntpd
[[email protected]~]# Date
Tue 4 15:30:34 CST 2015
Servers that require synchronization time:
Method 1,
[email protected] nrpe2.13]# ntpdate 192.168.1.200
4 15:39:48 ntpdate[26443]: Step time server 192.168.1.200 offset 333893.127016 sec
[[email protected] nrpe-2.13]# Date
Tue 4 15:39:54 CST 2015
[email protected] nrpe-2.13]#
And the device synchronizes the time server address:
[email protected] nrpe-2.13]# crontab-e
*/1 * * * */usr/sbin/ntpdate 192.168.1.200
[email protected] nrpe-2.13]# crontab-l
*/1 * * * */usr/sbin/ntpdate 192.168.1.200
[[email protected]nrpe-2.13]# Cat/etc/crontab
Shell=/bin/bash
Path=/sbin:/bin:/usr/sbin:/usr/bin
Mailto=root
home=/
# for details see Mans 4 Crontabs
# Example of Job definition:
#.----------------Minute (0-59)
# | .-------------Hour (0-23)
# | | .----------Day of Month (1-31)
# | | | .-------month (1-12) OR jan,feb,mar,apr ...
# | | | | .----Day of Week (0-6) (sunday=0 or 7) or Sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * * user-name command to be executed
[[email protected]~]#
Method 2,
[[email protected] NRPE-2.13]# VI /ETC/NTP.CONF 
[[email protected] nrpe-2.13]# cat /etc/ ntp.conf
# hosts on local network are less restricted.
#restrict 192.168.1.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. 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 192.168.1.200
[[email protected] ~]# CHKCONFIG NTPD ON
[[email protected] ~]#
[[email protected] ~]# vi /etc /SYSCONFIG/NTPD
[email protected] ~]# cat/etc/sysconfig/ntpd
# Command Line Options for NTPD
Options= "-G"
Sync_hwclock=yes
[email protected] ~]#
[email protected] ~]# service ntpd restart
This article is from the "mysql_db" blog, make sure to keep this source http://mysqldb.blog.51cto.com/10264653/1681831
NTP Network time server