初始化连接加载配置参数,这里只创建连接,具体操作hbase的api没有变化
static { try{ Configuration conf = HBaseConfiguration.create();conf.addResource(new Path("config/hbase-site.xml"));//读取配置文件conf.set("hadoop.security.authentication", "kerberos");//启用kerberosUserGroupInformation.setConfiguration(conf);UserGroupInformation.loginUserFromKeytab("hdfs@JAST.COM", "/root/jast/hbase-kerberos/config/hdfs.keytab");//读取hdfskeytabconnection = ConnectionFactory.createConnection(conf); }catch (Exception e){ e.printStackTrace(); } }
hbase-site.xml 配置如下
<?xml version="1.0" encoding="UTF-8"?><!--Autogenerated by Cloudera Manager-->
<configuration><property><name>hbase.rootdir</name><value>hdfs://hostname006.zh:8020/hbase</value></property><property><name>hbase.client.write.buffer</name><value>2097152</value></property><property><name>hbase.client.pause</name><value>100</value></property><property><name>hbase.client.retries.number</name><value>35</value></property><property><name>hbase.client.scanner.caching</name><value>100</value></property><property><name>hbase.client.keyvalue.maxsize</name><value>10485760</value></property><property><name>hbase.ipc.client.allowsInterrupt</name><value>true</value></property><property><name>hbase.client.primaryCallTimeout.get</name><value>10</value></property><property><name>hbase.client.primaryCallTimeout.multiget</name><value>10</value></property><property><name>hbase.fs.tmp.dir</name><value>/user/${user.name}/hbase-staging</value></property><property><name>hbase.client.scanner.timeout.period</name><value>60000</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,org.apache.hadoop.hbase.security.token.TokenProvider,org.apache.hadoop.hbase.security.access.SecureBulkLoadEndpoint</value></property><property><name>hbase.regionserver.thrift.http</name><value>true</value></property><property><name>hbase.thrift.ssl.enabled</name><value>false</value></property><property><name>hbase.thrift.support.proxyuser</name><value>true</value></property><property><name>hbase.rpc.timeout</name><value>60000</value></property><property><name>hbase.snapshot.enabled</name><value>true</value></property><property><name>hbase.snapshot.master.timeoutMillis</name><value>60000</value></property><property><name>hbase.snapshot.region.timeout</name><value>60000</value></property><property><name>hbase.snapshot.master.timeout.millis</name><value>60000</value></property><property><name>hbase.security.authentication</name><value>kerberos</value></property><property><name>hbase.rpc.protection</name><value>authentication</value></property><property><name>zookeeper.session.timeout</name><value>60000</value></property><property><name>zookeeper.znode.parent</name><value>/hbase</value></property><property><name>zookeeper.znode.rootserver</name><value>root-region-server</value></property><property><name>hbase.zookeeper.quorum</name><value>hostname006.zh,hostname008.zh,hostname007.zh</value></property><property><name>hbase.zookeeper.property.clientPort</name><value>2181</value></property><property><name>hbase.master.kerberos.principal</name><value>hbase/_HOST@IZHONGHONG.COM</value></property><property><name>hbase.regionserver.kerberos.principal</name><value>hbase/_HOST@IZHONGHONG.COM</value></property><property><name>hadoop.security.authorization</name><value>true</value></property><property><name>hbase.rest.ssl.enabled</name><value>false</value></property><property><name>phoenix.schema.isNamespaceMappingEnabled</name><value>true</value></property><property><name>phoenix.schema.mapSystemTablesToNamespace</name><value>true</value></property><property><name>hbase.regionserver.wal.codec</name><value>org.apache.hadoop.hbase.regionserver.wal.IndexedWALEditCodec</value></property><property><name>phoenix.query.timeoutMs</name><value>10800000</value></property><property><name>index.builder.threads.keepalivetime</name><value>1200000</value></property><property><name>index.write.threads.keepalivetime</name><value>1200000</value></property><property><name>phoenix.query.maxServerCacheBytes</name><value>1024000000</value></property>
</configuration>