HBase完全分布式

http://write.blog.csdn.NET/postedit

在上次我们搭建了hadoop2.8的高可用NameNode的HA环境,并引入了zookeeper

这次我们要在这个环境的基础上搭建Hbase

先说规划

编号
主机名
用途
0
xxCentosZero
HMaster(备用,尚未加入)
1
xxCentosOne
HMaster
2
xxCentosTwo
HRegionServer
3
xxCentosThree
HRegionServer
4
xxCentosFour
HRegionServer

如上所示,暂时没有加入xxCentosZero到HMaster的集群中

先说搭建的过程吧。


一、下载与部署

0,首先要注意的是hbaseHadoop的版本的对应匹配关系。详见官网



1,点击这里下载hbase的稳定版

2,放到/usr/local/下解压缩,改名为hbase

3,配置环境变量,修改/etc/profile 


二、修改配置文件

1,修改/usr/local/hbase/conf/hbase-env.sh 环境变量文件,主要修改以下几个地方

  1. <span style="font-family:KaiTi_GB2312;font-size:14px;"># The java implementation to use.  Java 1.7+ required.  
  2. #jdk的安装目录  
  3. export JAVA_HOME=/usr/local/java/jdk1.7.0_79</span>  

  1. <span style="font-family:KaiTi_GB2312;font-size:14px;"># Extra Java CLASSPATH elements.  Optional.  
  2. #用到的一些外部jar包的路径,有人这里写的是/usr/local/hbase/conf这个路径,我觉得是否写错了啊  
  3. export HBASE_CLASSPATH=/usr/local/hadoop/etc/hadoop</span>  

  1. <span style="font-family:KaiTi_GB2312;font-size:14px;"># The maximum amount of heap to use. Default is left to JVM default.  
  2. #   hbase用到的总体的堆内存的量。但是不确定写成“400M”这个样式会否被正确识别。同时我的虚拟机仅有1G内存分配给它们,所以我没有显式指定  
  3. # export HBASE_HEAPSIZE=400m</span>  

  1. <span style="font-family:KaiTi_GB2312;font-size:14px;"># Tell HBase whether it should manage it's own instance of Zookeeper or not.  
  2. #如果用的是自己安装的zookeeper,这里就写成false,如果用的是hbase自带zookeeper,就是true。  
  3. export HBASE_MANAGES_ZK=false</span>  

2,修改/usr/local/hbase/conf/hbase-site.xml配置文件。分为简化版和比较详细版

先来个简化版

  1. <span style="font-family:KaiTi_GB2312;font-size:14px;"><configuration>  
  2.     <!--如果不是集群的话,应该与core-site.xml文件的fs.defaultFS一致-->  
  3.     <property>  
  4.         <name>hbase.rootdir</name>  
  5.         <value>hdfs://xxCentosOne:9000/hbase</value>  
  6.     </property>  
  7.     <!--是否分布式-->  
  8.     <property>  
  9.         <name>hbase.cluster.distributed</name>  
  10.         <value>true</value>  
  11.     </property>  
  12.     <!--zookeeper部署的主机名和访问的端口号-->  
  13.     <property>  
  14.         <name>hbase.zookeeper.quorum</name>  
  15.         <value>xxCentosZero:2181,xxCentosOne:2181,xxCentosTwo:2181,xxCentosThree:2181,xxCentosFour:2181</value>  
  16.     </property>  
  17.     <!--每台服务器上zookeeper的data文件夹下路径-->  
  18.     <property>  
  19.         <name>hbase.zookeeper.property.dataDir</name>  
  20.         <value>/usr/local/zookeeper/data</value>  
  21.     </property>  
  22. </configuration></span>  

再来个较详细版
  1. <span style="font-family:KaiTi_GB2312;font-size:14px;"><?xml version="1.0"?>  
  2. <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>  
  3. <!--  
  4. /**  
  5.  *  
  6.  * Licensed to the Apache Software Foundation (ASF) under one  
  7.  * or more contributor license agreements.  See the NOTICE file  
  8.  * distributed with this work for additional information  
  9.  * regarding copyright ownership.  The ASF licenses this file  
  10.  * to you under the Apache License, Version 2.0 (the  
  11.  * "License"); you may not use this file except in compliance  
  12.  * with the License.  You may obtain a copy of the License at  
  13.  *  
  14.  *     http://www.apache.org/licenses/LICENSE-2.0  
  15.  *  
  16.  * Unless required by applicable law or agreed to in writing, software  
  17.  * distributed under the License is distributed on an "AS IS" BASIS,  
  18.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
  19.  * See the License for the specific language governing permissions and  
  20.  * limitations under the License.  
  21.  */  
  22. -->  
  23. <configuration>  
  24.     <property>  
  25.         <name>hbase.rootdir</name>  
  26.         <value>hdfs://xxCentosOne:9000/hbase</value><!--这里必须跟core-site.xml中的fs.defaultFS键配置一样-->  
  27.     </property>  
  28.     <!-- 开启分布式模式 -->  
  29.     <property>  
  30.         <name>hbase.cluster.distributed</name>  
  31.         <value>true</value>  
  32.     </property>  
  33.     <!--只配置端口,为了配置多个HMaster -->  
  34.     <property>  
  35.         <name>hbase.master</name>  
  36.         <value>xxCentosOne:60000</value>  
  37.     </property>  
  38.     <property>  
  39.         <name>hbase.tmp.dir</name>  
  40.         <value>/usr/local/hbase/tmp</value>  
  41.     </property>  
  42.   
  43.     <!--这里设置hbase API客户端侧缓存值,大于此值就进行一次提交,/opt/hbase-1.2.1/conf/hbase-site.xml统一配置为5M,对所有HTable都生效,那么客户端API就可不设置-->  
  44.     <!--htable.setWriteBufferSize(5242880);//5M -->  
  45.     <property>  
  46.         <name>hbase.client.write.buffer</name>  
  47.         <value>5242880</value>  
  48.     </property>  
  49.     <!--这里设置Master并发最大线程数,经常有人设为300左右-->  
  50.     <property>  
  51.         <name>hbase.regionserver.handler.count</name>  
  52.         <value>20</value>  
  53.     </property>  
  54.     <!--  
  55.     默认值 :256M  
  56.     说明      :在当前ReigonServer上单个Reigon的最大存储空间,单个Region超过该值时,这个Region会被自动split成更小的region。  
  57.     数据表创建时会预分区,每个预分区最大大小这里设置为10G,防止频繁的split阻塞数据读写,  
  58.     只有当预分区超过10G时才会进行split,正式环境应该首先预测数据存储时间内的大致数据量,  
  59.     然后如果每个预分区为10G,计算出分区数,建表时指定分区设置,防止后期频繁split  
  60.     写法,如果你想设为128兆,但绝不可以写成128M这样,最安全的写法是128*1024*1024的数值,如下  
  61.     -->  
  62.     <property>  
  63.         <name>hbase.hregion.max.filesize</name>  
  64.         <value>134217728</value>  
  65.     </property>  
  66.     <!--  
  67.     默认hbase每24小时会进行一次major_compact,major_compact会阻塞读写,这里先禁用,但不代表这个操作不做,  
  68.     可以后期指定linux shell加入到cron定时任务在hbase集群空闲情况下执行  
  69.     -->    
  70.     <property>  
  71.         <name>hbase.hregion.majorcompaction</name>  
  72.         <value>0</value>  
  73.     </property>  
  74.     <!--  
  75.     hbase本质上可以说是HADOOP HDFS的客户端,虽然Hadoop的core-site.xml里设置了文件副本数,但是仍然是客户端传值优先,这里设置为2,  
  76.     意思是一个文件,最终在Hadoop上总个数为2,正式环境最好设置为3,目前发现此值小于3时,  
  77.     在遇到All datanodes xxx.xxx.xxx.xxx:port are bad. Aborting...错误信息时,如果某个DataNode宕机,原则上hbase调用的DFSClient会去其他Datanode    
  78.     上重试写,但发现配置的值低于3就不会去尝试  
  79.     -->    
  80.     <property>  
  81.         <name>dfs.replication</name>  
  82.         <value>2</value>  
  83.     </property>  
  84.     <!--  
  85.     IncreasingToUpperBoundRegionSplitPolicy策略的意思是,数据表如果预分区为2,配置的memstore flush size=128M,那么下一次分裂大小是2的平方然后乘以128MB,即2*2*128M=512MB;  
  86.     ConstantSizeRegionSplitPolicy策略的意思是按照上面指定的region大小超过30G才做分裂  
  87.     -->  
  88.     <property>  
  89.         <name>hbase.regionserver.region.split.policy</name>  
  90.         <value>org.apache.hadoop.hbase.regionserver.ConstantSizeRegionSplitPolicy</value>  
  91.     </property>  
  92.     <!--一个edit版本在内存中的cache时长,默认3600000毫秒-->  
  93.     <property>  
  94.         <name>hbase.regionserver.optionalcacheflushinterval</name>  
  95.         <value>7200000</value>  
  96.     </property>  
  97.     <!--分配给HFile/StoreFile的block cache占最大堆(-Xmx setting)的比例。默认0.3意思是分配30%,设置为0就是禁用,但不推荐。-->  
  98.     <property>  
  99.         <name>hfile.block.cache.size</name>  
  100.         <value>0.3</value>  
  101.     </property>  
  102.     <!--当memstore的大小超过这个值的时候,会flush到磁盘。这个值被一个线程每隔hbase.server.thread.wakefrequency检查一下。-->  
  103.     <property>  
  104.         <name>hbase.hregion.memstore.flush.size</name>  
  105.         <value>52428800</value>  
  106.     </property>  
  107.     <!--  
  108.     默认值 :0.4/0.35  
  109.     说明      :hbase.hregion.memstore.flush.size 这个参数的作用是当单个Region内所有的memstore大小总和超过指定值时,flush该region的所有memstore  
  110.     单个region server的全部memtores的最大值。超过这个值,一个新的update操作会被挂起,强制执行flush操作。  
  111.     以前版本中是通过hbase.regionserver.global.memstore.upperLimit设置,老版本中含义是在hbase-env.sh中配置的HEAP_SIZE比如4G,  
  112.     那么以该值4G乘以配置的0.5就是2G,意思是所有memstore总和达到2G值时,阻塞所有读写,现在1.2.1版本hbase中被hbase.regionserver.global.memstore.size替代,  
  113.     计算方法仍然是HEAP_SIZE乘以配置的百分比比如下面的0.5,那么阻塞读写的阀值就为2G  
  114.     -->    
  115.     <property>  
  116.         <name>hbase.regionserver.global.memstore.size</name>  
  117.         <value>0.5</value>  
  118.     </property>  
  119.     <!--  
  120.     当强制执行flush操作的时候,当低于这个值的时候,flush会停止。  
  121.     默认是堆大小的 35% . 如果这个值和 hbase.regionserver.global.memstore.upperLimit 相同就意味着当update操作因为内存限制被挂起时,  
  122.     会尽量少的执行flush(译者注:一旦执行flush,值就会比下限要低,不再执行)。    
  123.     在老版本中该值是通过hbase.regionserver.global.memstore.size.lower.limit设置,  
  124.     计算方法是以hbase-env.sh的HEAP_SIZE乘以配置的百分比比如0.3就是HEAP_SIZE4G乘以0.3=1.2G,达到这个值的话就在所有memstore中选择最大的那个做flush动作,  
  125.     新版本则完全不同了,首先是通过hbase.regionserver.global.memstore.lowerLimit设置,而且不是以HEAP_SIZE作为参考,  
  126.     二是以配置的hbase.regionserver.global.memstore.size的值再乘以配置的比例比如0.5,如果HEAP_SIZE=4G,  
  127.     hbase.regionserver.global.memstore.size配置为0.5,hbase.regionserver.global.memstore.size.lower.limit配置的为0.5,  
  128.     则计算出来的值为4G乘以0.5再乘以0.5就是1G了,达到1G就先找最大的memstore触发flush  
  129.     -->    
  130.     <property>  
  131.         <name>hbase.regionserver.global.memstore.size.lower.limit</name>  
  132.         <value>0.5</value>  
  133.     </property>  
  134.     <!--这里设置HDFS客户端最大超时时间,尽量改大,后期hbase经常会因为该问题频繁宕机-->  
  135.     <property>  
  136.         <name>dfs.client.socket-timeout</name>  
  137.         <value>600000</value>  
  138.     </property>  
  139.   
  140.     <!--  
  141.     hbase.table.sanity.checks是一个开关,主要用于hbase各种参数检查,当为true时候,检查步骤如下  
  142.     1.check max file size,hbase.hregion.max.filesize,最小为2MB  
  143.     2.check flush size,hbase.hregion.memstore.flush.size,最小为1MB  
  144.     3.check that coprocessors and other specified plugin classes can be loaded  
  145.     4.check compression can be loaded  
  146.     5.check encryption can be loaded  
  147.     6.Verify compaction policy  
  148.     7.check that we have at least 1 CF  
  149.     8.check blockSize  
  150.     9.check versions  
  151.     10.check minVersions <= maxVerions  
  152.     11.check replication scope  
  153.     12.check data replication factor, it can be 0(default value) when user has not explicitly set the value, in this case we use default replication factor set in the file system.  
  154.     详细情况可以去查看源代码org.apache.hadoop.hbase.master.HMaster的方法sanityCheckTableDescriptor,  
  155.     该代码位于hbase源码的模块hbase-server下  
  156.     -->  
  157.     <property>  
  158.         <name>hbase.table.sanity.checks</name>  
  159.         <value>false</value>  
  160.     </property>  
  161.     <!--ZooKeeper 会话超时.HBase把这个值传递改zk集群,向他推荐一个会话的最大超时时间-->  
  162.     <property>  
  163.     <!--every 30s,the master will check regionser is working -->  
  164.         <name>zookeeper.session.timeout</name>  
  165.         <value>30000</value>  
  166.     </property>  
  167.     <!--     Hbase的外置zk集群时,使用下面的zk端口。因为我这5台机子打算都安装hbase,所以都指定zookeeper。  
  168.                 有个问题就是,hbase和hadoop使用同一个zookeeper,是否可以,这样如果某台服务器上的某个应用挂了,zookeeper会不会认错。  
  169.                 把这个机子上挂的A应用误会成B应用呢  
  170.      -->  
  171.     <property>  
  172.         <name>hbase.zookeeper.quorum</name>  
  173.         <value>xxCentosZero:2181,xxCentosOne:2181,xxCentosTwo:2181,xxCentosThree:2181,xxCentosFour:2181</value>  
  174.     </property>  
  175.     <property>  
  176.         <name>hbase.zookeeper.property.dataDir</name>  
  177.         <value>/usr/local/zookeeper/data</value>  
  178.     </property>  
  179. </configuration></span>  

我本地使用的是这个较详细版本。


3,修改/usr/local/hbase/conf/regionservers

  1. <span style="font-family:KaiTi_GB2312;font-size:14px;">xxCentosTwo  
  2. xxCentosThree  
  3. xxCentosFour</span>  

需要修改的配置文件基本来说就这三个,但是需要注意的是

因为hbase所支持的最稳定的hadoop版本未必与你下载的hadoop版本一致,所以建议最好将你的hadoop中的一些jar包替换到hbase

安全起见,我是把/usr/local/hbase/lib/路径下的hadoop开头的jar包都替换了一遍,旧版本改名做备份,以便恢复用



然后分发到各个服务器上


三、启动

在保证hadoop和zookeeper启动的前提下,启动hbase即可

  1. <span style="font-family:KaiTi_GB2312;font-size:14px;">/usr/local/hbase/bin/start-hbase.sh</span>  

如果正常启动,可以看到hbase的主页了


在HMaster服务器上执行hbase shell能看到类似下面的东西


上图是没有报错的正常情况


四、说说遇到的问题吧

1:zookeeper和hdfs最好重新格式化

本来以为,在启动过hbase之后甚至启动hbase之前,需要重新格式化一次zookeeper。以确保在zookeeper的目录下,产生hbase相关的东西。不过我最终没有做格式化zookeeper这一步,但是在zookeeper的目录下仍然看到对应的目录了。

但是在第一次启动之后,执行hbase shell看到一些报错信息

  1. <span style="font-family:KaiTi_GB2312;font-size:14px;">SLF4J: Class path contains multiple SLF4J bindings.  
  2.     SLF4J: Found binding in [jar:file:/usr/hbase/lib/slf4j-log4j12-1.6.4.jar!/org/slf4j/impl/StaticLoggerBinder.class]  
  3.     SLF4J: Found binding in [jar:file:/usr/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]  
  4.     SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.</span>  
开始以为没啥要紧的,然后偶然看到别人的帖子,才知道这是个异常信息
需要删掉重复的jar包,也就是删掉下面的这个即可
  1. <span style="font-family:KaiTi_GB2312;font-size:14px;">/usr/hbase/lib/slf4j-log4j12-1.6.4.jar</span>  

2:重新格式化后的报错信息

  1. <span style="font-family:KaiTi_GB2312;font-size:14px;">ERROR:org.apache.hadoop.hbase.PleaseHoldException: Master is initializing</span>  

网上搜了下,发现hbase-site.xml中的hbase.rootdir对应的value没有端口号。加上再分发到每个服务器,重启就好了。

其实就是最早我的hbase-site.xml是这样的

  1. <span style="font-family:KaiTi_GB2312;font-size:14px;"><property>  
  2.     <name>hbase.rootdir</name>  
  3.     <value>hdfs://lwns/hbase</value><!--这里必须跟core-site.xml中的fs.defaultFS键配置一样-->  
  4. </property></span>  

既没有端口号,同时我写的是HA的别名,然后我开始保持集群名不变,加上了端口号9000.启动,

执行hbase shell进入后,执行status或list,仍然报错。但是错误信息改变了,如下所示

  1. <span style="font-family:KaiTi_GB2312;font-size:14px;">ERROR: Can't get master address from ZooKeeper; znode data == null </span>  

有的说重启hbase就好了。还有的说要重新格式化hadoop的namenode
我选择先重启。发现起不来。查看日志,显示如下
  1. <span style="font-family:KaiTi_GB2312;font-size:14px;">java.lang.RuntimeException: Failed construction of Master: class org.apache.hadoop.hbase.master.HMaster.   
  2.     at org.apache.hadoop.hbase.master.HMaster.constructMaster(HMaster.java:2512)  
  3.     at org.apache.hadoop.hbase.master.HMasterCommandLine.startMaster(HMasterCommandLine.java:231)  
  4.     at org.apache.hadoop.hbase.master.HMasterCommandLine.run(HMasterCommandLine.java:137)  
  5.     at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:76)  
  6.     at org.apache.hadoop.hbase.util.ServerCommandLine.doMain(ServerCommandLine.java:126)  
  7.     at org.apache.hadoop.hbase.master.HMaster.main(HMaster.java:2522)  
  8. Caused by: java.io.IOException: Port 9000 specified in URI hdfs://lwns:9000/hbase but host 'lwns' is a logical (HA) namenode and does not use port information.  
  9.     at org.apache.hadoop.hdfs.NameNodeProxiesClient.createFailoverProxyProvider(NameNodeProxiesClient.java:254)  
  10.     at org.apache.hadoop.hdfs.NameNodeProxiesClient.createProxyWithClientProtocol(NameNodeProxiesClient.java:124)  
  11.     at org.apache.hadoop.hdfs.DFSClient.<init>(DFSClient.java:343)  
  12.     at org.apache.hadoop.hdfs.DFSClient.<init>(DFSClient.java:287)  
  13.     at org.apache.hadoop.hdfs.DistributedFileSystem.initialize(DistributedFileSystem.java:156)  
  14.     at org.apache.hadoop.fs.FileSystem.createFileSystem(FileSystem.java:2811)  
  15.     at org.apache.hadoop.fs.FileSystem.access$200(FileSystem.java:100)  
  16.     at org.apache.hadoop.fs.FileSystem$Cache.getInternal(FileSystem.java:2848)  
  17.     at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:2830)  
  18.     at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:389)  
  19.     at org.apache.hadoop.fs.Path.getFileSystem(Path.java:356)  
  20.     at org.apache.hadoop.hbase.util.FSUtils.getRootDir(FSUtils.java:1003)  
  21.     at org.apache.hadoop.hbase.regionserver.HRegionServer.initializeFileSystem(HRegionServer.java:609)  
  22.     at org.apache.hadoop.hbase.regionserver.HRegionServer.<init>(HRegionServer.java:564)  
  23.     at org.apache.hadoop.hbase.master.HMaster.<init>(HMaster.java:412)  
  24.     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)  
  25.     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)  
  26.     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)  
  27.     at java.lang.reflect.Constructor.newInstance(Constructor.java:526)  
  28.     at org.apache.hadoop.hbase.master.HMaster.constructMaster(HMaster.java:2505)  
  29.     ... 5 more</span>  

考虑还是我的hbase-site.xml的“hbase.rootdir”属性的问题。我改成不使用hadoop的HA的别名,直接使用HMaster的主机名
  1. <span style="font-family:KaiTi_GB2312;font-size:14px;"><property>  
  2.     <name>hbase.rootdir</name>  
  3.     <value>hdfs://xxCentosOne:9000/hbase</value>  
  4. </property></span>  
这样修改后,再次重新启动hbase,启动ok。


3、解决了上面的问题后,执行hbase shell,进入执行list,再次有问题

又出现第一次的错误ERROR:org.apache.hadoop.hbase.PleaseHoldException: Master is initializing
继续查,网上说可以尝试先分别启动regionserver,再启动hmaster,我尝试了,仍然同样的问题。

只好尝试删除NameNode的tmp文件夹和zookeeper的data文件夹下的version内容,然后重新格式化NameNode和zookeeper

为了安全起见,将/usr/local/hadoop/journalnode/下的内容也一起删除。

这是因为在格式化zk和hadoop的namenode的时候,会涉及到JournalNode的东西


然后我先把每台hadoop中的tmp文件夹清空,再把somedata文件夹清空(这个文件夹是存放NameNode或DataNode节点的数据的,

同时它是在hdfs-site.xml配置文件的dfs.namenode.name.dir和dfs.datanode.name.dir里面对应的路径得到的)

然后再把zookeeper下的data路径下的version-2文件夹清空(zoo.cfg中的dataDir键对应的值)

后面的格式化和重启过程在这里就不赘述了。详见上一篇文章

该格式化和重启的都弄完,重启hbase,跟踪日志,发现错误如下

  1. <span style="font-family:KaiTi_GB2312;font-size:14px;">2017-06-07 00:48:57,661 INFO  [xxCentosOne:16000.activeMasterManager] zookeeper.MetaTableLocator: Failed verification of hbase:meta,,1 at address=xxcentosfour,  
  2.         16020,1496766839655, exception=org.apache.hadoop.hbase.NotServingRegionException: Region hbase:meta,,1 is not online on xxcentosfour,16020,1496767744442  
  3.         at org.apache.hadoop.hbase.regionserver.HRegionServer.getRegionByEncodedName(HRegionServer.java:2942)  
  4.         at org.apache.hadoop.hbase.regionserver.RSRpcServices.getRegion(RSRpcServices.java:1072)  
  5.         at org.apache.hadoop.hbase.regionserver.RSRpcServices.getRegionInfo(RSRpcServices.java:1356)  
  6.         at org.apache.hadoop.hbase.protobuf.generated.AdminProtos$AdminService$2.callBlockingMethod(AdminProtos.java:22233)  
  7.         at org.apache.hadoop.hbase.ipc.RpcServer.call(RpcServer.java:2188org.apache.hadoop.fs.PathIsNotEmptyDirectoryException)  
  8.         at org.apache.hadoop.hbase.ipc.CallRunner.run(CallRunner.java:112)  
  9.         at org.apache.hadoop.hbase.ipc.RpcExecutor.consumerLoop(RpcExecutor.java:133)  
  10.         at org.apache.hadoop.hbase.ipc.RpcExecutor$1.run(RpcExecutor.java:108)  
  11.         at java.lang.Thread.run(Thread.java:745)</span>  

然后再报出这个错误之前,还有一个错误,就是hbase.hregion.max.filesize这个键对应的值不正确
我配置的值是"128M"。既然说不对,我查了下网上的别人写法,有人写成"1G",有人写成"134217728"这样的形式,我选择了后者。修改并分发到所有主机上
再重启,上面的"Failed verification of hbase"仍然会出现,但是我再执行"hbase shell"和"status","list"都不会报错了。说明可以正常启动了。



2017-06-07:追加报错与解决

当我重启了几台虚拟机之后,再次启动hbase,发现hmaster服务器的日志中还是有报错信息,然后我追查了一下

  1. <span style="font-family:KaiTi_GB2312;font-size:14px;">org.apache.hadoop.ipc.RemoteException(org.apache.hadoop.fs.PathIsNotEmptyDirectoryException): `/hbase/WALs/xxcentosthree,16020,1496845541229-splitting is non empty': Directory is not empty  
  2.         at org.apache.hadoop.hdfs.server.namenode.FSDirDeleteOp.delete(FSDirDeleteOp.java:115)  
  3.         at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.delete(FSNamesystem.java:2783)  
  4.         at org.apache.hadoop.hdfs.server.namenode.NameNodeRpcServer.delete(NameNodeRpcServer.java:1047)  
  5.         at org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolServerSideTranslatorPB.delete(ClientNamenodeProtocolServerSideTranslatorPB.java:626)  
  6.         at org.apache.hadoop.hdfs.protocol.proto.ClientNamenodeProtocolProtos$ClientNamenodeProtocol$2.callBlockingMethod(ClientNamenodeProtocolProtos.java)  
  7.         at org.apache.hadoop.ipc.ProtobufRpcEngine$Server$ProtoBufRpcInvoker.call(ProtobufRpcEngine.java:447)  
  8.         at org.apache.hadoop.ipc.RPC$Server.call(RPC.java:989)  
  9.         at org.apache.hadoop.ipc.Server$RpcCall.run(Server.java:845)  
  10.         at org.apache.hadoop.ipc.Server$RpcCall.run(Server.java:788)  
  11.         at java.security.AccessController.doPrivileged(Native Method)  
  12.         at javax.security.auth.Subject.doAs(Subject.java:415)  
  13.         at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1807)  
  14.         at org.apache.hadoop.ipc.Server$Handler.run(Server.java:2455)  
  15.   
  16.         at org.apache.hadoop.ipc.Client.getRpcResponse(Client.java:1481)  
  17.         at org.apache.hadoop.ipc.Client.call(Client.java:1427)  
  18.         at org.apache.hadoop.ipc.Client.call(Client.java:1337)  
  19.         at org.apache.hadoop.ipc.ProtobufRpcEngine$Invoker.invoke(ProtobufRpcEngine.java:227)  
  20.         at org.apache.hadoop.ipc.ProtobufRpcEngine$Invoker.invoke(ProtobufRpcEngine.java:116)  
  21.         at com.sun.proxy.$Proxy14.delete(Unknown Source)  
  22.         at org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolTranslatorPB.delete(ClientNamenodeProtocolTranslatorPB.java:559)  
  23.         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  
  24.         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)  
  25.         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)  
  26.         at java.lang.reflect.Method.invoke(Method.java:606)  
  27.         at org.apache.hadoop.io.retry.RetryInvocationHandler.invokeMethod(RetryInvocationHandler.java:398)  
  28.         at org.apache.hadoop.io.retry.RetryInvocationHandler$Call.invokeMethod(RetryInvocationHandler.java:163)  
  29.         at org.apache.hadoop.io.retry.RetryInvocationHandler$Call.invoke(RetryInvocationHandler.java:155)  
  30.         at org.apache.hadoop.io.retry.RetryInvocationHandler$Call.invokeOnce(RetryInvocationHandler.java:95)  
  31.         at org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:335)  
  32.         at com.sun.proxy.$Proxy15.delete(Unknown Source)  
  33.         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  
  34.         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)  
  35.         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)  
  36.         at java.lang.reflect.Method.invoke(Method.java:606)  
  37.         at org.apache.hadoop.hbase.fs.HFileSystem$1.invoke(HFileSystem.java:279)  
  38.         at com.sun.proxy.$Proxy16.delete(Unknown Source)  
  39.         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  
  40.         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)  
  41.         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)  
  42.         at java.lang.reflect.Method.invoke(Method.java:606)  
  43.         at org.apache.hadoop.hbase.fs.HFileSystem$1.invoke(HFileSystem.java:279)  
  44.         at com.sun.proxy.$Proxy16.delete(Unknown Source)  
  45.         at org.apache.hadoop.hdfs.DFSClient.delete(DFSClient.java:1642)  
  46.         at org.apache.hadoop.hdfs.DistributedFileSystem$17.doCall(DistributedFileSystem.java:794)  
  47.         at org.apache.hadoop.hdfs.DistributedFileSystem$17.doCall(DistributedFileSystem.java:791)  
  48.         at org.apache.hadoop.fs.FileSystemLinkResolver.resolve(FileSystemLinkResolver.java:81)  
  49.         at org.apache.hadoop.hdfs.DistributedFileSystem.delete(DistributedFileSystem.java:791)  
  50.         at org.apache.hadoop.hbase.master.SplitLogManager.splitLogDistributed(SplitLogManager.java:296)  
  51.         at org.apache.hadoop.hbase.master.MasterFileSystem.splitLog(MasterFileSystem.java:398)  
  52.         at org.apache.hadoop.hbase.master.MasterFileSystem.splitMetaLog(MasterFileSystem.java:313)  
  53.         at org.apache.hadoop.hbase.master.MasterFileSystem.splitMetaLog(MasterFileSystem.java:304)  
  54.         at org.apache.hadoop.hbase.master.HMaster.splitMetaLogBeforeAssignment(HMaster.java:1046)  
  55.         at org.apache.hadoop.hbase.master.HMaster.assignMeta(HMaster.java:976)  
  56.         at org.apache.hadoop.hbase.master.HMaster.finishActiveMasterInitialization(HMaster.java:783)  
  57.         at org.apache.hadoop.hbase.master.HMaster.access$600(HMaster.java:189)  
  58.         at org.apache.hadoop.hbase.master.HMaster$2.run(HMaster.java:1803)  
  59.         at java.lang.Thread.run(Thread.java:745)</span>  


开始以括号前面的条件作为条件去百度,结果得到的都是乱七八糟的东西。感觉有问题

然后以括号内为条件去百度。有一个帖子对我有点借鉴作用HBase简介

其中有一段就说这个报错的。里面说进入hadoop系统,删除为空的目录即可。因为那个目录不是普通的Linux文件系统的目录

然后我执行hadoop fs -ls /hadoop/WALs发现

  1. <span style="font-family:KaiTi_GB2312;font-size:14px;">ls: Port 9000 specified in URI hdfs://lwns:9000 but host 'lwns' is a logical (HA) namenode and does not use port information.</span>  

很奇怪的错误,字面意思是这个HA的别名不应该有端口号

然后我检查了一下我的hadoop下的core-site.xml文件fs.defaultFS这个键对应的值中,果然有端口号

然后去掉端口号,分发到其他服务器上。重启。却告诉我有一个文件找不到

  1. <span style="font-family:KaiTi_GB2312;font-size:14px;">stopping hbasecat: /tmp/hbase-root-master.pid: No such file or directory</span>  
看了一下,确实没有,然后去其他的regionserver服务器上看了一下对应路径下,却是有那些HRegionServer的pid的文件

其实就是记录了当前这个HRegionServer或者HMaster的进程号。

jps了一下那几个HRegionServer的服务器,发现HRegionServer进程都存在

然后在HMaster服务器上jps,不存在这个进程。。。。

考虑直接启动HMaster试试看

  1. <span style="font-family:KaiTi_GB2312;font-size:14px;">单独启动某台服务器的regionserver  
  2. /usr/local/hbase/bin/hbase-daemon.sh start regionserver  
  3. 启动集群所有regionserver  
  4. /usr/local/hbase/bin/hbase-daemons.sh start regionserver  
  5. 单独启动hmaster  
  6. /usr/local/hbase/bin/hbase-daemon.sh start master</span>  

同时跟踪日志,发现报错
  1. <span style="font-family:KaiTi_GB2312;font-size:14px;">2017-06-08 05:22:47,566 FATAL [xxCentosOne:16000.activeMasterManager] master.HMaster: Unhandled exception. Starting shutdown.  
  2. org.apache.hadoop.ipc.RemoteException(org.apache.hadoop.ipc.StandbyException): Operation category READ is not supported in state standby. Visit https://s.apache.org/sbnn-error  
  3.         at org.apache.hadoop.hdfs.server.namenode.ha.StandbyState.checkOperation(StandbyState.java:88)  
  4.         at org.apache.hadoop.hdfs.server.namenode.NameNode$NameNodeHAContext.checkOperation(NameNode.java:1896)  
  5.         at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.checkOperation(FSNamesystem.java:1346)  
  6.         at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.getFileInfo(FSNamesystem.java:2924)  
  7.         at org.apache.hadoop.hdfs.server.namenode.NameNodeRpcServer.getFileInfo(NameNodeRpcServer.java:1106)  
  8.         at org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolServerSideTranslatorPB.getFileInfo(ClientNamenodeProtocolServerSideTranslatorPB.java:858)  
  9.         at org.apache.hadoop.hdfs.protocol.proto.ClientNamenodeProtocolProtos$ClientNamenodeProtocol$2.callBlockingMethod(ClientNamenodeProtocolProtos.java)  
  10.         at org.apache.hadoop.ipc.ProtobufRpcEngine$Server$ProtoBufRpcInvoker.call(ProtobufRpcEngine.java:447)  
  11.         at org.apache.hadoop.ipc.RPC$Server.call(RPC.java:989)  
  12.         at org.apache.hadoop.ipc.Server$RpcCall.run(Server.java:845)  
  13.         at org.apache.hadoop.ipc.Server$RpcCall.run(Server.java:788)  
  14.         at java.security.AccessController.doPrivileged(Native Method)  
  15.         at javax.security.auth.Subject.doAs(Subject.java:415)  
  16.         at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1807)  
  17.         at org.apache.hadoop.ipc.Server$Handler.run(Server.java:2455)  
  18.   
  19.         at org.apache.hadoop.ipc.Client.getRpcResponse(Client.java:1481)  
  20.         at org.apache.hadoop.ipc.Client.call(Client.java:1427)  
  21.         at org.apache.hadoop.ipc.Client.call(Client.java:1337)  
  22.         at org.apache.hadoop.ipc.ProtobufRpcEngine$Invoker.invoke(ProtobufRpcEngine.java:227)  
  23.         at org.apache.hadoop.ipc.ProtobufRpcEngine$Invoker.invoke(ProtobufRpcEngine.java:116)  
  24.         at com.sun.proxy.$Proxy14.getFileInfo(Unknown Source)  
  25.         at org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolTranslatorPB.getFileInfo(ClientNamenodeProtocolTranslatorPB.java:787)  
  26.         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  
  27.         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)  
  28.         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)  
  29.         at java.lang.reflect.Method.invoke(Method.java:606)  
  30.         at org.apache.hadoop.io.retry.RetryInvocationHandler.invokeMethod(RetryInvocationHandler.java:398)  
  31.         at org.apache.hadoop.io.retry.RetryInvocationHandler$Call.invokeMethod(RetryInvocationHandler.java:163)  
  32.         at org.apache.hadoop.io.retry.RetryInvocationHandler$Call.invoke(RetryInvocationHandler.java:155)  
  33.         at org.apache.hadoop.io.retry.RetryInvocationHandler$Call.invokeOnce(RetryInvocationHandler.java:95)  
  34.         at org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:335)  
  35.         at com.sun.proxy.$Proxy15.getFileInfo(Unknown Source)  
  36.         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  
  37.         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)  
  38.         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)  
  39.         at java.lang.reflect.Method.invoke(Method.java:606)  
  40.         at org.apache.hadoop.hbase.fs.HFileSystem$1.invoke(HFileSystem.java:279)  
  41.         at com.sun.proxy.$Proxy16.getFileInfo(Unknown Source)  
  42.         at org.apache.hadoop.hdfs.DFSClient.getFileInfo(DFSClient.java:1700)  
  43.         at org.apache.hadoop.hdfs.DistributedFileSystem$27.doCall(DistributedFileSystem.java:1436)  
  44.         at org.apache.hadoop.hdfs.DistributedFileSystem$27.doCall(DistributedFileSystem.java:1433)  
  45.         at org.apache.hadoop.fs.FileSystemLinkResolver.resolve(FileSystemLinkResolver.java:81)  
  46.         at org.apache.hadoop.hdfs.DistributedFileSystem.getFileStatus(DistributedFileSystem.java:1433)  
  47.         at org.apache.hadoop.fs.FileSystem.exists(FileSystem.java:1436)  
  48.         at org.apache.hadoop.hbase.master.MasterFileSystem.checkRootDir(MasterFileSystem.java:431)  
  49.         at org.apache.hadoop.hbase.master.MasterFileSystem.createInitialFileSystemLayout(MasterFileSystem.java:153)  
  50.         at org.apache.hadoop.hbase.master.MasterFileSystem.<init>(MasterFileSystem.java:128)  
  51.         at org.apache.hadoop.hbase.master.HMaster.finishActiveMasterInitialization(HMaster.java:693)  
  52.         at org.apache.hadoop.hbase.master.HMaster.access$600(HMaster.java:189)  
  53.         at org.apache.hadoop.hbase.master.HMaster$2.run(HMaster.java:1803)  
  54.         at java.lang.Thread.run(Thread.java:745)  
  55. 2017-06-08 05:22:47,566 INFO  [xxCentosOne:16000.activeMasterManager] regionserver.HRegionServer: STOPPED: Unhandled exception. Starting shutdown.</span>  

根据字面意思,是说不能在standby的hadoop上启动hmaster。真的是吗

我打开页面,访问192.168.122.10和11两台服务器的50070端口,果然,11是standby,10是active

熟悉我这个架构的朋友应该知道,我的11是设计为active的hadoop,10是设计为standby的hadoo

同时10服务器上没有安装hbase

问题因该就在这里了,就是11在这次启动的时候成为了standby的hadoop所以才不能在这种hadoop上启动hmaster

然后杀掉所有HRegionServer,再重启整个hadoop,确认192.168.122.11服务器是active后,再启动hbase

发现11服务器上已经起来了HMaster进程。



2017-06-08:

继续处理昨天那个“路径非空”的问题

  1. <span style="font-size:14px;">2017-06-08 17:33:18,766 INFO  [xxCentosOne:16000.activeMasterManager] zookeeper.MetaTableLocator: Failed verification of hbase:meta,,1 at address=xxcentosthree,16020,1496912989215, exception=org.apache.hadoop.hbase.NotServingRegionException: Region hbase:meta,,1 is not online on xxcentosthree,16020,1496914404566  
  2.         at org.apache.hadoop.hbase.regionserver.HRegionServer.getRegionByEncodedName(HRegionServer.java:2942)  
  3.         at org.apache.hadoop.hbase.regionserver.RSRpcServices.getRegion(RSRpcServices.java:1072)  
  4.         at org.apache.hadoop.hbase.regionserver.RSRpcServices.getRegionInfo(RSRpcServices.java:1356)  
  5.         at org.apache.hadoop.hbase.protobuf.generated.AdminProtos$AdminService$2.callBlockingMethod(AdminProtos.java:22233)  
  6.         at org.apache.hadoop.hbase.ipc.RpcServer.call(RpcServer.java:2188)  
  7.         at org.apache.hadoop.hbase.ipc.CallRunner.run(CallRunner.java:112)  
  8.         at org.apache.hadoop.hbase.ipc.RpcExecutor.consumerLoop(RpcExecutor.java:133)  
  9.         at org.apache.hadoop.hbase.ipc.RpcExecutor$1.run(RpcExecutor.java:108)  
  10.         at java.lang.Thread.run(Thread.java:745)</span>  
执行hadoop  fs -ls /hbase/WALs/ 不再报昨天那个不能有端口的错误了。

然后可以看到这个路径下有好多东西,删除掉提示说非空的那些路径即可。
完毕后,重启hbase,跟踪日志,报下面的错误


  1. <span style="font-size:14px;">2017-06-08 17:33:18,766 INFO  [xxCentosOne:16000.activeMasterManager] zookeeper.MetaTableLocator: Failed verification of hbase:meta,,1 at address=xxcentosthree,16020,1496912989215, exception=org.apache.hadoop.hbase.NotServingRegionException: Region hbase:meta,,1 is not online on xxcentosthree,16020,1496914404566  
  2.         at org.apache.hadoop.hbase.regionserver.HRegionServer.getRegionByEncodedName(HRegionServer.java:2942)  
  3.         at org.apache.hadoop.hbase.regionserver.RSRpcServices.getRegion(RSRpcServices.java:1072)  
  4.         at org.apache.hadoop.hbase.regionserver.RSRpcServices.getRegionInfo(RSRpcServices.java:1356)  
  5.         at org.apache.hadoop.hbase.protobuf.generated.AdminProtos$AdminService$2.callBlockingMethod(AdminProtos.java:22233)  
  6.         at org.apache.hadoop.hbase.ipc.RpcServer.call(RpcServer.java:2188)  
  7.         at org.apache.hadoop.hbase.ipc.CallRunner.run(CallRunner.java:112)  
  8.         at org.apache.hadoop.hbase.ipc.RpcExecutor.consumerLoop(RpcExecutor.java:133)  
  9.         at org.apache.hadoop.hbase.ipc.RpcExecutor$1.run(RpcExecutor.java:108)  
  10.         at java.lang.Thread.run(Thread.java:745)</span>  

网上说这是某个regionserver处于offline状态。

首先执行hbase hbck,用来检查hbase的一致性(类似于hadoop fsck命令,fsck是用来检查hdfs的不一致问题的命令)

如果发现问题,可以使用hbase hbck -fix修复

但是我执行了hbase hbck之后,貌似没有问题

  1. <span style="font-size:14px;">Version: 1.2.5  
  2. Number of live region servers: 3  
  3. Number of dead region servers: 0  
  4. Master: xxcentosone,16000,1496914389895  
  5. Number of backup masters: 0  
  6. Average load: 0.6666666666666666  
  7. Number of requests: 0  
  8. Number of regions: 2  
  9. Number of regions in transition: 0  
  10. 2017-06-08 17:43:00,449 INFO  [main] util.HBaseFsck: Loading regionsinfo from the hbase:meta table  
  11.   
  12. Number of empty REGIONINFO_QUALIFIER rows in hbase:meta: 0</span>  

  1. <span style="font-size:14px;">Table hbase:meta is okay.  
  2.     Number of regions: 1  
  3.     Deployed on:  xxcentosthree,16020,1496914404566  
  4. Table hbase:namespace is okay.  
  5.     Number of regions: 1  
  6.     Deployed on:  xxcentosfour,16020,1496914405385  
  7. 0 inconsistencies detected.  
  8. Status: OK</span>  

怀疑又是启动过程中出现的临时错误吧。暂时不做处理

不过把别人的解决方式放到下面做个记录

方案一:

模拟这个连接中说的来做

1 ) 停掉hbase集群
2)删除hbase在hdfs目录下所有表目录下的recovered.edits

3)重启hbase集群,所有的region就都online了

注意,这种通过删除recovered.edits的方式来恢复集群,会丢失部分数据。

方案二:

这次是模拟这个连接

根据上面的思路,我们需要在集群所有RegionServer的hbase-site.xml配置文件里面增加如下配置:

<property>   
    <name>hbase.regionserver.executor.openregion.threads</name> 
    <value>100</value> 
</property>

然后重启HBase集群就可以了。

这种解决方案应该不会丢数据,推荐使用这种方式来恢复。


HRegionServer的一些配置信息

参数名称

 默认值含义
hbase.client.retries.number10客户端的重试次数
hbase.regionserver.msginterval3000未知
hbase.regionserver.checksum.verifyfalse

是否启用hbase的

checksum

hbase.server.thread.wakefrequency10秒检查线程的频率
hbase.regionserver.numregionstoreport10未知
hbase.regionserver.handler.count10

处理用户表的工作

线程数量

hbase.regionserver.metahandler.count10

处理meta和root表

的工作线程数量

hbase.rpc.verbosefalse未知
hbase.regionserver.nbreservationblocksfalse未知

hbase.regionserver.compactionChecker.

majorCompactPriority

max int未知
hbase.regionserver.executor.openregion.threads3

开打用户表region

的线程数量

hbase.regionserver.executor.openroot.threads1

打开root表region

的线程数量

hbase.regionserver.executor.openmeta.threads1

打开meta表region

的线程数量

hbase.regionserver.executor.closeregion.threads3

关闭用户表region

的线程数量

hbase.regionserver.executor.closeroot.threads1

关闭root表region

的线程数量

hbase.regionserver.executor.closemeta.threads1

关闭meta表region

的线程数量



2017-06-11:新增HMaster的高可用配置

在文章的开篇我就写过,有一个叫xxCentosZero的主机,我是打算做HMaster的备份的但是之前不会配置HMaster的高可用,所以就一直搁置了下来

最近参考了一篇帖子,感觉不错,尝试了一下,竟然成功了 有一种帖子叫人家的帖子

那篇文章感兴趣的诸位可以看看,我就说我改动的地方吧

1、各种配置文件

hbase-site.xml

  1. <!--这里必须跟core-site.xml中的fs.defaultFS键配置一样。-->  
  2. <!--  
  3. <property>  
  4.     <name>hbase.rootdir</name>  
  5.     <value>hdfs://xxCentosOne:9000/hbase</value>  
  6. </property>  
  7. -->  
  8. <!-- 原本我在这里写的是某一台主机的名称外加端口。然后参考了一些别人的帖子,以及打算超HMaster的HA方向努力  
  9. 所以尝试了一下去掉HMaster的主机名,改为hadoop的hdfs的集群名称,并且去掉端口号。 -->  
  10. <property>  
  11.     <name>hbase.rootdir</name>  
  12.     <value>hdfs://lwns/hbase</value>  
  13. </property>  
  14. <!-- 如果只配置端口,为了配置多个HMaster(HMaster的HA),否则就是单HMaster模式 -->  
  15. <!--   
  16. <property>  
  17.     <name>hbase.master</name>  
  18.     <value>xxCentosOne:60000</value>  
  19. </property>  
  20. -->  
  21. <property>  
  22.     <name>hbase.master</name>  
  23.     <value>60000</value>  
  24. </property>  

上面我注释掉的地方就是我之前的非HA的写法,保留下来的是HA的写法。

通过对比可知,其实就是将过去写死成服务器名称的地方或者改为hdfs的NameSpace,就是将原有的主机名去掉,只留端口

2、hadoop的core-site.xml的写法。我就上一个地方, 用以和hbase-site.xml对比使用

  1. <!-- 指定hdfs的nameservice为lw_ns,需要与hdfs-site.xml中的名字一致。注意好像这里不可以有端口号  -->  
  2.     <property>  
  3.         <name>fs.defaultFS</name>  
  4.         <value>hdfs://lwns</value>  
  5.     </property>  

区别只是在于,hbase-site.xml中在hdfs;//lwns后面加上了"/hbase"而已。


3、启动

记得我之前说过,在standby的hadoop上面是无法启动HMaster的么,我之前说的应该不够详细

之前的详细情况是这样的。

在没有修改hbase-site.xml配置文件的前提下,启动了所有的zookeeper,并且启动了hadoop集群之后

只能在状态为active的hadoop的NameNode上面启动hbase(执行/usr/local/hbase/bin/start-hbase.sh )

否则在状态为standby的hadoop的NameNode上执行上面的命令,会提示hadoop的NameNode状态不对的错误

核心原因就是在于,hbase-site.xml中hbase.rootdir和hbase.master写死了主机名的原因。


现在我们则不需要考虑hadoop的NameNode是否standby状态的问题了,

可以任意在某一个NameNode上执行/usr/local/hbase/bin/start-hbase.sh。都可以启动当前这个HMaster和所有的HRegionServer

而其他的HMaster,则需要在每台主机上分别执行/usr/local/hbase/bin/hbase-daemon.sh start master来启动


4、效果及对比

启动后可以在前台看到当前的HMaster和备份的HMaster的区别,如下图




从日志中也能看到备份HMaster与当前HMaster的区别

  1. 2017-06-11 08:48:13,156 INFO  [RpcServer.responder] ipc.RpcServer: RpcServer.responder: starting  
  2. 2017-06-11 08:48:13,160 INFO  [RpcServer.listener,port=16000] ipc.RpcServer: RpcServer.listener,port=16000: starting  
  3. 2017-06-11 08:48:13,393 INFO  [main] mortbay.log: Logging to org.slf4j.impl.Log4jLoggerAdapter(org.mortbay.log) via org.mortbay.log.Slf4jLog  
  4. 2017-06-11 08:48:13,402 INFO  [main] http.HttpRequestLog: Http request log for http.requests.master is not defined  
  5. 2017-06-11 08:48:13,427 INFO  [main] http.HttpServer: Added global filter 'safety' (class=org.apache.hadoop.hbase.http.HttpServer$QuotingInputFilter)  
  6. 2017-06-11 08:48:13,427 INFO  [main] http.HttpServer: Added global filter 'clickjackingprevention' (class=org.apache.hadoop.hbase.http.ClickjackingPreventionFilter)  
  7. 2017-06-11 08:48:13,429 INFO  [main] http.HttpServer: Added filter static_user_filter (class=org.apache.hadoop.hbase.http.lib.StaticUserWebFilter$StaticUserFilter) to context master  
  8. 2017-06-11 08:48:13,429 INFO  [main] http.HttpServer: Added filter static_user_filter (class=org.apache.hadoop.hbase.http.lib.StaticUserWebFilter$StaticUserFilter) to context static  
  9. 2017-06-11 08:48:13,430 INFO  [main] http.HttpServer: Added filter static_user_filter (class=org.apache.hadoop.hbase.http.lib.StaticUserWebFilter$StaticUserFilter) to context logs  
  10. 2017-06-11 08:48:13,459 INFO  [main] http.HttpServer: Jetty bound to port 16010  
  11. 2017-06-11 08:48:13,460 INFO  [main] mortbay.log: jetty-6.1.26  
  12. 2017-06-11 08:48:14,186 INFO  [main] mortbay.log: Started SelectChannelConnector@0.0.0.0:16010  
  13. 2017-06-11 08:48:14,194 INFO  [main] master.HMaster: hbase.rootdir=hdfs://lwns/hbase, hbase.cluster.distributed=true  
  14. 2017-06-11 08:48:14,226 INFO  [main] master.HMaster: Adding backup master ZNode /hbase/backup-masters/xxcentoszero,16000,1497142091312  
  15. 2017-06-11 08:48:14,445 INFO  [xxCentosZero:16000.activeMasterManager] <span style="background-color: rgb(255, 255, 102);"><span style="color:#FF6666;">master.ActiveMasterManager: Another master is the active master, xxcentosone,16000,1497141734452; waiting to become the next active master</span></span>  
  16. 2017-06-11 08:48:14,555 INFO  [master/xxCentosZero/192.168.122.10:16000] zookeeper.RecoverableZooKeeper: Process identifier=hconnection-0x66c6b2fe connecting to ZooKeeper ensemble=xxCentosZero:2181,xxCentosOne:2181,xxCentosTwo:2181,xxCentosThree:2181,xxCentosFour:2181  
  17. 2017-06-11 08:48:14,561 INFO  [master/xxCentosZero/192.168.122.10:16000] zookeeper.ZooKeeper: Initiating client connection, connectString=xxCentosZero:2181,xxCentosOne:2181,xxCentosTwo:2181,xxCentosThree:2181,xxCentosFour:2181 sessionTimeout=30000 watcher=hconnection-0x66c6b2fe0x0, quorum=xxCentosZero:2181,xxCentosOne:2181,xxCentosTwo:2181,xxCentosThree:2181,xxCentosFour:2181, baseZNode=/hbase  
  18. 2017-06-11 08:48:14,565 INFO  [master/xxCentosZero/192.168.122.10:16000-SendThread(xxCentosTwo:2181)] zookeeper.ClientCnxn: Opening socket connection to server xxCentosTwo/192.168.122.12:2181. Will not attempt to authenticate using SASL (unknown error)  
  19. 2017-06-11 08:48:14,568 INFO  [master/xxCentosZero/192.168.122.10:16000-SendThread(xxCentosTwo:2181)] zookeeper.ClientCnxn: Socket connection established to xxCentosTwo/192.168.122.12:2181, initiating session  
  20. 2017-06-11 08:48:14,573 INFO  [master/xxCentosZero/192.168.122.10:16000-SendThread(xxCentosTwo:2181)] zookeeper.ClientCnxn: Session establishment complete on server xxCentosTwo/192.168.122.12:2181, sessionid = 0x25c947d51cd0005, negotiated timeout = 30000  
  21. 2017-06-11 08:48:14,636 INFO  [master/xxCentosZero/192.168.122.10:16000] regionserver.HRegionServer: ClusterId : 9d1223e6-9947-422e-a966-94d9e48d101f  

到这里,HMaster的高可用可以告一段落了。


转载自:http://blog.csdn.net/darkdragonking/article/details/72901330

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值