1.连接kerberos代码示例

1.1测试方法

package com.ztesoft.testClusterCdh;import java.security.PrivilegedExceptionAction;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import java.util.Properties;import org.apache.commons.lang.StringUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.security.UserGroupInformation;import com.ztesoft.util.PropertiesUtil;/*** Hello world!**/
public class App {public static void main(String[] args) throws Exception {Connection conn = getConnection();System.out.println("获取连接成功:" + conn);// 执行的sqlfinal String hql = PropertiesUtil.getProperty("hql", "");System.out.println("hql=" + hql);Statement stmt = conn.createStatement();final String queue = PropertiesUtil.getProperty("queue");if (StringUtils.isNotBlank(queue)) {stmt.execute(" set mapreduce.job.queuename=" + queue);}String[] hqls = hql.split(";");for (int i = 0; i < hqls.length; i++) {String currentHql = hqls[i];if (currentHql.trim().endsWith(";")) {currentHql = currentHql.trim().substring(0, currentHql.length() - 1);}stmt.execute(currentHql);}}/*** 进行kerberos认证获取连接* * @return* @throws IOException* @throws InterruptedException*/private static Connection getConnection() throws Exception {// final String tenantCode = "bdp/admin@NBDP.COM";// final String keytabPath = "D:\\bdp.keytab";// final String realm = "NBDP.COM";// final String kdc = "host165";// final String krb5ConfDir = "";//// final String queue = "";// final String url = "";// final String password = "";final String tenantCode = PropertiesUtil.getProperty("tenantCode", "");final String keytabPath = PropertiesUtil.getProperty("keytabPath", "");final String realm = PropertiesUtil.getProperty("realm", "");final String kdc = PropertiesUtil.getProperty("kdc", "");final String krb5ConfDir = PropertiesUtil.getProperty("krb5ConfDir", "");final String queue = PropertiesUtil.getProperty("queue", "");final String url = PropertiesUtil.getProperty("url", "");final String user = PropertiesUtil.getProperty("user", "");final String password = PropertiesUtil.getProperty("password", "");System.setProperty("sun.security.krb5.debug", "false");System.setProperty("java.security.krb5.kdc", kdc);System.setProperty("java.security.krb5.realm", realm);System.out.println("tenantCode=" + tenantCode + ",keytabPath=" + keytabPath + ",realm=" + realm + ",kdc=" + kdc+ ",krb5ConfDir=" + krb5ConfDir + ",queue=" + queue + ",url=" + url + ",user=" + user + ",password="+ password);Configuration conf = new Configuration();// 设置连接信息conf.set("hadoop.security.authentication", "Kerberos");conf.set("hadoop.security.authorization", "true");if (StringUtils.isNotEmpty(krb5ConfDir)) {System.setProperty("java.security.krb5.conf", krb5ConfDir);}UserGroupInformation.setConfiguration(conf);UserGroupInformation userGroupInformation = UserGroupInformation.loginUserFromKeytabAndReturnUGI(tenantCode,keytabPath);UserGroupInformation.setLoginUser(userGroupInformation);boolean hasKerberosCredentials = userGroupInformation.hasKerberosCredentials();if (!hasKerberosCredentials) {throw new RuntimeException("kerberos认证失败!");} else {System.out.println("kerberos认证成功!");}final Properties properties = new Properties();properties.setProperty("user", user);properties.setProperty("password", password);final String driverName = PropertiesUtil.getProperty("driverName", "org.apache.hive.jdbc.HiveDriver");Class.forName(driverName);Connection connection = userGroupInformation.doAs(new PrivilegedExceptionAction<Connection>() {public Connection run() throws Exception {return DriverManager.getConnection(url.toString(), properties);}});return connection;}}

1.2工具类

package com.ztesoft.util;import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;public class PropertiesUtil {private static Logger logger = LoggerFactory.getLogger(PropertiesUtil.class);private static Properties prop = null;static {loadProperties("config.properties");}private static synchronized void loadProperties(String fileName) {prop = new Properties();InputStream in = null;if (StringUtils.isNotEmpty(fileName)) {if (!fileName.endsWith(".properties")) {fileName = fileName + ".properties";}try {in = new BufferedInputStream(new FileInputStream(new File(fileName)));} catch (FileNotFoundException var16) {logger.info("{} 包外配置文件不存在,继续加载包内配置文件", fileName);}}try {if (in == null) {in = PropertiesUtil.class.getClassLoader().getResourceAsStream(fileName);}prop.load((InputStream) in);} catch (FileNotFoundException var14) {logger.error("{} 配置文件不存在", fileName);} catch (IOException var15) {logger.error(var15.getMessage());} finally {if (in != null) {try {((InputStream) in).close();} catch (IOException var13) {logger.error(var13.getMessage());}}}}public static Map getProperties() {Map properties = new HashMap();Iterator<Map.Entry<Object, Object>> it = prop.entrySet().iterator();while (it.hasNext()) {Map.Entry<Object, Object> entry = it.next();properties.put(entry.getKey().toString(), entry.getValue());}return properties;}public static String getProperty(String property) {return prop.getProperty(property);}public static String getProperty(String property, String defaultValue) {String value = prop.getProperty(property);if (value == null || "".equals(value)) {value = defaultValue;}return value;}
}

1.3配置文件

[doda@host166 mytest]$ more config.properties 
tenantCode=bdp/admin@NBDP.COM
keytabPath=/home/keydir/bdp/bdp.keytab
realm=NBDP.COM
kdc=host165
krb5ConfDir=/etc/krb5.conf
queue=default
url=jdbc:hive2://172.21.72.165:10000/smart_test;principal=hive/host165@NBDP.COM;auth=kerberos
user=bdp/admin@NBDP.COM
password=
hql=create table smart_test.hdm(a string)

2.maven依赖引入

2.1集群为cdh5.8版本全部依赖

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.ztesoft</groupId><artifactId>testClusterCdh</artifactId><version>0.0.1-SNAPSHOT</version><packaging>jar</packaging><name>testClusterCdh</name><url>http://maven.apache.org</url><repositories><repository><id>cdh.repo</id><url>https://repository.cloudera.com/artifactory/cloudera-repos</url><name>Cloudera Repository</name></repository><repository><id>nexus</id><name>Ztesoft-GZ Nexus Repository</name><url>http://10.45.47.168:8081/nexus/content/groups/public</url></repository><repository><id>cloudera-local</id><name>cloudera-local Repository</name><url>http://10.45.47.168:8081/nexus/content/repositories/cloudera</url></repository><repository><id>releases</id><url>http://172.16.22.184:8081/nexus/content/repositories/releases/</url></repository><repository><id>thirdparty</id><url>http://10.45.47.168:8081/nexus/content/repositories/thirdparty</url></repository></repositories><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><hadoop.version>2.6.0-cdh5.8.4</hadoop.version><hbase.version>1.2.0-cdh5.8.4</hbase.version><hive.version>1.1.0-cdh5.8.4</hive.version><cloudera.version>5.10.0</cloudera.version><zk.version>3.4.5-cdh5.8.4</zk.version><phoenix.version>4.13.1-cdh5.8.4</phoenix.version><curator.version>2.12.0</curator.version></properties><dependencies><dependency><groupId>org.apache.hbase</groupId><artifactId>hbase-server</artifactId><version>${hbase.version}</version><exclusions><exclusion><groupId>org.mortbay.jetty</groupId><artifactId>servlet-api-2.5</artifactId></exclusion><exclusion><groupId>org.mortbay.jetty</groupId><artifactId>jsp-api-2.1</artifactId></exclusion><exclusion><groupId>javax.servlet</groupId><artifactId>servlet-api</artifactId></exclusion><exclusion><artifactId>slf4j-log4j12</artifactId><groupId>org.slf4j</groupId></exclusion><exclusion><artifactId>curator-framework</artifactId><groupId>org.apache.curator</groupId></exclusion><exclusion><artifactId>protobuf-java</artifactId><groupId>com.google.protobuf</groupId></exclusion></exclusions></dependency><dependency><groupId>org.apache.hbase</groupId><artifactId>hbase-thrift</artifactId><version>${hbase.version}</version><exclusions><exclusion><groupId>org.mortbay.jetty</groupId><artifactId>servlet-api-2.5</artifactId></exclusion><exclusion><groupId>org.mortbay.jetty</groupId><artifactId>jsp-api-2.1</artifactId></exclusion><exclusion><groupId>javax.servlet</groupId><artifactId>servlet-api</artifactId></exclusion><exclusion><artifactId>protobuf-java</artifactId><groupId>com.google.protobuf</groupId></exclusion></exclusions></dependency><dependency><groupId>org.apache.hbase</groupId><artifactId>hbase-shell</artifactId><version>${hbase.version}</version></dependency><dependency><groupId>org.apache.hbase</groupId><artifactId>hbase-protocol</artifactId><version>${hbase.version}</version><exclusions><exclusion><artifactId>protobuf-java</artifactId><groupId>com.google.protobuf</groupId></exclusion></exclusions></dependency><dependency><groupId>org.apache.hbase</groupId><artifactId>hbase-client</artifactId><version>${hbase.version}</version><exclusions><exclusion><artifactId>protobuf-java</artifactId><groupId>com.google.protobuf</groupId></exclusion></exclusions></dependency><dependency><groupId>org.apache.hbase</groupId><artifactId>hbase-hadoop-compat</artifactId><version>${hbase.version}</version></dependency><dependency><groupId>org.apache.hbase</groupId><artifactId>hbase-common</artifactId><version>${hbase.version}</version><exclusions><exclusion><artifactId>protobuf-java</artifactId><groupId>com.google.protobuf</groupId></exclusion></exclusions></dependency><dependency><groupId>org.apache.hbase</groupId><artifactId>hbase-it</artifactId><version>${hbase.version}</version></dependency><dependency><groupId>org.apache.hbase</groupId><artifactId>hbase-examples</artifactId><version>${hbase.version}</version><exclusions><exclusion><artifactId>protobuf-java</artifactId><groupId>com.google.protobuf</groupId></exclusion></exclusions></dependency><dependency><groupId>org.apache.hbase</groupId><artifactId>hbase-prefix-tree</artifactId><version>${hbase.version}</version><exclusions><exclusion><artifactId>protobuf-java</artifactId><groupId>com.google.protobuf</groupId></exclusion></exclusions></dependency><dependency><groupId>org.apache.hbase</groupId><artifactId>hbase-assembly</artifactId><version>${hbase.version}</version><type>pom</type><exclusions><exclusion><artifactId>slf4j-log4j12</artifactId><groupId>org.slf4j</groupId></exclusion><exclusion><artifactId>protobuf-java</artifactId><groupId>com.google.protobuf</groupId></exclusion></exclusions></dependency><dependency><groupId>com.google.protobuf</groupId><artifactId>protobuf-java</artifactId><version>2.5.0</version></dependency><!-- hive --><dependency><groupId>org.apache.hive</groupId><artifactId>hive-jdbc</artifactId><version>${hive.version}</version><exclusions><exclusion><artifactId>httpcore</artifactId><groupId>org.apache.httpcomponents</groupId></exclusion><exclusion><artifactId>hive-exec</artifactId><groupId>org.apache.hive</groupId></exclusion><exclusion><groupId>org.eclipse.jetty.aggregate</groupId><artifactId>*</artifactId></exclusion><exclusion><artifactId>slf4j-log4j12</artifactId><groupId>org.slf4j</groupId></exclusion><exclusion><groupId>org.apache.curator</groupId><artifactId>curator-client</artifactId></exclusion><exclusion><artifactId>curator-framework</artifactId><groupId>org.apache.curator</groupId></exclusion><exclusion><artifactId>protobuf-java</artifactId><groupId>com.google.protobuf</groupId></exclusion></exclusions></dependency><dependency><groupId>org.apache.hive</groupId><artifactId>hive-service</artifactId><version>${hive.version}</version><exclusions><exclusion><artifactId>httpcore</artifactId><groupId>org.apache.httpcomponents</groupId></exclusion><exclusion><artifactId>hive-exec</artifactId><groupId>org.apache.hive</groupId></exclusion><exclusion><groupId>org.eclipse.jetty.aggregate</groupId><artifactId>*</artifactId></exclusion><exclusion><artifactId>slf4j-log4j12</artifactId><groupId>org.slf4j</groupId></exclusion><exclusion><artifactId>curator-framework</artifactId><groupId>org.apache.curator</groupId></exclusion><exclusion><artifactId>curator-recipes</artifactId><groupId>org.apache.curator</groupId></exclusion></exclusions></dependency><dependency><groupId>org.apache.hadoop</groupId><artifactId>hadoop-common</artifactId><version>${hadoop.version}</version><exclusions><exclusion><artifactId>httpcore</artifactId><groupId>org.apache.httpcomponents</groupId></exclusion><exclusion><artifactId>hive-exec</artifactId><groupId>org.apache.hive</groupId></exclusion><exclusion><groupId>org.eclipse.jetty.aggregate</groupId><artifactId>*</artifactId></exclusion><exclusion><groupId>javax.servlet</groupId><artifactId>servlet-api</artifactId></exclusion><exclusion><groupId>org.apache.curator</groupId><artifactId>curator-client</artifactId></exclusion><exclusion><artifactId>slf4j-log4j12</artifactId><groupId>org.slf4j</groupId></exclusion><exclusion><artifactId>curator-recipes</artifactId><groupId>org.apache.curator</groupId></exclusion><exclusion><artifactId>protobuf-java</artifactId><groupId>com.google.protobuf</groupId></exclusion></exclusions></dependency><!-- ######################################################### --><dependency><groupId>org.apache.solr</groupId><artifactId>solr-solrj</artifactId><version>4.4.0</version><type>jar</type></dependency><dependency><groupId>org.apache.zookeeper</groupId><artifactId>zookeeper</artifactId><version>${zk.version}</version><exclusions><exclusion><artifactId>slf4j-log4j12</artifactId><groupId>org.slf4j</groupId></exclusion></exclusions></dependency><dependency><groupId>com.cloudera.api</groupId><artifactId>cloudera-manager-api</artifactId><version>${cloudera.version}</version><exclusions><exclusion><groupId>org.apache.cxf</groupId><artifactId>cxf-rt-frontend-jaxrs</artifactId></exclusion><exclusion><groupId>javax.servlet</groupId><artifactId>servlet-api</artifactId></exclusion></exclusions></dependency><dependency><groupId>org.apache.phoenix</groupId><artifactId>phoenix-core</artifactId><version>${phoenix.version}</version><exclusions><exclusion><groupId>javax.servlet</groupId><artifactId>servlet-api</artifactId></exclusion><exclusion><artifactId>slf4j-log4j12</artifactId><groupId>org.slf4j</groupId></exclusion><exclusion><artifactId>protobuf-java</artifactId><groupId>com.google.protobuf</groupId></exclusion></exclusions></dependency><dependency><groupId>org.apache.curator</groupId><artifactId>curator-client</artifactId><version>${curator.version}</version></dependency><dependency><groupId>org.apache.curator</groupId><artifactId>curator-framework</artifactId><version>${curator.version}</version></dependency><dependency><groupId>org.apache.curator</groupId><artifactId>curator-recipes</artifactId><version>${curator.version}</version><exclusions><exclusion><artifactId>curator-framework</artifactId><groupId>org.apache.curator</groupId></exclusion></exclusions></dependency></dependencies><build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><configuration><source>1.8</source><target>1.8</target></configuration></plugin><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><configuration><!-- 默认启动 程序 --><mainClass>com.ztesoft.testClusterCdh.App</mainClass><layout>JAR</layout><addResources>true</addResources></configuration><executions><execution><goals><goal>repackage</goal></goals></execution></executions></plugin></plugins></build>
</project>

2.2集群为bc30依赖引入

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.ztesoft</groupId><artifactId>testClusterHhht</artifactId><version>0.0.1-SNAPSHOT</version><packaging>jar</packaging><name>testClusterHhht</name><url>http://maven.apache.org</url><repositories><repository><id>cdh.repo</id><url>https://repository.cloudera.com/artifactory/cloudera-repos</url><name>Cloudera Repository</name></repository><repository><id>nexus</id><name>Ztesoft-GZ Nexus Repository</name><url>http://10.45.47.168:8081/nexus/content/groups/public</url></repository><repository><id>cloudera-local</id><name>cloudera-local Repository</name><url>http://10.45.47.168:8081/nexus/content/repositories/cloudera</url></repository><repository><id>releases</id><url>http://172.16.22.184:8081/nexus/content/repositories/releases/</url></repository><repository><id>thirdparty</id><url>http://10.45.47.168:8081/nexus/content/repositories/thirdparty</url></repository></repositories><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><hadoop.version>3.1.0</hadoop.version><hbase.version>2.1.2</hbase.version><hive.version>3.1.0</hive.version><hbase-prefix-tree.version>2.0.0-alpha4</hbase-prefix-tree.version><zk.version>3.4.13</zk.version><phoenix.version>5.0.0-HBase-2.0</phoenix.version><curator.version>2.12.0</curator.version></properties><dependencies><!-- hadoop --><dependency><groupId>org.apache.hadoop</groupId><artifactId>hadoop-distcp</artifactId><version>${hadoop.version}</version><scope>provided</scope></dependency><dependency><groupId>org.apache.hadoop</groupId><artifactId>hadoop-client</artifactId><version>${hadoop.version}</version></dependency><dependency><groupId>org.apache.hadoop</groupId><artifactId>hadoop-mapreduce-client-app</artifactId><version>${hadoop.version}</version><exclusions><exclusion><artifactId>slf4j-log4j12</artifactId><groupId>org.slf4j</groupId></exclusion><exclusion><artifactId>protobuf-java</artifactId><groupId>com.google.protobuf</groupId></exclusion></exclusions></dependency><dependency><groupId>org.apache.hadoop</groupId><artifactId>hadoop-mapreduce-client-common</artifactId><version>${hadoop.version}</version><exclusions><exclusion><artifactId>slf4j-log4j12</artifactId><groupId>org.slf4j</groupId></exclusion><exclusion><artifactId>protobuf-java</artifactId><groupId>com.google.protobuf</groupId></exclusion></exclusions></dependency><dependency><groupId>org.apache.hadoop</groupId><artifactId>hadoop-auth</artifactId><version>${hadoop.version}</version><exclusions><exclusion><artifactId>slf4j-log4j12</artifactId><groupId>org.slf4j</groupId></exclusion><exclusion><artifactId>curator-client</artifactId><groupId>org.apache.curator</groupId></exclusion><exclusion><artifactId>curator-framework</artifactId><groupId>org.apache.curator</groupId></exclusion><exclusion><artifactId>zookeeper</artifactId><groupId>org.apache.zookeeper</groupId></exclusion></exclusions></dependency><dependency><groupId>org.apache.hadoop</groupId><artifactId>hadoop-annotations</artifactId><version>${hadoop.version}</version></dependency><dependency><groupId>org.apache.hadoop</groupId><artifactId>hadoop-mapreduce-client-shuffle</artifactId><version>${hadoop.version}</version><exclusions><exclusion><artifactId>slf4j-log4j12</artifactId><groupId>org.slf4j</groupId></exclusion><exclusion><artifactId>curator-framework</artifactId><groupId>org.apache.curator</groupId></exclusion><exclusion><artifactId>curator-recipes</artifactId><groupId>org.apache.curator</groupId></exclusion><exclusion><artifactId>hadoop-yarn-registry</artifactId><groupId>org.apache.hadoop</groupId></exclusion><exclusion><artifactId>zookeeper</artifactId><groupId>org.apache.zookeeper</groupId></exclusion><exclusion><artifactId>protobuf-java</artifactId><groupId>com.google.protobuf</groupId></exclusion></exclusions></dependency><dependency><groupId>org.apache.hadoop</groupId><artifactId>hadoop-yarn-registry</artifactId><version>${hadoop.version}</version><exclusions><exclusion><artifactId>curator-framework</artifactId><groupId>org.apache.curator</groupId></exclusion><exclusion><artifactId>curator-recipes</artifactId><groupId>org.apache.curator</groupId></exclusion><exclusion><artifactId>zookeeper</artifactId><groupId>org.apache.zookeeper</groupId></exclusion></exclusions></dependency><dependency><groupId>org.apache.hadoop</groupId><artifactId>hadoop-yarn-api</artifactId><version>${hadoop.version}</version><exclusions><exclusion><artifactId>protobuf-java</artifactId><groupId>com.google.protobuf</groupId></exclusion></exclusions></dependency><dependency><groupId>org.apache.hadoop</groupId><artifactId>hadoop-mapreduce-client-jobclient</artifactId><version>${hadoop.version}</version><scope>provided</scope><exclusions><exclusion><artifactId>slf4j-log4j12</artifactId><groupId>org.slf4j</groupId></exclusion><exclusion><artifactId>protobuf-java</artifactId><groupId>com.google.protobuf</groupId></exclusion></exclusions></dependency><dependency><groupId>org.apache.hadoop</groupId><artifactId>hadoop-mapreduce-client-core</artifactId><version>${hadoop.version}</version><exclusions><exclusion><artifactId>slf4j-log4j12</artifactId><groupId>org.slf4j</groupId></exclusion><exclusion><artifactId>protobuf-java</artifactId><groupId>com.google.protobuf</groupId></exclusion></exclusions></dependency><dependency><groupId>org.apache.hadoop</groupId><artifactId>hadoop-common</artifactId><version>${hadoop.version}</version><exclusions><exclusion><artifactId>httpcore</artifactId><groupId>org.apache.httpcomponents</groupId></exclusion><exclusion><artifactId>hive-exec</artifactId><groupId>org.apache.hive</groupId></exclusion><exclusion><groupId>org.eclipse.jetty.aggregate</groupId><artifactId>*</artifactId></exclusion><exclusion><artifactId>servlet-api</artifactId><groupId>javax.servlet</groupId></exclusion><exclusion><artifactId>jasper-compiler</artifactId><groupId>tomcat</groupId></exclusion><exclusion><artifactId>jasper-runtime</artifactId><groupId>tomcat</groupId></exclusion><exclusion><artifactId>jsp-api</artifactId><groupId>javax.servlet.jsp</groupId></exclusion><exclusion><artifactId>slf4j-log4j12</artifactId><groupId>org.slf4j</groupId></exclusion><exclusion><artifactId>curator-recipes</artifactId><groupId>org.apache.curator</groupId></exclusion><exclusion><artifactId>zookeeper</artifactId><groupId>org.apache.zookeeper</groupId></exclusion><exclusion><artifactId>protobuf-java</artifactId><groupId>com.google.protobuf</groupId></exclusion></exclusions></dependency><dependency><groupId>org.apache.hadoop</groupId><artifactId>hadoop-hdfs</artifactId><version>${hadoop.version}</version><exclusions><exclusion><artifactId>protobuf-java</artifactId><groupId>com.google.protobuf</groupId></exclusion></exclusions></dependency><!-- hbase --><dependency><groupId>org.apache.hbase</groupId><artifactId>hbase-server</artifactId><version>${hbase.version}</version><exclusions><exclusion><groupId>commons-logging</groupId><artifactId>commons-logging</artifactId></exclusion><exclusion><groupId>log4j</groupId><artifactId>log4j</artifactId></exclusion><exclusion><groupId>org.slf4j</groupId><artifactId>slf4j-log4j12</artifactId></exclusion><exclusion><groupId>tomcat</groupId><artifactId>jasper-compiler</artifactId></exclusion><exclusion><groupId>tomcat</groupId><artifactId>jasper-runtime</artifactId></exclusion><exclusion><groupId>org.mortbay.jetty</groupId><artifactId>jetty-util</artifactId></exclusion><exclusion><groupId>org.mortbay.jetty</groupId><artifactId>jetty</artifactId></exclusion><exclusion><groupId>org.mortbay.jetty</groupId><artifactId>jetty-sslengine</artifactId></exclusion><exclusion><groupId>org.mortbay.jetty</groupId><artifactId>jsp-2.1</artifactId></exclusion><exclusion><groupId>org.mortbay.jetty</groupId><artifactId>jsp-api-2.1</artifactId></exclusion><exclusion><groupId>org.mortbay.jetty</groupId><artifactId>servlet-api-2.5</artifactId></exclusion><exclusion><groupId>com.sun.jersey.jersey-test-framework</groupId><artifactId>jersey-test-framework-grizzly2</artifactId></exclusion><exclusion><artifactId>zookeeper</artifactId><groupId>org.apache.zookeeper</groupId></exclusion><exclusion><artifactId>protobuf-java</artifactId><groupId>com.google.protobuf</groupId></exclusion></exclusions></dependency><dependency><groupId>org.apache.hbase</groupId><artifactId>hbase-thrift</artifactId><version>${hbase.version}</version><exclusions><exclusion><groupId>commons-logging</groupId><artifactId>commons-logging</artifactId></exclusion><exclusion><groupId>log4j</groupId><artifactId>log4j</artifactId></exclusion><exclusion><groupId>org.mortbay.jetty</groupId><artifactId>jsp-2.1</artifactId></exclusion><exclusion><groupId>org.mortbay.jetty</groupId><artifactId>jsp-api-2.1</artifactId></exclusion><exclusion><groupId>org.mortbay.jetty</groupId><artifactId>servlet-api-2.5</artifactId></exclusion><exclusion><groupId>tomcat</groupId><artifactId>jasper-compiler</artifactId></exclusion><exclusion><groupId>tomcat</groupId><artifactId>jasper-runtime</artifactId></exclusion></exclusions></dependency><dependency><groupId>org.apache.hbase</groupId><artifactId>hbase-shell</artifactId><version>${hbase.version}</version><exclusions><exclusion><artifactId>zookeeper</artifactId><groupId>org.apache.zookeeper</groupId></exclusion><exclusion><artifactId>protobuf-java</artifactId><groupId>com.google.protobuf</groupId></exclusion></exclusions></dependency><dependency><groupId>org.apache.hbase</groupId><artifactId>hbase-protocol</artifactId><version>${hbase.version}</version><exclusions><exclusion><groupId>commons-logging</groupId><artifactId>commons-logging</artifactId></exclusion><exclusion><groupId>log4j</groupId><artifactId>log4j</artifactId></exclusion><exclusion><artifactId>protobuf-java</artifactId><groupId>com.google.protobuf</groupId></exclusion></exclusions></dependency><dependency><groupId>org.apache.hbase</groupId><artifactId>hbase-client</artifactId><version>${hbase.version}</version><exclusions><exclusion><groupId>commons-logging</groupId><artifactId>commons-logging</artifactId></exclusion><exclusion><groupId>log4j</groupId><artifactId>log4j</artifactId></exclusion><exclusion><groupId>org.slf4j</groupId><artifactId>slf4j-log4j12</artifactId></exclusion><exclusion><groupId>org.mortbay.jetty</groupId><artifactId>jetty-util</artifactId></exclusion><exclusion><artifactId>zookeeper</artifactId><groupId>org.apache.zookeeper</groupId></exclusion><exclusion><artifactId>protobuf-java</artifactId><groupId>com.google.protobuf</groupId></exclusion></exclusions></dependency><dependency><groupId>org.apache.hbase</groupId><artifactId>hbase-hadoop-compat</artifactId><version>${hbase.version}</version></dependency><dependency><groupId>org.apache.hbase</groupId><artifactId>hbase-common</artifactId><version>${hbase.version}</version><exclusions><exclusion><groupId>commons-logging</groupId><artifactId>commons-logging</artifactId></exclusion><exclusion><groupId>log4j</groupId><artifactId>log4j</artifactId></exclusion><exclusion><groupId>org.slf4j</groupId><artifactId>slf4j-log4j12</artifactId></exclusion><exclusion><groupId>tomcat</groupId><artifactId>jasper-compiler</artifactId></exclusion><exclusion><groupId>tomcat</groupId><artifactId>jasper-runtime</artifactId></exclusion><exclusion><groupId>org.mortbay.jetty</groupId><artifactId>jetty-util</artifactId></exclusion><exclusion><groupId>org.mortbay.jetty</groupId><artifactId>jetty</artifactId></exclusion><exclusion><groupId>com.sun.jersey.jersey-test-framework</groupId><artifactId>jersey-test-framework-grizzly2</artifactId></exclusion><exclusion><artifactId>protobuf-java</artifactId><groupId>com.google.protobuf</groupId></exclusion></exclusions></dependency><dependency><groupId>org.apache.hbase</groupId><artifactId>hbase-it</artifactId><version>${hbase.version}</version><exclusions><exclusion><artifactId>zookeeper</artifactId><groupId>org.apache.zookeeper</groupId></exclusion><exclusion><artifactId>protobuf-java</artifactId><groupId>com.google.protobuf</groupId></exclusion></exclusions></dependency><dependency><groupId>org.apache.hbase</groupId><artifactId>hbase-examples</artifactId><version>${hbase.version}</version><exclusions><exclusion><artifactId>curator-client</artifactId><groupId>org.apache.curator</groupId></exclusion><exclusion><artifactId>curator-framework</artifactId><groupId>org.apache.curator</groupId></exclusion><exclusion><artifactId>curator-recipes</artifactId><groupId>org.apache.curator</groupId></exclusion><exclusion><artifactId>zookeeper</artifactId><groupId>org.apache.zookeeper</groupId></exclusion><exclusion><artifactId>protobuf-java</artifactId><groupId>com.google.protobuf</groupId></exclusion></exclusions></dependency><dependency><groupId>org.apache.hbase</groupId><artifactId>hbase-prefix-tree</artifactId><version>${hbase-prefix-tree.version}</version><exclusions><exclusion><artifactId>protobuf-java</artifactId><groupId>com.google.protobuf</groupId></exclusion></exclusions></dependency><dependency><groupId>org.apache.hbase</groupId><artifactId>hbase-assembly</artifactId><version>${hbase.version}</version><type>pom</type></dependency><dependency><groupId>com.google.protobuf</groupId><artifactId>protobuf-java</artifactId><version>2.5.0</version></dependency><!-- hive --><dependency><groupId>org.apache.hive</groupId><artifactId>hive-jdbc</artifactId><version>${hive.version}</version><exclusions><exclusion><groupId>ch.qos.logback</groupId><artifactId>logback-classic</artifactId></exclusion><exclusion><groupId>org.apache.logging.log4j</groupId><artifactId>log4j-slf4j-impl</artifactId></exclusion><exclusion><groupId>org.slf4j</groupId><artifactId>slf4j-log4j12</artifactId></exclusion><exclusion><groupId>org.eclipse.jetty.orbit</groupId><artifactId>*</artifactId></exclusion><exclusion><groupId>org.eclipse.jetty.aggregate</groupId><artifactId>*</artifactId></exclusion><exclusion><groupId>tomcat</groupId><artifactId>*</artifactId></exclusion><exclusion><groupId>javax.servlet</groupId><artifactId>servlet-api</artifactId></exclusion><exclusion><groupId>org.mortbay.jetty</groupId><artifactId>*</artifactId></exclusion><exclusion><artifactId>httpcore</artifactId><groupId>org.apache.httpcomponents</groupId></exclusion><exclusion><artifactId>hive-exec</artifactId><groupId>org.apache.hive</groupId></exclusion><exclusion><groupId>org.apache.derby</groupId><artifactId>derby</artifactId></exclusion><exclusion><artifactId>zookeeper</artifactId><groupId>org.apache.zookeeper</groupId></exclusion><exclusion><artifactId>curator-framework</artifactId><groupId>org.apache.curator</groupId></exclusion><exclusion><artifactId>protobuf-java</artifactId><groupId>com.google.protobuf</groupId></exclusion></exclusions></dependency><dependency><groupId>org.apache.hive</groupId><artifactId>hive-service</artifactId><version>${hive.version}</version><exclusions><exclusion><artifactId>httpcore</artifactId><groupId>org.apache.httpcomponents</groupId></exclusion><exclusion><artifactId>hive-exec</artifactId><groupId>org.apache.hive</groupId></exclusion><exclusion><groupId>org.eclipse.jetty.aggregate</groupId><artifactId>*</artifactId></exclusion><exclusion><groupId>org.eclipse.jetty</groupId><artifactId>jetty-runner</artifactId></exclusion><exclusion><artifactId>curator-framework</artifactId><groupId>org.apache.curator</groupId></exclusion><exclusion><artifactId>curator-recipes</artifactId><groupId>org.apache.curator</groupId></exclusion></exclusions></dependency><dependency><groupId>org.apache.hive</groupId><artifactId>hive-common</artifactId><version>${hive.version}</version></dependency><!-- zookeeper --><dependency><groupId>org.apache.zookeeper</groupId><artifactId>zookeeper</artifactId><version>${zk.version}</version><exclusions><exclusion><groupId>log4j</groupId><artifactId>log4j</artifactId></exclusion><exclusion><groupId>org.slf4j</groupId><artifactId>slf4j-log4j12</artifactId></exclusion></exclusions></dependency><dependency><groupId>org.apache.curator</groupId><artifactId>curator-client</artifactId><version>${curator.version}</version><exclusions><exclusion><artifactId>zookeeper</artifactId><groupId>org.apache.zookeeper</groupId></exclusion></exclusions></dependency><dependency><groupId>org.apache.curator</groupId><artifactId>curator-framework</artifactId><version>${curator.version}</version></dependency><dependency><groupId>org.apache.curator</groupId><artifactId>curator-recipes</artifactId><version>${curator.version}</version><exclusions><exclusion><artifactId>curator-framework</artifactId><groupId>org.apache.curator</groupId></exclusion></exclusions></dependency><!-- Phoenix --><dependency><groupId>org.apache.phoenix</groupId><artifactId>phoenix-core</artifactId><version>${phoenix.version}</version><exclusions><exclusion><groupId>javax.servlet</groupId><artifactId>servlet-api</artifactId></exclusion><exclusion><groupId>org.mortbay.jetty</groupId><artifactId>jetty</artifactId></exclusion><exclusion><groupId>org.mortbay.jetty</groupId><artifactId>jetty-util</artifactId></exclusion><exclusion><groupId>org.mortbay.jetty</groupId><artifactId>jsp-2.1</artifactId></exclusion><exclusion><groupId>org.mortbay.jetty</groupId><artifactId>jsp-api-2.1</artifactId></exclusion><exclusion><groupId>org.mortbay.jetty</groupId><artifactId>servlet-api-2.1</artifactId></exclusion><exclusion><groupId>javax.servlet</groupId><artifactId>servlet-api</artifactId></exclusion><exclusion><groupId>javax.servlet.jsp</groupId><artifactId>jsp-api</artifactId></exclusion><exclusion><groupId>tomcat</groupId><artifactId>jasper-compiler</artifactId></exclusion><exclusion><groupId>tomcat</groupId><artifactId>jasper-runtime</artifactId></exclusion><exclusion><artifactId>zookeeper</artifactId><groupId>org.apache.zookeeper</groupId></exclusion><exclusion><artifactId>protobuf-java</artifactId><groupId>com.google.protobuf</groupId></exclusion></exclusions></dependency></dependencies><build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><configuration><source>1.8</source><target>1.8</target></configuration></plugin><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><configuration><!-- 默认启动 程序 --><mainClass>com.ztesoft.TestClusterHHHT.App</mainClass><layout>JAR</layout><addResources>true</addResources></configuration><executions><execution><goals><goal>repackage</goal></goals></execution></executions></plugin></plugins></build></project>

Hive-JDBC-Kerberos认证java代码实现相关推荐

  1. Spark操作Hive(开启Kerberos认证)代码提交华为云DAYU的MRS Spark组件--方法流程及注意事项

    背景: 最近在测试华为云DAYU MRS Spark操作Hive的流程,因kerberos认证的问题一直测试失败. 代码示例: val sparkSession = SparkSession.buil ...

  2. (转载)详解Hive配置Kerberos认证

    Hive提供了运行SQL语句查询存储在HDFS上数据的能力,Hive提供的查询引擎,可以将SQL语句转化成MapReduce任务,提交到Hadoop集群上执行.MapReduce任务运行的结果会存在H ...

  3. 连接端口 配置hive_Zeppelin带有Kerberos认证的Hive解释器的配置

    2.zeppelin连接Hive安装配置 zeppelin 版本0.8.2 ,hive版本:3.0.0 2.1.安装启动hive3 略 2.1.配置hiveserver2 如果需要配置zeppelin ...

  4. python 权限认证 impala_python操作具有kerberos认证的hive(impala)

    ▌前言 python中用于连接HiveServer2的客户端有3个:pyhs2,pyhive,impyla.官网的示例采用的是pyhs2,但pyhs2的官网已声明不再提供支持,建议使用impyla和p ...

  5. 使用java代码编写脚本,把oracle建表语句变成hive建表语句

    使用java代码编写脚本,把oracle建表语句变成hive建表语句 java代码 测试oracle.sql 生成hive创表语句 java代码 import java.io.File; import ...

  6. 浅析java代码是如何获取kerberos principal 的realm和kdc相关信息的

    我们知道,使用 kerberos 时 java 代码中最关键的配置项是指定默认的realm和默认的kdc,一般我们可以通过在代码中配置环境变量 java.security.krb5.realm 和 j ...

  7. hadoop生态的kerberos认证系列2-hadoop

    hadoop生态的kerberos认证系列2-hadoop 一.准备工作 二.配置 1.hdfs配置kerberos认证 1.1所有节点安装autoconf 1.2所有节点安装gcc 1.3安装jsv ...

  8. Kafka 认证三:添加 Kerberos 认证详细流程

    背景 上一章节介绍了 Kerberos 服务端和客户端的部署过程,本章节继续介绍 Kafka 添加 Kerberos 认证的部署流程,及 Java API 操作的注意事项. sasl.kerberos ...

  9. python调用hive与java调用区别_python3.6.5基于kerberos认证的hive和hdfs连接调用方式

    1. Kerberos是一种计算机网络授权协议,用来在非安全网络中,对个人通信以安全的手段进行身份认证.具体请查阅官网 2. 需要安装的包(基于centos) yum install libsasl2 ...

最新文章

  1. request.getSession(false)到底返回什么
  2. mysql数据聚合技术_Mysql 去重 聚合
  3. swift x输入流_Swift 中不同窗体的切换和传递数据 (segue 的用法)
  4. linq to json for sl
  5. 第八节:Task的各类TaskTResult返回值以及通用线程的异常处理方案
  6. mysql 随机取不重复数据_随机生成不重复数字,想做Excel抽奖器你必须掌握!
  7. RS-485总线和Modbus通信协议的关系
  8. 面试没过的程序员都到哪去了?
  9. java中Cookie类详解
  10. 我的世界php motd,ColorMOTD 彩色字体插件 | 我的世界 | MC世界侠
  11. Eucalyptus的结构
  12. mac上如何安装夜神模拟器
  13. 2022-2027年中国熔融碳酸盐型燃料电池行业市场全景评估及发展战略规划报告
  14. 周记——20151221
  15. mysql容灾方案_mysql 容灾 灾备 备份
  16. C#时间格式转换为时间戳
  17. DICOM医学图像处理:fo-dicom网络传输之 C-Echo and C-Store
  18. 通过Dashboard熟悉并创建云主机
  19. FPGA经验谈系列文章——FPGA资源评估
  20. TCP/IP之蓟辽督师 转

热门文章

  1. TemplateBinding和Binding的区别
  2. LoadRunner 回放出错
  3. 小王的研发日记-自动对焦(硬件与计算机通信)
  4. 将进酒翻译软件测试,乐府诗《将进酒》拼音及翻译整理
  5. BLOB与CLOB的区别
  6. 通用局部搜索算法之WALKSAT
  7. 数学建模:线性规划及 Python 求解
  8. 数字图像处理——第七章(小波变换和多分辨率处理)
  9. 动画模拟实现电梯的载客运行过程
  10. 小学生灯谜计算机,小学生谜语大全