1、解压Hbase后,将$HBASE_INSTALL/bin加入环境变量。
2、配置$HBASE_INSTALL/conf/hbase-env.sh:
export JAVA_HOME=$YOUR_JAVA_HOME
# Tell HBase whether it should manage it's own instance of Zookeeper or not.
export HBASE_MANAGES_ZK=false <==默认为true,我们不使用hbase自带的zookeeper实例。
3、配置hbase-site.xml
<configuration> <property> <name>hbase.rootdir</name> <value>hdfs://[color=red]HadoopName[/color]:9000/hbase</value> </property> <property> <name>hbase.cluster.distributed</name> <value>true</value> </property> <property> <name>dfs.replication</name> <value>1</value> </property> <property> <name>hbase.zookeeper.quorum</name> <value>[color=red]hadoopName[/color]</value> </property> <property> <name>zookeeper.session.timeout</name> <value>60000</value> </property>5、将$HBASE_INSTALL/lib下的hadoop-core-0.20-append-r1056497.jar删除,替换为$HADOOP_INSTALL/hadoop-0.20.2-core.jar
如果不替换,则在调用start-hbase.sh时HMaster无法启动。
报错异常如下:
12/02/26 00:35:02 INFO zookeeper.ClientCnxn: Session establishment complete on server hadoopname/192.168.0.23:2181, sessionid = 0x135b544b002000f, negotiated timeout = 40000 12/02/26 00:35:02 INFO client.HConnectionManager$HConnectionImplementation: ZooKeeper available but no active master location found 12/02/26 00:35:02 INFO client.HConnectionManager$HConnectionImplementation: getMaster attempt 0 of 1 failed; no more retrying. org.apache.hadoop.hbase.MasterNotRunningException at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.getMaster(HConnectionManager.java:357) at org.apache.hadoop.hbase.client.HBaseAdmin.<init>(HBaseAdmin.java:94) at org.apache.hadoop.hbase.master.HMasterCommandLine.stopMaster(HMasterCommandLine.java:163) at org.apache.hadoop.hbase.master.HMasterCommandLine.run(HMasterCommandLine.java:104) at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:65) at org.apache.hadoop.hbase.util.ServerCommandLine.doMain(ServerCommandLine.java:76) at org.apache.hadoop.hbase.master.HMaster.main(HMaster.java:1078) 12/02/26 00:35:02 ERROR master.HMasterCommandLine: Master not runningps:在hbase官方说明中有另外一种方法,小生暂时未试验过。
6、这时我们再启动start-hbase.sh,就会成功啦!
[root@hadoopname conf]# start-hbase.sh
starting master, logging to /usr/local/hbase-0.90.4/logs/hbase-root-master-hadoopname.out
hadoopName: starting regionserver, logging to /usr/local/hbase-0.90.4/logs/hbase-root-regionserver-hadoopname.out
[root@hadoopname conf]# jps
5004 HMaster
5101 HRegionServer
4208 SecondaryNameNode
5181 Jps
4587 QuorumPeerMain
4498 QuorumPeerMain
4273 JobTracker
4014 NameNode
4106 DataNode
4547 QuorumPeerMain
4424 TaskTracker
至此,hadoop、hbase、zookeeper在虚拟机下的整合就完毕了。
总结:
从整合的过程中可以感受到,hadoop的问题较少,而hbase和zk问题较多。比如zk的zoo.cfg配置参数中,dataDir指定的目录如果未创建,则zk会自动创建;但是dataLogDir参数指定的路径却不会自动创建。
最后,如果本文中有什么遗漏或不正确的地方,还请各位朋友斧正。在下感激不尽!