1.使用hadoop账号解压到/opt/hadoop目录下:
# su hadoop
$ tar -zxvf hbase-${version} -C /opt/hadoop
$ ln -s hbase-${version}/ hbase
2.进入/opt/hadoop/hbase/conf目录,修改hbase-env.sh文件内容:
export JAVA_HOME=/opt/java
export HBASE_PID_DIR=/opt/hadoop/hadoop/pids
export HADOOP_HOME=/opt/hadoop/hadoop
export HBASE_HOME=/opt/hadoop/hbase
3.修改hbase-site.xml文件内容:
添加下面内容
<configuration>
<property>
<name>hbase.rootdir</name>
<value>hdfs://baseline01:9000/hbase</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>baseline01,baseline02,baseline03</value>
</property>
</configuration>
4.修改/opt/hadoop/hbase/conf/regionservers文件内容:
baseline02
baseline03
5.通过scp复制到其它两台机器上:
$ scp -r /opt/hadoop/hbase-${version} [email protected]baseline02:/opt/hadoop
$ ln -s hbase-${version}/ hbase
$ scp -r /opt/hadoop/hbase-${version} [email protected]:/opt/hadoop
$ ln -s hbase-${version}/ hbase
6.在baseline01上启动hbase集群:
$ /opt/hadoop/hbase/bin/start-hbase.sh
7.查看集群是否启动,运行jps
若baseline01如下所示:
$ jps
22898 ResourceManager
20739 Jps
24383 JobHistoryServer
20286 HMaster
22722 SecondaryNameNode
22488 NameNode
若baseline02和baseline03如下所示:
2141 NodeManager
3257 HRegionServer
25283 Jps
1841 DataNode
显示有HMaster和HRegionServer,则说明启动成功
8.使用/opt/hadoop/hbase/bin/hbase shell命令测试安装结果:
a.创建表test:
hbase(main):002:0> create "test", "cf"
0 row(s) in 2.5840 seconds
=> Hbase::Table - test
b.列出全部表:
hbase(main):003:0> list
TABLE
test
1 row(s) in 0.0310 seconds
=> ["test"]
c.插入数据到test表:
hbase(main):001:0> put "test","row","cf:a","value"
0 row(s) in 0.4150 seconds
d.查看test表信息:
hbase(main):002:0> scan ‘test‘
ROW COLUMN+CELL
row column=cf:a, timestamp=1447246157917, value=value
1 row(s) in 0.0270 seconds
若hbase shell测试成功,则进入浏览器访问以下网址:
http://baseline01:16010/,若正常显示,则hbase集群安装成功! 用ip保险一点,用域名首先要在自己的电脑host文件中配置。
9.启动thriftserver2服务
$ nohup /opt/hadoop/hbase/bin/hbase-daemon.sh start thrift2 &