hiveserver2 设置用户登录验证
来源:互联网 发布:遗传基因算法 编辑:程序博客网 时间:2024/05/17 21:41
编写验证程序
package com.aiso.hive.hiveserver2.auth;import java.io.BufferedReader;import java.io.File;import java.io.FileReader;import java.io.IOException;import javax.security.sasl.AuthenticationException;import org.apache.commons.codec.digest.DigestUtils;import org.apache.hadoop.conf.Configuration;import org.apache.hadoop.hive.conf.HiveConf;import org.apache.hive.service.auth.PasswdAuthenticationProvider;public class CustomHiveServer2Auth implements PasswdAuthenticationProvider { @Override public void Authenticate(String username, String password) throws AuthenticationException { boolean ok = false; String passMd5 = DigestUtils.md5Hex(password); HiveConf hiveConf = new HiveConf(); Configuration conf = new Configuration(hiveConf); String filePath = conf.get("hive.server2.custom.authentication.file"); System.out.println("hive.server2.custom.authentication.file [" + filePath + "] .."); File file = new File(filePath); BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(file)); String tempString = null; while ((tempString = reader.readLine()) != null) { String[] datas = tempString.split(",", -1); if (datas.length != 2) continue; //ok if (datas[0].equals(username) && datas[1].equals(passMd5)) { ok = true; break; } } reader.close(); } catch (Exception e) { e.printStackTrace(); throw new AuthenticationException("read auth config file error, [" + filePath + "] ..", e); } finally { if (reader != null) { try { reader.close(); } catch (IOException e1) { } } } if (ok) { System.out.println("user [" + username + "] auth check ok .. "); } else { System.out.println("user [" + username + "] auth check fail .. "); throw new AuthenticationException("user [" + username + "] auth check fail .. "); } } public static void main(String[] args) { System.out.println(DigestUtils.md5Hex("password".getBytes())); }}
将验证程序打包
放在$HIVE_HOME/lib目录下
验证的配置文件
密码采用Md5加密,可添加多用户,放在$HIVE_HOME/conf目录下
hive.server2.users.conf:
xiaoyuzhou,29fe3d760e64b4e055ec3cda455833ab
user,5f4dcc3b5aa765d61d8327deb882cf99
测试
开启HiveServer2服务
[xiaoyuzhou@xyz01 hive-0.13.1-cdh5.3.6]$ bin/hiveserver2 & [2] 5929[1] Exit 255 bin/hiveserver2[xiaoyuzhou@xyz01 hive-0.13.1-cdh5.3.6]$ Starting HiveServer2hive.server2.custom.authentication.file [conf/hive.server2.users.conf] ..user [user] auth check ok .. OK
使用beeline 连接
[xiaoyuzhou@xyz01 hive-0.13.1-cdh5.3.6]$ bin/beelineBeeline version 0.13.1-cdh5.3.6 by Apache Hivebeeline> !connect jdbc:hive2://xyz01.aiso.com:10000/default scan complete in 3msConnecting to jdbc:hive2://xyz01.aiso.com:10000/defaultEnter username for jdbc:hive2://xyz01.aiso.com:10000/default: userEnter password for jdbc:hive2://xyz01.aiso.com:10000/default: ********Connected to: Apache Hive (version 0.13.1-cdh5.3.6)Driver: Hive JDBC (version 0.13.1-cdh5.3.6)Transaction isolation: TRANSACTION_REPEATABLE_READ0: jdbc:hive2://xyz01.aiso.com:10000/default> show databases;+----------------+--+| database_name |+----------------+--+| default |+----------------+--+1 row selected (0.742 seconds)0: jdbc:hive2://xyz01.aiso.com:10000/default>
输入密码 连接成功!
0 0
- hiveserver2 设置用户登录验证
- 用户登录系统验证码设置
- andriid基础用户登录验证,弹窗,设置标题(详解)
- HiveServer2用户名密码验证
- HiveServer2用户名密码验证
- Jstl验证用户登录
- 用户登录验证
- RCP用户登录验证
- 用户登录验证安全问题
- 用户登录验证完整版
- 用户登录验证
- 用户登录验证
- 用户登录验证
- ajax 验证用户登录
- 验证用户登录
- 用户登录验证
- Yii 用户登录验证
- Yii 用户登录验证
- 人工智能现状
- 配置java环境变量...不是入门的(准备装jdk的)童鞋就没必要看了= =...因为win10最新版的配置变量值那里改了...
- 软件行业的思考
- Android 高仿 IOS 滚轮选择控件
- 构建需求响应式亿级商品详情页
- hiveserver2 设置用户登录验证
- 死锁概述
- 毕业工作一年的想法
- 目标文件
- vim学习进阶: cscope 学习
- linux下快速删除大量文件
- Makefile 出现./simv up to date.如何解决?
- jQuery基础
- Dubbo分布式事务处理--视频教程