当前位置: 代码迷 >> 综合 >> Hbase1.3.x单机版安装
  详细解决方案

Hbase1.3.x单机版安装

热度:49   发布时间:2024-01-16 11:37:01.0

 

    1. Hbase1.x单机版安装

参考文档:

http://blog.csdn.net/it_taojingzhan/article/details/51789739

http://blog.csdn.net/blackenn/article/details/52234420

http://blog.csdn.net/wtq1993/article/details/53088968

Hbase版本http://apache.fayea.com/hbase/

http://archive.apache.org/dist/hbase/1.1.5/hbase-1.1.5-bin.tar.gz

 

 

      1. 解压缩到/usr/local目录

[root@localhost65 download]# tar -zxf hbase-1.1.5-bin.tar.gz -C /usr/local/

[root@localhost65 download]#

[root@localhost65 download]# cd /usr/local/

[root@localhost65 local]# ls

apache-hive-1.2.2-bin              bin           hbase        jdk1.8.0_65  sbin                              vmware-tools-distrib

apache-hive-2.1.1-bin              etc           hbase-1.1.5  lib          share                             zookeeper-3.4.6

apache-kylin-1.5.0-HBase1.1.3-bin  games         hbase-1.3.1  lib64        src

apache-kylin-1.6.0-bin             hadoop-2.6.2  include      libexec      VMwareTools-9.6.1-1378637.tar.gz

[root@localhost65 local]#

 

      1. 设置环境变量

[root@localhost65 local]# vim /etc/profile

export HBASE_HOME=/usr/local/hbase-1.1.5

export HBASE_CONF_DIR=$HBASE_HOME/conf

export PATH=$HBASE_HOME/bin:$PATH

[root@localhost65 local]#

 

 

      1. 修改hbase-env.sh配置文件

[root@localhost65 ~]# cd /usr/local/

[root@localhost65 local]# ls

apache-hive-1.2.2-bin              bin           hbase        jdk1.8.0_65  sbin                              vmware-tools-distrib

apache-hive-2.1.1-bin              etc           hbase-1.1.5  lib          share                             zookeeper-3.4.6

apache-kylin-1.5.0-HBase1.1.3-bin  games         hbase-1.3.1  lib64        src

apache-kylin-1.6.0-bin             hadoop-2.6.2  include      libexec      VMwareTools-9.6.1-1378637.tar.gz

[root@localhost65 local]# cd hbase

hbase/       hbase-1.1.5/ hbase-1.3.1/

[root@localhost65 local]# cd hbase-1.1.5/

[root@localhost65 hbase-1.1.5]# ls

bin  CHANGES.txt  conf  docs  hbase-webapps  LEGAL  lib  LICENSE.txt  logs  NOTICE.txt  README.txt

[root@localhost65 hbase-1.1.5]# cd conf/

[root@localhost65 conf]# ls

hadoop-metrics2-hbase.properties  hbase-env.cmd  hbase-env.sh  hbase-policy.xml  hbase-site.xml  log4j.properties  regionservers

 

修改hbase-env.sh

[root@localhost65 conf]# vim hbase-env.sh

#添加一下内容:

# The java implementation to use.  Java 1.7+ required.

export JAVA_HOME=/usr/local/jdk1.8.0_65

 

# Extra Java CLASSPATH elements.  Optional.

#设置到Hadoop的etc/hadoop目录是用来引导Hbase找到Hadoop,即hbase和hadoop进行关联

export HBASE_CLASSPATH=/usr/local/hadoop-2.6.2/etc/Hadoop  #使用hadoop配置文件,此处如果不配置hadoop_conf目录,则需要将hadoop配置文件(hdfs-site.xml)复制到hbase_conf目录中。

export HBASE_MANAGES_ZK=false #默认为true,使用自带的zookeeper,如果设置为false,需要自己配置zookeeper.

[root@localhost65 conf]#

 

 

      1. 修改hbase-site.xml配置文件

[root@localhost65 conf]#

[root@localhost65 conf]# vim 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

 * 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>

        <!--hbase.rootdir的前端与$HADOOP_HOME/conf/core-site.xml的fs.defaultFS一致 -->

        <property>

                <name>hbase.rootdir</name>

                <value>hdfs://192.168.3.65:9000/hbase</value>

        </property>

        <property>

                <name>hbase.cluster.distributed</name>

                <value>true</value>

        </property>

 

<!--本地文件系统的临时文件夹。可以修改到一个更为持久的目录上。(默认/tmp会在重启时清除) -->

        <property>

                <name>hbase.tmp.dir</name>

                <value>/home/hbase/tmp</value>

        </property>

 

<!--如果只设置单个 Hmaster,那么 hbase.master 属性参数需要设置为 master5:60000 (主机名:60000) -->

<!--如果要设置多个 Hmaster,那么我们只需要提供端口 60000,因为选择真正的 master 的事情会有 zookeeper 去处理 -->

        <property>

                <name>hbase.master</name>

                <value>60000</value>

        </property>

 

<!--这个参数用户设置 ZooKeeper 快照的存储位置,默认值为 /tmp,显然在重启的时候会清空。因为笔者的 ZooKeeper 是独立安装的,所以这里路径是指向了 $ZOOKEEPER_HOME/conf/zoo.cfg 中 dataDir 所设定的位置 -->

        <property>

                <name>hbase.zookeeper.property.dataDir</name>

                <value>/home/zookeeper/data</value>

        </property>

<!--客户端连接 ZooKeeper服务地址,这里有几个集群zookeeper就配置几个,多个以逗号分隔,zookeeper集群最好是奇数个,由于zookeeper的选举机>制是过半原则,偶数集群选举时间比较长 -->

        <property>

                <name>hbase.zookeeper.quorum</name>

                <value>localhost65</value>

        </property>

<!--表示客户端连接 ZooKeeper 的端口 -->

        <property>

                <name>hbase.zookeeper.property.clientPort</name>

                <value>2181</value>

        </property>

<!--ZooKeeper 会话超时。Hbase 把这个值传递改 zk 集群,向它推荐一个会话的最大超时时间 -->

        <property>

                <name>zookeeper.session.timeout</name>

                <value>120000</value>

        </property>

 

<!--当 regionserver 遇到 ZooKeeper session expired , regionserver 将选择 restart 而不是 abort -->

        <property>

                <name>hbase.regionserver.restart.on.zk.expire</name>

                <value>true</value>

        </property>

</configuration>

 

 

      1. 修改regionservers文件

编辑所有机器的HBase的HMasters和HRegionServers。修改/conf 文件夹下的regionservers文件。添加DataNode的IP即可。

[root@localhost65 conf]#

[root@localhost65 conf]# vim regionservers

localhost65  #本机域名,由于本次是单机版,配置自己服务器。

[root@localhost65 conf]#

 

 

      1. 启动hbase服务

[root@localhost65 bin]# pwd

/usr/local/hbase-1.1.5/bin

[root@localhost65 bin]# ls

draining_servers.rb   hbase.cmd         hbase-daemons.sh        master-backup.sh  rolling-restart.sh        stop-hbase.sh

get-active-master.rb  hbase-common.sh   hbase-jruby             region_mover.rb   shutdown_regionserver.rb  test

graceful_stop.sh      hbase-config.cmd  hirb.rb                 regionservers.sh  start-hbase.cmd           thread-pool.rb

hbase                 hbase-config.sh   local-master-backup.sh  region_status.rb  start-hbase.sh            zookeepers.sh

hbase-cleanup.sh      hbase-daemon.sh   local-regionservers.sh  replication       stop-hbase.cmd

[root@localhost65 bin]#

[root@localhost65 bin]# start-hbase.sh

starting master, logging to /usr/local/hbase-1.1.5/logs/hbase-root-master-localhost65.out

Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0

Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0

localhost65: starting regionserver, logging to /usr/local/hbase-1.1.5/bin/../logs/hbase-root-regionserver-localhost65.out

localhost65: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0

localhost65: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0

[root@localhost65 bin]#

 

 

      1. 查看hbase服务是否已经启动

[root@localhost65 bin]# jps

24272 SecondaryNameNode

5219 Main

24534 NodeManager

24439 ResourceManager

24152 DataNode

25400 HMaster  #表示hbase已经启动成功

17960 RunJar

12841 RunJar

25867 Jps

25516 HRegionServer

4335 QuorumPeerMain

24063 NameNode

[root@localhost65 bin]#

 

 

 

      1. 登录zookeeper查看hbase

[root@localhost65 local]# cd zookeeper-3.4.6/

[root@localhost65 zookeeper-3.4.6]# ls

bin          conf        docs             lib          README_packaging.txt  src                      zookeeper-3.4.6.jar.md5

build.xml    contrib     ivysettings.xml  LICENSE.txt  README.txt            zookeeper-3.4.6.jar      zookeeper-3.4.6.jar.sha1

CHANGES.txt  dist-maven  ivy.xml          NOTICE.txt   recipes               zookeeper-3.4.6.jar.asc

[root@localhost65 zookeeper-3.4.6]# bin/zk

zkCleanup.sh  zkCli.cmd     zkCli.sh      zkEnv.cmd     zkEnv.sh      zkServer.cmd  zkServer.sh  

[root@localhost65 zookeeper-3.4.6]# bin/zkCli.sh

Connecting to localhost:2181

2017-08-25 16:11:38,751 [myid:] - INFO  [main:Environment@100] - Client environment:zookeeper.version=3.4.6-1569965, built on 02/20/2014 09:09 GMT

2017-08-25 16:11:38,757 [myid:] - INFO  [main:Environment@100] - Client environment:host.name=localhost65

2017-08-25 16:11:38,757 [myid:] - INFO  [main:Environment@100] - Client environment:java.version=1.8.0_65

2017-08-25 16:11:38,760 [myid:] - INFO  [main:Environment@100] - Client environment:java.vendor=Oracle Corporation

2017-08-25 16:11:38,760 [myid:] - INFO  [main:Environment@100] - Client environment:java.home=/usr/local/jdk1.8.0_65/jre

2017-08-25 16:11:38,761 [myid:] - INFO  [main:Environment@100] - Client environment:java.class.path=/usr/local/zookeeper-3.4.6/bin/../build/classes:/usr/local/zookeeper-3.4.6/bin/../build/lib/*.jar:/usr/local/zookeeper-3.4.6/bin/../lib/slf4j-log4j12-1.6.1.jar:/usr/local/zookeeper-3.4.6/bin/../lib/slf4j-api-1.6.1.jar:/usr/local/zookeeper-3.4.6/bin/../lib/netty-3.7.0.Final.jar:/usr/local/zookeeper-3.4.6/bin/../lib/log4j-1.2.16.jar:/usr/local/zookeeper-3.4.6/bin/../lib/jline-0.9.94.jar:/usr/local/zookeeper-3.4.6/bin/../zookeeper-3.4.6.jar:/usr/local/zookeeper-3.4.6/bin/../src/java/lib/*.jar:/usr/local/zookeeper-3.4.6/bin/../conf:.:/usr/local/jdk1.8.0_65/lib

2017-08-25 16:11:38,761 [myid:] - INFO  [main:Environment@100] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib

2017-08-25 16:11:38,762 [myid:] - INFO  [main:Environment@100] - Client environment:java.io.tmpdir=/tmp

2017-08-25 16:11:38,764 [myid:] - INFO  [main:Environment@100] - Client environment:java.compiler=<NA>

2017-08-25 16:11:38,765 [myid:] - INFO  [main:Environment@100] - Client environment:os.name=Linux

2017-08-25 16:11:38,765 [myid:] - INFO  [main:Environment@100] - Client environment:os.arch=amd64

2017-08-25 16:11:38,765 [myid:] - INFO  [main:Environment@100] - Client environment:os.version=2.6.32-431.el6.x86_64

2017-08-25 16:11:38,765 [myid:] - INFO  [main:Environment@100] - Client environment:user.name=root

2017-08-25 16:11:38,765 [myid:] - INFO  [main:Environment@100] - Client environment:user.home=/root

2017-08-25 16:11:38,765 [myid:] - INFO  [main:Environment@100] - Client environment:user.dir=/usr/local/zookeeper-3.4.6

2017-08-25 16:11:38,769 [myid:] - INFO  [main:ZooKeeper@438] - Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@67424e82

Welcome to ZooKeeper!

2017-08-25 16:11:38,835 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@975] - Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181. Will not attempt to authenticate using SASL (unknown error)

JLine support is enabled

2017-08-25 16:11:38,961 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@852] - Socket connection established to localhost/0:0:0:0:0:0:0:1:2181, initiating session

2017-08-25 16:11:38,981 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1235] - Session establishment complete on server localhost/0:0:0:0:0:0:0:1:2181, sessionid = 0x15e17152f380013, negotiated timeout = 30000

 

WATCHER::

 

WatchedEvent state:SyncConnected type:None path:null

[zk: localhost:2181(CONNECTED) 0] ls /

[zookeeper, hbase]

[zk: localhost:2181(CONNECTED) 1] ls /hbase

[replication, meta-region-server, rs, splitWAL, backup-masters, table-lock, flush-table-proc, region-in-transition, online-snapshot, switch, master, running, recovering-regions, draining, namespace, hbaseid, table]

[zk: localhost:2181(CONNECTED) 2]

 

 

      1. 关闭hbase服务

[root@localhost65 bin]#

[root@localhost65 bin]# stop-hbase.sh

stopping hbase.....................

[root@localhost65 bin]#

[root@localhost65 bin]# jps

24272 SecondaryNameNode

5219 Main

24534 NodeManager

24439 ResourceManager

24152 DataNode

17960 RunJar

12841 RunJar

26220 Jps

4335 QuorumPeerMain

24063 NameNode

[root@localhost65 bin]#

 

      1. 测试hbase服务

浏览器输入:http://192.168.3.65:16010/  hbase默认端口是16010。