通过前面两篇介绍的内容:1、Centos6.5编译Hadoop2.5.2-64位2、如何搭建一个高可用的Hadoop集群现在基本上一个Hadoop的高可用集群已经搭建好了,那么Hbase的集群需要在Hadoop集群的基础上搭建,那么HBASE的官方文档也有如何搭建,我就直接复制粘贴过来稍作整理,Hbase在国内用的还是比较多的,也有一个低版本的中文文档,推荐的书籍呢是《Hbase权威指南》,想要深入了解的呢可以买本书自己看或者直接官方文档走起~毕竟我也是初学者。OK那么下面介绍如何搭建Hbase的集群:配置集群的基础:四台虚拟机分别为[node1 | node2 | node3 | node4] hosts分别已经修改。四台虚拟机已经配置好Hadoop2.x的集群。选择其中一台机器进行配置:首先配置环境变量:export HBASE_HOME=/root/hbase-0.98export PATH=$PATH:$HBASE_HOME/bin其次按照官方文档按步骤配置:1、配置免登录:Onnode-a, generate a key pair.While logged in as the user who will run HBase, generate a SSH key pair, using the following command:$ ssh-keygen -t rsaIf the command succeeds, the location of the key pair is printed to standard output. The default name of the public key isid_rsa.pub. Create the directory that will hold the shared keys on the other nodes.Onnode-bandnode-c, log in as the HBase user and create a.ssh/directory in the user’s home directory, if it does not already exist. If it already exists, be aware that it may already contain other keys. Copy the public key to the other nodes.Securely copy the public key fromnode-ato each of the nodes, by using thescpor some other secure means. On each of the other nodes, create a new file called.ssh/authorized_keysif it does not already exist, and append the contents of theid_rsa.pubfile to the end of it. Note that you also need to do this fornode-aitself.$ cat id_rsa.pub >> ~/.ssh/authorized_keys Test password-less login.If you performed the procedure correctly, if you SSH fromnode-ato either of the other nodes, using the same username, you should not be prompted for a password. Sincenode-bwill run a backup Master, repeat the procedure above, substitutingnode-beverywhere you seenode-a. Be sure not to overwrite your existing.ssh/authorized_keysfiles, but concatenate the new key onto the existing file using the>>operator rather than the>operator. 2、配置conf/regionserversEditconf/regionserversand remove the line which containslocalhost. Add lines with the hostnames or IP addresses fornode-bandnode-c.Even if you did want to run a RegionServer onnode-a, you should refer to it by the hostname the other servers would use to communicate with it. In this case, that would benode-a.example.com. This enables you to distribute the configuration to each node of your cluster any hostname conflicts. Save the file.最终效果[root@node4 conf]# more regionserversnode4node2node33、配置backup master.Create a new file inconf/calledbackup-masters, and add a new line to it with the hostname fornode-b. In this demonstration, the hostname isnode-b.example.com.4、配置环境变量hbase-env.sh只需要配置JDK即可5、配置hbase-site.xml文件
hbase.rootdir
hdfs://codelee/hbase
hbase.zookeeper.property.dataDir
/opt/zookeeper
hbase.cluster.distributed
true
hbase.zookeeper.quorum
node1,node2,node3
6、将Hadoop2.x的集群配置文件hdfs-site.xml复制进来7、将环境变量文件、Hbase配置文件都复制到其他主机,启动集群。OK,一个Hbase的集群也搭建完毕,不过大家也看到了,我在所有hadoop、Storm相关的文章中用到的一个域名codelee实际上是我另一个域名。OK,里面的有关名字的都可以自己定义。当然一般Hbase都是在程序中来调用API执行操作的,Hbase Shell用的比较少,那么请看下一篇《HBase官方API的简单使用》未经允许不得转载:李阳博客»如何搭建一个Hbase集群