您现在的位置 >> Hadoop教程 >> Hadoop实战 >> hbase专题  
 

HBase-0.98.0与Phoenix-4.0.0分布式安装指导

【作者:Hadoop实战专家】【关键词:配置 安装 错误 】 【点击:61269次】【2013-01-1】
关于分布式安装,请浏览:http://hbase.apache.org/book/standalone_dist.html#distributed,关于HBase使用外置的ZooKeeper配置,请浏览:http://hbase.apache.org/book/zookeeper.html。。这个错误是因为HMaster上的时间和RegionServer上的时间相差超过30秒。  

相关热门搜索:

大数据标签:hadoop hdfs hbase zookeeper bigdata

问题导读:
相关端口中2888端口是用来做什么的?
用于Leader选举的是哪个端口?
HMaster的http端口是哪个?
hbase.master.info.port作用是什么?
备HMaster配置该如何配置?
Host key not found from database错误的可能原因是什么?
Failed deleting my ephemeral node错误的可能原因是什么?

目录
1. 前言
2. 约定
3. 相关端口
4. 下载HBase
5. 安装步骤
5.1. 修改conf/regionservers
5.2. 修改conf/hbase-site.xml
5.2.1. hbase.master.info.port
5.2.2. hbase.master.info.bindAddress
5.3. 修改conf/hbase-env.sh
6. 启动运行
7. 基本的HBase命令
8. 备HMaster配置
9. 常见错误
10. 相关文档
附:phoenix的安装

1. 前言
本文将HBase-0.98.0安装在Hadoop-2.4.0上,关于Hadoop-2.4.0的安装,请参见《Hadoop-2.4.0分布式安装手册》一文。
安装环境为64位SuSE-Linux 10.1版本。
本文将在HBase官方提供的quickstart.html文件的指导下进行,在docs/getting_started目录下可找到quickstart.html,或直接浏览在线的:http://hbase.apache.org/book/quickstart.html。
安装使用外置的ZooKeeper,有关ZooKeeper的安装,请参见《ZooKeeper-3.4.6分布式安装指南》一文。
关于分布式安装,请浏览:http://hbase.apache.org/book/standalone_dist.html#distributed,关于HBase使用外置的ZooKeeper配置,请浏览:http://hbase.apache.org/book/zookeeper.html。
所有在线的文档,均会出现在二进制安装包解压后的docs目录下。本文的安装环境为64位SuSE 10.1 Linux。

2. 约定
假设将Hadoop-2.4.0安装在/data/hadoop/current目录,而/data/hadoop/current实际是到/data/hadoop/hadoop-2.4.0的软链接。
HBase安装目录为/data/hadoop/hbase,而/data/hadoop/hbase实际是到hbase-0.98.0-hadoop2的软链接。
建议JDK为1.7版本,在JDK1.8上可以成功安装Hadoop-2.4.0,但基于JDK1.8编译Hadoop-2.4.0则会遇到困难。

3. 相关端口
2888     ZooKeeper,如果是Leader,用来监听Follower的连接
3888     ZooKeeper,用于Leader选举
2181     ZooKeeper,用来监听客户端的连接
60010   hbase.master.info.port,HMaster的http端口
60000   hbase.master.port,HMaster的RPC端口
60030   hbase.regionserver.info.port,HRegionServer的http端口
60020   hbase.regionserver.port,HRegionServer的RPC端口
8080     hbase.rest.port,HBase REST server的端口

4. 下载HBase
官网:http://hbase.apache.org/,在这里即可找到下载HBase的链接。
下载国内映像站点:http://mirror.bit.edu.cn/apache/hbase/,HBase-0.98.0版本的下载网址:http://mirror.bit.edu.cn/apache/hbase/hbase-0.98.0/。选择下载hbase-0.98.0-hadoop2-bin.tar.gz。

5. 安装步骤
5.1. 修改conf/regionservers
regionservers类似于Hadoop的slaves文件,不需要在RegionServer机器上执行些修改。
将所有HRegionServers的IP或主机名一行一行的例举在在regionservers文件中,注意必须一行一个,不能一行多个。本文配置如下:
hadoop@VM_40_171_sles10_64:~/hbase/conf> cat regionservers
10.12.154.77
10.12.154.78
10.12.154.79

5.2. 修改conf/hbase-site.xml
需要在所有机器上做同样的操作,可以借助scp命令,先配置好一台,然后复制过去,如:scp hbase-site.xml hadoop@10.12.154.79:/data/hadoop/hbase/conf/。
hbase-site.xml是HBase的配置文件。默认的hbase-site.xml是空的,如下所示:

1. 

2. 

3. 

23. 

24. 

复制代码

没关系,就用它。不要用docs目录下的hbase-default.xml,这个会让你看得难受。
编辑hbase-site.xml,添加如下内容(摘自standalone_dist.html,搜索“Fully-distributed”):

1. 

2.   

3.     hbase.rootdir

4.     hdfs://172.25.40.171:9001/hbase

5.     The directory shared by RegionServers.

6.   

7.

8.   

9.     hbase.cluster.distributed

10.     true

11.     The mode the cluster will be in. Possible values are

12.       false: standalone and pseudo-distributed setups with managed Zookeeper

13.       true: fully-distributed with unmanaged Zookeeper Quorum (see hbase-env.sh)

14.     

15.   

16.

17.   

18.     hbase.zookeeper.quorum

19.     DEVNET-154-77,DEVNET-154-70,DEVNET-154-79

20.     Comma separated list of servers in the ZooKeeper Quorum.

21.       For example, "host1.mydomain.com,host2.mydomain.com,host3.mydomain.com".

22.       By default this is set to localhost for local and pseudo-distributed modes

23.       of operation. For a fully-distributed setup, this should be set to a full

24.       list of ZooKeeper quorum servers. If HBASE_MANAGES_ZK is set in hbase-env.sh

25.       this is the list of servers which we will start/stop ZooKeeper on.

26.     

27.   

28.

29.

30.   

31.     hbase.master.maxclockskew

32.     600000

33.     Time(ms) difference of regionserver from master

34.   

35. 

复制代码

“hbase.zookeeper.quorum”可以填写IP列表。hdfs://172.25.40.171:9001对应hdfs-site.xml中的“dfs.namenode.rpc-address”。“hbase.zookeeper.quorum”配置为ZooKeeper集群各节点主机名或IP。
更多的信息,可以浏览:http://hbase.apache.org/book/config.files.html。
5.2.1. hbase.master.info.port
用于指定HMaster的http端口。
5.2.2. hbase.master.info.bindAddress
用于指定HMaster的http的IP地址,如果不设定该值,可能使用IPv6地址。
5.3. 修改conf/hbase-env.sh
需要在所有机器上做同样的操作,可以借助scp命令,先配置好一台,然后复制过去,如:scp hbase-site.xml hadoop@10.12.154.79:/data/hadoop/hbase/conf/,修改内容如下:

1) 设置JAVA_HOME
# The java implementation to use.  Java 1.6 required.
export JAVA_HOME=/data/jdk
上述/data/jdk是JDK的安装目录。
2) 设置HBASE_MANAGES_ZK
# Tell HBase whether it should manage it's own instance of Zookeeper or not.
export HBASE_MANAGES_ZK=false

如果HBASE_MANAGES_ZK值为true,则表示使用HBase自带的ZooKeeper,建议单独部署ZooKeeper,这样便于ZooKeeper同时为其它系统提供服务。
3) 设置HBASE_CLASSPATH
# Extra Java CLASSPATH elements.  Optional.
export HBASE_CLASSPATH=/data/hadoop/current/etc/hadoop

6. 启动运行
进入HBASE_HOME/bin目录,执行start-hbase.sh即可启动HBase。请使用JDK提供的jps命令,分别查看HMaster和HRegionServer进程是否已经起来,同时检查日志文件是否有错误。

7. 基本的HBase命令
通过执行“hbase shell”进入命令行操作界面。详细请浏览官方文档:quickstart.html。
hbase(main):003:0> create 'test', 'cf'  # 创建表test,一个列族cf
0 row(s) in 1.2200 seconds
hbase(main):003:0> list 'test'
..
1 row(s) in 0.0550 seconds
hbase(main):004:0> put 'test', 'row1', 'cf:a', 'value1'  # 往表test的cf列族的a字段插入值value1
0 row(s) in 0.0560 seconds
hbase(main):005:0> put 'test', 'row2', 'cf:b', 'value2'
0 row(s) in 0.0370 seconds
hbase(main):006:0> put 'test', 'row3', 'cf:c', 'value3'
0 row(s) in 0.0450 seconds

hbase(main):007:0> scan 'test'  # 扫描表test
ROW        COLUMN+CELL
row1       column=cf:a, timestamp=1288380727188, value=value1
row2       column=cf:b, timestamp=1288380738440, value=value2
row3       column=cf:c, timestamp=1288380747365, value=value3
3 row(s) in 0.0590 seconds

hbase(main):008:0> get 'test', 'row1'  # 从表test取一行数据
COLUMN      CELL
cf:a        timestamp=1288380727188, value=value1
1 row(s) in 0.0400 seconds

hbase(main):012:0> disable 'test'
0 row(s) in 1.0930 seconds
hbase(main):013:0> drop 'test'
0 row(s) in 0.0770 seconds

hbase(main):014:0> exit

8. 备HMaster配置
备HMaster可以有0到多个,配置和主HMaster完全相同,所以只需要复制一份已配置好的HMaster过去即可,然后同样的命令启动。启动好后,一样可以执行HBase shell命令。

9. 常见错误
本文的实践过程中遇到了如下一些错误:

1) 错误1:Host key not found from database
遇到如下错误,说明不能免密码登录DEVNET-154-70、DEVNET-154-77和DEVNET-154-79,假设用户名为hadoop,则可以试试ssh hadoop@DEVNET-154-70来检查是否能免密码登录:
./start-hbase.sh
DEVNET-154-70: Host key not found from database.
DEVNET-154-70: Key fingerprint:
DEVNET-154-70: xihad-rotuf-lykeh-mapup-kylin-kybub-sohid-bucaf-gafyg-vecuc-tyxux
DEVNET-154-70: You can get a public key's fingerprint by running
DEVNET-154-70: % ssh-keygen -F publickey.pub
DEVNET-154-70: on the keyfile.
DEVNET-154-70: warning: tcgetattr failed in ssh_rl_set_tty_modes_for_fd: fd 1: Invalid argument
DEVNET-154-77: Host key not found from database.
DEVNET-154-77: Key fingerprint:
DEVNET-154-77: xuhog-tavip-donon-vuvac-tycyh-sysyz-zacur-didoz-fugif-vosar-ruxyx
DEVNET-154-77: You can get a public key's fingerprint by running
DEVNET-154-77: % ssh-keygen -F publickey.pub
DEVNET-154-77: on the keyfile.
DEVNET-154-77: warning: tcgetattr failed in ssh_rl_set_tty_modes_for_fd: fd 1: Invalid argument
DEVNET-154-79: Host key not found from database.
DEVNET-154-79: Key fingerprint:
DEVNET-154-79: xolim-mysyg-bozes-zilyz-futaf-tatig-zaryn-pilaf-betyf-meduf-tixux
DEVNET-154-79: You can get a public key's fingerprint by running
DEVNET-154-79: % ssh-keygen -F publickey.pub
DEVNET-154-79: on the keyfile.
DEVNET-154-79: warning: tcgetattr failed in ssh_rl_set_tty_modes_for_fd: fd 1: Invalid argument

2) 错误2:Failed deleting my ephemeral node
原因可能是因为之前配置错误,比如使用HBase自带的ZooKeeper启动过,后改为使用外围的ZooKeeper再启动。
2014-04-22 16:26:17,452 WARN  [regionserver60020] zookeeper.RecoverableZooKeeper: Node /hbase/rs/DEVNET-154-79,60020,1398155173411 already deleted, retry=false
2014-04-22 16:26:17,453 WARN  [regionserver60020] regionserver.HRegionServer: Failed deleting my ephemeral node
org.apache.zookeeper.KeeperException$NoNodeException: KeeperErrorCode = NoNode for /hbase/rs/DEVNET-154-79,60020,1398155173411
at org.apache.zookeeper.KeeperException.create(KeeperException.java:111)
at org.apache.zookeeper.KeeperException.create(KeeperException.java:51)
at org.apache.zookeeper.ZooKeeper.delete(ZooKeeper.java:873)
at org.apache.hadoop.hbase.zookeeper.RecoverableZooKeeper.delete(RecoverableZooKeeper.java:156)
at org.apache.hadoop.hbase.zookeeper.ZKUtil.deleteNode(ZKUtil.java:1273)
at org.apache.hadoop.hbase.zookeeper.ZKUtil.deleteNode(ZKUtil.java:1262)
at org.apache.hadoop.hbase.regionserver.HRegionServer.deleteMyEphemeralNode(HRegionServer.java:1273)
at org.apache.hadoop.hbase.regionserver.HRegionServer.run(HRegionServer.java:1003)
at java.lang.Thread.run(Thread.java:744)

3) 错误3:Master rejected startup because clock is out of sync
来自RegionServer端的日志,HMaster拒绝RegionServer的连接。这个错误是因为HMaster上的时间和RegionServer上的时间相差超过30秒。
两种解决办法:
一是同步时间,
二是修改hbase-site.xml中的hbase.master.maxclockskew(HMaster端的hdfs-site.xml文件):。
2014-04-22 16:34:36,701 FATAL [regionserver60020] regionserver.HRegionServer: Master rejected startup because clock is out of sync
org.apache.hadoop.hbase.ClockOutOfSyncException: org.apache.hadoop.hbase.ClockOutOfSyncException: Server DEVNET-154-79,60020,1398155672511 has been rejected; Reported time is too far out of sync with master.  Time difference of 175968ms > max allowed of 30000ms
at org.apache.hadoop.hbase.master.ServerManager.checkClockSkew(ServerManager.java:316)
at org.apache.hadoop.hbase.master.ServerManager.regionServerStartup(ServerManager.java:216)
at org.apache.hadoop.hbase.master.HMaster.regionServerStartup(HMaster.java:1281)
at org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos$RegionServerStatusService$2.callBlockingMethod(RegionServerStatusProtos.java:5085)
at org.apache.hadoop.hbase.ipc.RpcServer.call(RpcServer.java:2008)
at org.apache.hadoop.hbase.ipc.CallRunner.run(CallRunner.java:92)
at org.apache.hadoop.hbase.ipc.FifoRpcScheduler$1.run(FifoRpcScheduler.java:73)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:744)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
at org.apache.hadoop.ipc.RemoteException.instantiateException(RemoteException.java:106)
at org.apache.hadoop.ipc.RemoteException.unwrapRemoteException(RemoteException.java:95)
at org.apache.hadoop.hbase.protobuf.ProtobufUtil.getRemoteException(ProtobufUtil.java:284)
at org.apache.hadoop.hbase.regionserver.HRegionServer.reportForDuty(HRegionServer.java:1998)
at org.apache.hadoop.hbase.regionserver.HRegionServer.run(HRegionServer.java:839)
at java.lang.Thread.run(Thread.java:744)

将hbase.master.maxclockskew改成可以容忍10分钟:

hbase.master.maxclockskew
600000
Time(ms) difference of regionserver from master


phoenix的安装
Phoenix的安装非常简单。官网有说明(http://phoenix.incubator.apache.org/download.html),二进制安装包可从http://www.apache.org/dyn/closer.cgi/incubator/phoenix/上下载,本文下载的是phoenix-4.0.0-incubating.tar.gz,注意和HBase的兼容关系:
Phoenix版本
HBase版本
Phoenix 2.x
HBase 0.94.x
Phoenix 3.x
HBase 0.94.x
Phoenix 4.x
HBase 0.98.1+

安装步骤为:
1) 将phoenix-4.0.0-incubating.tar.gz上传到Phoenix客户端机器,假设安装到/data/hadoop
2) 解压phoenix-4.0.0-incubating.tar.gz,解压后生成phoenix-4.0.0-incubating目录
3) 建立软链接:ln -s phoenix-4.0.0-incubating phoenix
4) 将/data/hadoop/phoenix/hadoop-2/phoenix-4.0.0-incubating-client.jar添加到CLASSPATH
5) 将phoenix/common目录下的phoenix-core-4.0.0-incubating.jar复制到所有HBase region server的的CLASSPATH中,比如HBase的lib目录
6) 重启HBase集群

运行phoenix也非常简单,命令格式为:
sqlline.py zookeeper file.sql

示例:
hadoop@VM-40-171-sles10-64:~/phoenix/bin> ./sqlline.py 10.12.154.78
Setting property: [isolation, TRANSACTION_READ_COMMITTED]
issuing: !connect jdbc:phoenix:10.12.154.78 none none org.apache.phoenix.jdbc.PhoenixDriver
Connecting to jdbc:phoenix:10.12.154.78
Connected to: Phoenix (version 4.0)
Driver: org.apache.phoenix.jdbc.PhoenixDriver (version 4.0)
Autocommit status: true
Transaction isolation: TRANSACTION_READ_COMMITTED
Building list of tables and columns for tab-completion (set fastconnect to true to skip)...
53/53 (100%) Done
Done
sqlline version 1.1.2
0: jdbc:phoenix:10.12.154.78>   select * from test;
Error: ERROR 1012 (42M03): Table undefined. tableName=TEST (state=42M03,code=1012)
0: jdbc:phoenix:10.12.154.78> create table test ( a int, b string);
Error: ERROR 601 (42P00): Syntax error. Unsupported sql type: INT (state=42P00,code=601)
0: jdbc:phoenix:10.12.154.78> create table test (a integer, b integer);
Error: ERROR 509 (42888): The table does not have a primary key. tableName=TEST (state=42888,code=509)
0: jdbc:phoenix:10.12.154.78> create table test (a integer primary key, b integer) ;
No rows affected (1.424 seconds)
0: jdbc:phoenix:10.12.154.78> UPSERT INTO TEST VALUES (1, 1);
1 row affected (0.099 seconds)
0: jdbc:phoenix:10.12.154.78> UPSERT INTO TEST VALUES (2, 12);
1 row affected (0.02 seconds)
0: jdbc:phoenix:10.12.154.78> select * from test;
+------------+------------+
|     A      |     B      |
+------------+------------+
| 1          | 1          |
| 2          | 12         |
+------------+------------+
2 rows selected (0.116 seconds)
0: jdbc:phoenix:10.12.154.78>

有关语法请浏览:http://phoenix.incubator.apache.org/language/index.html,有关数据类型请浏览:http://phoenix.incubator.apache.org/language/datatypes.html。

http://aquester.cublog.cn

大数据系列hbase相关文章:

最新评论
超仔2014-09-10 04:25:06
小米刘绍辉:从MySQL迁移到NoSQL的HBase实践 2013年11月22至23日,大数据领域的盛会,2013年Hadoop中国技术峰会在北京召开,来自国内外的技术专家齐聚一堂,来探讨大数据技术 (分享自 @ZOL中关村在线) http://t.cn/Rve4Rio
Leah2014-09-09 04:25:27
我这边下了一半,域名就解析不了了
杨夏陵2014-09-09 02:39:54
百科 耶律齐
韩凌枫2014-09-08 08:21:26
这样划分感觉不科学啊
情殇2014-09-08 05:57:24
等会儿你就可以下载了 群共享
yukangkk2014-09-08 02:37:59
HBase、Hadoop、ZooKeeper、Hive、Akka、JetMQ...
夏天微凉2014-09-07 03:29:55
夏倾心2014-09-07 03:19:28
Oracle unveils big data search software - Oracle's new Big Data SQL software allows users to run joint queries across both SQL databases such as Oracle's flagship 12c, and semi-structured and unstructured data stores such as Hadoop big data framework and NoSQL
anning2014-09-06 06:56:15
发表了博文 《ToolRunner与eclipse hadoop 插件的替代品,简化M/R程序的开发》 - 目前开发的时候测试M/R程序有三种方式 1. 直接打成jar包,然后放到服务器中去执行。此方 http://t.cn/8sUO2Gr
2014-09-05 02:45:09
#大数据时代已来到# Hadoop已成为大数据的代名词,大数据助力企业选择战略方向,制定方案策略,掌握"Hadoop生态系统"起薪1w6每月,上不封顶。想学习的同学可以私信我,课程中有与企业相同真实环境练习实验,数据范例全部来自项目中的真实数据。IT已进入数据变革的时代,抓住机遇掌握未来成为IT精英。
 
  • Hadoop生态系统资料推荐