hive、impala集成ldap


1、概要

1.1 環境信息

  • hadoop:cdh5.10
  • os:centos6.7
  • user:root
  • hive、impala已集成sentry

1.2 訪問控制權限

這里通過使用openldap來控制hive、impala的訪問權限,即通過用戶名、密碼來進行訪問。而hive、impala內部則已集成了sentry來控制更為細粒度的權限訪問。

2、openldap

2.1 安裝

# yum install -y openldap-*

2.2 配置

  • 拷貝ldap配置文件到ldap目錄
# cp /usr/share/openldap-servers/slapd.conf.obsolete 
# /etc/openldap/slapd.conf
  • 創建ldap管理員密碼
# slappasswd 
New password: 
Re-enter new password: 
{SSHA}k8d0PcF3Y1VcI/ixMiss8e5ZmIkFC8dl

輸入保存管理員密碼,返回的是加密后的一串密文

  • 編輯配置文件
    注:這里組織的域為 zpbigdata.com
# vim /etc/openldap/slapd.conf 修改對應如下內容
database config
access to *
	by dn.exact="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth" manage
	by * none

# enable server status monitoring (cn=monitor)
database monitor
access to *
	by dn.exact="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth" read
        by dn.exact="cn=Manager,dc=zpbigdata,dc=com" read
        by * none

#######################################################################
# database definitions
#######################################################################

database	bdb
suffix		"dc=zpbigdata,dc=com"
checkpoint	1024 15
rootdn		"cn=Manager,dc=zpbigdata,dc=com"
# Cleartext passwords, especially for the rootdn, should
# be avoided.  See slappasswd(8) and slapd.conf(5) for details.
# Use of strong authentication encouraged.
rootpw		{SSHA}k8d0PcF3Y1VcI/ixMiss8e5ZmIkFC8dl #加密后的管理員密碼
#rootpw		{SSHA}k8d0PcF3Y1VcI/ixMiss8e5ZmIkFC8dl
  • 拷貝DB_CONFIG文件到指定目錄
cp /usr/share/openldap-servers/DB_CONFIG.example  /var/lib/ldap/DB_CONFIG
  • 刪除默認/etc/openldap/slapd.d下面的所有內容
rm -rf /etc/openldap/slapd.d/*
  • 賦予配置目錄相應權限
# chown -R ldap:ldap /var/lib/ldap  
# chown -R ldap:ldap /etc/openldap/  
# service slapd start
  • 生成配置文件並賦值
# slaptest -f /etc/openldap/slapd.conf -F /etc/openldap/slapd.d
config file testing succeeded
# chown -R ldap:ldap /etc/openldap/slapd.d/*
# service slapd restart

2.3 migrationtools

  • 安裝migrationtools
# yum install -y migrationtools
  • 修改migrate_common.ph文件
# vim /usr/share/migrationtools/migrate_common.ph
# Default DNS domain
$DEFAULT_MAIL_DOMAIN = "zpbigdata.com";

# Default base 
$DEFAULT_BASE = "dc=zpbigdata,dc=com";
  • 利用pl腳本將/etc/passwd 和/etc/group生成LDAP能讀懂的文件格式
# 這里導入一個etl用戶來測試
# cat /etc/passwd | grep etl > /tmp/passwd 
# cat /etcgroup | grep etl > /tmp/group

# /usr/share/migrationtools/migrate_base.pl > /tmp/base.ldif  
# /usr/share/migrationtools/migrate_passwd.pl  /tmp/passwd > /tmp/passwd.ldif  
# /usr/share/migrationtools/migrate_group.pl  /tmp/group > /tmp/group.ldif
  • 將文件導入到LDAP
# ldapadd -x -D "cn=Manager,dc=zpbigdata,dc=com" -W -f /tmp/base.ldif 
# ldapadd -x -D "cn=Manager,dc=zpbigdata,dc=com" -W -f /tmp/passwd.ldif 
# ldapadd -x -D "cn=Manager,dc=zpbigdata,dc=com" -W -f /tmp/group.ldif 

2.4 phpldapadmin

phpLDAPadmin是一個LDAP web客戶端,它提供一個簡單的、支持多語言多環境的LDAP管理功能。安裝部署略。

可以看到剛剛測試導入的用戶etl。

3、hive集成ldap

3.1 修改配置

在/etc/hive/conf/hive-site.xml中添加

    <property>
        <name>hive.server2.authentication</name>
        <value>LDAP</value>
    </property>

    <property>
        <name>hive.server2.authentication.ldap.url</name>
        <value>ldap://ip</value>
    </property>

    <property>
        <name>hive.server2.authentication.ldap.baseDN</name>
        <value>ou=People,dc=zpbigdata,dc=com</value>
    </property>

添加完后重啟hive-server2.

3.2 驗證

此時通過beeline連接,需要ldap中對應的用戶名密碼才能連接成功。

4、impala集成ldap

4.1 修改配置

修改/etc/default/impala文件,在IMPALA_SERVER_ARGS中添加:

-enable_ldap_auth=true 
-ldap_tls=false 
-ldap_passwords_in_clear_ok=true 
-ldap_uri=ldap://idap_ip
-ldap_baseDN=ou=People,dc=zpbigdata,dc=com 

添加完后重啟impala。

3.3 驗證

驗證命令:
impala-shell -i impalad-server -u etl -l --auth_creds_ok_in_clear
-i 集群中任意一台impalad服務器都可以
-u 登錄用戶
-l 使用ldap
--auth_creds_ok_in_clear 由於沒有使用ssl,需要添加該參數。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM