NTP时间服务器
-
NTP简介
NTP(Network Time Protocol,网络时间协议)是用来使网络中的各个计算机时间同步的一种协议,它的用途是把计算机的时钟同步到世界协调时UTC,其精度在局域网内可达0.1ms,在互联网上绝大多数的地方其精度可以达到1-50ms。
NTP服务器就是利用NTP协议提供时间同步服务的。
-
NTP时间服务器搭建
-
实验环境
-
操作系统及内核版本
-
[root@m01 ~]# cat /etc/redhat-release
-
CentOS release 6.9 (Final)
-
[root@m01 ~]# uname -r
-
2.6.32-696.el6.x86_64
-
主机IP地址规划
-
-
主机名 |
操作系统版本 |
外网IP |
内网IP |
用途 |
|
m01 |
CentOS release 6.9 |
10.0.0.71/24 |
172.16.1.71/24 |
时间服务器 |
-
安装ntp
yum -y install ntp
-
修改/etc/ntp.conf:
-
在文件中将restrict default kod nomodify notrap nopeer noquery 注释掉(前添加"#"),这个应该是对客户端的限制太多,所以把它去掉。
-
restrict default kod notrap nomodify
-
注释掉默认的server同步,添加新的同步时间服务器
-
server 0.cn.pool.ntp.org
-
server 1.cn.pool.ntp.org
-
server 2.cn.pool.ntp.org
-
server 3.cn.pool.ntp.org
-
-
启动ntp服务
-
[root@m01 /]# /etc/init.d/ntpd start
-
-
查看ntp服务状态
-
[root@m01 /]# ntpstat
-
synchronised to NTP server (101.6.6.172) at stratum 3
-
time correct to within 329 ms
-
polling server every 64 s
-
-
客户端测试
-
[root@tomcat ~]# ntpdate 172.16.1.61
-
27 Jul 09:16:43 ntpdate[16670]: step time server 172.16.1.61 offset -46031.777540 sec
-
-
添加到定时任务
-
echo "*/5 * * * * /usr/sbin/ntpdate ntp 172.16.1.71 &>/dev/null"
-
注释 :配置好服务器后,需要一段时间才能同步 !在客户端测试的时候后会出现一下问题。过 10 到 15 分钟就好了
甲壳虫免杀论坛版主------jks_巴顿