码迷,mamicode.com
首页 > 系统相关 > 详细

linux运维、架构之路-内网NTP时间服务器

时间:2017-10-10 16:55:11      阅读:201      评论:0      收藏:0      [点我收藏+]

标签:not   code   不可用   modify   etc   /usr   关闭   服务器   use   

技术分享

 

一、环境

[root@m01 tmp]# cat /etc/redhat-release
CentOS release 6.9 (Final)
[root@m01 tmp]# hostname -I
10.0.0.61(外网) 172.16.1.61(内网)

二、检查服务软件是否安装

[root@m01 tmp]# rpm -qa ntp
ntp-4.2.6p5-10.el6.centos.2.x86_64

三、修改ntp配置文件

vim /etc/ntp.conf
# restrict default kod nomodify notrap nopeer noquery
restrict default nomodify
# 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 ntp1.aliyun.com
server time.nist.gov

四、启动ntp服务(这台服务器是需要外网的)

[root@m01 tmp]# /etc/init.d/ntpd start
Starting ntpd:                                             [  OK  ]

注:

启动后会自动更新时间

如果原来有同步时间的任务,关闭,否则会报如下的错误。

ntpdate[118978]: the NTP socket is in use, exiting

五、无外网的服务器同步时间

[root@nfs01 ~]# ntpdate 172.16.1.61
10 Oct 14:49:18 ntpdate[21609]: adjust time server 172.16.1.61 offset 0.000652 sec
#时间服务器启动后,需要过几分钟才能进行同步。
ntpdate[5687]: no server suitable for synchronization found

六、把同步命令放入定时任务

[root@nfs01 ~]# crontab -l
#time sync by yanxinjiang at 2017-10-10
*/5 * * * * /usr/sbin/ntpdate 172.16.1.61  >/dev/null 2>&1

linux运维、架构之路-内网NTP时间服务器

标签:not   code   不可用   modify   etc   /usr   关闭   服务器   use   

原文地址:http://www.cnblogs.com/yanxinjiang/p/7645605.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!