linux ntp 时间同步

linux ntp 时间同步

2016年10月26日 18:43:26 leys123 阅读数:9219 标签: ntpntpdate时间同步 更多

个人分类: linux

一:外网同步时间

1.查看ntpd服务状态

[root@cdh sbin]# service ntpd status 

ntp: unrecognized service

说明 ntpd没有安装。

2.查看是否存在ntp的yum源

[root@cdh sbin]# yum list |grep ntp

3.如果有显示出yum源则安装ntp服务

[root@cdh sbin]# yum -y install ntp; 

首先启动ntp服务:service ntpd start 即可,并设置ntp服务,开机自启动:chkconfig ntpd on。

4.同步时间:(在每台服务器上执行,或者建一个crontab定时)

[root@cdh sbin]# ntpdate asia.pool.ntp.org

 

 

二:内网同步时间

1.内网时搭建时间服务器,,,把cdh做为时间服务器。修改cdh1中的/etc/ntp.conf

增加 

restrict default kod nomodify notrap nopeer noquery

restrict -6 default kod nomodify notrap nopeer noquery

restrict default ignore

 

restrict 172.16.1.0 mask 255.255.255.0 nomodify notrap #172.16.1.0为本集群的ip段,只允许本ip段同步此ntp服务器

 

server 127.127.1.0 #local clock   

保存,退出。

2.service ntpd restart;

3.使用watch ntpq -p命令查看:

当reach达到7及以上时,就可以去其他节点上执行ntpdate cdh,不然会报如下提示:

.

3.在其他节点机器上也需要检查ntp服务是否存在(service ntpd status ),无则安装yum -y install ntp;

假如其他节点都不能连外网,则需要拷贝cdh这个节点机器下的/usr/sbin/ntpdate到其他节点的/usr/sbin/下,并执行chmod u+x  ntpdate;

4.然后在每台机器(除了cdh1之外的)上去同步cdh1上的时间,ntpdate cdh(每个节点机器上都要运行此句)。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值