較新版本的Apache HBase(0.92版本以後)支持客戶端的可選SASL身份驗證。
本節介紹如何設置Apache HBase和客戶端,以便用戶訪問HBase資源。
簡單與安全訪問
以下部分介紹如何設置用戶訪問Apache HBase的一種簡單方法。簡單的用戶訪問不是一種運行HBase的安全方法。此方法用於防止用戶犯錯。它可用於在開發系統上模擬訪問控制,而無需設置Kerberos。
此方法不用於防止惡意或黑客入侵。為了使HBase能夠抵禦這些類型的攻擊,您必須配置HBase進行安全操作。請參閱客戶端安全訪問Apache HBase部分並完成此處描述的所有步驟。
簡單用戶訪問操作的服務器端配置
將以下內容添加到群集中每個服務器計算機上的hbase-site.xml文件中:
<code><
property
><
name
>hbase.security.authenticationname
><
value
>simplevalue
>property
><
property
><
name
>hbase.security.authorizationname
><
value
>truevalue
>property
><
property
><
name
>hbase.coprocessor.master.classesname
><
value
>org.apache.hadoop.hbase.security.access.AccessControllervalue
>property
><
property
><
name
>hbase.coprocessor.region.classesname
><
value
>org.apache.hadoop.hbase.security.access.AccessControllervalue
>property
><
property
><
name
>hbase.coprocessor.regionserver.classesname
><
value
>org.apache.hadoop.hbase.security.access.AccessControllervalue
>property
>/<code>
對於Apache HBase 0.94版本,請將以下內容添加到集群中每臺服務器計算機上的hbase-site.xml文件中:
<code><
property
><
name
>hbase.rpc.enginename
><
value
>org.apache.hadoop.hbase.ipc.SecureRpcEnginevalue
>property
><
property
><
name
>hbase.coprocessor.master.classesname
><
value
>org.apache.hadoop.hbase.security.access.AccessControllervalue
>property
><
property
><
name
>hbase.coprocessor.region.classesname
><
value
>org.apache.hadoop.hbase.security.access.AccessControllervalue
>property
>/<code>
部署這些配置更改時,需要完全關閉並重新啟動HBase服務。
簡單用戶訪問操作的客戶端配置
將以下內容添加到每個客戶端上的hbase-site.xml文件中:
<code><
property
><
name
>hbase.security.authenticationname
><
value
>simplevalue
>property
>/<code>
對於Apache HBase 0.94版本,請將以下內容添加到集群中每臺服務器計算機上的hbase-site.xml文件中:
<code><
property
><
name
>hbase.rpc.enginename
><
value
>org.apache.hadoop.hbase.ipc.SecureRpcEnginevalue
>property
>/<code>
請注意,如果客戶端和服務器端站點文件中的hbase.security.authentication不匹配,則客戶端將無法與群集進行通信。
簡單用戶訪問操作的客戶端配置 - Thrift Gateway
用戶將需要訪問Thrift網關。例如,要為Thrift API用戶提供thrift_server管理訪問,你可能需要使用如下的命令:
<code>grant
'thrift_server'
,'RWCA'
/<code>
Thrift網關將使用提供的憑證向HBase進行身份驗證。Thrift網關本身不會執行任何身份驗證。所有通過Thrift網關訪問的客戶端都將使用Thrift網關的憑證並擁有其權限。
簡單用戶訪問操作的客戶端配置 - REST Gateway
REST網關將使用提供的憑證對HBase進行身份驗證。REST網關本身不會執行任何身份驗證。所有通過REST網關訪問的客戶端都將使用REST網關的憑證並擁有其權限。
REST網關用戶將需要訪問。例如,要為REST API用戶提供rest_server管理訪問,你可能需要使用如下的命令:
<code>grant
'rest_server'
,'RWCA'
/<code>