hbase是分布式的,面向列(族)的数据库, 很常用, 网上介绍一大堆。本文说说在linux环境中安装hbase. 一般来说,都是需要先安装hadoop, 再安装hbase. 但是, 为了简便起见, 也可以先不管hadoop, 先聚焦于hbase, 照样可以玩hbase.
0. 老生常谈安装jdk, 路径为:
/usr/lib/jvm/java-8-openjdk-amd64
1. 下载hbase-1.2.3-bin.tar.gz并解压
ubuntu@VM-0-15-ubuntu:~/taoge/hbase_db$ pwd
/home/ubuntu/taoge/hbase_db
ubuntu@VM-0-15-ubuntu:~/taoge/hbase_db$ ls
hbase-1.2.3 hbase-1.2.3-bin.tar.gz
2. 按如下方式设置JAVA_HOME
ubuntu@VM-0-15-ubuntu:~/taoge/hbase_db/hbase-1.2.3$ cat conf/hbase-env.sh | grep JAVA_HOME
# export JAVA_HOME=/usr/java/jdk1.6.0/
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64
ubuntu@VM-0-15-ubuntu:~/taoge/hbase_db/hbase-1.2.3$
然后source一下,使之生效:
ubuntu@VM-0-15-ubuntu:~/taoge/hbase_db/hbase-1.2.3$ source conf/hbase-env.sh
ubuntu@VM-0-15-ubuntu:~/taoge/hbase_db/hbase-1.2.3$
3.修改配置文件,如下
ubuntu@VM-0-15-ubuntu:~/taoge/hbase_db/hbase-1.2.3$ cat conf/hbase-site.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
/**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<configuration>
<property>
<name>hbase.rootdir</name>
<value>file:/home/ubuntu/taoge/hbase_db</value>
</property>
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/home/ubuntu/taoge/hbase_db</value>
</property>
</configuration>
ubuntu@VM-0-15-ubuntu:~/taoge/hbase_db/hbase-1.2.3$
其中configuration中是新增内容, 改后保存。
4. 改PATH, 如下:
ubuntu@VM-0-15-ubuntu:~/taoge/hbase_db/hbase-1.2.3$ tail ~/.bashrc
. /etc/bash_completion
fi
fi
export HBASE_HOME=/home/ubuntu/taoge/hbase_db/hbase-1.2.3
export HBASE_CONF_DIR=$HBASE_HOME/conf
export BASE_CLASS_PATH=$HBASE_CONF_DIR
export PATH=$PATH:$HBASE_HOME/bin
ubuntu@VM-0-15-ubuntu:~/taoge/hbase_db/hbase-1.2.3$
最后的4个export就是新增的内容。 改完后保存,然后souce一下:
ubuntu@VM-0-15-ubuntu:~/taoge/hbase_db/hbase-1.2.3$ source ~/.bashrc
ubuntu@VM-0-15-ubuntu:~/taoge/hbase_db/hbase-1.2.3$
可以看到,安装成功:
ubuntu@VM-0-15-ubuntu:~/taoge/hbase_db/hbase-1.2.3$ hbase version
HBase 1.2.3
Source code repository git://kalashnikov.att.net/Users/stack/checkouts/hbase.git.commit revision=bd63744624a26dc3350137b564fe746df7a721a4
Compiled by stack on Mon Aug 29 15:13:42 PDT 2016
From source with checksum 0ca49367ef6c3a680888bbc4f1485d18
ubuntu@VM-0-15-ubuntu:~/taoge/hbase_db/hbase-1.2.3$
安装完毕, 后面在继续介绍hbase的启动和使用。