使用hbase shell 命令登陆,创建一个表
create 'test035','c1','c2'
hbase(main):003:0> put 'test035','1','c1:name','dailiang'
17/12/21 18:17:16 ERROR client.AsyncProcess: Failed to get region location
org.apache.hadoop.hbase.client.NoServerForRegionException: No server address listed in hbase:meta for region test035,,1513851169227.0f33963c39a5c82c0c1f3d71e5976c27. containing row 1
仔细看一下报错:
17/12/21 18:17:16 ERROR client.AsyncProcess: Failed to get region location
org.apache.hadoop.hbase.client.
NoServerForRegionException: No server address listed in hbase:meta for region test035
应该是没有分配region的问题,所以我们登录到CDH页面,找到region server角色
打开region server的配置文件
发现如下报错
12月 21, 晚上6点22:00.962分 ERROR org.apache.hadoop.hbase.regionserver.handler.OpenRegionHandler
Failed open of region=test035,,1513851169227.0f33963c39a5c82c0c1f3d71e5976c27., starting to roll back the global memstore size.
java.io.IOException: java.io.IOException: Exception in createDir
Caused by: org.apache.hadoop.security.AccessControlException: Permission denied: user=hbase, access=WRITE, inode="/hbase/data/default/test035/0f33963c39a5c82c0c1f3d71e5976c27":hdfs:hbase:drwxr-xr-x
原因是HDFS文件的权限问题
我们查看下HDFS目录的权限:
[root@test028 ~]# hdfs dfs -ls /hbase/data/default
Found 8 items
drwxrwxrwx - hdfs hbase 0 2017-12-20 15:25 /hbase/data/default/TEST_IA_TF
drwxrwxrwx - hbase hbase 0 2017-10-24 16:27 /hbase/data/default/ismhash
drwxrwxrwx - hbase hbase 0 2017-10-24 16:27 /hbase/data/default/ismproinfo
drwxrwxrwx - hbase hbase 0 2017-10-24 10:33 /hbase/data/default/mauser_info
drwxr-xr-x - hdfs hbase 0 2017-12-21 18:12 /hbase/data/default/test035
发现手动创建的表文件目录属主是hdfs,而程序创建的目录属主是hbase,权限问题
所以最简单的方式就是修改这个目录的权限
[root@test028 ~]# hdfs dfs -chown -R hbase:hbase /hbase/data/default/test035
或者可以使用chmod 777
也行
再检查一遍,发现权限变过来了
[root@test028 ~]# hdfs dfs -ls /hbase/data/default
Found 8 items
drwxrwxrwx - hdfs hbase 0 2017-12-20 15:25 /hbase/data/default/TEST_IA_TF
drwxrwxrwx - hbase hbase 0 2017-10-24 16:27 /hbase/data/default/ismhash
drwxrwxrwx - hbase hbase 0 2017-10-24 16:27 /hbase/data/default/ismproinfo
drwxrwxrwx - hbase hbase 0 2017-10-24 10:33 /hbase/data/default/mauser_info
drwxr-xr-x - hbase hbase 0 2017-12-21 18:12 /hbase/data/default/test035
然后通过页面重启CDH 的HBASE组件
再试试插入数据,发现ok了