hbase 建的表删除不掉的问题,已成功解决,经验分享

所用平台:hadoop 2.7.1,hbase 1.0.1.1,hbase api 1.0.1.1
发现的问题:之前在eclipse中调用api建表、填充数据、查看数据、删除数据、删除表都已经成功,但有一天同事用api建了一张表city,在hbase shell里删不掉。
我试了下,可以disable,但drop报错ERROR: Retries exhausted, it took too long to wait for the table city to be deleted.,以下是实验操作记录摘要,表名users2,供大家参考:

hbase(main):012:0> describe 'users2'
Table users2 is ENABLED

hbase(main):013:0> disable 'users2'
0 row(s) in 0.1750 seconds

hbase(main):014:0> drop 'users2'

此处卡住很久很久,ctrl+c强制退出了,重进hbase shell继续。

hbase(main):002:0> describe 'users2'
Table users2 is DISABLED

hbase(main):003:0> enable 'users2'

ERROR: Table 'users2' not yet enabled, after 1229139ms.

Here is some help for this command:
Start enable of named table:
hbase> enable 't1'
hbase> enable 'ns1:t1'

无法删除,那启用试试能不能操作,报错。

hbase(main):004:0> describe 'users2'
Table users2 is ENABLED

发现实际已经启用了,禁用之后再试试删除。

hbase(main):009:0> drop 'users2'

ERROR: Retries exhausted, it took too long to wait for the table users2 to be deleted.

Here is some help for this command:
Drop the named table. Table must first be disabled:
hbase> drop 't1'
hbase> drop 'ns1:t1'

过了很久,报错:重试次数用尽,等待删除表users2用了太久的时间。
到底怎么回事,根据这些错误信息去搜索,也没有找到可用的结果,期间考虑过权限问题:

hbase(main):001:0> user_permission 'city'
User Namespace,Table,Family,Qualifier:Permission

ERROR: DISABLED: Security features are not available

Here is some help for this command:
Show all permissions for the particular user.
Syntax : user_permission

Note: A namespace must always precede with '@' character.For example:hbase> user_permission
hbase> user_permission '@ns1'
hbase> user_permission 'table1'
hbase> user_permission 'namespace1:table1'
hbase> user_permission '.*'
hbase> user_permission '^[A-C].*'

还报过各种各样的错误:

ERROR: org.apache.hadoop.hbase.TableNotDisabledException: city
at org.apache.hadoop.hbase.master.handler.EnableTableHandler.prepare(EnableTableHandler.java:121)
at org.apache.hadoop.hbase.master.HMaster.enableTable(HMaster.java:1601)
at org.apache.hadoop.hbase.master.MasterRpcServices.enableTable(MasterRpcServices.java:559)
at org.apache.hadoop.hbase.protobuf.generated.MasterProtos$MasterService$2.callBlockingMethod(MasterProtos.java:42430)
at org.apache.hadoop.hbase.ipc.RpcServer.call(RpcServer.java:2031)
at org.apache.hadoop.hbase.ipc.CallRunner.run(CallRunner.java:107)
at org.apache.hadoop.hbase.ipc.RpcExecutor.consumerLoop(RpcExecutor.java:130)
at org.apache.hadoop.hbase.ipc.RpcExecutor$1.run(RpcExecutor.java:107)
at java.lang.Thread.run(Thread.java:745)

最后关闭hbase,关闭hadoop,重新打开hadoop,重新打开hbase,进入hbase shell,执行drop删除表,成功了。

hbase(main):011:0> describe 'users2'
Table users2 is ENABLED

hbase(main):012:0> disable 'users2'
0 row(s) in 1.2450 seconds

hbase(main):013:0> drop 'users2'
0 row(s) in 0.4300 seconds

至此,问题已经解决。
删除同事当时发现问题的表,还是报错:

hbase(main):002:0> list
TABLE
city
test
2 row(s) in 0.0250 seconds

hbase(main):003:0> describe 'city'
ERROR: Unknown table city!

hbase(main):004:0> desc 'city'
ERROR: Unknown table city!

hbase(main):005:0> drop 'city'
ERROR: Table city does not exist.

hbase(main):006:0> list
TABLE
test
1 row(s) in 0.0240 seconds

用list查看实际已经删掉了,问题原因基本确定:同事用api操作hbase时,可能哪里操作失误导致hbase卡住,重启hbase解决问题,本例重启了hadoop,或许不需要重启hadoop也行。
本次全部都在实验平台进行实验,生产环境请勿随意重启。