在Ubuntu中安装HBase
关于作者:
- 张丹(Conan), 程序员Java,R,PHP,Javascript
- weibo:@Conan_Z
- blog: http://blog.fens.me
- email: bsspirit@gmail.com
转载请注明出处:
http://blog.fens.me/linux-hbase-install/
前言
HBase是Hadoop家族中的一个分布式数据库产品,HBase支持高并发读写,列式数据存储,高效的索引,自动分片,自动Region迁移等许多优点,已经越来越多的被界业认可并实施。
目录
- 在Ubuntu中环境准备
- HBase安装
- Thrift安装
1 在Ubuntu中环境准备
HBase是基于Java开发的运行Hadoop平台上分布式NoSQL数据库软件,HBase没有提供Windows系统安装版本。我在这里也只介绍HBase在Linux Ubuntu系统中的安装。
由于HBase是运行在Hadoop平台上面的,因此我们需要先安装好Hadoop的环境,Hadoop的安装请参考文章:[Hadoop历史版本安装](http://blog.fens.me/hadoop-history-source-install/)
HBase没有提供apt的软件源安装,我们需要自己去官方网络下载HBase软件包进行安装。HBase下载页:http://www.apache.org/dyn/closer.cgi/hbase/
系统环境:
- Linux Ubuntu 12.04.2 LTS 64bit server
- Java JDK 1.6.0_45
- Hadoop 1.1.2
2 HBase安装
2.1 下载HBase
# 通过wget命令下载
~ wget http://www.gaidso.com/apache/hbase/stable/hbase-0.94.18.tar.gz# 解压HBase
~ tar xvf hbase-0.94.18.tar.gz# 移动HBase目录到文件夹
~ mv hbase-0.94.18/ /home/conan/hadoop/# 进入目录
~ cd /home/conan/hadoop/hbase-0.94.18
2.2 配置HBase
2.2.1 修改启动文件hbase-env.sh
~ vi conf/hbase-env.sh#打开注释
export JAVA_HOME=/home/conan/toolkit/jdk16
export HBASE_CLASSPATH=/home/conan/hadoop/hadoop-1.1.2/conf
export HBASE_MANAGES_ZK=true
2.2.2 修改配置文件 hbase-site.xml
~ vi conf/hbase-site.xml<configuration>
<property>
<name>hbase.rootdir</name>
<value>hdfs://master:9000/hbase</value>
</property><property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property><property>
<name>dfs.replication</name>
<value>1</value>
</property><property>
<name>hbase.zookeeper.quorum</name>
<value>master</value>
</property><property>
<name>hbase.zookeeper.property.clientPort</name>
<value>2181</value>
</property><property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/home/conan/hadoop/hdata</value>
</property>
</configuration>
复制hadoop环境的配置文件和类库
~ cp ~/hadoop/hadoop-1.1.2/conf/hdfs-site.xml conf/
~ cp ~/hadoop/hadoop-1.1.2/hadoop-core-1.1.2.jar lib/
~ mkdir /home/conan/hadoop/hdata
2.3 启动hadoop和hbase
~ /home/conan/hadoop/hadoop-1.1.2/bin/start-all.sh
~ /home/conan/hadoop/hbase-0.94.18/bin/start-hbase.sh# 查看hbase进程
~ jps
13838 TaskTracker
13541 JobTracker
15946 HMaster
16756 Jps
12851 NameNode
13450 SecondaryNameNode
13133 DataNode
15817 HQuorumPeer
16283 HRegionServer
2.4 打开HBase命令行客户端访问Hbase
~ bin/hbase shell
HBase Shell; enter 'help' for list of supported commands.
Type "exit" to leave the HBase Shell
Version 0.94.18, r1577788, Sat Mar 15 04:46:47 UTC 2014hbase(main):002:0> help
HBase Shell, version 0.94.18, r1577788, Sat Mar 15 04:46:47 UTC 2014
Type 'help "COMMAND"', (e.g. 'help "get"' -- the quotes are necessary) for help on a specific command.
Commands are grouped. Type 'help "COMMAND_GROUP"', (e.g. 'help "general"') for help on a command group.COMMAND GROUPS:Group name: generalCommands: status, version, whoamiGroup name: ddlCommands: alter, alter_async, alter_status, create, describe, disable, disable_all, drop, drop_all, enable, enable_all, exists, is_disabled, is_enabled, list, show_filtersGroup name: dmlCommands: count, delete, deleteall, get, get_counter, incr, put, scan, truncateGroup name: toolsCommands: assign, balance_switch, balancer, close_region, compact, flush, hlog_roll, major_compact, move, split, unassign, zk_dumpGroup name: replicationCommands: add_peer, disable_peer, enable_peer, list_peers, list_replicated_tables, remove_peer, start_replication, stop_replicationGroup name: snapshotCommands: clone_snapshot, delete_snapshot, list_snapshots, restore_snapshot, snapshotGroup name: securityCommands: grant, revoke, user_permissionSHELL USAGE:
Quote all names in HBase Shell such as table and column names. Commas delimit
command parameters. Type after entering a command to run it.
Dictionaries of configuration used in the creation and alteration of tables are
Ruby Hashes. They look like this:{'key1' => 'value1', 'key2' => 'value2', ...}and are opened and closed with curley-braces. Key/values are delimited by the
'=>' character combination. Usually keys are predefined constants such as
NAME, VERSIONS, COMPRESSION, etc. Constants do not need to be quoted. Type
'Object.constants' to see a (messy) list of all constants in the environment.If you are using binary keys or values and need to enter them in the shell, use
double-quote'd hexadecimal representation. For example:hbase> get 't1', "key\x03\x3f\xcd"hbase> get 't1', "key\003\023\011"hbase> put 't1', "test\xef\xff", 'f1:', "\x01\x33\x40"The HBase shell is the (J)Ruby IRB with the above HBase-specific commands added.
For more on the HBase Shell, see http://hbase.apache.org/docs/current/book.html
2.5 HBase简单命令操作
#创建一个新表student
hbase(main):003:0> create 'student','info'
0 row(s) in 1.2680 seconds#查看所有的表
hbase(main):004:0> list
TABLE
student
1 row(s) in 0.0330 seconds#查看student的表结构
hbase(main):005:0> describe 'student'
DESCRIPTION ENABLED'student', {NAME => 'info', DATA_BLOCK_ENCODING => 'NONE', trueBLOOMFILTER => 'NONE', REPLICATION_SCOPE => '0', VERSIONS=> '3', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => '2147483647', KEEP_DELETED_CELLS => 'false', BLOCKSIZE => '65536', IN_MEMORY => 'false', ENCODE_ON_DISK => 'true',BLOCKCACHE => 'true'}
1 row(s) in 0.1100 seconds#同student表中插入一条数据
hbase(main):007:0> put 'student','mary','info:age','19'
0 row(s) in 0.0490 seconds#从student表中取出mary的数据
hbase(main):008:0> get 'student','mary'
COLUMN CELLinfo:age timestamp=1396366643298, value=19
1 row(s) in 0.0190 seconds#让student表失效
hbase(main):009:0> disable 'student'
0 row(s) in 1.2400 seconds#列出所有表
hbase(main):010:0> list
TABLE
student
1 row(s) in 0.0310 seconds#删除student表
hbase(main):013:0> drop 'student'
0 row(s) in 1.1100 seconds#列出所有表
hbase(main):014:0> list
TABLE
0 row(s) in 0.0400 seconds
3 Thrift安装
安装完成HBase后,我们还需要安装Thrift,因为其他语言调用HBase的时候,是通过Thrift连接的。
Thrift是需要本地编译的,官方没有提供二进制安装包,首先下载thrift-0.9.1,Thrift下载页:http://thrift.apache.org/download
3.1 下载thrift
下载Thrift有两种方式,直接下载源代码发行包,或者通过git下载源代码,请选择其中一种方式下载。
3.1.1 直接下载源代码发行包 thrift-0.9.1.tar.gz
~ wget http://apache.fayea.com/apache-mirror/thrift/0.9.1/thrift-0.9.1.tar.gz
~ tar xvf thrift-0.9.1.tar.gz
~ mv thrift-0.9.1/ /home/conan/hadoop/
~ cd /home/conan/hadoop/
注:后文中的各种错误,都是这个包引起的
3.1.2 通过git下载源代码
~ git clone https://git-wip-us.apache.org/repos/asf/thrift.git thrift-git
~ mv thrift-git/ /home/conan/hadoop/
~ cd /home/conan/hadoop/
为了避免各种出错,建议使用git下载源代码安装
3.2 通过thrift-0.9.1.tar.gz 发行包安装Thrift
Thrift是需要本地编译的,在Thrift解压目录输入./configure,会列Thrift在当前机器所支持的语言环境。
3.2.1 安装Thrift的依赖包
sudo apt-get install libboost-dev libboost-test-dev libboost-program-options-dev libevent-dev automake libtool flex bison pkg-config g++ libssl-dev
如果只是为了连接rhbase,默认配置就可以了。如果除了希望支持rhbase访问,还支持PHP,Python,C++等语言的访问,就需要在系统中,装一些额外的类库。大家可以根据自己的要求,安装对应的软件包并设置Thrift的编译参数。
生成配置脚本
~ ./configure//省略部分日志输出thrift 0.9.1Building C++ Library ......... : yes
Building C (GLib) Library .... : no
Building Java Library ........ : yes
Building C# Library .......... : no
Building Python Library ...... : yes
Building Ruby Library ........ : no
Building Haskell Library ..... : no
Building Perl Library ........ : no
Building PHP Library ......... : no
Building Erlang Library ...... : no
Building Go Library .......... : no
Building D Library ........... : noC++ Library:Build TZlibTransport ...... : yesBuild TNonblockingServer .. : yesBuild TQTcpServer (Qt) .... : noJava Library:Using javac ............... : javacUsing java ................ : javaUsing ant ................. : /home/conan/toolkit/ant184/bin/antPython Library:Using Python .............. : /usr/bin/pythonIf something is missing that you think should be present,
please skim the output of configure to find the missing
component. Details are present in config.log.
我本机的已支持C++, Java与Thrift的通信。
3.2.2 增加Python语言的通信
虽然Python已被显示支持与Thrift但在后面编译过程中,还是缺少一些Python的库,我们需要再增加Python的依赖库
安装Python的依赖包
sudo apt-get install python-all python-all-dev python-all-dbg
3.2.3 增加PHP语言的通信
安装PHP的依赖包
sudo apt-get install php5-dev php5-cli phpunit
生成配置脚本
~ ./configure --enable-thrift_protocol//省略部分日志输出thrift 0.9.1Building C++ Library ......... : yes
Building C (GLib) Library .... : no
Building Java Library ........ : yes
Building C# Library .......... : no
Building Python Library ...... : yes
Building Ruby Library ........ : no
Building Haskell Library ..... : no
Building Perl Library ........ : no
Building PHP Library ......... : yes
Building Erlang Library ...... : no
Building Go Library .......... : no
Building D Library ........... : noC++ Library:Build TZlibTransport ...... : yesBuild TNonblockingServer .. : yesBuild TQTcpServer (Qt) .... : noJava Library:Using javac ............... : javacUsing java ................ : javaUsing ant ................. : /home/conan/toolkit/ant184/bin/antPython Library:Using Python .............. : /usr/bin/pythonPHP Library:Using php-config .......... : /usr/bin/php-configIf something is missing that you think should be present,
please skim the output of configure to find the missing
component. Details are present in config.log.
我们看到Thrift的配置中,增加了对PHP语言的支持。
3.2.4 编译和安装
# 编译Thrift
~ make//省略部分日志make[5]: 正在进入目录 `/home/conan/hadoop/thrift-0.9.1/lib/php/src/ext/thrift_protocol'
make[5]: *** 没有指明目标并且找不到 makefile。 停止。
make[5]:正在离开目录 `/home/conan/hadoop/thrift-0.9.1/lib/php/src/ext/thrift_protocol'
make[4]: *** [src/ext/thrift_protocol/modules/thrift_protocol.so] 错误 2
make[4]:正在离开目录 `/home/conan/hadoop/thrift-0.9.1/lib/php'
make[3]: *** [all-recursive] 错误 1
make[3]:正在离开目录 `/home/conan/hadoop/thrift-0.9.1/lib/php'
make[2]: *** [all-recursive] 错误 1
make[2]:正在离开目录 `/home/conan/hadoop/thrift-0.9.1/lib'
make[1]: *** [all-recursive] 错误 1
make[1]:正在离开目录 `/home/conan/hadoop/thrift-0.9.1'
make: *** [all] 错误 2
在make生成过程,出现PHP的编译错误。从Thrift的错误列表中,我们可以找到错误描述( https://issues.apache.org/jira/browse/THRIFT-2265 ),这是由于Thrift-0.9.1发行包,打包时缺少了PHP扩展文件造成的错误,并在Thrift-0.9.2版本中修复。
所以,我们如果还想继续使用Thrift-0.9.1版本,则不能支持PHP语言。
# 生成配置信息,不包括PHP模块
~ ./configure --without-php_extension# 编译Thrift
~ make
编译过程中,又出现了C++编译错误。
Makefile:832: 警告:覆盖关于目标“gen-cpp/ThriftTest.cpp”的命令
Makefile:829: 警告:忽略关于目标“gen-cpp/ThriftTest.cpp”的旧命令
/bin/bash ../../libtool --tag=CXX --mode=link g++ -Wall -g -O2 -L/usr/lib -o libtestgencpp.la ThriftTest_constants.lo ThriftTest_types.lo ../../lib/cpp/libthrift.la -lssl -lcrypto -lrt -lpthread
libtool: link: ar cru .libs/libtestgencpp.a .libs/ThriftTest_constants.o .libs/ThriftTest_types.o
ar: .libs/ThriftTest_constants.o: No such file or directory
make[3]: *** [libtestgencpp.la] 错误 1
make[3]:正在离开目录 `/home/conan/hadoop/thrift-0.9.1/test/cpp'
make[2]: *** [all-recursive] 错误 1
make[2]:正在离开目录 `/home/conan/hadoop/thrift-0.9.1/test'
make[1]: *** [all-recursive] 错误 1
make[1]:正在离开目录 `/home/conan/hadoop/thrift-0.9.1'
make: *** [all] 错误 2
对于上面的2个编译错误,我决定换成git源代码的版本重新操作。
3.2 通过git源代码安装Thrift
运行安装命令
# 进行thrift-git目录
~ cd /home/conan/hadoop/thrift-git# 复制0.9.1标签到新分支thrift-0.9.1
~ git checkout -b thrift-0.9.1 0.9.1# 产生配置脚本
~ ./bootstrap.sh# 生成配置信息
~ ./configure# 编译Thrift
~ make# 安装Thrift
~ sudo make install
走了许多弯路,终于使用git源代码版本安装好了Thrift。
查看thrift版本
~ thrift -version
Thrift version 0.9.1
接下来,我们启动HBase的Thrift Server服务
# 启动HBase的Thrift服务
~ /home/conan/hadoop/hbase-0.94.18/bin/hbase-daemon.sh start thrift
starting thrift, logging to /home/conan/hadoop/hbase-0.94.18/bin/../logs/hbase-conan-thrift-master.out# 检查系统进程
~ jps
13838 TaskTracker
13541 JobTracker
15946 HMaster
32120 Jps
12851 NameNode
13450 SecondaryNameNode
13133 DataNode
32001 ThriftServer
15817 HQuorumPeer
16283 HRegionServer
我们看到ThriftServer已被启动,后面我们就可以使用多种语言,通过Thrift来访问HBase了,这样就完成了HBase的安装。
转载请注明出处:
http://blog.fens.me/linux-hbase-install/
在Ubuntu中安装HBase相关推荐
- Ubuntu中安装docker-compose
安装最新Docker社区版请看博客<Ubuntu中安装最新Docker社区版> Compose是用于定义和运行多容器Docker应用程序的工具.通过Compose,我们可以使用YAML文件 ...
- abp 打包部署到ubuntu_如何在Ubuntu中安装Docker和运行 Docker容器
Docker是一种开源且流行的操作系统级虚拟化(俗称"容器化")技术,主要在Linux和Windows上运行. Docker使用容器可以更轻松地创建,部署和运行应用程序. 使用容器 ...
- ubuntu安装matlab2009,Ubuntu中安装Matlab2010a
Ubuntu中安装Matlab2010a 一.前言: 相信大家对于Matlab应该很熟悉吧,我就不多做介绍了. 对于如何在Ubuntu中安装Matlab很多人都不懂,大家都是新手,可以理解.我自己本身 ...
- unbantu上python安装步骤_如何在Ubuntu中安装Python 3.6?
Python是增长最快的主要通用编程语言.原因有很多,比如它的可读性和灵活性,易于学习和使用,可靠和高效. 有两个主要的Python版本被使用- 2和3 (Python的现在和未来);前者将看不到新的 ...
- Ubuntu中安装Eclipse的SVN插件——subclipse
Ubuntu中安装Eclipse的SVN插件--subclipse (2010-07-01 18:38) 分类: Linux 安装好Eclipse以后 进入菜单Help->Install new ...
- samba服务器新建文件权限,Ubuntu中安装samba服务器创建文件共享的方法及普通用户设置共享的问题解析...
Ubuntu中安装samba服务器创建文件共享的方法及普通用户设置共享的问题解析 发布时间:2011-01-04 19:10:00 作者:佚名 我要评论 本文是基于ubuntu桌面版进行操作说 ...
- labview linux 内核 不匹配,Linux CentOS7(或Ubuntu)中安装NI-VISA后一打开范例Simple Serial.vi就闪退,LabVIEW就崩溃。...
Linux CentOS7(或Ubuntu)中安装NI-VISA后一打开范例Simple Serial.vi就闪退,LabVIEW就崩溃. 我安装了LabVIEW pro 2017 for Linux ...
- 在Ubuntu中安装MySQL (转载)
MySQL在Linux Ubuntu中安装 本文使用的Linux是Ubuntu 12.04.2 LTS 64bit的系统,安装MySQL数据库软件包可以通过apt-get实现. 在Linux Ubun ...
- Ubuntu: Ubuntu中安装使用Source Inside 3.5
Ubuntu: Ubuntu中安装使用Source Inside 3.5 1. 安装wine $ sudo apt-get install wine 2. 安装Source Inside 3.5 $ ...
最新文章
- 算法笔记 --- 记忆搜索算法 --- 动态规划算法
- 终于成功地在Pluto中部署了一个Portlet了
- 算法入门篇三 详解桶排序和整理排序知识 堆的相关操作 补充 不完整
- 苹果iOS 16将改进通知 添加新的健康追踪功能
- 前方 Bug 出没?盘他!
- 基于Qt的抽奖小程序
- 嘉立创PCB CAM软件
- 激活navicat12
- 流程图连接线生成算法
- Kafka报错:Couldn't find leaders for Set
- 【好奇心驱动力】APP每日打卡自动化测试
- Thingworx- 创建一个事物
- 2016年,续航新能量
- 腾讯物联网云平台 密钥 MQTT参数生成及密码加密算法实现
- 动态链接(地址无关技术)
- 代理arp 无故arp 反向arp
- 2058 笨拙的手指
- 颜值绝绝子的 14 款 Chrome 官方主题 !
- Go和Golang的安装
- 储能之动力电池与储能电池区别?
热门文章
- 高盛发布区块链报告:从理论到实践(中文版)
- Philip S. Yu 讲的广度学习到底是什么?
- 为什么大型科技公司更会发生人员流失 标准 ceo 软件 技术 图 阅读2479 原文:Why Good People Leave Large Tech Companies 作者:steve
- 移动应用开发必备工具盘点
- 算法与数据结构(Java解八皇后问题)
- 实战SSM_O2O商铺_34【商品】商品编辑之Controller层的实现
- 11.10错题集(7-函数)
- 职业中专的计算机综合应用,职业中专计算机教学的思考
- 日期格式php用点隔离,PHP学习之校验日期格式合法性?(使用strtotime()和date())...
- 为什么在进程中还需要线程呢?