栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

九、Hadoop集群同步时间

九、Hadoop集群同步时间

目的:为了后续数据版本的一致性,保证多台服务器的时间是一致的。
设置一台时间服务器,其他服务器同步时间服务器的时间。
1)安装ntp
yum install ntp -y
2)时间服务器配置(必须是root用户)
(1)在所有节点关闭ntp服务和自启动
sudo systemctl stop ntpd
sudo systemctl disable ntpd
(2)在hadoop102上修改ntp配置文件(hadoop102为时间服务器)
vim /etc/ntp.conf
(a)修改1
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
改为(去掉注释#)
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
(b)修改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
(c)添加配置(当该节点丢失网络连接,依然可以采用本地时间作为时间服务器为集群中的其他节点提供时间同步)
server 127.127.1.0
fudge 127.127.1.0 stratum 10
(3)修改/etc/sysconfig/ntpd文件
vim /etc/sysconfig/ntpd
添加内容(让硬件时间和系统时间一起同步)
SYNC_HWCLOCK=yes
(4)重新启动ntpd服务(在hadoop102,时间服务器启动)
systemctl start ntpd
(5)设置ntpd服务开机启动(在hadoop102,时间服务器启动)
systemctl enable ntpd
(6)查看状态
systemctl is-enabled ntpd
systemctl status ntpd
3)其他机器配置定时任务(必须root用户)
(1)在其他机器配置1分钟与时间服务器同步一次
sudo crontab -e
编写定时任务如下:
*/1 * * * * /usr/sbin/ntpdate hadoop102
查看任务
crontab -l (没有任务,因为是root用户创建的)
sudo crontab -l(有定时任务)
(2)删除定时任务
sudo crontab -r

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/672259.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号