Hadoop集群时间同步
1.时间同步源配置(必须为root用户)
检查是否安装ntp服务
命令
# rpm -qa |grep ntp
如果有以下三个软件就不需要安装,否则自行安装
fontpackages-filesystem-1.41-1.1.el6.noarch ntp-4.2.6p5-10.el6.centos.x86_64 ntpdate-4.2.6p5-10.el6.centos.x86_64
修改ntp的配置文件
命令
$ vim /etc/ntp.conf
需要修改的内容
# Hosts on local network are less restricted. #打开这一句的注释,修改自己的网段 restrict 192.168.10.0 mask 255.255.255.0 nomodify notrap # 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 fudge 127.127.1.0 startum 10
同步时间到RTC
命令
# vi /etc/sysconfig/ntpd
添加内容
SYNC_HWCLOCK=yes
重新启动ntpd
查看ntpd服务的状态
# service ntpd status
开启ntpd服务
# service ntpd start # chkconfig ntpd on
2.其他主机配置(必须为root用户)
使用corntab设置定时更新,添加crontab任务命令添加crontab任务命令
# crontab -e
添加内容
# For details see man 4 crontabs
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
*/10 * * * * /usr/sbin/ntpdate hadoop101
corntab服务相关命令
service crond start //启动服务
service crond stop //关闭服务
service crond restart //重启服务
service crond reload //重新载入配置
service crond status //查看服务状态