设为首页 收藏本站
查看: 506|回复: 0

[经验分享] NTP网络时间服务器

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2015-8-6 11:07:28 | 显示全部楼层 |阅读模式
一.安装方法:
1.RPM包安装:
mount  /dev/cdrom/media/
rpm -ivh  /media/centos/ntp/-4.XXXX.rpm
2. 源码编译安装:
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安装:
yum  install  ntp
二:配置
[root@NMS ~]# cat /etc/ntp.conf
# For more information about this file, see 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 our time source, but do not
# permit the source to 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
# be tightened as well, but to do 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 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 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 is a fake driver intended for backup
# and when no outside source of synchronized time is available.
server        127.127.1.0        # local clock
#fudge        127.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 are 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

[root@NMS ~]#
[root@NMS ~]# chkconfig ntpd on
[root@NMS ~]#
[root@NMS ~]# vi /etc/sysconfig/ntpd
[root@NMS ~]# service ntpd restart
Shutting down ntpd:                                        [  OK  ]
Starting ntpd:                                             [  OK  ]
[root@NMS ~]#
[root@NMS ~]# netstat -ntulp |grep
Usage: grep [OPTION]... PATTERN [FILE]...
Try `grep --help' for more information.
[root@NMS ~]# netstat -ntulp |grep 123
udp        0      0 192.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         
[root@NMS ~]# date
Tue Aug  4 15:30:34 CST 2015
需要同步时间的服务器:
方法1、
[root@acs421 nrpe2.13]# ntpdate 192.168.1.200
4 Aug 15:39:48 ntpdate[26443]: step time server 192.168.1.200 offset 333893.127016 sec
[root@acs421 nrpe-2.13]# date
Tue Aug  4 15:39:54 CST 2015
[root@acs421 nrpe-2.13]#
并且设备同步时间服务器地址:
[root@acs421 nrpe-2.13]# crontab -e
*/1 * * * * /usr/sbin/ntpdate 192.168.1.200
[root@acs421 nrpe-2.13]# crontab -l
*/1 * * * * /usr/sbin/ntpdate 192.168.1.200
[root@acs421 nrpe-2.13]# cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# For details see man 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
[root@NMS ~]#
方法2、
[root@acs421 nrpe-2.13]# vi /etc/ntp.conf
[root@acs421 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

[root@NMS ~]# chkconfig ntpd on
[root@NMS ~]#
[root@NMS ~]# vi /etc/sysconfig/ntpd
[root@NMS ~]# cat /etc/sysconfig/ntpd
# Command line options for ntpd
OPTIONS="-g"
SYNC_HWCLOCK=yes
[root@NMS ~]#
[root@NMS ~]# service ntpd restart




运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-94732-1-1.html 上篇帖子: RedHat 6.6自建yum仓库 下篇帖子: Linux中/etc/fstab /etc/mtab /proc/mounts这三个文件的分析与比较 服务器 网络
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表