一、获取hbase的官方安装文件 网址:http://mirrors.cnnic.cn/apache/hbase/

[hadoop@master ~]$ wget http://mirrors.cnnic.cn/apache/hbase/0.98.18/hbase-0.98.18-hadoop2-bin.tar.gz

[hadoop@master ~]$ ls

file  hbase-0.98.18-hadoop2-bin.tar.gz  id_dsa.pub


二、切换到root用户,拷贝解压该文件,并赋予hadoop用户权限

[hadoop@master ~]$ sudo su -

[sudo] password for hadoop:

[root@master ~]# cp /home/hadoop/hbase-0.98.18-hadoop2-bin.tar.gz /usr/local/

[root@master local]# cd /usr/local/

[root@master local]# tar -zxvf hbase-0.98.18-hadoop2-bin.tar.gz

[root@master local]# ls

hbase-0.98.18-hadoop2 

[root@master local]# chown -R hadoop:hadoop hbase-0.98.18-hadoop2


三、编辑hbase配置文件

[root@master conf]# pwd

/usr/local/hbase-0.98.18-hadoop2/conf

[root@master conf]# vim hbase-env.sh

export JAVA_HOME=/usr/local/jdk1.8.0_20

export HBASE_MANAGES_ZK=true

export HBASE_CLASSPATH=/usr/local/hadoop-2.6.0


四、编辑hbase-site.xml

[root@master conf]# pwd

/usr/local/hbase-0.98.18-hadoop2/conf

[root@master conf]# ls

hadoop-metrics2-hbase.properties  hbase-policy.xml  regionservers

hbase-env.cmd                     hbase-site.xml

hbase-env.sh                      log4j.properties

[root@master conf]# vim hbase-site.xml

<property>

<name>hbase.master</name>

<value>master.hadoop:60000</value>

</property>

<property>

<name>hbase.master.maxclockskew</name>

<value>180000</value>

</property>

<property>

<name>hbase.rootdir</name>

<value>hdfs://master:9000/hbase</value>

</property>

<property>

<name>hbase.cluster.distributed</name>

<value>true</value>

</property>

<property>

 <name>hbase.zookeeper.quorum</name>

 <value>slave1,slave2</value>

</property>

<property>

 <name>hbase.zookeeper.property.dataDir</name>

 <value>/home/ ${user.name} /tmp/zookeeper</value>

</property>


五、配置 regionservers 

该文件“regionservers”位于“/usr/local/hbase-0.98.18-hadoop2/conf/”目录下

[root@master conf]# vim /usr/local/hbase-0.98.18-hadoop2/conf/regionservers

slave1

slave2


六、添加 HBase 环境变量

在“/etc/profile”文件的尾部添加以下内容,并使其有效(source /etc/profile)

[root@master conf]# vim /etc/profile

export HBASE_HOME=/usr/local/hadoop-2.6.0/

export PATH=$PATH:$HBASE_HOME/bin

[root@master conf]# source /etc/profile


七、复制 HBase 到其他节点

将 Master 上配置好的 hadoop 所在文件夹“/usr/local/hbase-0.98.18-hadoop2”复制到所有的 Slave 的“/usr” 目录下,用下面命令格式进行

[root@master local]# scp -r /usr/local/hbase-0.98.18-hadoop2 root@slave1:/usr/local/

[root@master local]# ssh slave1

root@slave1's password:

Last login: Mon Apr  4 07:11:21 2016 from master

[root@slave1 ~]# cd /usr/local/

[root@slave1 local]#  chown -R hadoop:hadoop hbase-0.98.18-hadoop2

[root@slave1 local]# exit

logout

Connection to slave1 closed.

[root@master local]# ssh slave2

root@slave2's password:

Last login: Sat Apr  2 16:39:20 2016

[root@slave2 ~]# cd /usr/local/

[root@slave2 local]# chown -R hadoop:hadoop hbase-0.98.18-hadoop2


八、启动 HBase

“Master”机器上,使用用户“hadoop”执行下面命令启动 HBase 数据库

[hadoop@master hbase-0.98.18-hadoop2]$ bin/start-hbase.sh

slave1: starting zookeeper, logging to /usr/local/hbase-0.98.18-hadoop2/bin/../logs/hbase-hadoop-zookeeper-slave1.out

slave3: ssh: connect to host slave3 port 22: Connection timed out

slavep: ssh: connect to host slavep port 22: Connection timed out

starting master, logging to /usr/local/hbase-0.98.18-hadoop2/bin/../logs/hbase-hadoop-master-master.out

slave2: starting regionserver, logging to /usr/local/hbase-0.98.18-hadoop2/bin/../logs/hbase-hadoop-regionserver-slave2.out

slave1: starting regionserver, logging to /usr/local/hbase-0.98.18-hadoop2/bin/../logs/hbase-hadoop-regionserver-slave1.out


[hadoop@master hbase-0.98.18-hadoop2]$ jps

4130 ResourceManager

3988 SecondaryNameNode

21260 HMaster

21388 Jps

3839 NameNode

[hadoop@master hbase-0.98.18-hadoop2]$ ssh slave1

Last login: Mon Apr  4 22:52:40 2016 from master

[hadoop@slave1 ~]$ jps

7904 Jps

4185 NodeManager

4105 DataNode

7822 HRegionServer