HBase 组件安装与配置
1.HBase 安装与配置
[root@master local]# tar -xvf hbase-1.7.1-bin.tar.gz -C /usr/local/
[root@master local]# ln -s /usr/local/hbase-1.7.1/ /usr/local/hbase
# 在所有节点添加环境变量
[root@master ~]# vi /etc/profile
export HBASE_HOME=/usr/local/hbase
export PATH=$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$HIVE_HOME/bin:$ZOOKEEPER_HOME/bin:$HBASE_HOME/bin
[root@master ~]# source /etc/profile
[root@master ~]# cd /usr/local/hbase/conf/
[root@master conf]# vim hbase-env.sh
#Java 安装位置
export JAVA_HOME=/usr/local/jdk
#值为 true 使用 HBase 自带的 ZooKeeper,值为 false 使用在 Hadoop 上装的 ZooKeeper
export HBASE_MANAGES_ZK=false
#HBase 类路径
export HBASE_CLASSPATH=/usr/local/hadoop/etc/hadoop/
# 在 master 节点配置 hbase-site.xml
[root@master conf]# vim hbase-site.xml
<property>
<name>hbase.rootdir</name>
<value>hdfs://master:9000/hbase</value> # 使用 9000 端口
<description>The directory shared by region servers.</description>
</property>
<property>
<name>hbase.master.info.port</name>
<value>60010</value> # 使用 master 节点 60010 端口
</property>
<property>
<name>hbase.zookeeper.property.clientPort</name>
<value>2181</value> # 使用 master 节点 2181 端口
<description>Property from ZooKeeper's config zoo.cfg. The port at
which the clients will connect.
</description>
</property>
<property>
<name>zookeeper.session.timeout</name>
<value>120000</value> # ZooKeeper 超时时间
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>master,slave1,slave2</value> # ZooKeeper 管理节点
</property>
<property>
<name>hbase.tmp.dir</name>
<value>/usr/local/hbase/tmp</value> # HBase 临时文件路径
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value> # 使用分布式 HBase
</property>
hbase.rootdir:该项配置了数据写入的目录,默认 hbase.rootdir 是指向/tmp/hbase-
${user.name},也就说你会在重启后丢失数据(重启的时候操作系统会清理/tmp 目录)。
hbase.zookeeper.property.clientPort:指定 zk 的连接端口
zookeeper.session.timeout:RegionServer 与 ZooKeeper 间的连接超时时间。当超
时时间到后,ReigonServer 会被 ZooKeeper 从 RS 集群清单中移除,HMaster 收到移除通
知后,会对这台 server 负责的 regions 重新 balance,让其他存活的 RegionServer 接管.
hbase.zookeeper.quorum:默认值是 localhost,列出 zookeepr ensemble 中的
servers
hbase.master.info.port:浏览器的访问端口
# 在 master 节点创建 hbase.tmp.dir 目录
[root@master conf]# mkdir /usr/local/hbase/tmp
# 删除 localhost,每一行写一个 slave 节点主机机器名
[root@master conf]# vim regionservers
slave1
slave2
# 将 master 上的 hbase 安装文件同步到 slave1 slave2
[root @master ~]# scp -r /usr/local/hbase/ root@slave1:/usr/local/
[root @master ~]# scp -r /usr/local/hbase/ root@slave2:/usr/local/
# master 节点修改权限
[root @master ~]# chown -R hadoop:hadoop /usr/local/hbase/
# slave1 节点修改权限
[root @slave1 ~]# chown -R hadoop:hadoop /usr/local/hbase/
# slave2 节点修改权限
[root @slave2 ~]# chown -R hadoop:hadoop /usr/local/hbase/
# 在所有节点切换到 hadoop 用户
# master 节点
[root @master ~]#su - hadoop
[root @master ~]#source /etc/profile
# slave1 节点
[root @slave1 ~]#su - hadoop
[root @slave1 ~]#source /etc/profile
# slave2 节点
[root @slave2~]#su - hadoop
[root @slave2~]#source /etc/profile
2. 启动HBASE
# 首先在 master 节点启动 Hadoop。
[hadoop@master ~]$ start-all.sh
[hadoop@master ~]$ jps
15059 SecondaryNameNode
15336 ResourceManager
14648 NameNode
17741 Jps
# slave1 节点
[hadoop@slave1 ~]$ jps
14821 NodeManager
17594 Jps
14508 DataNode
# slave2 节点
[hadoop@slave2 ~]$ jps
14481 DataNode
17668 Jps
14778 NodeManager
3.在所有节点启动 ZooKeeper
# master
[hadoop@master ~]$ zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[hadoop@master ~]$ zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost. Client SSL: false.
Mode: leader
[hadoop@master ~]$ jps
15059 SecondaryNameNode
15336 ResourceManager
14648 NameNode
20123 QuorumPeerMain
23998 Jps
# slave1
[hadoop@slave1 ~]$ zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[hadoop@slave1 ~]$ zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost. Client SSL: false.
Mode: follower
[hadoop@slave1 ~]$ jps
14821 NodeManager
19381 QuorumPeerMain
14508 DataNode
23311 Jps
# slave2
[hadoop@slave2 ~]$ zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[hadoop@slave2 ~]$ zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost. Client SSL: false.
Mode: follower
[hadoop@slave2 ~]$ jps
23425 Jps
14481 DataNode
14778 NodeManager
19469 QuorumPeerMain
4.在 master 节点启动 HBase
# master
[hadoop@master conf]$ start-hbase.sh
[hadoop@master conf]$ jps
47506 Jps
15059 SecondaryNameNode
47172 HMaster
15336 ResourceManager
14648 NameNode
20123 QuorumPeerMain
# slave1
[hadoop@slave1 ~]$ jps
51441 Jps
14821 NodeManager
19381 QuorumPeerMain
45482 HRegionServer
14508 DataNode
# slave2
[hadoop@slave2 ~]$ jps
14481 DataNode
52195 Jps
14778 NodeManager
19469 QuorumPeerMain
45261 HRegionServer
在浏览器输入 master:60010 出现如下图
http://191.168.91.10:60010