一、说明
1、环境说明
11、3台服务器(h1、h2、h3)的SSH配置见:Hadoop环境搭建之SSH免密码相互访问
12、hadoop的安装配置见:Hadoop环境搭建之Hadoop安装
2、软件说明
zookeeper:zookeeper-3.3.1.tar.gz , 下载地址:https://yunpan.cn/cS45WHyjTIR2c (提取码:92d4)
hbase:hbase-0.94.12.tar,下载地址:https://yunpan.cn/cS455DsCMYiyV (提取码:fbe6)
二、安装zookeeper
由于hbase需要zookeeper做协同服务,所以得先安装zookeeper
21、将zookeeper-3.3.1.tar.gz在/bdata/中解压,解压后的文件为zookeeper-3.3.1,命令如下:
tar -zxvf zookeeper-3.3.1.tar.gz
22、配置zookeeper
221、切换到zookeeper-3.3.1的conf目录,将zoo_sample.cfg复制为zoo.cfg
cp zoo_sample.cfg zoo.cfg
222、修改zoo.cfg的内容为:
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
dataDir=/bdata/zookeeper-3.3.1/server/data
# the port at which the clients will connect
clientPort=2181
server.1=h1:2888:3888
server.2=h2:2888:3888
server.3=h3:2888:3888
其中h1、h2、h3是三个服务器
223、创建/bdata/zookeeper-3.3.1/server/data目录,并在目录创建myid的文件,h1、h2、h3相应目录下的文件内容依次为1、2、3
23、将配置好的zookeeper-3.3.1发送给h2、h3的/bdata目录下,分别执行以下命令
scp -r /bdata/zookeeper-3.3.1 root@h2:/bdata/
scp -r /bdata/zookeeper-3.3.1 root@h3:/bdata/
24、修改h2、h3 /bdata/zookeeper-3.3.1/server/data/myid的内容为2、3
三、安装Hbase
31、将hbase-0.94.12.tar在/bdata目录下解压,解压后的文件名为hbase-0.94.12,目录如下
tar -zxvf hbase-0.94.12.tar
32、配置文件
321、修改/bdata/hbase-0.94.12/conf/hbase-env.sh,将其内容修改为
#
#/**
# * Copyright 2007 The Apache Software Foundation
# *
# * 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.
# */
# Set environment variables here.
# The java implementation to use. Java 1.6 required.
#export JAVA_HOME=/usr/java/jdk.1.6.0_45
export JAVA_HOME=/usr/java/jdk1.6.0_45
# Extra Java CLASSPATH elements. Optional.
# export HBASE_CLASSPATH=
# The maximum amount of heap to use, in MB. Default is 1000.
# export HBASE_HEAPSIZE=1000
# Extra Java runtime options.
# Below are what we set by default. May only work with SUN JVM.
# For more on why as well as other possible settings,
# see http://wiki.apache.org/hadoop/PerformanceTuning
export HBASE_OPTS="-ea -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode"
# Uncomment below to enable java garbage collection logging.
# export HBASE_OPTS="$HBASE_OPTS -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:$HBASE_HOME/logs/gc-hbase.log"
# Uncomment and adjust to enable JMX exporting
# See jmxremote.password and jmxremote.access in $JRE_HOME/lib/management to configure remote password access.
# More details at: http://java.sun.com/javase/6/docs/technotes/guides/management/agent.html
#
# export HBASE_JMX_BASE="-Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
# export HBASE_MASTER_OPTS="$HBASE_JMX_BASE -Dcom.sun.management.jmxremote.port=10101 -javaagent:lib/HelloWorldAgent.jar"
# export HBASE_REGIONSERVER_OPTS="$HBASE_JMX_BASE -Dcom.sun.management.jmxremote.port=10102"
# export HBASE_THRIFT_OPTS="$HBASE_JMX_BASE -Dcom.sun.management.jmxremote.port=10103"
# export HBASE_ZOOKEEPER_OPTS="$HBASE_JMX_BASE -Dcom.sun.management.jmxremote.port=10104"
# File naming hosts on which HRegionServers will run. $HBASE_HOME/conf/regionservers by default.
# export HBASE_REGIONSERVERS=${HBASE_HOME}/conf/regionservers
# Extra ssh options. Empty by default.
# export HBASE_SSH_OPTS="-o ConnectTimeout=1 -o SendEnv=HBASE_CONF_DIR"
# Where log files are stored. $HBASE_HOME/logs by default.
# export HBASE_LOG_DIR=${HBASE_HOME}/logs
# A string representing this instance of hbase. $USER by default.
# export HBASE_IDENT_STRING=$USER
# The scheduling priority for daemon processes. See 'man nice'.
# export HBASE_NICENESS=10
# The directory where pid files are stored. /tmp by default.
# export HBASE_PID_DIR=/var/hadoop/pids
# Seconds to sleep between slave commands. Unset by default. This
# can be useful in large clusters, where, e.g., slave rsyncs can
# otherwise arrive faster than the master can service them.
# export HBASE_SLAVE_SLEEP=0.1
# Tell HBase whether it should manage it's own instance of Zookeeper or not.
export HBASE_MANAGES_ZK=true
此文件主要配置了jdk的安装路径,以及“HBASE_MANAGES_ZK”是否管理一个zookeeper集群,其值是“true”表示启动hbase的时候,他会去启动zookeeper
322、配置hbase-site.xml,将其内容该为
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>hbase.rootdir</name>
<value>hdfs://h1:9000/hbase</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.master.port</name>
<value>60000</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>h1,h2,h3</value>
</property>
</configuration>
33、将配置好的hbase-0.94.12发送到h2、h3的/bdata/目录下,在h1下分别执行以下命令
scp -r /bdata/hbase-0.94.12 root@h2:/
scp -r /bdata/hbase-0.94.12 root@h3:/
34、启动hbase
在/bdata/hbase-0.94.12/bin目录下执行./start-hbase
cd /bdata/hbase-0.94.12/bin
./start-hbase
4、简单玩玩hbase
如果前边几个步骤执行顺利的话,接下来我们就进入hbase的shell控制台,去hbase进行简单的操作吧
41、进入控制台
cd /bdata/hbase-0.94.12/bin/
./hbase shell
42、创建一张表
创建了表,名称为t_user,列簇为name,other
43、插入两条条数据
行键为liw,在列簇name下边建了列firstname、lastname
44、查看插入的数据