1、說明html
一、環境說明java
十一、3臺服務器(h一、h二、h3)的SSH配置見:Hadoop環境搭建之SSH免密碼相互訪問shell
十二、hadoop的安裝配置見:Hadoop環境搭建之Hadoop安裝express
二、軟件說明apache
zookeeper:zookeeper-3.3.1.tar.gz , 下載地址:https://yunpan.cn/cS45WHyjTIR2c (提取碼:92d4)服務器
hbase:hbase-0.94.12.tar,下載地址:https://yunpan.cn/cS455DsCMYiyV (提取碼:fbe6)app
2、安裝zookeeperless
因爲hbase須要zookeeper作協同服務,因此得先安裝zookeeperssh
2一、將zookeeper-3.3.1.tar.gz在/bdata/中解壓,解壓後的文件爲zookeeper-3.3.1,命令以下:ide
tar -zxvf zookeeper-3.3.1.tar.gz
2二、配置zookeeper
22一、切換到zookeeper-3.3.1的conf目錄,將zoo_sample.cfg複製爲zoo.cfg
cp zoo_sample.cfg zoo.cfg
22二、修改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
其中h一、h二、h3是三個服務器
22三、建立/bdata/zookeeper-3.3.1/server/data目錄,並在目錄建立myid的文件,h一、h二、h3相應目錄下的文件內容依次爲一、二、3
2三、將配置好的zookeeper-3.3.1發送給h二、h3的/bdata目錄下,分別執行如下命令
scp -r /bdata/zookeeper-3.3.1 root@h2:/bdata/
scp -r /bdata/zookeeper-3.3.1 root@h3:/bdata/
2四、修改h二、h3 /bdata/zookeeper-3.3.1/server/data/myid的內容爲二、3
3、安裝Hbase
3一、將hbase-0.94.12.tar在/bdata目錄下解壓,解壓後的文件名爲hbase-0.94.12,目錄以下
tar -zxvf hbase-0.94.12.tar
3二、配置文件
32一、修改/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
32二、配置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>
3三、將配置好的hbase-0.94.12發送到h二、h3的/bdata/目錄下,在h1下分別執行如下命令
scp -r /bdata/hbase-0.94.12 root@h2:/
scp -r /bdata/hbase-0.94.12 root@h3:/
3四、啓動hbase
在/bdata/hbase-0.94.12/bin目錄下執行./start-hbase
cd /bdata/hbase-0.94.12/bin
./start-hbase
四、簡單玩玩hbase
若是前邊幾個步驟執行順利的話,接下來咱們就進入hbase的shell控制檯,去hbase進行簡單的操做吧
4一、進入控制檯
cd /bdata/hbase-0.94.12/bin/ ./hbase shell
4二、建立一張表
建立了表,名稱爲t_user,列簇爲name,other
4三、插入兩條條數據
行鍵爲liw,在列簇name下邊建了列firstname、lastname
4四、查看插入的數據