码迷,mamicode.com
首页 > 其他好文 > 详细

NTP 配置

时间:2015-03-14 21:42:28      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:

今天对虚拟机的的几台主机做了一下NTP配置。

NTP(Network Time Protocol)是用来使计算机时间同步化的一种协议,它可以使计算机对其服务器或时钟源做同步化,它可以提供高精准度的时间校正。

确认系统是否安装ntp服务:rmp -qa | grep ntp

[root@hadoop03 hadoop]# rpm  -qa | grep ntp
fontpackages-filesystem-1.41-1.1.el6.noarch
ntp-4.2.4p8-3.el6.centos.x86_64
ntpdate-4.2.4p8-3.el6.centos.x86_64

如果未安装请自行安装。

说明:

三台主机:

192.168.153.101(NTP服务器)

192.168.153.102

192.168.153.103

操作系统:

[root@hadoop03 hadoop]# cat /etc/issue
CentOS release 6.4 (Final)

 

NTP服务器配置:

修改ntp配置文件:vi /etc/ntp.conf 追加以下

restrict 192.168.153.1/24 mask 255.255.255.0 nomodify #限制只能192.168.153.x 网段从NTP服务器同步时间,并且客户端主机不能修改
server time-b.nist.gov #远程时间服务器的地址
server 127.127.1.0 # local clock 本地时间服务器
fudge 127.127.1.0 stratum 10

关闭iptable
sudo chkconfig iptables off
sudo /etc/init.d/iptables stop

如果没有关闭:

vi /etc/sysconfig/iptables 打开防火墙配置文件。加入如下配置项:
#open port for NTP server
-A  INPUT -m state --state NEW -m udp -p udp --dport 123 -j ACCEPT
重启防火墙  service iptables restart

相关命令:

service ntpd stop 关闭ntp服务

service ntpd start 开启ntp服务

service ntpd restart 重启ntp服务

ntpstat 查看同步情况:

[root@hadoop01 hadoop]# ntpstat 
synchronised to local net at stratum 11 
time correct to within 11 ms
polling server every 512 s
[root@hadoop03 hadoop]# ntpstat 
synchronised to NTP server (192.168.153.101) at stratum 12 
time correct to within 18 ms
polling server every 64 s

立即同步时间:

service ntpd stop

ntpdate ntpserverip

 

客户端配置:

修改ntp配置文件:vi /etc/ntp.conf 追加以下

server 192.168.153.101

重启ntp服务 service ntpd restart

NTP 配置

标签:

原文地址:http://www.cnblogs.com/gongice/p/4338204.html

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