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四、查看插入的数据