集群的时间同步配置步骤

时间同步的方式:找一台机器作为时间服务器,将所有的机器与这台集群时间进行定时的同步,避免运行时间较长时或者部分机器断网情况下造成时间误差过大。
配置时间同步具体步骤:
1.1 选择时间服务器,在root用户下操作或者添加sudo权限
1.2 检查ntp是否安装: rpm -qa|grep ntp
ntp-4.2.6p5-10.el6.centos.x86_64
fontpackages-filesystem-1.41-1.1.el6.noarch
ntpdate-4.2.6p5-10.el6.centos.x86_64
1.3 关闭ntpd服务:
service ntpd stop(此次登陆关闭)
chkconfig ntpd off(开机自启关闭)
service ntpd status (查看ntp状态)
1.4 修改ntp配置文件: vim /etc/ntp.conf
1.4.1 修改1 :授权192.168.1.0-192.168.1.255网段上的所有机器可以从这台机器上查询和同步时间
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap为
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
1.4.2 修改2:集群在局域网中,不使用其他互联网上的时间
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 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
1.4.3 修改3:当该节点丢失网络连接,依然可以采用本地时间 作为时间服务器为集群中的其他节点提供时间同步。
添加
server 127.127.1.0
fudge 127.127.1.0 stratum 10
1.5 修改ntpd 文件:vim /etc/sysconfig/ntpd
添加内容(让硬件时间与系统时间一起同步)
SYNC_HWCLOCK=yes
1.6 重新启动ntpd服务:service ntpd start
设置开机自启:chkconfig ntpd on
1.7 集群中其他服务器设置(root用户下)
1.7.1 配置10分钟与时间服务器同步一次
crontab -e (编写定时任务)
*/10 * * * * /usr/sbin/ntpdate hadoop1(时间服务器名称)
1.7.2 配置所有服务器完成后任意设置一台服务器时间:
date -s “1996-9-21 11:04:11”
十分钟后查看该台服务器时间是否与时间服务器同步,设置完成。

发布了6 篇原创文章 · 获赞 0 · 访问量 99

猜你喜欢

转载自blog.csdn.net/weixin_46057712/article/details/105394571