Hadoop集群(CDH4)实践之 (2) HBase&Zookeeper搭建


目录结构
Hadoop集群(CDH4)实践之 (0) 前言
Hadoop集群(CDH4)实践之 (1) Hadoop(HDFS)搭建
Hadoop集群(CDH4)实践之 (2) HBase&Zookeeper搭建
Hadoop集群(CDH4)实践之 (3) Hive搭建
Hadoop集群(CHD4)实践之 (4) Oozie搭建
Hadoop集群(CHD4)实践之 (5) Sqoop安装

本文内容
Hadoop集群(CDH4)实践之 (2) HBase&Zookeeper搭建

参考资料
http://www.cloudera.com/content/cloudera-content/cloudera-docs/CDH4/latest/CDH4-Installation-Guide/CDH4-Installation-Guide.html

环境准备
OS: CentOS 6.4 x86_64
Servers:
hadoop-master: 172.17.20.230 内存10G
- namenode
- hbase-master

hadoop-secondarynamenode: 172.17.20.234 内存10G
- secondarybackupnamenode,jobtracker

hadoop-node-1: 172.17.20.231 内存10G sudo yum install hbase-regionserver
- datanode,tasktracker
- hbase-regionserver,zookeeper-server

hadoop-node-2: 172.17.20.232 内存10G
- datanode,tasktracker
- hbase-regionserver,zookeeper-server

hadoop-node-3: 172.17.20.233 内存10G
- datanode,tasktracker
- hbase-regionserver,zookeeper-server

对以上角色做一些简单的介绍:
namenode - 整个HDFS的命名空间管理服务
secondarynamenode - 可以看做是namenode的冗余服务
jobtracker - 并行计算的job管理服务
datanode - HDFS的节点服务
tasktracker - 并行计算的job执行服务
hbase-master - Hbase的管理服务
hbase-regionServer - 对Client端插入,删除,查询数据等提供服务
zookeeper-server - Zookeeper协作与配置管理服务

本文定义的规范,避免在配置多台服务器上产生理解上的混乱:
所有直接以 $ 开头,没有跟随主机名的命令,都代表需要在所有的服务器上执行,除非后面有单独的//开头或在标题说明。

1. 安装前的准备
Hadoop集群(CDH4)实践之 (1) Hadoop(HDFS)搭建

配置NTP时钟同步
$ sudo yum install ntp
$ sudo /etc/init.d/ntpd start

配置ulimit与nproc参数
$ sudo vim /etc/security/limits.conf

 
hdfs  -       nofile  32768
hbase -       nofile  32768

退出并重新登录SSH使设置生效

2. 在hadoop-master上安装hbase-master
$ sudo yum install hbase-master
$ sudo yum install hbase-rest
$ sudo yum install hbase-thrift

3. 在hadoop-node上安装hbase-regionserver
$ sudo yum install hbase-regionserver

4. 在HDFS中创建HBase的目录
以下HDFS操作仅需在任意一台主机上执行一次
$ sudo -u hdfs hadoop fs -mkdir /hbase
$ sudo -u hdfs hadoop fs -chown hbase /hbase

5. 配置hbase-site.xml
$ sudo vim /etc/hbase/conf/hbase-site.xml
$ cat /etc/hbase/conf/hbase-site.xml

 
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<configuration>
<property>
  <name>hbase.rest.port</name>
  <value>60050</value>
</property>
<property>
  <name>hbase.cluster.distributed</name>
  <value>true</value>
</property>
<property>
  <name>hbase.rootdir</name>
  <value>hdfs://hadoop-master:8020/hbase</value>
</property>
<property>
  <name>hbase.zookeeper.quorum</name>
  <value>hadoop-node-1,hadoop-node-2,hadoop-node-3</value>
</property>
</configuration>

6. 配置regionservers
$ sudo vim /etc/hbase/conf/regionservers

 
hadoop-node-1
hadoop-node-2
hadoop-node-3

7. 安装Zookeeper
$ sudo yum install zookeeper
$ sudo vim /etc/zookeeper/conf/zoo.cfg
$ cat /etc/zookeeper/conf/zoo.cfg

 
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/var/lib/zookeeper
clientPort=2181
maxClientCnxns=0
server.1=hadoop-node-1:2888:3888
server.2=hadoop-node-2:2888:3888
server.3=hadoop-node-3:2888:3888

8. 在hadoop-node上安装zookeeper-server并创建myid文件
$ sudo yum install zookeeper-server
$ sudo touch /var/lib/zookeeper/myid
$ sudo chown -R zookeeper:zookeeper /var/lib/zookeeper
$ echo 1 > /var/lib/zookeeper/myid //仅在hadoop-node-1上执行
$ echo 2 > /var/lib/zookeeper/myid //仅在hadoop-node-2上执行
$ echo 3 > /var/lib/zookeeper/myid //仅在hadoop-node-3上执行

$ sudo /etc/init.d/zookeeper-server init //仅在任一hadoop-node上执行一次
$ sudo /etc/init.d/zookeeper-server start

9. 启动Hbase服务
仅在hadoop-master上
$ sudo /etc/init.d/hbase-master start
$ sudo /etc/init.d/hbase-thrift start
$ sudo /etc/init.d/hbase-rest start

仅在hadoop-node上
$ sudo /etc/init.d/hbase-regionserver start

10. 查看服务的状态
通过网页查看 http://hadoop-master:60010

11. 至此,HBase&Zookeeper的搭建就已经完成。

, , ,

  1. No comments yet.
(will not be published)
*