林炳文Evankaka原创作品。转载请注明出处http://blog.csdn.net/evankaka
摘要:本文主要讲了如何进行Zookeeper和HBabse的安装.
安装hbase时,要先安装好hadoop和zookeeper(这个可以不装)。本文讲了如何使用安装hbase1.2.1在ubuntu14.04上,以及如何配置和自己安装的zookeeper一起使用。
一、安装hadoop2.7.2
详情看笔者另一博文
二、安装zookeeper3.4.8
1、首先肯定是从官网下载相应的tar包,并解压
网址:http://www.apache.org/dyn/closer.cgi/zookeeper/
解压:tar -zxvf zookeeper-3.4.8.tar.gz
2、添加环境变量
gedit ~/.bashrc在最后添加
#zookeeper start export ZOOKEEPER_HOME=/usr/zookeeper/zookeeper-3.4.8 export PATH=$PATH:$ZOOKEEPER_HOME/bin #zookeeper end环境变量生效
source ~/.bashrc3、修改配置文件
cd zookeeper-3.4.8/conf ,将zoo_sample.cfg复制为zoo.cfg,并修改zoo.cfg的内容如下: cp ./zoo_sample.cfg ./zoo.cfg
mkdir /usr/zookeeper/zookeeper-3.4.8/zkdata mkdir /usr/zookeeper/zookeeper-3.4.8/zkdatalog打开 zoo.cfg
dataDir=/usr/zookeeper/zookeeper-3.4.8/zkdata dataLogDir=/usr/zookeeper/zookeeper-3.4.8/zkdatalog在这里需要注意zoo.cfg的配置文件中的dataDir和dataLogDir的路径当中的文件夹必须要已存在,否则后面启动zkServer服务的时候会失败。
/usr/zookeeper/zookeeper-3.4.8/bin/zkServer.sh start6. 检查是否启动成功:
root@lin-virtual-machine:/usr/zookeeper/zookeeper-3.4.8/conf# jps
cd /usr/hbase/hbase-1.2.1/
1.下载安装包hbase-1.2.1-bin.tar.gz放置于/usr/hbase/
下载地址http://apache.fayea.com/hbase/1.2.1/。注意要下载带有bin的压缩包
tar -zxvf hbase-1.2.1-bin.tar.gz
gedit ~/.bashrc添加
#HBase start export HBASE_HOME=/usr/hbase/hbase-1.2.1 export PATH=$PATH:$HBASE_HOME/bin #HBase end使之生效:
source ~/.bashrc4、配置相关的文件
gedit hbase-env.sh export JAVA_HOME=/usr/java/jdk/jdk1.8.0_65 #Java安装路径 export HBASE_CLASSPATH=/usr/hbase/hbase-1.2.1/conf #HBase类路径 export HBASE_MANAGES_ZK=false #由HBase负责启动和关闭Zookeeper
注意下面的hbase.rootdir要和hadoop中core-site.xml中的fs.defaultFS配置一样的IP和端口
<?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>hdfs://linmaster:9000/hbase</value> </property> <property> <name>hbase.cluster.distributed</name> <value>true</value> </property> <property> <name>hbase.master</name> <value>linmaster</value> </property> <property> <name>hbase.zookeeper.property.clientPort</name> <value>2181</value> </property> <property> <name>hbase.zookeeper.quorum</name> <value>linmaster</value> </property> <property> <name>hbase.tmp.dir</name> <value>/usr/hbase/hbase-1.2.1/tmp</value> </property> <property> <name>hbase.zookeeper.property.dataDir</name> <value>/usr/local/zookeeper-3.4.6/data</value> </property> </configuration>其中linmaster对应IP,在 /etc/hosts配置对应关系 5、启动hbase
先启动hadoop,然后启动zookeeper,最后再启动hbase
cd /usr/hbase/hbase-1.2.1/bin
start-hbse.sh
4、启动hbase shell
cd /usr/hbase/hbase-1.2.1/bin. /hbase shell
创建一个member表
create 'member','member_id','address','info'
显示表内容:
list