溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

HBase-0.98.9如何搭建配置

發(fā)布時(shí)間:2021-11-18 17:02:41 來(lái)源:億速云 閱讀:136 作者:小新 欄目:云計(jì)算

這篇文章主要介紹HBase-0.98.9如何搭建配置,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!

一     配置

1.1      hbase-env.sh

其它不變,export HBASE_MANAGES_ZK=false,這表示不使用hbase自帶的zookeeper,而使用外部的zookeeper(我使用的是跟hadoop集群配置的zookeeper)

1.2      hbase-site.xml

<configuration>
<property>
 <name>hbase.rootdir</name>
 <value>hdfs://master1:8020/hbase</value>
 <description>The directory shared by region servers.</description>
</property>
<property>
 <name>hbase.zookeeper.property.clientPort</name>
 <value>2181</value>
 <description>Property from ZooKeeper's config zoo.cfg. The port at which the clients will connect.
 </description>
</property>
<property>
 <name>zookeeper.session.timeout</name>
 <value>120000</value>
</property>
<property>
 <name>hbase.zookeeper.quorum</name>
 <value>master1,master2,slave1</value>
</property>
<property>
 <name>hbase.tmp.dir</name>
 <value>/root/hbasedata</value>
</property>
<property>
 <name>hbase.cluster.distributed</name>
 <value>true</value>
</property>
</configuration>

HBase-0.98.9如何搭建配置

1.3      regionservers

master1
master2
slave1

1.4      一些配置參數(shù)的解釋

hbase.zookeeper.property.clientPort:指定zk的連接端口

zookeeper.session.timeout:RegionServer與Zookeeper間的連接超時(shí)時(shí)間。當(dāng)超時(shí)時(shí)間到后,ReigonServer會(huì)被Zookeeper從RS集群清單中移除,HMaster收到移除通知后,會(huì)對(duì)這臺(tái)server負(fù)責(zé)的regions重新balance,讓其他存活的RegionServer接管.

hbase.zookeeper.quorum:默認(rèn)值是 localhost,列出zookeepr ensemble中的servers

2     啟動(dòng)/關(guān)閉

在master1上執(zhí)行

bin/start-hbase.sh

bin/stop-hbase.sh

3     測(cè)試

如果web管理頁(yè)面可以打開(kāi),說(shuō)明Hmaster啟動(dòng)成功:http:master1:60010

在master1上執(zhí)行

{HBASE_HOME}/bin/hbase shell

進(jìn)入shell命令行,通過(guò)創(chuàng)建表等操作來(lái)檢查不是不工作正常。

hbase(main):001:0> create 'scores','grade', 'course'

4     注意事項(xiàng)

HBase集群需要依賴于一個(gè)Zookeeper ensemble。HBase集群中的所有節(jié)點(diǎn)以及要訪問(wèn)HBase的客戶端都需要能夠訪問(wèn)到該Zookeeper  ensemble。HBase自帶了Zookeeper,但為了方便其他應(yīng)用程序使用Zookeeper,最好使用單獨(dú)安裝的Zookeeper ensemble。

此外,Zookeeper ensemble一般配置為奇數(shù)個(gè)節(jié)點(diǎn),并且Hadoop集群、Zookeeper ensemble、HBase集群是三個(gè)互相獨(dú)立的集群,并不需要部署在相同的物理節(jié)點(diǎn)上,他們之間是通過(guò)網(wǎng)絡(luò)通信的。

需要注意的是,如果要禁止啟動(dòng)hbase自帶的zookeeper,那么,不僅僅需要?jiǎng)偛诺膃xport HBASE_MANAGES_ZK=false配置,還需要hdfs-site.xml中的hbase.cluster.distributed為true,否則你在啟動(dòng)時(shí)會(huì)遇到Could not start ZK at requested port of 2181 錯(cuò)誤,這是因?yàn)閔base嘗試啟動(dòng)自帶的zookeeper,而我們已經(jīng)啟動(dòng)了自己安裝的那個(gè)zookeeper,默認(rèn)都使用2181端口,所以出錯(cuò)。

還有,有時(shí)候會(huì)遇到stop-hbase.sh執(zhí)行很長(zhǎng)時(shí)間未結(jié)束,很可能的原因是你之前把zookeeper關(guān)閉了.

最后,Hbase不需要mapreduce,所以只要start-dfs.sh啟動(dòng)hdfs,然后到zookeeper各節(jié)點(diǎn)上啟動(dòng)zookeeper,最后再hbase-start.sh啟動(dòng)hbase即可.

二  安裝運(yùn)行遇到的錯(cuò)誤匯總:

1. habse啟動(dòng)失敗,查看日志發(fā)現(xiàn)報(bào)錯(cuò):

zookeeper 啟動(dòng)失敗 BindException: Address already in use

原因:zk在hbase啟動(dòng)之前就已經(jīng)啟動(dòng)(因?yàn)槲也捎玫氖峭獠康膠k集群)。解決方法是環(huán)境變量設(shè)置export HBASE_MANAGES_ZK=false,同時(shí)確保hbase-env.sh里也是相同設(shè)置。

2. 再次啟動(dòng)發(fā)現(xiàn)hmaster還是沒(méi)有起起來(lái),查看日志發(fā)現(xiàn)報(bào)錯(cuò):

hbase java.lang.runtimeexception hmaster aborted,查找error那一行是failed on connection exception: java.net.ConnectException: master1 Connection refused

原因:master1節(jié)點(diǎn)跟hadoop集群連接失敗,懷疑是hbase-site.xml配置有問(wèn)題。其與hadoop連接配置為:

<name>hbase.rootdir</name>

<value>hdfs://master1:9000/hbase</value>

這里配置的9000,而集群fs.defaultfs 本來(lái)端口是8020:HBase-0.98.9如何搭建配置

修改之后,重新啟動(dòng)hvase,一切正常。。。

3. hbase內(nèi)置hadoop jar包跟已有的集群版本不一樣,需要進(jìn)行替換以確保穩(wěn)定性和一致性。
rm -rf /usr/hbase-0.98.21-hadoop2/lib/hadoop*.jar

find /usr/hadoop/share/hadoop -name "hadoop*jar" | xargs -i cp {} /usr/hbase-0.98.21-hadoop2/lib

替換之后重啟發(fā)現(xiàn)hmaster又啟動(dòng)不起來(lái)了,查看日志發(fā)現(xiàn):

Caused by: java.lang.ClassNotFoundException: com.amazonaws.auth.AWSCredentialsProvider

少了一個(gè)jar包。

解決方案:
需要將 hadoop-2.6.3/share/hadoop/tools/lib/aws-java-sdk-1.7.4.jar 拷貝到hbase/lib下

4.經(jīng)過(guò)上面幾次折騰之后發(fā)現(xiàn)重啟hbase之后,只有hMaster能啟動(dòng),其他節(jié)點(diǎn)起不了。日志錯(cuò)誤如下。手動(dòng)啟動(dòng)regionserver后,發(fā)現(xiàn)hmaster又是變成阻塞狀態(tài),在shell控制臺(tái)無(wú)法進(jìn)行表操作。

2015-07-01 04:39:34,480 WARN  [MASTER_META_SERVER_OPERATIONS-master:60000-0] master.AssignmentManager: Can't move 1588230740, there is no destination server available. 
2015-07-01 04:39:34,480 WARN  [MASTER_META_SERVER_OPERATIONS-master:60000-0] master.AssignmentManager: Unable to determine a plan to assign {ENCODED => 1588230740, NAME => 'hbase:meta,,1', STARTKEY => '', ENDKEY => ''} 
2015-07-01 04:39:35,480 WARN  [MASTER_META_SERVER_OPERATIONS-master:60000-0] master.AssignmentManager: Can't move 1588230740, there is no destination server available. 
2015-07-01 04:39:35,481 WARN  [MASTER_META_SERVER_OPERATIONS-master:60000-0] master.AssignmentManager: Unable to determine a plan to assign {ENCODED => 1588230740, NAME => 'hbase:meta,,1', STARTKEY => '', ENDKEY => ''} 
2015-07-01 04:39:36,379 ERROR [RpcServer.handler=6,port=60000] master.HMaster: Region server server2.corp.gs.com,60020,1435743503791 reported a fatal error: 
ABORTING region server server1.corp.gs.com,60020,1435743483790: org.apache.hadoop.hbase.YouAreDeadException: Server REPORT rejected; currently processing server1.corp.gs.com,60020,1435743483790 as dead server 
        at org.apache.hadoop.hbase.master.ServerManager.checkIsDead(ServerManager.java:339) 
        at org.apache.hadoop.hbase.master.ServerManager.regionServerReport(ServerManager.java:254) 
        at org.apache.hadoop.hbase.master.HMaster.regionServerReport(HMaster.java:1343) 
        at org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos$RegionServerStatusService$2.callBlockingMethod(RegionServerStatusProtos.java:5087) 
        at org.apache.hadoop.hbase.ipc.RpcServer.call(RpcServer.java:2175) 
        at org.apache.hadoop.hbase.ipc.RpcServer$Handler.run(RpcServer.java:1879) 

Cause: 
org.apache.hadoop.hbase.YouAreDeadException: org.apache.hadoop.hbase.YouAreDeadException: Server REPORT rejected; currently processing server1.corp.gs.com,60020,1435743483790 as dead server

原因:極有可能是zk機(jī)器的hbase數(shù)據(jù)錯(cuò)誤。

解決方案:

1. 停掉所有hbase的進(jìn)程先
2. 刪掉zk中的hbase數(shù)據(jù)

hbase zkcli或者bin/zkCli.sh進(jìn)入zk命令行
ls / #可以看到hbase數(shù)據(jù)存在
rmr /hbase #刪除hbase數(shù)據(jù)


3. 運(yùn)行hdfs fsck /hbase 確保數(shù)據(jù)沒(méi)有沖突
4. 重新啟動(dòng)start-hbase.sh  
5. 如果還是只有主節(jié)點(diǎn)運(yùn)行,則手動(dòng)啟動(dòng)regionserver

./hbase-daemon.sh start regionserver


6. 運(yùn)行 hbase hbck  監(jiān)測(cè)數(shù)據(jù)是否一致。如果有問(wèn)題再運(yùn)行 hbase hbck -fix (or 
-repair) 

* 運(yùn)行hbase hbck - repair 有時(shí)候會(huì)報(bào)錯(cuò)connection refuse,這是因?yàn)閞egionserver又掛掉了,要確保regionserver是運(yùn)行狀態(tài)

還有問(wèn)題參考下這篇文章吧http://apache-hbase.679495.n3.nabble.com/Corrupted-META-td4072787.html。

5. 重啟hbase之后Hmaster啟動(dòng)不了,報(bào)錯(cuò)org.apache.hadoop.hbase.util.FileSystemVersionException: File system needs to be upgraded. You have version null and I want version 8。

解決方法:

log中可以發(fā)現(xiàn)可能是hbase.version文件消失了,如果只是測(cè)試hbase,可以直接把hdfs中的/hbase刪掉。,然后重啟就好了,但是以前的數(shù)據(jù)就丟失了。

bin/hadoop fs -ls /hbase

發(fā)現(xiàn)/hbase/hbase.version確實(shí)已經(jīng)消失了,去/lost+found目錄找確實(shí)能找到。

如果需要保留以前數(shù)據(jù),可以按下面步驟:

bin/hadoop fs -mv /hbase /hbase.bk

重啟HBase,這時(shí)就生成了/hbase/hbase.version文件,然后:

bin/hadoop fs -cp /hbase/hbase.version /hbase.bk/

bin/hadoop fs -rmr /hbase 

bin/hadoop fs -mv /hbase.bk /hbase

這樣再次重啟HBase,發(fā)現(xiàn)Hbase開(kāi)始splitting hlogs,數(shù)據(jù)得以恢復(fù)。

6. hbase升級(jí)到1.1.6之后,發(fā)現(xiàn)web端口60010打不開(kāi)了。

原來(lái)是因?yàn)?.0版本之后的hbase的master web 默認(rèn)是不運(yùn)行的,所以需要自己配置默認(rèn)端口。配置如下

在hbase-site.xml中加入一下內(nèi)容即可

<property>
<name>hbase.master.info.port</name>
<value>60010</value>
</property>

同理可以配置regionserver web端口

以上是“HBase-0.98.9如何搭建配置”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI