hbase是一款分布式的列式数据库,其数据源寄生在hadoop上,因而与hadoop共生,广泛应用在大数据领域,利用zookeeper作为其分布式协同服务,存储非结构化和半结构化的松散数据,其特点是高可靠,高性能,面向列,可伸缩,实时读写。
下载hbase安装包:hbase-2.0.0 这里我下载的版本是2.0.0,为了与hive3.1.1版本实现同步,hive3.1.1与hbase实现同步所使用的hbase版本是2.0.0。当然,也可以根据自己的需要下载其他版本的hbase。
切换到下载路径,解压hbase安装包
tar -zxvf hbase-2.0.0-bin.tar.gz -C /usr/local修改hbase安装路径
mv /usr/local/hbase-2.0.0-bin /usr/local/hbase修改hbase的配置文件
hbase-env.sh
找到对应的key,修改成以下的值
export JAVA_HOME=/usr/java/jdk1.8.0_211 export HBASE_MANAGES_ZK=falseJAVA_HOME 填写自身对应的jdk路径
HBASE_MANAGES_ZK 禁用hbase自带的zookeeper
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 * 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://hadoop1:9000/hbase</value> </property> <property> <name>hbase.cluster.distributed</name> <value>true</value> </property> <property> <name>hbase.zookeeper.quorum</name> <value>hadoop2,hadoop3,hadoop4</value> </property> </configuration> hbase.rootdir 配置hbase在hadoop上的根目录hbase.cluster.distributed 开启hbase的集群模式hbase.zookeeper.quorum 配置hbase在zk上注册集群regionservers文件上填写需要集群的机器,每台机器启动一个regionServer进程,我这里使用三台机器作为regionServer,hadoop1作为master
backup-masters
在hbase的conf目录下可能不存在这个文件,那么需要手动创建一个,如没搭建hive,请参考hive的集群搭建
vi backup-masters在上面填写一个备份节点,master节点一旦挂了,这个备份节点将成为新的master节点,这里我使用hadoop2作为备份节点。
hdfs-site.xml
将搭建好的hadoop的配置文件hdfs-site.xml拷贝到hbase的conf目录下
配置hbase的环境变量
vi /etc/profile export HBASE_HOME=/usr/local/hbase export PATH=$PATH:$HBASE_HOME/bin source /etc/profile分发配置好的hbase到其他机器上
scp -r /usr/local/hbase hadoop2:/usr/local scp -r /usr/local/hbase hadoop3:/usr/local scp -r /usr/local/hbase hadoop4:/usr/local其他机器按照上述步骤配置环境变量
先启动zookeeper集群,可参考:zookeeper集群搭建
在hadoop1上启动hbase,在备份节点hadoop2上也启动hbase
start-hbase.shhbase管理界面
可以看到有备份节点hadoop2
在zk上注册了3台机器,用于regionServer之间的通讯,而master可以不用注册到上面
如启动之后hmaster闪退,或者打不开管理界面,那么请按以下步骤操作:
关闭hbasestop-hbase.sh,一定要脚本去跑完,再去杀死进程kill -9 xxx
清除zk上的hbase元数据信息
zkCli.sh //启动zk客户端 ls / //查看zk节点 rmr /hbase //删除hbase重启hbase
启动hbase的控制台命令
hbase shell测试一下hbase的命令
显示命名空间 list_namespace 创建一个User表,并且有一个info列族 create 'User','info' list //列出所有表