无authentication有authorization模式下使用hbase
hbase默认情况下对客户端不做任何权限控制,这对于很多应用场景是不适用的。而kerberos的SASL验证方式比较啰嗦(主要是增加服务端、客户端的认证配置),而且Secure Access to Apache HBase会对性能有%10左右的损失,这对于轻安全重性能的场景下同样不适合。“Simple User Access to Apache HBase”是一种无authentication有authorization的使用模式,我们可以通过对预定义的用户进行授权,而不需要预先做身份验证。这样可以做到不需增加身份验证的配置工作,而对不同用户的访问权限进行控制与隔离。
实验环境:
hbase版本1.0.2
hadoop版本2.7.1
jdk版本 1.7
服务端侧配置
Add the following to the hbase-site.xml file on every server machine in the cluster:
<property> <name>hbase.security.authentication</name> <value>simple</value> </property> <property> <name>hbase.security.authorization</name> <value>true</value> </property> <property> <name>hbase.coprocessor.master.classes</name> <value>org.apache.hadoop.hbase.security.access.AccessController</value> </property> <property> <name>hbase.coprocessor.region.classes</name> <value>org.apache.hadoop.hbase.security.access.AccessController</value> </property> <property> <name>hbase.coprocessor.regionserver.classes</name> <value>org.apache.hadoop.hbase.security.access.AccessController</value> </property>
客户端侧配置
Add the following to the hbase-site.xml file on every client:
<property> <name>hbase.security.authentication</name> <value>simple</value> </property>
默认即为simple模式,因此不配这个也没关系。
在服务端增加访问用户(即运行客户端进程的当前系统用户)的权限配置,
如,
注意:此处的用户,即为客户端进程运行时进程所属的系统用户。因此没有用户添加的过程,可以直接对用户授权。
客户端代码示例,
pom.xml
<dependencies> <dependency> <groupId>org.apache.hbase</groupId> <artifactId>hbase-client</artifactId> <version>1.0.2</version> </dependency> </dependencies>
hbase-site.xml
<?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <configuration> <property> <name>hbase.security.authentication</name> <value>simple</value> </property> <property> <name>hbase.zookeeper.quorum</name> <value>zknode1,zknode2,zknode3</value> </property> <property> <name>zookeeper.znode.parent</name> <value>/bda/hbase3</value> </property> </configuration>
client代码,
package com.test; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.HColumnDescriptor; import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.Admin; import org.apache.hadoop.hbase.client.Connection; import org.apache.hadoop.hbase.client.ConnectionFactory; public class HBaseTest { public static void main(String args[]) { Connection connection = null; Configuration configuration = HBaseConfiguration.create(); try { TableName tableName = TableName.valueOf("ziyang_client_test"); connection = ConnectionFactory.createConnection(configuration); Admin hBaseAdmin = connection.getAdmin(); if (hBaseAdmin.isTableAvailable(tableName)) { hBaseAdmin.disableTable(tableName); hBaseAdmin.deleteTable(tableName); System.out.println(tableName + " is exist,detele...."); } HTableDescriptor tableDescriptor = new HTableDescriptor(tableName); tableDescriptor.addFamily(new HColumnDescriptor("column1")); tableDescriptor.addFamily(new HColumnDescriptor("column2")); tableDescriptor.addFamily(new HColumnDescriptor("column3")); hBaseAdmin.createTable(tableDescriptor); System.out.println(tableName + " created...."); } catch (Exception e) { e.printStackTrace(); } finally { if(connection != null){ connection.close(); } } } }
相关推荐
apache hbase reference guide version 3.00 pdf,hbase查询指导第三版pdf
Apache HBase™是Hadoop数据库,这是一个分布式,可伸缩的大数据存储。当您需要对大数据进行随机,实时的读/写访问时,请使用Apache HBase™。该项目的目标是在商品硬件群集上托管超大型表-数十亿行X数百万列。...
Apache HBase at DIDI
Apache HBase 2.1.5 API chm格式文档 hbase-apache离线官方文档
Apache HBase Primer
Apache HBase™ 参考指南 2 官方文档中文版
Chapter 2: Apache HBase and HDFS Chapter 3: Application Characteristics Part II: Data Model Chapter 4: Physical Storage Chapter 5: Column Family and Column Qualifi er Chapter 6: Row ...
Apache HBase ™ Reference Guide pdf 英文版 官方文档
Hbase相关技术(官网手册),基于此手册可开发相关Hbase应用程序。
Apache HBase技术参考手册
Apache Hbase面试题
hbase的官方文档,比较详细,值得一看
Apache HBase开发者教程 100多页PPT 2016 strata+Hadoop大会资料
Apache HBase发布的1.0版本应用指南. HBase 为列数据库, 在大数据应用背景下提供快速的数据查询. 也是作为 cubeless BI 的支撑.
Learn the fundamental foundations and concepts of the Apache HBase (NoSQL) open source database. It covers the HBase data model, architecture, schema design, API, and administration.Apache HBase is ...
apache hbase reference guide
Learn the fundamental foundations and concepts of the Apache HBase (NoSQL) open source database. It covers the HBase data model, architecture, schema design, API, and administration. Apache HBase is ...
藏经阁-Apache Spark – Apache HBase Connector.pdf
藏经阁-Apache Spark -Apache HBase Con.pdf