1.基本信息
版本 | 1.2.4 |
---|---|
安装机器 | 三台机器 |
账号 | hadoop |
源路径 | /opt/software/hbase-1.2.4-bin.tar.gz |
目标路径 | /opt/hbase -> /opt/hbase-1.2.4 |
依赖关系 | 无 |
2.安装过程
1).使用hadoop账号解压到/opt/hadoop目录下并设置软连接:
[root @bgs -5p173-wangwenting opt]# su hadoop [hadoop @bgs -5p173-wangwenting opt]$ cd /opt/software [hadoop @bgs -5p173-wangwenting software]$ tar -zxvf hbase-${version}-bin.tar.gz -C /opt [hadoop @bgs -5p173-wangwenting software]$ cd /opt [hadoop @bgs -5p173-wangwenting opt]$ ln -s hbase-${version}/ hbase |
2).进入/opt/hbase/conf目录,修改hbase-env.sh文件内容:
[hadoop @bgs -5p173-wangwenting opt]$ cd /opt/hbase/conf [hadoop @bgs -5p173-wangwenting opt]$ vim hbase-env.sh export JAVA_HOME=/opt/java export HBASE_PID_DIR=/opt/pids export HADOOP_HOME=/opt/hadoop export HBASE_HOME=/opt/hbase |
3).修改hbase-site.xml文件内容:
[hadoop @bgs -5p173-wangwenting opt]$ vim hbase-site.xml 添加下面内容 <configuration> <property> <name>hbase.rootdir</name> <value>hdfs: //bgs-5p173-wangwenting:9000/hbase</value> </property> <property> <name>hbase.cluster.distributed</name> <value> true </value> </property> <property> <name>hbase.zookeeper.quorum</name> <value>bgs-5p173-wangwenting,bgs-5p174-wangwenting,bgs-5p175-wangwenting</value> </property> </configuration> |
4).修改/opt/hadoop/hbase/conf/regionservers文件内容:
[hadoop @bgs -5p173-wangwenting opt]$ vim /opt/hbase/conf/regionservers 添加以下内容: bgs-5p174-wangwenting bgs-5p175-wangwenting |
5).通过scp复制到其它两台机器上:
[hadoop @bgs -5p173-wangwenting opt]$ scp -r /opt/hbase-${version} hadoop @bgs -5p174-wangwenting:/opt [hadoop @bgs -5p174-wangwenting opt]$ ln -s hbase-${version}/ hbase [hadoop @bgs -5p173-wangwenting opt]$ scp -r /opt/hbase-${version} hadoop @bgs -5p175-wangwenting:/opt [hadoop @bgs -5p175-wangwenting opt]$ ln -s hbase-${version}/ hbase |
6).在bgs-5p173-wangwenting上启动hbase集群:
[hadoop @bgs -5p173-wangwenting opt]$ /opt/hbase/bin/start-hbase.sh |
7).查看集群是否启动,运行jps
[hadoop @bgs -5p173-wangwenting opt]$ jps 若bgs-5p173-wangwenting如下所示: 22898 ResourceManager 20739 Jps 24383 JobHistoryServer 20286 HMaster 22722 SecondaryNameNode 22488 NameNode [hadoop @bgs -5p174-wangwenting opt]$ jps 2141 NodeManager 3257 HRegionServer 25283 Jps 1841 DataNode [hadoop @bgs -5p175-wangwenting opt]$ jps 2141 NodeManager 3257 HRegionServer 25283 Jps 1841 DataNode 显示有HMaster和HRegionServer,则说明启动成功 |
8).使用/opt/hadoop/hbase/bin/hbase shell命令测试安装结果:
[hadoop @bgs -5p173-wangwenting opt]$ /opt/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" ] |
如果在输入list,有好几次,启动Hadoop和HBase之后,执行jps命令,已经看到有HMaster的进程,但是进入到HBase的shell,执行一个命令,会出现下面的错误:
解决方法:
进入到logs目录查看master的日志:发现一直显示下面的内容:
vim hbase-hadoop-master-s1.log
2017-03-13 17:13:17,374 INFO org.apache.hadoop.hbase.util.FSUtils: Waiting for dfs to exit safe mode...
2017-03-13 17:13:27,377 INFO org.apache.hadoop.hbase.util.FSUtils: Waiting for dfs to exit safe mode...
2017-03-13 17:13:37,386 INFO org.apache.hadoop.hbase.util.FSUtils: Waiting for dfs to exit safe mode...
2017-03-13 17:13:47,393 INFO org.apache.hadoop.hbase.util.FSUtils: Waiting for dfs to exit safe mode...
2017-03-13 17:13:57,395 INFO org.apache.hadoop.hbase.util.FSUtils: Waiting for dfs to exit safe mode...
2017-03-13 17:14:07,409 INFO org.apache.hadoop.hbase.util.FSUtils: Waiting for dfs to exit safe mode...
原来是Hadoop在刚启动的时候,还处在安全模式造成的,手动退出Hadoop的安全模式.然后重新启动hbase服务。
重启后输入list,便不再报错了。
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://172.24.5.173:16010/,
若正常显示,则hbase集群安装成功! 用ip保险一点,用域名首先要在自己的电脑host文件中配置。
9).启动thriftserver2服务
[hadoop @bgs -5p173-wangwenting opt]$ nohup /opt/hbase/bin/hbase-daemon.sh start thrift2 & |