美文网首页
2018-07-17

2018-07-17

作者: 林情又_88a1 | 来源:发表于2018-08-24 14:25 被阅读0次

各个节点实现时间同步

有三台虚拟机, tt-hadoop1为主, tt-hadoop2 和 tt-hadoop3 为从

要实现从节点的date永远和主节点的date保持一致

1> 在tt-hadoop1检查ntp包是否安装

命令: rpm -qa|grep ntpd

如图所示,说明有ntp包

2> 修改配置文件

在 /etc/目录下找到ntp.conf

a.  在ntp.conf中添加以下内容

restrict 192.168.11.0 mask 255.255.255.0 nomodify notrap

b.  注释以下四行内容

#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

c.  去掉以下注释(如果没有,直接手动添加)

server 127.127.1.0

fudge 127.127.1.0 stratum 10

3> 启动ntp

命令: service ntpd start

查看ntp状态

命令(三个都可): service ntpd status

                           ntpstat

                           ntpq -p

设置ntp为开机自启

命令: chkconfig ntpd on

4> 查看ntp的启动路径  命令:which ntpdate

在从机上执行 ntpdate tt-hadoop1,就实现了时间的同步,但为了方便,而不是每次开启虚拟机都执行这个语句才能同步,所以写一个脚本

命令: crontab -e   (-e为编辑,-l为查看)

写入以下内容,如图所示

0-59/1 * * * * /usr/sbin/ntpdate tt-hadoop1

也可以设置BIOS与系统时间同步

a> 查看

b> 编辑 在[OPTIONS]前添加以下内容

vi /etc/sysconfig/ntpd

SYNC_HWCLOCK=yes

c> 测试

ntpstat

sudo ntpq -p

相关文章

网友评论

      本文标题:2018-07-17

      本文链接:https://www.haomeiwen.com/subject/ixdwpftx.html