参考:
http://blog.csdn.net/shenfuli/article/details/52765975
http://blog.csdn.net/lifuxiangcaohui/article/details/39854737
一. 环境介绍
三台主机,主机名和ip分别为:
ubuntu1 10.3.19.171
ubuntu2 10.3.19.172
ubuntu3 10.3.19.173
三台主机的登录用户名是bigdata,home目录是/home/bigdata
现在三台主机上部署hbase集群。ubuntu1作为master, ubuntu1 ubuntu2 ubuntu3均作为HRegionServer。
二.在一台主机ubuntu1上部署hbase
bigdata@ubuntu1:~/download$ tar -zxvf hbase-1.3.1-bin.tar.gz
bigdata@ubuntu1:~/download$ mv hbase-1.3.1 ../run/
bigdata@ubuntu1:~/download$ cd ../run/
bigdata@ubuntu1:~/run$ ln -s hbase-1.3.1 hbase
修改hbase-env.sh配置文件
bigdata@ubuntu1:~/run/hbase/conf$ cat hbase-env.sh
......
export JAVA_HOME=/home/bigdata/usr/jdk1.8.0_131
# 告诉hbase使用内部的zk(单机伪分布式),如果使用外部的zk,设置为false
export HBASE_MANAGES_ZK=true
修改hbase-site.xml配置文件
bigdata@ubuntu1:~/run/hbase/conf$ cat hbase-site.xml
......
<configuration>
<property>
<name>hbase.rootdir</name>
<value>hdfs://ubuntu1:9000/hbase</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.master.port</name>
<value>16000</value>
</property>
<property>
<name>hbase.master.info.port</name>
<value>16010</value>
</property>
</configuration>
修改 regionservers文件
指定机器为regionserver,不单独指定master。其中:在哪个机器上启动,哪台就是master,在regionservers文件说明要启动的HRegionServer
bigdata@ubuntu1:~/run/hbase/conf$ cat regionservers
ubuntu1
ubuntu2
ubuntu3
三. 将hbase部署到主机ubuntu2 ubuntu3上
1. 为了部署方便,直接将文件夹/home/bigdata/run/hbase打包,拷贝到主机ubuntu2 ubuntu3的相同路径下即可。
2. hbase-site文件需要做点修改,增加zookeeper的配置,如下:
bigdata@ubuntu2:~/run/hbase/conf$ cat hbase-site.xml
......
<configuration>
<property>
<name>hbase.rootdir</name>
<value>hdfs://ubuntu1:9000/hbase</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>ubuntu1:2181</value>
</property>
<property>
<name>hbase.master.port</name>
<value>16000</value>
</property>
<property>
<name>hbase.master.info.port</name>
<value>16010</value>
</property>
</configuration>
bigdata@ubuntu2:~/run/hbase/conf$ cat hbase-site.xml
......
<configuration>
<property>
<name>hbase.rootdir</name>
<value>hdfs://ubuntu1:9000/hbase</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>ubuntu1:2181</value>
</property>
<property>
<name>hbase.master.port</name>
<value>16000</value>
</property>
<property>
<name>hbase.master.info.port</name>
<value>16010</value>
</property>
</configuration>
至此,hbase已部署到三台主机。
四. 启动&&页面
启动命令:
bigdata@ubuntu1:~/run/hbase/bin$ ./start-hbase.sh
查看进程是否启动:
bigdata@ubuntu1:~/run/hbase/bin$ jps -l | grep hbase
6323 org.apache.hadoop.hbase.master.HMaster
6467 org.apache.hadoop.hbase.regionserver.HRegionServer
6269 org.apache.hadoop.hbase.zookeeper.HQuorumPeer
bigdata@ubuntu2:~/run/hbase/conf$ jps -l | grep hbase
1558 org.apache.hadoop.hbase.regionserver.HRegionServer
访问页面:
master访问页面:http://10.3.19.171:16010
regionserver访问页面:http://10.3.19.171:16030