hbase1.2.4 伪分布式安装
注意:在安装hbase或者hadoop的时候,要注意hadoop和hbase的对应关系。如果版本不对应可能造成系统的不稳定和一些其他的问题。在hbase的lib目录下可以看到hadoop对应jar文件,默认情况下hbase下lib的jar文件对应hadoop的相对稳定的版本。如果需要使用其他的hadoop版本,需要将hbase lib下的hadoopjar包,替换掉需要使用的hadoop版本
下载:http://archive.apache.org/dist/hbase/stable/(hbase下载历史版本)
配置环境变量
########hbase####################
export HBASE_HOME=/usr/local/development/hbase-1.2.4
export PATH=$HBASE_HOME/bin:$PATH
配置hbase-env.sh
export JAVA_HOME=/usr/local/development/jdk1.7.0_15
export HBASE_MANAGES_ZK=false --如果你是使用hbase自带的zk就是true,如果使用自己的zk就是false
配置hbase-site.xml
<property> <name>hbase.rootdir</name> --hbase持久保存的目录 <value>hdfs://hadoop-node1.com:8020/opt/hbase</value> </property> <property> <name>hbase.cluster.distributed</name> --是否是分布式 <value>true</value> </property> <property> <name>hbase.zookeeper.property.clientPort</name> --指定要连接zk的端口 <value>2181</value> </property> <property> <name>hbase.zookeeper.quorum</name> --指定要连接zk的节点 <value>hadoop-node1.com</value> </property> <property> <name>hbase.zookeeper.property.dataDir</name> <value>/home/zhangxs/datainfo/developmentData/hbase/zkData</value> </property>
为了防止因为hbase和hadoop版本不一致而出现的问题,可以看下{hbase_home}/lib/下相关hadoop*.jar的jar包,跟你的hadoop是否是同一个版本,如果不是可以从{hadoop_home}/ share/hadoop/ 下复制
启动hbase(启动的hbase的时候要保证hadoop集群已经启动)
/hbase/bin/start-hbase.sh
查看hbase的进程
[root@node4 bin]# ./start-hbase.sh
localhost: starting zookeeper, logging to /home/zhangxs/hbase/bin/../logs/hbase-root-zookeeper-node4.out
starting master, logging to /usr/local/development/hbase-1.2.4/logs/hbase-node4-master-node4.out
starting regionserver, logging to /usr/local/development/hbase-1.2.4/logs/hbase-node4-1-regionserver-node4.out
[root@node4 bin]# jps
8057 Jps
3166 NodeManager
7830 HRegionServer
2933 SecondaryNameNode
2561 NameNode
5568 QuorumPeerMain
7706 HMaster
3071 ResourceManager
2650 DataNode
5749 GetConf
输入hbase shell(进入shell命令行)
[root@node4 bin]# hbase shell SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/usr/local/development/hbase-1.2.4/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/usr/local/development/hadoop-2.6.4/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory] HBase Shell; enter 'help<RETURN>' for list of supported commands. Type "exit<RETURN>" to leave the HBase Shell Version 1.2.4, r67592f3d062743907f8c5ae00dbbe1ae4f69e5af, Tue Oct 25 18:10:20 CDT 2016 hbase(main):001:0>
通过web页面访问hbase
![](https://images2015.cnblogs.com/blog/899606/201612/899606-20161227141410945-555098442.png)
----------------------------安装hbase完成-----------------------------------
遇到问题:
1:当我启动hbase的时候,抛出下面错误
HBase does not run after ./start-hbase.sh - Permission Denied?
这问题是因为,我这个版本的hbase下的bin/* 所有以.sh结尾的文件,都不是可执行文件,所以我修改了/hbase/bin/* 所有以.sh文件结尾的文件属性
chmod 711 *.sh
修改后的文如下
![](https://images2015.cnblogs.com/blog/899606/201612/899606-20161227141458867-990039531.png)
要将hbase文件也修改为可执行文件(我的hbase文件一开始是不可执行文件)
2:当我启动hbase后发现hmaster进程启动又马上关闭了,查看hbase日志,这个异常是说hbase链接zk访问被拒绝,我的方法是在我的机器上搭建了zk,然后启动zk
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:692)
at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1081)
2016-12-27 00:26:55,995 INFO [main-SendThread(localhost:2181)] zookeeper.ClientCnxn: Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
2016-12-27 00:26:55,996 WARN [main-SendThread(localhost:2181)] zookeeper.ClientCnxn: Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:692)
at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1081)
2016-12-27 00:26:57,104 INFO [main-SendThread(localhost:2181)] zookeeper.ClientCnxn: Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
2:当我搭建好zk,又出现hmaster进程启动又马上关闭的问题,查看日志出现下面错误,这个错误是说hbase链接不到hadoop集群,这个是因为,我hadoop的core-site.xml文件中 nameNode端口配置的是8020,而我hbase的hbase-site.xml 链接hadoop的端口配置的是9000,然后我修改了hbase-site.xml
java.net.ConnectException: Call From node4/192.168.177.124 to hadoop-node4.com:9000 failed on connection exception: java.net.ConnectException: Connection refused; For more details see: http://wiki.apache.org/hadoop/ConnectionRefused
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at org.apache.hadoop.net.NetUtils.wrapWithMessage(NetUtils.java:791)
at org.apache.hadoop.net.NetUtils.wrapException(NetUtils.java:731)
at org.apache.hadoop.ipc.Client.call(Client.java:1473)
at org.apache.hadoop.ipc.Client.call(Client.java:1400)
at org.apache.hadoop.ipc.ProtobufRpcEngine$Invoker.invoke(ProtobufRpcEngine.java:232)
at com.sun.proxy.$Proxy18.setSafeMode(Unknown Source)
at org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolTranslatorPB.setSafeMode(ClientNamenodeProtocolTranslatorPB.java:647)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.apache.hadoop.io.retry.RetryInvocationHandler.invokeMethod(RetryInvocationHandler.java:187)
at org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:102)
at com.sun.proxy.$Proxy19.setSafeMode(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)