HBase Shell command collection 2

One: Introduction

The name of HBase comes from the Hadoop database, that is, the hadoop database, which is different from the general relational database. It is a database for unstructured data storage, and it is based on columns rather than rows.

HBase is a distributed, column-oriented, open source implementation based on Google Bigtable.
Use Hadoop HDFS as its file storage system,
use Hadoop MapReduce to process massive data in HBase, and
use Zookeeper as a collaborative service.

Two: HBase important concepts

2.1 HBase table structure

HBase stores data in the form of tables. A table consists of rows and columns. Columns are divided into several column families/column families, and each column family/column family can have multiple common columns.
insert image description here

2.2 Table Table

HBase uses tables to store data.

2.3 namespace namespace

Namespace Namespace refers to the logical grouping of a set of tables , similar to the database in RDBMS, which facilitates the division of tables in business.
The HBase system defines two default namespaces by default:

  • hbase: system built-in tables, including namespace and meta tables
  • default: tables that do not specify a namespace when the user creates the table are created here

2.3 Row Key

Row key, the primary key column of each row, the row key of each row must be unique, the value of the row key is any string (the maximum length is 64KB, the length is generally 10-100bytes in practical applications), 在HBase内部,rowKey保存为字节数组byte[].
A read and write of a row is an atomic operation (regardless of how many columns are read and written at a time)

2.4 Region Region

Table is divided into multiple Regions in the row direction.

Regions are divided by size. Each table starts with only one region. As the data increases, the region continues to grow. When it reaches a threshold, the region will be divided into two new regions. There are more and more regions.

Region is the smallest unit of distributed storage and load balancing in HBase. Different Regions are distributed to different RegionServers.

Region consists of one or more Stores, each Store stores a column family, and each Store consists of a MemStore (stored in memory) and 0 to more StoreFiles (stored on HDFS)
insert image description here

column family column family

The column family is the parent of each child column. Each child column belongs to a column family. A column family contains one or more related columns. When creating a table, the column family needs to be specified, but the column does not need to be specified. A specific sub-column is represented by "column family name: column name".

Schema in HBase is TableName + Column Family Name

column qualifier

It is the name of each sub-column under the column family, or the related column, or the qualifier, but the translation is different.
Use columnFamily:columnto locate a subcolumn.

storage unit cell

Each cell we see from the outside actually corresponds to multiple storage units. By default, a cell corresponds to a storage unit, and a storage unit can store a piece of data. If a cell has multiple storage units, it means A cell can store multiple values. The number of storage units can be set by version. A storage unit can be
rowKey + columnFamily + column + timestampuniquely identified by The data in the cell has no type and is stored in bytecode form.

hbase sorts the time versions in descending order of timestamp, and other mappings are sorted in ascending order.

Timestamp version number timestamp

Each cell holds multiple versions of the same data. Versions are indexed by timestamp. The type of the timestamp is a 64-bit integer. The timestamp can be assigned by hbase (automatically when data is written), and the timestamp is the current system time accurate to milliseconds. Timestamps can also be explicitly assigned by clients. If applications want to avoid data version conflicts, they must generate unique timestamps themselves. In each cell, different versions of data are sorted in reverse chronological order, that is, the latest data is at the top.

In order to avoid the burden of management (including storage and indexing) caused by too many versions of data, hbase provides two data version recycling methods. One is to save the last n versions of the data, and the other is to save the most recent version (such as the last seven days). Users can set it per column family.

三:HBase Shell

name describe grammar
help 'Named' to view the description of the command help 'command name'
whoami who I am whoami
version Return hbase version information version
status Return the status information of the hbase cluster status
table_help See how to table table_help
create create table create 'table name', 'column family name 1', 'column family name 2', 'column family name N'
alter modify column family Add a column family: alter 'table name', 'column family name'
Delete column family: alter 'table name', {NAME=> 'column family name', METHOD=> 'delete'}
describe Display detailed information about a table describe 'table name'
list List all tables present in hbase list
exists Tests whether the table exists exists 'table name'
put Added or modified table values put 'table name', 'row key', 'column family name', 'column value'
put 'table name', 'row key', 'column family name: column name', 'column value'
scan Obtain the corresponding value by scanning the table scan 'table name'
scans a column family: scan 'table name', {COLUMN=>'column family name'}
scans a column of a certain column family: scan 'table name', {COLUMN=>'column family Name: column name'}
Query multiple columns of the same column family: scan 'table name', {COLUMNS => [ 'column family name 1: column name 1', 'column family name 1: column name 2', … ]}
get Get the value of a row or cell get 'table name', 'row key'
get 'table name', 'row key', 'column family name'
count counts the number of rows in the table count 'table name'
incr Increment the value of the specified table row or column incr 'table name', 'row key', 'column family: column name', step value
get_counter get counter get_counter 'table name', 'row key', 'column family: column name'
delete Delete the value of the specified object (can be the value corresponding to the table, row, column, or specify the value of the timestamp) Delete a column of the column family: delete 'table name', 'row key', 'column family name: column name'
deleteall Delete all element values ​​of the specified row deleteall 'table name', 'row key'
truncate Recreate the specified table truncate 'table name'
enable make table valid enable 'table name'
is_enabled Whether to enable is_enabled 'table name'
disable invalidate table disable 'table name'
is_disabled Is it invalid is_disabled 'table name'
drop delete table The drop table must be disabled disable
'table name'
drop 'table name'
shutdown Close the hbase cluster (different from exit)
tools List the tools supported by hbase
exit exit hbase shell

HBase Shell is a set of commands officially provided to operate HBase.如果配置了HBase的环境变量了,就可以知己在命令行中输入hbase shell 命令进入命令行。

hbase shell

insert image description here

help command

Can be help '命名名称'来viewed by 命令行的具体使用,包括命令的作用和用法.
Use help 'hbase' to view all the commands supported by the hbase shell. Hbase groups the commands, among which ddl and dml are used more.
insert image description here

insert image description here

Four: general naming

1. Display cluster status status

Can be 'summary', 'simple', 'detailed', or 'replication'. Defaults to 'summary'

hbase> status
hbase> status 'simple'
hbase> status 'summary'
hbase> status 'detailed'
hbase> status 'replication'
hbase> status 'replication', 'source'
hbase> status 'replication', 'sink'

insert image description here

2. Query the database version version

insert image description here

3. Display the current user and group whoami

insert image description here

4. View the command table_help of the operation table

insert image description here

5. Exit HBase Shell exit

exit

Five: ddl command

1. Create table create

Note: When creating a table, you only need to specify the column family name, not the column name.

# 语法
create '表名', {
    
    NAME => '列族名1'}, {
    
    NAME => '列族名2'}, {
    
    NAME => '列族名3'}
# 此种方式是上上面的简写方式,使用上面方式可以为列族指定更多的属性,如VERSIONS、TTL、BLOCKCACHE、CONFIGURATION等属性
create '表名', '列族名1', '列族名2', '列族名3'

create '表名', {
    
    NAME => '列族名1', VERSIONS => 版本号, TTL => 过期时间, BLOCKCACHE => true}


# 示例
create 'tbl_user', 'info', 'detail'
create 't1', {
    
    NAME => 'f1', VERSIONS => 1, TTL => 2592000, BLOCKCACHE => true}

insert image description here

2. 修改(添加、删除)表结构Schema alter

2.1 添加一个列族

# 语法 
alter '表名', '列族名'

# 示例
alter 'tbl_user', 'address'

insert image description here

2.2 删除一个列族

# 语法 
alter '表名', {
    
    NAME=> '列族名', METHOD=> 'delete'}

# 示例
alter 'tbl_user', {
    
    NAME=> 'address', METHOD=> 'delete'}

insert image description here

2.3 修改列族的属性

可以修改列族的VERSIONS、IN_MEMORY

# 修改f1列族的版本为5
alter 't1', NAME => 'f1', VERSIONS => 5

# 修改多个列族,修改f2为内存,版本号为5
alter 't1', 'f1', {
    
    NAME => 'f2', IN_MEMORY => true}, {
    
    NAME => 'f3', VERSIONS => 5}

# 也可以修改table-scope属性,例如MAX_FILESIZE, READONLY,MEMSTORE_FLUSHSIZE, DEFERRED_LOG_FLUSH等。
# 例如,修改region的最大大小为128MB:
alter 't1', MAX_FILESIZE => '134217728'

3. 异步修改Schema alter_async

# change or add the 'f1' column family in table 't1' from defaults
to instead keep a maximum of 5 cell VERSIONS
alter_async 't1', NAME => 'f1', VERSIONS => 5

# delete the 'f1' column family in table 'ns1:t1'
alter_async 'ns1:t1', NAME => 'f1', METHOD => 'delete'
alter_async 'ns1:t1', 'delete' => 'f1'

# change the max size of a family to 128MB
alter 't1', METHOD => 'table_att', MAX_FILESIZE => '134217728'
alter 't1', {
    
    NAME => 'f1'}, {
    
    NAME => 'f2', METHOD => 'delete'}

4. 获取alter_async执行的状态 alter_status

alter_status '表名'

5. 获取表的描述describe

# 语法 
describe '表名'

# 示例
describe 'tbl_user'

insert image description here

6. 列举所有表list

insert image description here

7. 表是否存在exists

# 语法 
exists '表名'

# 示例
exists 'tbl_user'

insert image description here

8. 启用表enable和禁用表disable

通过enable和disable来启用/禁用这个表,相应的可以通过is_enabled和is_disabled来检查表是否被禁用。

# 语法
enable '表名'
is_enabled '表名'

disable '表名'
is_disabled '表名'

# 示例
disable 'tbl_user'
is_disabled 'tbl_user'

enable 'tbl_user'
is_enabled 'tbl_user'

insert image description here

9. 禁用满足正则表达式的所有表disable_all

  • .匹配除“\n”和"\r"之外的任何单个字符
  • *匹配前面的子表达式任意次
# 匹配以t开头的表名
disable_all 't.*'
# 匹配指定命名空间ns下的以t开头的所有表
disable_all 'ns:t.*'
# 匹配ns命名空间下的所有表
disable_all 'ns:.*'

10. 启用满足正则表达式的所有表enable_all

enable_all 't.*'
enable_all 'ns:t.*'
enable_all 'ns:.*'

11. 删除表drop

需要先禁用表,然后再删除表,启用的表是不允许删除的

# 语法
disable '表名'
drop '表名'

# 示例
disable 'tbl_user'
drop 'tbl_user'

insert image description here

12. 删除满足正则表达式的所有表drop_all

drop_all 't.*'
drop_all 'ns:t.*'
drop_all 'ns:.*'

13. 获取某个表赋值给一个变量 get_table

通过 var = get_table ‘表名’ 赋值给一个变量对象,然后对象.来调用,就像面向对象编程一样,通过对象.方法来调用,这种方式在操作某个表时就不必每次列举表名了。
insert image description here

14. 获取rowKey所在的区 locate_region

locate_region '表名', '行键'

insert image description here

15. 显示hbase所支持的所有过滤器show_filters

过滤器用于get和scan命令中作为筛选数据的条件,类型关系型数据库中的where的作用
insert image description here

六:namespace命令

6.1 列举命名空间 list_namespace

insert image description here

6.2 获取命名空间描述 describe_namespace

insert image description here

6.3 查看命名空间下的所有表 list_namespace_tables

insert image description here

6.4 创建命名空间create_namespace

insert image description here

6.5 修改命名空间的属性

# add/modify a property
alter_namespace 'ns1', {
    
    METHOD => 'set', 'PROPERTY_NAME' => 'PROPERTY_VALUE'}
# delete a property
alter_namespace 'ns1', {
    
    METHOD => 'unset', NAME=>'PROPERTY_NAME'}

6.6 删除命名空间drop_namespace

drop_namespace '命名空间名称'

七:dml命令

1. 插入或者修改数据put

# 语法
# 当列族中只有一个列时'列族名:列名'使用'列族名'
put '表名', '行键', '列族名', '列值'
put '表名', '行键', '列族名:列名', '列值'

# 示例

# 创建表
create 'tbl_user', 'info', 'detail', 'address'

# 第一行数据
put 'tbl_user', 'mengday', 'info:id', '1'
put 'tbl_user', 'mengday', 'info:name', '张三'
put 'tbl_user', 'mengday', 'info:age', '28'

put 'tbl_user', 'mengday', 'detail:birthday', '1990-06-26'
put 'tbl_user', 'mengday', 'detail:email', '[email protected]'
put 'tbl_user', 'mengday', 'detail:create_time', '2019-03-04 14:26:10'

put 'tbl_user', 'mengday', 'address', '上海市'

# 第二行数据
put 'tbl_user', 'vbirdbest', 'info:id', '2'
put 'tbl_user', 'vbirdbest', 'info:name', '李四'
put 'tbl_user', 'vbirdbest', 'info:age', '27'

put 'tbl_user', 'vbirdbest', 'detail:birthday', '1990-06-27'
put 'tbl_user', 'vbirdbest', 'detail:email', '[email protected]'
put 'tbl_user', 'vbirdbest', 'detail:create_time', '2019-03-05 14:26:10'

put 'tbl_user', 'vbirdbest', 'address', '北京市'


# 第一行数据
put 'tbl_user', 'xiaoming', 'info:id', '3'
put 'tbl_user', 'xiaoming', 'info:name', '王五'
put 'tbl_user', 'xiaoming', 'info:age', '26'

put 'tbl_user', 'xiaoming', 'detail:birthday', '1990-06-28'
put 'tbl_user', 'xiaoming', 'detail:email', '[email protected]'
put 'tbl_user', 'xiaoming', 'detail:create_time', '2019-03-06 14:26:10'

put 'tbl_user', 'xiaoming', 'address', '杭州市'

insert image description here

2. 全表扫描scan

获取表的所有数据

# 语法
scan '表名'

# 示例
scan 'tbl_user'

insert image description here

注意:中文编码了

扫描整个列簇

# 语法
scan '表名', {
    
    COLUMN=>'列族名'}

# 示例
scan 'tbl_user', {
    
    COLUMN=>'info'}

insert image description here

扫描整个列簇的某个列

# 语法
scan '表名', {
    
    COLUMN=>'列族名:列名'}

# 示例
scan 'tbl_user', {
    
    COLUMN=>'info:age'}

insert image description here

3. 获取数据get

# 语法
get '表名', '行键'

# 示例
get 'tbl_user', 'mengday'

insert image description here

根据某一行某列族的数据

# 语法
get '表名', '行键', '列族名'

# 示例
get 'tbl_user', 'mengday', 'info'

insert image description here

# 创建表,c1版本为4, 元数据mykey=myvalue
hbase(main):009:0> create 't1', {
    
    NAME => 'c1', VERSIONS => 4}, METADATA => {
    
     'mykey' => 'myvalue' }
0 row(s) in 2.2810 seconds

=> Hbase::Table - t1
# 添加列族c2, c3
hbase(main):010:0> alter 't1', 'c2', 'c3'
Updating all regions with the new schema...
1/1 regions updated.
Done.
Updating all regions with the new schema...
1/1 regions updated.
Done.
0 row(s) in 3.8320 seconds

# 出入数据,c1 插入4个版本的值
hbase(main):011:0> put 't1', 'r1', 'c1', 'v1'
0 row(s) in 0.1000 seconds

hbase(main):012:0> put 't1', 'r1', 'c1', 'v11'
0 row(s) in 0.0180 seconds

hbase(main):013:0> put 't1', 'r1', 'c1', 'v111'
0 row(s) in 0.0140 seconds

hbase(main):014:0> put 't1', 'r1', 'c1', 'v1111'
0 row(s) in 0.0140 seconds

# 插入c2、c3的值
hbase(main):015:0> put 't1', 'r1', 'c2', 'v2'
0 row(s) in 0.0140 seconds

hbase(main):016:0> put 't1', 'r1', 'c3', 'v3'
0 row(s) in 0.0210 seconds

# 获取rowKey=r1的一行记录
hbase(main):017:0> get 't1', 'r1'
COLUMN                                              CELL
 c1:                                                timestamp=1552819382575, value=v1111
 c2:                                                timestamp=1552819392398, value=v2
 c3:                                                timestamp=1552819398244, value=v3
3 row(s) in 0.0550 seconds

# 获取rowKey=r1并且 1552819392398 <= 时间戳范围 < 1552819398244
hbase(main):018:0> get 't1', 'r1', {
    
    TIMERANGE => [1552819392398, 1552819398244]}
COLUMN                                              CELL
 c2:                                                timestamp=1552819392398, value=v2
1 row(s) in 0.0090 seconds

# 获取指定列的值
hbase(main):019:0> get 't1', 'r1', {
    
    COLUMN => 'c1'}
COLUMN                                              CELL
 c1:                                                timestamp=1552819382575, value=v1111
1 row(s) in 0.0160 seconds

# 获取指定列的值,多个值使用数组表示
hbase(main):020:0> get 't1', 'r1', {
    
    COLUMN => ['c1', 'c2', 'c3']}
COLUMN                                              CELL
 c1:                                                timestamp=1552819382575, value=v1111
 c2:                                                timestamp=1552819392398, value=v2
 c3:                                                timestamp=1552819398244, value=v3
3 row(s) in 0.0170 seconds

# 获取c1的值,获取4个版本的值,默认是按照时间戳降续排序的
hbase(main):021:0> get 't1', 'r1', {
    
    COLUMN => 'c1', VERSIONS => 4}
COLUMN                                              CELL
 c1:                                                timestamp=1552819382575, value=v1111
 c1:                                                timestamp=1552819376343, value=v111
 c1:                                                timestamp=1552819368993, value=v11
 c1:                                                timestamp=1552819362975, value=v1
4 row(s) in 0.0180 seconds

# 获取c1的3个版本值
hbase(main):027:0* get 't1', 'r1', {
    
    COLUMN => 'c1', VERSIONS => 3}
COLUMN                                               CELL
 c1:                                                 timestamp=1552819382575, value=v1111
 c1:                                                 timestamp=1552819376343, value=v111
 c1:                                                 timestamp=1552819368993, value=v11
3 row(s) in 0.0090 seconds

# 获取指定时间戳版本的列
hbase(main):022:0> get 't1', 'r1', {
    
    COLUMN => 'c1', TIMESTAMP => 1552819376343}
COLUMN                                              CELL
 c1:                                                timestamp=1552819376343, value=v111
1 row(s) in 0.0170 seconds

hbase(main):023:0> get 't1', 'r1', {
    
    COLUMN => 'c1', TIMESTAMP => 1552819376343, VERSIONS => 4}
COLUMN                                              CELL
 c1:                                                timestamp=1552819376343, value=v111
1 row(s) in 0.0130 seconds

# 获取rowKey=r1中的值等于v2的所有列
hbase(main):024:0> get 't1', 'r1', {
    
    FILTER => "ValueFilter(=, 'binary:v2')"}
COLUMN                                              CELL
 c2:                                                timestamp=1552819392398, value=v2
1 row(s) in 0.0510 seconds


hbase(main):025:0> get 't1', 'r1', {
    
    COLUMN => 'c1', ATTRIBUTES => {
    
    'mykey'=>'myvalue'}}
COLUMN                                              CELL
 c1:                                                timestamp=1552819382575, value=v1111
1 row(s) in 0.0100 seconds

4. 删除某个列族中的某个列delete

# 语法
delete '表名', '行键', '列族名:列名'


create 'tbl_test', 'columnFamily1'

put 'tbl_test', 'rowKey1', 'columnFamily1:column1', 'value1'
put 'tbl_test', 'rowKey1', 'columnFamily1:column2', 'value2'

delete 'tbl_test', 'rowKey1', 'columnFamily1:column1'

insert image description here

5. 删除某行数据deleteall

# 语法
deleteall '表名', '行键'

# 示例
deleteall 'tbl_test', 'rowKey1'

insert image description here

6. 清空整个表的数据truncate

先disable表,然后再drop表,最后重新create表

truncate '表名'

insert image description here

7. 查询表中有多少行count

# 语法
count '表名'

# 示例
count 'tbl_user'

insert image description here

8. 自增incr

# 语法
incr '表名', '行键', '列族:列名', 步长值

# 示例 
# 注意:incr 可以对不存的行键操作,如果行键已经存在会报错,如果使用put修改了incr的值再使用incr也会报错
# ERROR: org.apache.hadoop.hbase.DoNotRetryIOException: Field is not a long, it's 2 bytes wide
incr 'tbl_user', 'xiaohong', 'info:age', 1

insert image description here

9. 计数器get_counter

# 点击量:日、周、月
create 'counters', 'daily', 'weekly', 'monthly'
incr 'counters', '20110101', 'daily:hits', 1
incr 'counters', '20110101', 'daily:hits', 1
get_counter 'counters', '20110101', 'daily:hits'

insert image description here

10. 修饰词

10.1 COLUMNS: 查询同一个列族的多个列

# 语法

scan '表名', {
    
    COLUMNS => [ '列族名1:列名1', '列族名1:列名2', ...]}

# 示例
scan 'tbl_user', {
    
    COLUMNS => [ 'info:id', 'info:age']}

insert image description here

10.2 TIMESTAMP 指定时间戳

scan 't1', {
    
    COLUMNS => 'c2', TIMESTAMP=> 1552819392398}

10.3 TIMERANGE表示的是”>=开始时间 and <结束时间“

# 语法
scan '表名',{
    
    TIMERANGE=>[timestamp1, timestamp2]}

# 示例
scan 'tbl_user',{
    
    TIMERANGE=>[1551938004321, 1551938036450]}

insert image description here

10.4 VERSIONS

默认情况下一个列只能存储一个数据,后面如果修改数据就会将原来的覆盖掉,可以通过指定VERSIONS时HBase一列能存储多个值。

create 'tbl_test', 'columnFamily1'
describe 'tbl_test'

# 修改列族版本号
alter 'tbl_test', {
    
     NAME=>'columnFamily1', VERSIONS=>3 }

put 'tbl_test', 'rowKey1', 'columnFamily1:column1', 'value1'
put 'tbl_test', 'rowKey1', 'columnFamily1:column1', 'value2'
put 'tbl_test', 'rowKey1', 'columnFamily1:column1', 'value3'

# 默认返回最新的一条数据
get 'tbl_test','rowKey1','columnFamily1:column1'

# 返回3个
get 'tbl_test','rowKey1',{
    
    COLUMN=>'columnFamily1:column1', VERSIONS=>3}
# 返回2个
get 'tbl_test','rowKey1',{
    
    COLUMN=>'columnFamily1:column1', VERSIONS=>2}

insert image description here

10.5 STARTROW

ROWKEY起始行。会先根据这个key定位到region,再向后扫描

# 语法
scan '表名', {
    
     STARTROW => '行键名'}

# 示例
scan 'tbl_user', {
    
     STARTROW => 'vbirdbest'}

insert image description here

10.6 STOPROW :截止到STOPROW行,STOPROW行之前的数据,不包括STOPROW这行数据

# 语法
scan '表名', {
    
     STOPROW => '行键名'}

# 示例
scan 'tbl_user', {
    
     STOPROW => 'vbirdbest'}

insert image description here

10.7 LIMIT 返回的行数

# 语法
scan '表名', {
    
     LIMIT => 行数}

# 示例
scan 'tbl_user', {
    
     LIMIT => 2 }

insert image description here

11. FILTER条件过滤器

过滤器之间可以使用AND、OR连接多个过滤器。

ValueFilter 值过滤器

# 语法:binary 等于某个值
scan '表名', FILTER=>"ValueFilter(=,'binary:列值')"
# 语法 substring:包含某个值
scan '表名', FILTER=>"ValueFilter(=,'substring:列值')"

# 示例
scan 'tbl_user', FILTER=>"ValueFilter(=, 'binary:26')"
scan 'tbl_user', FILTER=>"ValueFilter(=, 'substring:6')"

insert image description here

ColumnPrefixFilter 列名前缀过滤器

# 语法 substring:包含某个值
scan '表名', FILTER=>"ColumnPrefixFilter('列名前缀')"

# 示例
scan 'tbl_user', FILTER=>"ColumnPrefixFilter('birth')"
# 通过括号、AND和OR的条件组合多个过滤器
scan 'tbl_user', FILTER=>"ColumnPrefixFilter('birth') AND ValueFilter(=,'substring:26')"

insert image description here

rowKey字典排序
Table中的所有行都是按照row key的字典排序的
insert image description here

三:HBase 常见错误

hbase shell在使用的时候经常会报错,这里列举了几个错误:

1. HBase创建不存在的表报已经存在错误 ERROR: Table already exists: !

解决办法:

# 1. 进入zookeeper client模式
cd /usr/local/Cellar/hbase/1.2.9/bin
hbase zkcli

# 2. 在zk client模式下输入ls /hbase/table命令看到zombie table
ls /hbase/table

# 3. 删除表,TABLE_NAME为要删除的表名
rmr /hbase/table/TABLE_NAME

# 4. 重启hbase
./stop-hbase.sh
./start-hbase.sh

2. ERROR: org.apache.hadoop.hbase.ipc.ServerNotRunningYetException: Server is not running yet

# 使用jps查看是否有datanode服务
jps

删除hadoop 的临时目录
/usr/local/Cellar/hadoop/3.1.1/libexec/tmp

3. ERROR: Can’t get master address from ZooKeeper; znode data == null

# 重启hbase
./stop-hbase.sh

./start-hbase.sh

4. ERROR: org.apache.hadoop.hbase.PleaseHoldException: Master is initializing

There are many reasons for this error. Let me talk about the reason for my error here. There is an attribute name configuration error in hbase-site.xml. Some of the Internet is hbase.rootdir, and the name is configured as this. Sometimes it will report an error and sometimes it will not report an error. , When an error is reported, format Hadoop and then restart it. Sometimes this method can solve the problem, and sometimes it cannot. Here I change hbase.rootdir to hbase.root.dir and no error will be reported. I don’t know if the attribute name configuration is different in different versions. My hadoop version is 3.1.1 and hbase version is 1.2.9

<!-- 正确的配置的属性名应为hbase.root.dir而不是hbase.rootdir -->
<property>
  <name>hbase.root.dir</name>
  <value>hdfs://localhost:8020/hbase</value>
</property>

Guess you like

Origin blog.csdn.net/liuwei0376/article/details/125765308