环境:
ubuntu 12.04
hadoop 1.2.1
hbase 0.94
安装步骤
1. 解压hbase安装包到你需要安装的目录
2. 由于 hbase 0.94 自带的hadoop 版本是1.04的,所以你需要把hadoop 1.2.1 的hadoop-core-1.2.1.jar拷贝到hbase 的lib 下,并把1.0.4 的包删掉
3. 配置环境变量
4. 配置conf/hbase-env.sh
export JAVA_HOME=/home/software/jdk1.7.0_55/
export HBASE_CLASSPATH=/opt/hadoop/conf
5. 配置conf/hbase-site.xml
<configuration>
<property>
<name>hbase.rootdir</name>
<value>hdfs://robinson-ubuntu:9000/hbase</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>robinson-ubuntu,datanode1</value>
</property>
<property>
<name>hbase.master</name>
<value>robinson-ubuntu:60000</value>
</property>
<property>
<name>zookeeper.session.timeout</name>
<value>120000</value>
</property>
<property>
<name>hbase.zookeeper.property.clientPort</name>
<value>2222</value>
</property>
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/home/hadoop/zookeeper</value>
</property>
<property>
<name>hbase.zookeeper.property.ticketTime</name>
<value>60000</value>
</property>
<property>
<name>hbase.tmp.dir</name>
<value>/home/hadoop/hbase</value>
</property>
</configuration>
6. 把集群中所有的机器名加到conf/regionservers中
robinson-ubuntu
datanode1
例子
把csv 导入到hbase
一步导入到hbase
hadoop jar /opt/hbase/hbase-0.94.19.jar importtsv -Dimporttsv.columns=HBASE_ROW_KEY,info:firstname,info:lastname '-Dimporttsv.separator=,' user /test/data
出现的问题
14/06/09 14:10:03 INFO zookeeper.ZooKeeper: Initiating client connection, connectString=localhost:2181 sessionTimeout=180000 watcher=hconnection
14/06/09 14:10:03 INFO zookeeper.ClientCnxn: Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
14/06/09 14:10:03 INFO zookeeper.RecoverableZooKeeper: The identifier of this process is 27532@robinson-ubuntu
14/06/09 14:10:03 WARN zookeeper.ClientCnxn: Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect
java.net.ConnectException: 拒绝连接
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:739)
at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:350)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1068)
14/06/09 14:10:04 WARN zookeeper.RecoverableZooKeeper: Possibly transient ZooKeeper exception: org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /hbase/hbaseid
14/06/09 14:10:04 INFO util.RetryCounter: Sleeping 2000ms before retry #1...
14/06/09 14:10:05 INFO zookeeper.ClientCnxn: Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
14/06/09 14:10:05 WARN zookeeper.ClientCnxn: Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect
java.net.ConnectException: 拒绝连接
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:739)
at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:350)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1068)
14/06/09 14:10:06 INFO zookeeper.ClientCnxn: Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
14/06/09 14:10:06 WARN zookeeper.ClientCnxn: Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect
java.net.ConnectException: 拒绝连接
解决方案:
把hbase配置文件所在的路径加入到hadoop-env.sh 中的HADOOP_CLASSPATH中
问题:
有些文件找不到
比如guava,protobuf,zookeeper
需要把这些文件拷贝到hadoop安装目录下的lib中