HBase
HBase
一、安装
规划
Node Name | Master | ZooKeeper | RegionServer |
---|---|---|---|
node01 | yes | yes | no |
node02 | backup | yes | yes |
node03 | no | yes | yes |
1.1 前置依赖
1.2 安装Hbase
- 下载解压
访问Hbase官方,下载最新的bin安装包
[root@node01 opt]# wget https://dlcdn.apache.org/hbase/2.5.5/hbase-2.5.5-bin.tar.gz
[root@node01 opt]# tar -xzf hbase-2.5.5-bin.tar.gz
- 配置环境变量
[root@node01 opt]# vim /etc/profile.d/my_env.sh
#Hbase
export HBASE_HOME=/opt/hbase
export PATH=$PATH:$HBASE_HOME/bin
分发配置
[root@node01 opt]# xsync /etc/profile.d/my_env.sh
- 修改
hbase-env.sh
文件
[root@node01 opt]# vim /opt/hbase/conf/hbase-env.sh
# Tell HBase whether it should manage it's own instance of ZooKeeper or not.
export HBASE_MANAGES_ZK=false
- 修改
hbase-site.xml
文件
[root@node01 opt]# vim /opt/hbase/conf/hbase-site.xml
<property>
<name>hbase.rootdir</name>
<value>hdfs://node01:8020/HBase</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>node01,node02,node03</value>
</property>
- 修改
regionservers
文件
[root@node01 opt]# vim /opt/hbase/conf/regionservers
node01
node02
node03
- 修改
backup-masters
文件
[hadoop@node01 opt]$ vim /opt/hbase/conf/backup-masters
node02
node03
- 同步分发到其他机器
[root@node01 opt]# xsync hbase
- 单独配置
node01
修改conf/regionservers
,把node01去掉,因为它master不跑RegionServers
- HBase启动异常object is not an instance of declaring class 错误
因为和hadoop 包冲突,需要开启以下配置
vim /opt/hbase/conf/hbase-env.sh
# Tell HBase whether it should include Hadoop's lib when start up,
# the default value is false,means that includes Hadoop's lib.
export HBASE_DISABLE_HADOOP_CLASSPATH_LOOKUP="true"
- 单点启动
[root@master01 opt]# hbase-daemon.sh start master
[root@master01 opt]# hbase-daemon.sh start regionserver
- 群启hbase
[root@node01 opt]# /opt/hbase/bin/start-hbase.sh
- 检查
# jps查看
[root@node01 hbase]# xcall jps
=============== master01 ===============
37907 HMaster
38231 HRegionServer
=============== slave01 ===============
49774 HRegionServer
=============== slave02 ===============
49883 HRegionServer
# hdfs查看
[root@node01 hbase]# hadoop fs -ls /HBase
Found 12 items
drwxr-xr-x - root supergroup 0 2022-01-12 22:54 /HBase/.hbck
drwxr-xr-x - root supergroup 0 2022-01-12 22:54 /HBase/.tmp
drwxr-xr-x - root supergroup 0 2022-01-12 22:54 /HBase/MasterData
drwxr-xr-x - root supergroup 0 2022-01-12 22:54 /HBase/WALs
drwxr-xr-x - root supergroup 0 2022-01-12 22:54 /HBase/archive
drwxr-xr-x - root supergroup 0 2022-01-12 22:54 /HBase/corrupt
drwxr-xr-x - root supergroup 0 2022-01-12 22:54 /HBase/data
-rw-r--r-- 3 root supergroup 42 2022-01-12 22:54 /HBase/hbase.id
-rw-r--r-- 3 root supergroup 7 2022-01-12 22:54 /HBase/hbase.version
drwxr-xr-x - root supergroup 0 2022-01-12 22:54 /HBase/mobdir
drwxr-xr-x - root supergroup 0 2022-01-12 22:54 /HBase/oldWALs
drwx--x--x - root supergroup 0 2022-01-12 22:54 /HBase/staging
...
# shell查看
[hadoop@node01 opt]$ /opt/hbase/bin/hbase shell
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/hadoop-2.10.1/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/hbase-2.4.9/lib/client-facing-thirdparty/slf4j-log4j12-1.7.30.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
HBase Shell
Use "help" to get list of supported commands.
Use "exit" to quit this interactive shell.
For Reference, please visit: http://hbase.apache.org/2.0/book.html#shell
Version 2.4.9, rc49f7f63fca144765bf7c2da41791769286dfccc, Fri Dec 17 19:02:09 PST 2021
Took 0.0014 seconds
hbase:001:0> status
1 active master, 0 backup masters, 2 servers, 0 dead, 1.0000 average load
Took 0.4639 seconds
访问web-ui http://node01:16010
二、使用(shell)
查看表
hbase:001:0> scan 'user_info'
创建表
create 'employee','company','family'
put 'employee','row1','company:name','ted'
put 'employee','row1','company:position','worker'
put 'employee','row1','family:tel','13600912345'
put 'employee','row2','company:name','michael'
put 'employee','row2','company:position','manager'
put 'employee','row2','family:tel','1234912341324'
scan 'employee'
创建表空间
-- 查看表空间
hbase:001:0> list_namespace
NAMESPACE
default
hbase
2 row(s)
Took 0.6087 seconds
-- 创建表空间
hbase:005:0> create_namespace 'dice_realtime'
Took 0.2293 seconds
hbase:006:0>