hbase单节点搭建(ubuntu12.04)

一,环境:

ubuntu12.04-i386 虚拟机

jdk版本:jdk-6u27-linux-i586.bin     http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase6-419409.html#jdk-6u27-oth-JPR

hbase版本:hbase-0.90.3   http://download.csdn.net/detail/b854053514/4733450

二,搭建步骤:

1,jdk环境配置

chmod u+x jdk-6u31-linux-x64.bin
sh ./jdk-6u31-linux-x64.bin

编辑/etc/profile

export JAVA_HOME=/usr/java/jdk1.6.0_27
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar


2,Hbase配置

我的安装目录是/root/

解压,并创建tmp&data文件夹

tar –zxvf  hbase-0.90.3.tar.gz
mkdir /root/hbase-0.90.3/tmp
mkdir /root/hbase-0.90.3/data

配置/root/hbase-0.90.3/conf下的两个文件 

(1)hbase-env.sh 

export JAVA_HOME=/usr/java/jdk1.6.0_27/

(2)hbase-site.xml 

<property>
<name>hbase.rootdir</name>
<value>/root/hbase-0.93.0/data</value>
<description>local dir
</description>
</property>


到这里,配置就完成了,当然了,即使你照着做,肯定还是会遇到问题的,lz遇到了以下问题。

三,启动和各种问题
在安装hbase目录下的bin目录下有hbase守护启动停止之类的脚本,有兴趣就仔细看看,没兴趣会用就行了。

start-hbase.sh,这里lz还需要输入密码,因为一开始贪图搭建快,没有配ssh免密钥登录,这部分我会写在五里。

root@ubuntu-virtual-machine:~/hbase-0.90.3/bin# sh ./start-hbase.sh
./start-hbase.sh: 44: [: false: unexpected operator
localhost: Warning: Permanently added the ECDSA host key for IP address '10.109.254.103' to the list of known hosts.
root@localhost's password:
localhost: starting zookeeper, logging to /root/hbase-0.90.3/bin/../logs/hbase-root-zookeeper-ubuntu-virtual-machine.out
starting master, logging to /root/hbase-0.90.3/bin/../logs/hbase-root-master-ubuntu-virtual-machine.out
root@localhost's password:
localhost: starting regionserver, logging to /root/hbase-0.90.3/bin/../logs/hbase-root-regionserver-ubuntu-virtual-machine.out

开始用hbase shell

root@ubuntu-virtual-machine:~/hbase-0.90.3/bin# ./hbase shell
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 0.90.3, r1100350, Sat May  7 13:31:12 PDT 2011

hbase(main):001:0> create 'class','student','teacher'

大部分搭建文档到这就完了吧……但是lz比较呆,lz遇到了以下问题(基本根据遇到的顺序)

1,The markup in the document following the root element must be well-formed.

这个就是xml格式不对的报错,所以去查hbase-site.xml
发现当时图快,没有把<
property>的属性放到<config>里,所以hbase就不认识了,改过来,这个报错就没有了。

2,zookeeper.ZKConfig: no valid quorum servers found in zoo.cfg ERROR: org.apache.hadoop.hbase.ZooKeeperConnectionException: An error is preventing HBase from connecting to ZooKeeper

第二个报错,一开始我以为可能是zookeeper需要单装,后来看到了zookeep在hbase-dameons守护进程里写到了。

解决方法,在/root/.bashrc里面添加

export HBASE_CONF_DIR=/root/hbase-0.90.3/conf

3,ERROR: org.apache.hadoop.hbase.NotAllMetaRegionsOnlineException: org.apache.hadoop.hbase.NotAllMetaRegionsOnlineException: Timed out (10000ms)

解决方法:编辑/etc/hosts

10.109.254.103	localhost
10.109.254.103	ubuntu-virtual-machine

//127.0.0.1	localhost
//127.0.1.1	ubuntu-virtual-machine

以上都是执行create那步遇到的问题

四,建表测试

创建有2个列族的表

hbase(main):001:0> create 'class','student','teacher'
0 row(s) in 0.8570 seconds

添加数据

hbase(main):002:0> put 'class','one','student:A','80'
0 row(s) in 0.1300 seconds

hbase(main):003:0> put 'class','one','teacher:','zhang'
0 row(s) in 0.0140 seconds

hbase(main):004:0> put 'class','two','teacher:','liu'
0 row(s) in 0.0090 seconds

hbase(main):007:0* put 'class','two','student:D','90'
0 row(s) in 0.0090 seconds

查看

hbase(main):008:0> list
TABLE
class
1 row(s) in 0.0270 seconds
hbase(main):009:0> get 'class','one'
COLUMN                CELL
 student:A            timestamp=1379321608887, value=80
 teacher:             timestamp=1379321637842, value=zhang
2 row(s) in 0.0290 seconds


剩下就可以本机eclipse来写相关代码了,后续可以mapreduce来做分析

忘记写五了。。。

五,ssh免密钥登录

看自己的机器有木有安装,一般都是安装了的,木有就install ssh一下

then

ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
Generating public/private dsa key pair.
Your identification has been saved in /root/.ssh/id_dsa.
Your public key has been saved in /root/.ssh/id_dsa.pub.
The key fingerprint is:
e3:8b:66:b7:11:68:d9:98:66:c3:50:a8:03:cb:ce:3e root@ubuntu-virtual-machine
The key's randomart image is:
+--[ DSA 1024]----+
|     ..          |
|.   ..           |
|.o ..            |
|..o  o *         |
|o  .  @ S        |
| o   + o o       |
|.       o        |
| E    o..o       |
|  .  o..o.       |
+-----------------+

root@ubuntu-virtual-machine:~/hbase-0.90.3/bin# cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
最后测试一下

root@ubuntu-virtual-machine:~/hbase-0.90.3/bin# ssh localhost
Welcome to Ubuntu 12.04.2 LTS (GNU/Linux 3.5.0-23-generic i686)

 * Documentation:  https://help.ubuntu.com/

346 packages can be updated.
144 updates are security updates.

Last login: Mon Sep 16 16:49:08 2013 from 10.108.165.216
root@ubuntu-virtual-machine:~#

Done,再次start,无需输入密码

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值