如果想研究HBase的工作原理或是操作,最简单的就是安装一个单机版的HBase,这里不需要安装Hadoop,极为方便
但是即使是最简单的安装,也会出现意想不到的异常,我就遇到了一个。
先回顾一下安装单机版的步骤:
1、本文使用HBase稳定版:hbase-0.90.4.tar.gz。
2、将hbase-0.92.1.tar.gz放入自己选好的文件夹下,解压。
修改HBase配置文件
1、 hbase-env.sh
取消配置JDK的注释并做并如下修改(我的JDK安装路径):
export JAVA_HOME=/usr/java/jdk1.6.0_27/
2、 hbase-site.xml
因为是单机启动,所以只设定了HBase写入的本地路径,修改如下:
<?xml version=”1.0″?>
<?xml-stylesheet type=”text/xsl” href=”configuration.xsl”?>
<configuration>
<property>
<name>hbase.rootdir</name>
<value>/home/hbase</value>
</property>
</configuration>
启动HBase:
wu@ubuntu:~/opt/hbase-0.92.1$ bin/start-hbase.sh
执行hbase shell:
wu@ubuntu:~/opt/hbase-0.92.1$ bin/hbase shell
出现下面很长一串异常:
16/03/13 23:44:58 FATAL client.HConnectionManager$HConnectionImplementation: Unexpected exception during initialization, aborting
org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /hbase/master
at org.apache.zookeeper.KeeperException.create(KeeperException.java:99)
at org.apache.zookeeper.KeeperException.create(KeeperException.java:51)
at org.apache.zookeeper.ZooKeeper.exists(ZooKeeper.java:1021)
at org.apache.hadoop.hbase.zookeeper.RecoverableZooKeeper.exists(RecoverableZooKeeper.java:154)
at org.apache.hadoop.hbase.zookeeper.ZKUtil.watchAndCheckExists(ZKUtil.java:226)
at org.apache.hadoop.hbase.zookeeper.ZooKeeperNodeTracker.start(ZooKeeperNodeTracker.java:76)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.setupZookeeperTrackers(HConnectionManager.java:580)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.<init>(HConnectionManager.java:569)
at org.apache.hadoop.hbase.client.HConnectionManager.getConnection(HConnectionManager.java:186)
at org.apache.hadoop.hbase.client.HBaseAdmin.<init>(HBaseAdmin.java:98)
……
很多同学看到上面出现了zookeeper,以为单机模式下也需要安装zookeeper,其实是误解
解决办法:
wu@ubuntu:~$ sudo gedit /etc/hosts
127.0.0.1 localhost
127.0.0.1 ubuntu
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
修改为(将第二行的127.0.0.1 改为本机IP):
127.0.0.1 localhost
192.168.111.142 ubuntu
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
搞定
Comments