集群中所有主机必须保持时间同步,如果时间相差较大会引起各种问题。具体思路如下:
NameNode节点作为NTP服务器与外界的对时中心同步时间,随后对所有DataNode节点提供时间同步服务。所有DataNode节点以NameNode节点为基础同步时间。
所有节点安装相关组件:
yum install ntp
完成后,配置开机启动:
chkconfig ntpd on
检查是否设置成功:
chkconfig ——list ntpd
其中从第2~5个运行级系统服务转态为on状态就代表成功。
(1)主节点配置
在配置之前,先使用ntpdate手动同步一下时间,免得本机与对时中心时间差距太大,使得ntpd不能正常同步。这里选用127.127.1.0作为对时中心:
ntpdate -u 127.127.1.0
NTP服务只有一个配置文件(NTP配置文档只有一个/etc/ntp.conf,看看作者的ntp.conf),配置好了就可以了。这里只给出有用的配置,不需要的配置都用#注释掉,这里注释掉的内容就不再给出。
Master的NTP配置如下:
driftfile /var/lib/ntp/drift
restrict 127.0.0.1
restrict -6 ::1
restrict default nomodify notrap
server 127.127.1.0 prefer
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
(2)配置NTP客户端(所有DataNode节点)
DataNode的NTP配置如下:
driftfile /var/lib/ntp/drift
restrict 127.0.0.1
restrict -6 ::1
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
#这里是主节点的主机名或者ip
server namenode
include file /etc/ntp/crypto/pw
keys /etc/ntp/keys
启动NTP服务:
Service ntpd start
登录Master机器,执行命令:
ntpdate -u 127.127.1.0
登录所有Slave机器,同步主节点执行命令:
ntpdate -u hadoop11
检查是否成功,查看命令:
watch ntpq –p
NameNode节点作为NTP服务器与外界的对时中心同步时间,随后对所有DataNode节点提供时间同步服务。所有DataNode节点以NameNode节点为基础同步时间。
所有节点安装相关组件:
yum install ntp
完成后,配置开机启动:
chkconfig ntpd on
检查是否设置成功:
chkconfig ——list ntpd
其中从第2~5个运行级系统服务转态为on状态就代表成功。
(1)主节点配置
在配置之前,先使用ntpdate手动同步一下时间,免得本机与对时中心时间差距太大,使得ntpd不能正常同步。这里选用127.127.1.0作为对时中心:
ntpdate -u 127.127.1.0
NTP服务只有一个配置文件(NTP配置文档只有一个/etc/ntp.conf,看看作者的ntp.conf),配置好了就可以了。这里只给出有用的配置,不需要的配置都用#注释掉,这里注释掉的内容就不再给出。
Master的NTP配置如下:
driftfile /var/lib/ntp/drift
restrict 127.0.0.1
restrict -6 ::1
restrict default nomodify notrap
server 127.127.1.0 prefer
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
(2)配置NTP客户端(所有DataNode节点)
DataNode的NTP配置如下:
driftfile /var/lib/ntp/drift
restrict 127.0.0.1
restrict -6 ::1
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
#这里是主节点的主机名或者ip
server namenode
include file /etc/ntp/crypto/pw
keys /etc/ntp/keys
启动NTP服务:
Service ntpd start
登录Master机器,执行命令:
ntpdate -u 127.127.1.0
登录所有Slave机器,同步主节点执行命令:
ntpdate -u hadoop11
检查是否成功,查看命令:
watch ntpq –p