首页 > 其他分享 >hive身份验证

hive身份验证

时间:2023-12-07 11:35:43浏览次数:29  
标签:身份验证 auth hive conf apache org user

Hive 通过HiveServer2对外提供服务,HiveServer2 是一种能使客户端执行 Hive 查询的服务。

HiveServer2 实现了一个新的基于 Thrift 的 RPC 接口,该接口可以处理客户端并发请求。当前版本支持 Kerberos,LDAP 以及自定义可插拔身份验证。新的 RPC 接口也是 JDBC 和 ODBC 客户端更好的选择,尤其是对于元数据访问。

hive身份认证的三种方式:
NONE:即不做身份校验;(不输入账户密码或任意账户密码都可以访问)
LDAP: 使用基于 LDAP/AD 的用户身份校验;(优先选择)
KERBEROS: 使用 Kerberos/GSSAPI 做身份校验;
CUSTOM:自定义认证;

 

配置CUSTOM身份认证流程
1.首先需要编写用户权限验证的类

import org.apache.hadoop.conf.Configurable;
import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hive.service.auth.PasswdAuthenticationProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.hadoop.conf.Configuration;
import javax.security.sasl.AuthenticationException;
/**

* @author 

* @version 1.0.0

* @since 2022-09-28 10:00

**/

public class AuthLogin implements PasswdAuthenticationProvider, Configurable {

private static Logger LOG = LoggerFactory.getLogger(AuthLogin.class);

private String user;

private String pwd;

private Configuration conf = null;

public AuthLogin() {

user = getConf().get("hive.auth.user");

pwd = getConf().get("hive.auth.pwd");

}

@Override

public void setConf(Configuration configuration) {

}

@Override

public Configuration getConf() {

if (this.conf == null) {

HiveConf conf = new HiveConf();

this.conf = new Configuration(conf);

}

return this.conf;

}

@Override

public void Authenticate(String username, String password) throws AuthenticationException {

if (username == null || password == null) {

throw new AuthenticationException("error.");

}

LOG.info("user: " + username + " try login.");

if (!user.equals(username)) {

String message = "user name not exist:";

throw new AuthenticationException(message);

} else {

if (!password.equals(pwd)) {

String message = "user name and password is mismaPasswdAuthenticationProvidertch. user:" + username;

throw new AuthenticationException(message);

}

}

LOG.info("user " + username + " login system successfully.");

}

}

pom依赖


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">

4.0.0

cn.li

hive-auth

1.0



org.apache.hadoop

hadoop-common

3.3.1


org.apache.hive

hive-common

3.1.2


commons-logging

commons-logging

1.2


org.apache.hive

hive-service

3.1.2

将以上文件打包

mvn install

2.配置及复制jar包

将上面的程序打包的hive-auth-1.0.jar,放到$HIVE_HOME/lib下

配置hive-site.xml,追加以下文件


hive.server2.authentication

CUSTOM


hive.server2.custom.authentication.class

AuthLogin


hive.auth.user

admin


hive.auth.pwd

Aa123456

hive.auth.user为用户名

hive.auth.pwd为密码
View Code

 原文链接:https://www.kuazhi.com/post/420621.html

标签:身份验证,auth,hive,conf,apache,org,user
From: https://www.cnblogs.com/chong-zuo3322/p/17881305.html

相关文章

  • EMR-hive集成openldap
     LDAP认证:https://help.aliyun.com/zh/emr/emr-on-ecs/user-guide/use-ldap-authentication?spm=a2c4g.11186623.0.i4OpenLDAP试用说明参考:https://help.aliyun.com/zh/emr/emr-on-ecs/user-guide/use-openldap/?spm=a2c4g.11186623.0.i2......
  • 实验6熟悉的hive的基本操作
    今天完成了大数据实验六的hive的基本操作参照实验6熟悉Hive的基本操作_hive环境搭建实验报告-CSDN博客、这位博主的代码,但是前期的启动hive并没有按照博主的来,启动hive大家参照我之前的一篇博客来就行我是从黑马教程跟着下载的hiveHIVe的启动以及datagrip配置-王庆园-博客......
  • hive执行sql报错 FAILED: Execution Error, return code 3 from org.apache.hadoop.hi
    前言:执行hivesql报错,sql逻辑是两个表左连接并将数据插入新的表中。报错信息:[ERROR]2023-12-0515:49:49.165+0800-executesqlerror:Errorwhileprocessingstatement:FAILED:ExecutionError,returncode3fromorg.apache.hadoop.hive.ql.exec.mr.MapredLocalTa......
  • DBeaver连接hive
    配置maven仓库:窗口,首选项,连接,驱动,Maven,添加https://repo.huaweicloud.com/repository/maven/配置hive驱动:数据库,驱动管理器,Hadoop,ApacheHive,编辑库,添加工件填写hive-jdbc选自hive对应的版本连接hive:文件,新建,数据库连接Hadoop/大数据,ApacheHive......
  • datax采集txt文件数据到hive
    1、提前创建hive表结构DROPTABLEIFEXISTSods.ods_log_1diu;CREATETABLEIFNOTEXISTSods.ods_log_1diu(SI_NOSTRING,--varchar(10)notnull,主键SEND_TABLESTRING,--varchar(30)notnull,主键SEQSTRING,--varchar(11)notnull,主......
  • 关于hadoop hive中使用hive分区功能
    很多人习惯了使用第三方的工具去连接hive或者hbase数据库,并且使用其中的sql编辑器进行失去了语句的使用来进行数据的分析等一系列的操作,但是一些shell命令也可以在其中运行例如:1. sethive.exec.dynamic.partition=true;2. sethive.exec.dynamic.partition.mode=nonstr......
  • hive启动时有一堆WARN信息
    hive启动时有一堆WARN信息比如:SLF4J:ClasspathcontainsmultipleSLF4Jbindings.SLF4J:Foundbindingin[jar:file:/usr/local/hive/lib/log4j-slf4j-impl-2.17.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]SLF4J:Foundbindingin[jar:file:/usr/local/hadoop/......
  • Hive的安装与配置
    第1关:Hive的安装与配置在修改conf下面的hive-site.xml文件这里,题目给的信息是错误的,正确的内容如下:<?xmlversion="1.0"encoding="UTF-8"standalone="no"?><?xml-stylesheettype="text/xsl"href="configuration.xsl"?><configura......
  • hive启动出现Either your MetaData is incorrect, or you need to enable "datanucleu
    hive启动出现:Requiredtablemissing:"`VERSION`"inCatalog""Schema"".DataNucleusrequiresthistabletoperformitspersistenceoperations.EitheryourMetaDataisincorrect,oryouneedtoenable"datanucleus.schema......
  • hive升级元数据报错The reference to entity "useSSL" must end with the ';' delimit
    使用Hive自带的schematool工具升级元数据,也就是把最新的元数据重新写入MySQL数据库中。执行以下命令cd/usr/local/hive./bin/schematool-initSchema-dbTypemysql出现Thereferencetoentity"useSSL"mustendwiththe';'delimiter.修改之前配置的hive-site.xml原......