配置NTP服务器实现虚拟机间时间同步

  多台虚拟机之间实现时间同步是比较重要的,特别是在做集群的相关操作的时候。配置时间服务器,集群的其他机器都跟namenode所在机器同步时间。在时间服务器中配置好文件,监听其他机器。
NTP服务器【Network Time Protocol(NTP)】是用来使计算机时间同步化的一种协议
1、检查ntp是否安装,如果未安装,则安装

yum list installed | grep ntp //查看本机是否已安装
yum list | grep ntp //查看yum源中存在的ntp
yum -y install ntp.x86_64 //安装ntp

2.修改/etc/ntp.conf
a、在namenode上配置一个时间服务

# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
//在这个网段中 配置成自己的网段  也可以值某台主机
restrict 192.168.88.0 mask 255.255.255.0 nomodify notrap 

b、注释掉这四个server,添加一行

# 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 127.127.1.0 # local clock

3、修改完ntp配置后,需要重启ntpd服务

systemctl restart ntpd(或service ntpd restart )
systemctl status ntpd//查看状态
netstat -anup

这里写图片描述
这里写图片描述
成功:ntpstat
这里写图片描述
4、每个客户端安装ntpdate

yum -y install ntpdate.x86_64

这里写图片描述
5、测试,在每台客户端运行

ntpdate bigdata1

这里写图片描述

  • 7
    点赞
  • 33
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值