分享

HBase 因为权限不足无法创建表(Kerberos backend openldap)

Kevin517 发表于 2017-9-20 17:53:05 [显示全部楼层] 回帖奖励 阅读模式 关闭右栏 1 14546
公司的环境是 Ambari + Kerberos 使用 Openldap 做后端用户管理。
因为这个权限太严格的,所以总会在权限上遇到各种各样的问题。
集群是老大去年搭建好的。今年接收,一遍使用。遇到问题自己处理。。

在使用 HBase 中新用户创建表会出现权限问题。
即使使用 HBase 用户登录,发现也是无法创建表的。原因就是没有获取到 Kerberos 提供的权限。
曾经尝试了各种超级用户的 kgt 都是不行。

找了好久 google ,先是找到了一篇帖子,楼主解决了,但我操作没成功,后来又找了个帖子,对比了他们的不同之处,找到了原因。

今天在这里分享一下解决过程,为以后遇到这个痛苦问题的小伙伴提供个思路。同时方便大家在百度上搜索吧


如果不想继续看我闲扯的话可以直接查看下面两篇国外的帖子(可能要自带梯子哈)

cant create HBASE table

HBase SQL statement fails with Insufficient permissions for user


============================================================
这是另一个用户,用户身份在 Ambari 中存在,之前那个用户是在 openldap 中的,在提示用户的是时候有点区别,但是都是同一个问题,用户权限问题

[mw_shl_code=shell,true]base(main):001:0> create 'test_t1', 'test_f1'

ERROR: org.apache.hadoop.hbase.security.AccessDeniedException: Insufficient permissions (user=whg@TENDATA.CN, scope=default, params=[namespace=default,table=default:test_t1,family=test_f1],action=CREATE)

Here is some help for this command:
Creates a table. Pass a table name, and a set of column family
specifications (at least one), and, optionally, table configuration.
Column specification can be a simple string (name), or a dictionary
(dictionaries are described below in main help output), necessarily
including NAME attribute.
Examples:

Create a table with namespace=ns1 and table qualifier=t1
  hbase> create 'ns1:t1', {NAME => 'f1', VERSIONS => 5}

Create a table with namespace=default and table qualifier=t1
  hbase> create 't1', {NAME => 'f1'}, {NAME => 'f2'}, {NAME => 'f3'}
  hbase> # The above in shorthand would be the following:
  hbase> create 't1', 'f1', 'f2', 'f3'
  hbase> create 't1', {NAME => 'f1', VERSIONS => 1, TTL => 2592000, BLOCKCACHE => true}
  hbase> create 't1', {NAME => 'f1', CONFIGURATION => {'hbase.hstore.blockingStoreFiles' => '10'}}
  
Table configuration options can be put at the end.
Examples:

  hbase> create 'ns1:t1', 'f1', SPLITS => ['10', '20', '30', '40']
  hbase> create 't1', 'f1', SPLITS => ['10', '20', '30', '40']
  hbase> create 't1', 'f1', SPLITS_FILE => 'splits.txt', OWNER => 'johndoe'
  hbase> create 't1', {NAME => 'f1', VERSIONS => 5}, METADATA => { 'mykey' => 'myvalue' }
  hbase> # Optionally pre-split the table into NUMREGIONS, using
  hbase> # SPLITALGO ("HexStringSplit", "UniformSplit" or classname)
  hbase> create 't1', 'f1', {NUMREGIONS => 15, SPLITALGO => 'HexStringSplit'}
  hbase> create 't1', 'f1', {NUMREGIONS => 15, SPLITALGO => 'HexStringSplit', REGION_REPLICATION => 2, CONFIGURATION => {'hbase.hregion.scan.loadColumnFamiliesOnDemand' => 'true'}}

You can also keep around a reference to the created table:

  hbase> t1 = create 't1', 'f1'

Which gives you a reference to the table named 't1', on which you can then
call methods.


hbase(main):002:0> [/mw_shl_code]


解决方法

1. 首先获取 HBase Server 的 kgt

[mw_shl_code=shell,true][root@m1 ~]# klist -ket /etc/security/keytabs/hbase.service.keytab
Keytab name: FILE:/etc/security/keytabs/hbase.service.keytab
KVNO Timestamp           Principal
---- ------------------- ------------------------------------------------------
   1 11/16/2016 13:50:24 hbase/m1.node.hadoop@TENDATA.CN (des-cbc-md5)
   1 11/16/2016 13:50:24 hbase/m1.node.hadoop@TENDATA.CN (des3-cbc-sha1)
   1 11/16/2016 13:50:24 hbase/m1.node.hadoop@TENDATA.CN (arcfour-hmac)
   1 11/16/2016 13:50:24 hbase/m1.node.hadoop@TENDATA.CN (aes256-cts-hmac-sha1-96)
   1 11/16/2016 13:50:24 hbase/m1.node.hadoop@TENDATA.CN (aes128-cts-hmac-sha1-96)
[root@m1 ~]# kinit -kt /etc/security/keytabs/hbase.service.keytab hbase/m1.node.hadoop@TENDATA.CN
[root@m1 ~]# klist
Ticket cache: FILE:/tmp/krb5cc_0
Default principal: hbase/m1.node.hadoop@TENDATA.CN


Valid starting       Expires              Service principal
09/20/2017 16:23:53  09/21/2017 16:23:53  krbtgt/TENDATA.CN@TENDATA.CN
[root@m1 ~]#
[/mw_shl_code]

2. 登录到 HBase Shell 中授权普通用户使用 HBase

[mw_shl_code=shell,true]hbase(main):001:0> grant 'tendata', 'RWXCA'
0 row(s) in 0.3910 seconds

hbase(main):002:0> [/mw_shl_code]

3. 退出 HBase ,获取普通用户的 kgt 后登录 HBase Shell 就可以创建表了

[mw_shl_code=shell,true][root@m1 ~]# hbase shell
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 1.1.2.2.5.3.0-37, rcb8c969d1089f1a34e9df11b6eeb96e69bcf878d, Tue Nov 29 18:48:22 UTC 2016


hbase(main):001:0>
hbase(main):002:0*
hbase(main):003:0* create 't1', 'f1'
0 row(s) in 2.5960 seconds


=> Hbase::Table - t1
hbase(main):004:0> list
TABLE                                                                                                   
t1                                                                                                            
1 row(s) in 0.0200 seconds


=> ["t1"]
hbase(main):005:0>
[/mw_shl_code]


注意这里有个关键点,也是在第一个帖子中没有提到的。我也因为这个问题纠结了好久
就是在使用  HBase Service 获取 kgt 的时候 加上域
[mw_shl_code=shell,true][root@m1 ~]# kinit -kt /etc/security/keytabs/hbase.service.keytab hbase/m1.node.hadoop@TENDATA.CN[/mw_shl_code]

已有(1)人评论

跳转到指定楼层
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条