
Zookeeper安装

软件安装

Zookeeper配置

复制hbase到从机

HBase安装

软件安装

HBase配置

完全分布式
HBase
HBase

conf/hbase-env.sh

export HBASE_DISABLE_HADOOP_CLASSPATH_LOOKUP="true"
export HADOOP_CONF_DIR=/usr/local/hadoop-3.3.1/etc/hadoop
export HBASE_CLASSPATH=/usr/local/hbase/conf
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-1.el7_9.x86_64/jre
export HBASE_HEAPSIZE=512M
export HBASE_MANAGES_ZK=false
#指定ssh端口才需要打开如下设置
#export HBASE_SSH_OPTS="-p 8022"
export HADOOP_CONF_DIR=/usr/local/hadoop-3.3.1/etc/hadoop
export HBASE_CLASSPATH=/usr/local/hbase/conf
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-1.el7_9.x86_64/jre
export HBASE_HEAPSIZE=512M
export HBASE_MANAGES_ZK=false
#指定ssh端口才需要打开如下设置
#export HBASE_SSH_OPTS="-p 8022"

conf/hbase-site.xml

推荐配置

<configuration>
<property>
<name>hbase.rootdir</name>
<value>hdfs://master:9864/data/hbase_db</value>
</property>
<property>
<name>hbase.master</name>
<value>master</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>dfs.support.append</name>
<value>true</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>master,c22,c23</value>
</property>
<property>
<name>hbase.zookeeper.property.datadir</name>
<value>/home/hadoop/hbase/zookeeper</value>
</property>
<property>
<name>hbase.zookeeper.property.clientPort</name>
<value>2181</value>
</property>
</configuration>
<property>
<name>hbase.rootdir</name>
<value>hdfs://master:9864/data/hbase_db</value>
</property>
<property>
<name>hbase.master</name>
<value>master</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>dfs.support.append</name>
<value>true</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>master,c22,c23</value>
</property>
<property>
<name>hbase.zookeeper.property.datadir</name>
<value>/home/hadoop/hbase/zookeeper</value>
</property>
<property>
<name>hbase.zookeeper.property.clientPort</name>
<value>2181</value>
</property>
</configuration>

HBase使用

DDL操作命令

创建表

create 't', 'f'

hbase:007:0> create 't', 'f'
Created table t
Took 9.4125 seconds
=> Hbase::Table - t
hbase:008:0> scan 't'
ROW COLUMN+CELL
0 row(s)
Took 2.0022 seconds
hbase:009:0> describe 't'
Table t is ENABLED
t
COLUMN FAMILIES DESCRIPTION
{NAME => 'f', BLOOMFILTER => 'ROW', IN_MEMORY => 'false', VERSIONS => '1', KEEP_DELETED_CELLS => 'FALSE', DATA_BLOCK_ENCODING => 'NONE', COMPRESSION => 'NONE', TTL => 'FOREVER', MIN_VERSIONS => '0', BLOCKCACHE
=> 'true', BLOCKSIZE => '65536', REPLICATION_SCOPE => '0'}
1 row(s)
Quota is disabled
Took 0.6158 seconds
Created table t
Took 9.4125 seconds
=> Hbase::Table - t
hbase:008:0> scan 't'
ROW COLUMN+CELL
0 row(s)
Took 2.0022 seconds
hbase:009:0> describe 't'
Table t is ENABLED
t
COLUMN FAMILIES DESCRIPTION
{NAME => 'f', BLOOMFILTER => 'ROW', IN_MEMORY => 'false', VERSIONS => '1', KEEP_DELETED_CELLS => 'FALSE', DATA_BLOCK_ENCODING => 'NONE', COMPRESSION => 'NONE', TTL => 'FOREVER', MIN_VERSIONS => '0', BLOCKCACHE
=> 'true', BLOCKSIZE => '65536', REPLICATION_SCOPE => '0'}
1 row(s)
Quota is disabled
Took 0.6158 seconds

DML操作命令

获取表

get_table

hbase:016:0> tab = get_table 't'
Took 0.0027 seconds
=> Hbase::Table - t
hbase:017:0> tab.put 'r1' ,'f', 'v'
Took 7.2173 seconds
hbase:018:0> tab.scan
ROW COLUMN+CELL
r column=f:, timestamp=2022-08-27T07:43:21.327, value=v
r1 column=f:, timestamp=2022-08-27T07:47:05.313, value=v
2 row(s)
Took 0.2466 seconds
hbase:019:0>
Took 0.0027 seconds
=> Hbase::Table - t
hbase:017:0> tab.put 'r1' ,'f', 'v'
Took 7.2173 seconds
hbase:018:0> tab.scan
ROW COLUMN+CELL
r column=f:, timestamp=2022-08-27T07:43:21.327, value=v
r1 column=f:, timestamp=2022-08-27T07:47:05.313, value=v
2 row(s)
Took 0.2466 seconds
hbase:019:0>

常见问题

hbase shell中运行异常

status 状态查看报异常1

原因二,目录权限

修改所有的主从机:
sudo chown hadoop:users -R /usr/local/hadoop-3.3.1/
sudo chown hadoop:users -R /usr/local/spark/
sudo chown hadoop:users -R /usr/local/scala/
sudo chown hadoop:users -R /usr/local/hbase/
sudo chown hadoop:users -R /usr/local/zookeeper/
sudo chown hadoop:users -R /usr/local/hive/
sudo chown hadoop:users -R /usr/local/sqoop/
sudo chown hadoop:users -R /usr/local/hadoop-3.3.1/
sudo chown hadoop:users -R /usr/local/spark/
sudo chown hadoop:users -R /usr/local/scala/
sudo chown hadoop:users -R /usr/local/hbase/
sudo chown hadoop:users -R /usr/local/zookeeper/
sudo chown hadoop:users -R /usr/local/hive/
sudo chown hadoop:users -R /usr/local/sqoop/

logs/日志报异常