您现在的位置是:首页 > 文章详情

NTP时间同步

日期:2016-05-22点击:678

wKioL1dB0bnx2bbYAADhgNpVYM4356.png

(一).NTP服务端端配置

  1. NTP服务器安装


[root@oldboy ~]# rpm  -qa ntp ntp-4.2.6p5-5.el6.centos.x86_64 [root@oldboy ~]#  没有的话就安装 [root@oldboy ~]# yum -y install  ntp


2修改NTP的配置文件,并保存退出

[root@oldboy ~]# vim /etc/ntp.conf  #restrict default kod nomodify notrap nopeer noquery #restrict -6 default kod nomodify notrap nopeer noquery  restrict default nomodify          #nomodify客户端可以同步 #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 ntp1.aliyun.com                # 默认时间同步源改为阿里的和另外一个 server time.nist.gov

3..本地定时任务如果有同步时间的定时任务,注释时间同步的定时任务

[root@oldboy ~]# crontab -l  #set by  sanlang to get consistent time #*/5 * * * *  /usr/sbin/ntpdate time.nist.gov>/dev/null 2>&1 [root@oldboy ~]#

4..启动NTP服务器

[root@oldboy ~]# /etc/init.d/ntpd  start [root@oldboy ~]# ntpstat synchronised to NTP server (182.92.12.11) at stratum 3     time correct to within 7946 ms    polling server every 64 s [root@oldboy ~]#

(二).NTP客户端配置(第一次会有一定的延迟)

[root@lb02 ~]# ntpdate 10.0.0.61 22 May 23:14:48 ntpdate[11916]: step time server 10.0.0.61 offset 12727.969441 sec [root@lb02 ~]# echo "* * * *  /usr/sbin/ntpdate 10.0.0.61" >>/var/spool/cron/root  客户端将这个命令写入定时任务中就可以了,最好先写注释

 


反思:1.可以用分发机分发定时任务

          2.NTP服务器端时间会出现单点故障,所以要至少有两台

          3.客户端做定时任务看需求,多长时间同步一次

j_0057.gifj_0057.gif


原文链接:https://blog.51cto.com/wsxxsl/1776040
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章