CentOS分布式环境安装HBase-0.96.0

2022-06-29 19:32:54 浏览数 (1)

一、安装zookeeper

在安装好分布式Hadoop的环境下,继续安装zookeeper-3.4.5。

  1. $ wget http://124.202.164.9/download/32878722/41763290/4/gz/165/152/1353566847397_152/zookeeper-3.4.5.tar.gz
  2. $ tar -xf zookeeper-3.4.5.tar.gz
  3. $ cp zookeeper-3.4.5/conf/zoo_sample.cfg zookeeper-3.4.5/conf/zoo.cfg
代码语言:javascript复制
$ wget http://124.202.164.9/download/32878722/41763290/4/gz/165/152/1353566847397_152/zookeeper-3.4.5.tar.gz
$ tar -xf zookeeper-3.4.5.tar.gz
$ cp zookeeper-3.4.5/conf/zoo_sample.cfg zookeeper-3.4.5/conf/zoo.cfg 

修改zookeeper配置文件:

  1. $ vim zookeeper-3.4.5/conf/zoo.cfg
代码语言:javascript复制
$ vim zookeeper-3.4.5/conf/zoo.cfg

做如下修改:

  1. tickTime=2000
  2. dataDir=/home/ruifeng.shan/zookeeper
  3. clientPort=2181
  4. initLimit=5
  5. syncLimit=2
  6. server.1=master:2888:3888
  7. server.2=node:2888:3888
  8. server.3=slave:2888:3888
代码语言:javascript复制
tickTime=2000  
dataDir=/home/ruifeng.shan/zookeeper  
clientPort=2181  
initLimit=5  
syncLimit=2  
server.1=master:2888:3888  
server.2=node:2888:3888  
server.3=slave:2888:3888

在你指定的dataDir目录下新建一个文件myid,在里面添加你指定的server编号。例如,你为hostname名为master的指定了如下配置

server.1=master:2888:3888 ,所以它的编号应该是1.

将zookeeper-3.4.5分发到其他机器。然后修改对应的myid文件内容为之前给其指定的编号。如node为2,slave为3.

分别启动zookeeper服务。在每台机器上切换到zookeeper-3.4.5目录,执行

$bin/zkServer.sh start

就可以启动zookeeper服务。

二、安装hbase-0.96.0

为了和hadoop-2.2.0匹配,选择的hbase版本为0.96.0

  1. $ wget http://mirror.bit.edu.cn/apache/hbase/hbase-0.96.0/hbase-0.96.0-hadoop2-bin.tar.gz
  2. $ tar -xf hbase-0.96.0-hadoop2-bin.tar.gz
  3. $ cd hbase-0.96.0
代码语言:javascript复制
$ wget http://mirror.bit.edu.cn/apache/hbase/hbase-0.96.0/hbase-0.96.0-hadoop2-bin.tar.gz
$ tar -xf hbase-0.96.0-hadoop2-bin.tar.gz
$ cd  hbase-0.96.0

修改 conf 下的配置:

  1. vim conf/hbase-env.sh
代码语言:javascript复制
 vim conf/hbase-env.sh

修改 JAVA_HOME:

  1. # The java implementation to use. Java 1.6 required.
  2. export JAVA_HOME=/usr/lib/jvm/java/jdk1.6.0_37
代码语言:javascript复制
# The java implementation to use.  Java 1.6 required.
export  JAVA_HOME=/usr/lib/jvm/java/jdk1.6.0_37

修改HBase 使用zookeeper的方式:

  1. # Tell HBase whether it should manage it's own instance of Zookeeper or not.
  2. export HBASE_MANAGES_ZK=false
代码语言:javascript复制
# Tell HBase whether it should manage it's own instance of Zookeeper or not.
export HBASE_MANAGES_ZK=false

这个参数默认是 true。意思是是否让hbase 单独管理 zookeeper

如果安装的机器上已经安装了zookeeper,并且这个zookeeper是多个平台共用的,那么这个参数应该设置为 false

如果集群上没有安装zookeeper,并且只有hbase 自己使用zookeeper,那么这个参数应该设置为true。

修改其conf目录下的hbase-site.xml文件。内容如下:

  1. <configuration>
  2. <property>
  3. <name>hbase.rootdir</name>
  4. <value>hdfs://master:8089/hbase</value>
  5. </property>
  6. <property>
  7. <name>hbase.master</name>
  8. <value>hdfs://master:60000</value>
  9. </property>
  10. <property>
  11. <name>hbase.cluster.distributed</name>
  12. <value>true</value>
  13. </property>
  14. <property>
  15. <name>hbase.zookeeper.property.clientPort</name>
  16. <value>2181</value>
  17. </property>
  18. <property>
  19. <name>hbase.zookeeper.quorum</name>
  20. <value>master,node,slave</value>
  21. </property>
  22. <property>
  23. <name>hbase.zookeeper.property.dataDir</name>
  24. <value>/home/aaron/zookeeper</value>
  25. </property>
  26. <property>
  27. <name>hbase.client.scanner.caching</name>
  28. <value>200</value>
  29. </property>
  30. <property>
  31. <name>hbase.balancer.period</name>
  32. <value>300000</value>
  33. </property>
  34. <property>
  35. <name>hbase.client.write.buffer</name>
  36. <value>10485760</value>
  37. </property>
  38. <property>
  39. <name>hbase.hregion.majorcompaction</name>
  40. <value>7200000</value>
  41. </property>
  42. <property>
  43. <name>hbase.hregion.max.filesize</name>
  44. <value>67108864</value>
  45. <description>
  46. Maximum HStoreFile size. If any one of a column families' HStoreFiles has
  47. grown to exceed this value, the hosting HRegion is split in two.</description>
  48. </property>
  49. <property>
  50. <name>hbase.hregion.memstore.flush.size</name>
  51. <value>1048576</value>
  52. <description>
  53. Memstore will be flushed to disk if size of the memstore
  54. exceeds this number of bytes. Value is checked by a thread that runs
  55. every hbase.server.thread.wakefrequency.</description>
  56. </property>
  57. <property>
  58. <name>hbase.server.thread.wakefrequency</name>
  59. <value>30000</value>
  60. <description>Time to sleep in between searches for work (in milliseconds).
  61. Used as sleep interval by service threads such as log roller.</description>
  62. </property>
  63. </configuration>
代码语言:javascript复制
<configuration>
<property>
<name>hbase.rootdir</name>
<value>hdfs://master:8089/hbase</value>
</property>

<property>
<name>hbase.master</name>
<value>hdfs://master:60000</value>
</property>

<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>

<property>
<name>hbase.zookeeper.property.clientPort</name>
<value>2181</value>
</property>

<property>
<name>hbase.zookeeper.quorum</name>
<value>master,node,slave</value>
</property>

<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/home/aaron/zookeeper</value>
</property>

<property>
<name>hbase.client.scanner.caching</name>
<value>200</value>
</property>

<property>
<name>hbase.balancer.period</name>
<value>300000</value>
</property>

<property>
<name>hbase.client.write.buffer</name>
<value>10485760</value>
</property>

<property>
<name>hbase.hregion.majorcompaction</name>
<value>7200000</value>
</property>

<property>
<name>hbase.hregion.max.filesize</name>
<value>67108864</value>
<description>
Maximum HStoreFile size. If any one of a column families' HStoreFiles has
grown to exceed this value, the hosting HRegion is split in two.</description>
</property>

<property>
<name>hbase.hregion.memstore.flush.size</name>
<value>1048576</value>
<description>
Memstore will be flushed to disk if size of the memstore
exceeds this number of bytes. Value is checked by a thread that runs
every hbase.server.thread.wakefrequency.</description>
</property>

<property>
<name>hbase.server.thread.wakefrequency</name>
<value>30000</value>
<description>Time to sleep in between searches for work (in milliseconds).
Used as sleep interval by service threads such as log roller.</description>
</property>

</configuration>

其中hbase.rootdir要保持与hadoop的core-site.xml文件中的fs.default.name中的值一致。

hbase的master 和 regionserver的时钟要保持一致,否则启动regionserver的时候会报如下错误:

org.apache.hadoop.hbase.ClockOutOfSyncException: org.apache.hadoop.hbase.ClockOutOfSyncException: Server hadoop02,60020,1374576225508 has been rejected; Reported time is too far out of sync with master. Time difference of 62062623ms > max allowed of 30000ms

这是由于master 和 regionserver之间的时间误差太大造成的。

解决方法1 :修改下面的参数

  1. <name>hbase.master.maxclockskew</name>
  2. <value>180000</value>
  3. <description>Time difference of regionserver from master</description>
代码语言:javascript复制
<name>hbase.master.maxclockskew</name>
<value>180000</value>
<description>Time difference of regionserver from master</description>

该参数默认值为 30 000 (30秒)

解决方法2: 使用ntpdate 同步集群的时钟

修改regionservers 文件配置:

这个文件是用来指定regionserver的机器的,一行一个,一般使用datanode作为regionserver:

  1. $ vim conf/regionservers
代码语言:javascript复制
$ vim conf/regionservers

master

node

slave

配置 backup-masters:

  1. $ vim conf/backup-masters
代码语言:javascript复制
$ vim conf/backup-masters

master-backup

配置backup-masters 可以在master 挂掉之后自动启动backup masters

注意:为了兼容Hadoop-2.2.0,需要将hbase的lib包中的内容lib包中的hadoop-common-2.1.0-beta.jar替换成hadoop-2.2.0/share/hadoop/common目录下的hadoop-common-2.2.0.jar。

启动hbase:

如果集群各个机器都有ssh 无密码登陆,可以直接使用 start-hbase.sh 启动整个集群。

或者到每个机器上使用daemon脚本启动(切换到hbase目录下):

到master 机器上:bin/hbase-daemon.sh start master

到regionserver 机器上 : bin/hbase-daemon.sh start regionserver

查看集群是否正常:

查看master的监控页面:

http://master:60010

0 人点赞