SlideShare a Scribd company logo
1 of 24
Hive Authorization
July 2nd 2013
Minwoo Kim
michael.kim@nexr.com
이 문서는
• Hive 0.11.0 버전을 기준으로 작성 (하둡 1.1.2)
• 인증에 관한 자세한 내용은 포함하지 않음
• 다음을 참고하여 작성됨
- https://cwiki.apache.org/confluence/display/Hive/
LanguageManual+Authorization
- https://github.com/apache/hive BRANCH-0.11 브랜치
- 하이브 완벽 가이드, O’REILLY, 한빛 미디어
- http://www.slideshare.net/thejasmn/hive-authorization-models ,
Hadoop Summit 2013
권한 활성화
<property>
<name>hive.security.authorization.enabled</name>
<value>true</value>
<description>하이브 클라이언트 권환을 활성화 또는 비활성화하 한다
</description>
</property>
hive> set hive.security.authorization.enabled=true;
hive-site.xml
CLI
권한 대상
• 하이브는 사용자user, 그룹group, 역할role에 퍼미션을 부여하거
나 회수할 수 있다
- 하이브의 사용자는 시스템 사용자
- 그룹은 사용자의 첫번째 POSIX 그룹과 동일
- HiveServer2의 경우에는 사용자를 지정하여 접속 할 수 있다
사용자user, 그룹group
• 사용자user와 그룹group은
hive.security.authenticator.manager가 관리
org.apache.hadoop.hive.ql.security.HadoopDefaultAuthenticator
기본 구현체
- job configuration에서 hadoop.job.ugi 값으로 username과 group을 결정
HiveAuthenticationProvider
public interface HiveAuthenticationProvider extends Configurable{
public String getUserName();
public List<String> getGroupNames();
public void destroy() throws HiveException;
}
권한 관리 구현체
• 권한은 hive.security.authorization.manager가 관리
org.apache.hadoop.hive.ql.security.authorization.DefaultHiveAu
thorizationProvider
기본 구현체
HiveAuthenticationProvider
public interface HiveAuthorizationProvider extends Configurable{
public void init(Configuration conf) throws HiveException;
public HiveAuthenticationProvider getAuthenticator();
public void setAuthenticator(HiveAuthenticationProvider authenticator);
public void authorize(Privilege[] readRequiredPriv, Privilege[] writeRequiredPriv)
throws HiveException, AuthorizationException;
public void authorize(Database db, Privilege[] readRequiredPriv, Privilege[] writeRequiredPriv) throws
HiveException, AuthorizationException;
public void authorize(Table table, Privilege[] readRequiredPriv,
Privilege[] writeRequiredPriv) throws HiveException, AuthorizationException;
public void authorize(Partition part, Privilege[] readRequiredPriv, Privilege[] writeRequiredPriv) throws
HiveException, AuthorizationException;
public void authorize(Table table, Partition part, List<String> columns,
Privilege[] readRequiredPriv, Privilege[] writeRequiredPriv)
throws HiveException, AuthorizationException;
}
역할 role
• 역할role은 사용자user와 그룹group과 달리 사용자가
생성할 수 있다
CREATE ROLE role_name
DROP ROLE role_name
역할 생성
GRANT ROLE role_name TO USER user1, user2
GRANT ROLE role_name TO GROUP group1
GRANT ROLE role_name TO ROLE role1
REVOKE ROLE role_name FROM USER user1
REVOKE ROLE role_name FROM GROUP group1, group2
역할 부여 / 파기
특권 Privileges
이름 설명
ALL 모든 퍼미션을 한번에 부여
ALTER 테이블 변경 가능
UPDATE 테이블이나 파티션에 로드 또는 삽입 가능
CREATE 테이블 생성 가능
DROP 테이블이나 파티션 삭제 가능
INDEX 색인 생성 가능
LOCK 동시성을 활성화인 경우 테이블을 잠그거나 잠금을 푼다
SELECT 테이블이나 파티션 쿼리 가능
SHOW_DATABASE 이용 가능한 데이터베이스 조회 가능
권한 부여/ 회수
GRANT
priv_type [(column_list)] [, priv_type [(column_list)]] ...
[ON object_type]
TO principal_specification [, principal_specification] ...
[WITH GRANT OPTION]
REVOKE
priv_type [(column_list)] [, priv_type [(column_list)]] ...
[ON object_type priv_level]
FROM principal_specification [, principal_specification] ...
REVOKE ALL PRIVILEGES, GRANT OPTION FROM user [, user] ...
object_type: TABLE | DATABASE
priv_level: db_name | tbl_name
principal_specification : USER user | GROUP group | ROLE role
priv_type: ALL, ALTER, UPDATE, CREATE, DROP, INDEX, LOCK, SELECT, SHOW_DATABASE
권한 부여/ 회수
-- 테이블에 사용자 권한 부여 / 회수
grant select on table src_autho_test to user hive_test_user;
revoke select on table src_autho_test from user hive_test_user;
-- 컬럼에 사용자 권한 부여 / 회수
grant select(key) on table src_autho_test to user hive_test_user;
-- 테이블에 그룹 권한 부여 / 회수
grant select on table src_autho_test to group hive_test_group1;
revoke select on table src_autho_test from group hive_test_group1;
권한 보기
show grant user test_user on table src_autho_test;
show grant user test_user on table src_autho_test(key);
show grant group test_group1 on table src_autho_test;
show grant group test_group1 on table src_autho_test(key);
show grant role test_role1 on table src_autho_test;
show grant role test_role1 on table src_autho_test(key);
파티션 수준의 권한
• 파티션 단위로 퍼미션을 부여하려면
PARTITION_LEVEL_PRIVILEGE를 true로 설정해야 한다
CREATE TABLE authorize_part (key INT, value STRING) PARTITIONED BY (ds STRING);
-- 기존 테이블에 파티션 퍼미션 설정
ALTER TABLE authorization_part
SET TBLPROPERTIES (‘PARTITION_LEVEL_PRIVILEGE’=‘TRUE’);
-- 사용자에게 select 권한 파기
REVOKE SELECT ON TABLE authorization_part PARTITION (ds=’3’) FROM USER admin;
-- 사용자에게 select 권한 부여
GRANT SELECT ON TABLE authorization_part PARTITION (ds=’3’) TO USER admin;
자동 권한 부여
<property>
<name>hive.security.authorization.createtable.owner.grants</name>
<value>ALL</value>
<description>테이블이 생성될 때 소유자에게 자동으로 퍼미션을 설정한다. select, drop이
라 설정하면 select와 drop 퍼미션이 테이블 소유자에게 자동으로 부여된다.
</description>
</property>
• 기타 자동 권한 부여 설정들
- hive.security.authorization.createtable.user.grant
- hive.security.authorization.createtable.group.grant
- hive.security.authorization.createtable.role.grant
자동 권한 부여 예
<property>
<name>hive.security.authorization.createtable.user.grants</name>
<value>admin1,michael:select;user1:create</value>
</property>
• 특정 사용자는 생성한 테이블에 대한 퍼미션을 자동
으로 부여 받을 수 있다
HiveSever2 시작
hive --service hiveserver2
beeline로 hs2 접근
hive --service beeline
beeline 실행
• hiveserver2 를 위한 새로운 CLI
beeline 접속
!connect jdbc:hive2://localhost:10000 user password org.apache.hive.jdbc.HiveDriver
JDBC로 hs2 접근
Connection con = DriverManager.getConnection("jdbc:hive2://
localhost:10000/default", "user", "password");
Statement stmt = con.createStatement();
String sql = "select * from dual";
System.out.println("Running: " + sql);
ResultSet res = stmt.executeQuery(sql);
while (res.next()) {
System.out.println(String.valueOf(res.getInt(1)));
}
HDFS 권한 설정
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
<description>location of default database for the warehouse</description>
</property>
기본 warehouse 위치 설정
<property>
<name>hive.exec.scratchdir</name>
<value>/tmp/hive-${user.name}</value>
<description>Scratch space for Hive jobs</description>
</property>
기본 scratchdir 위치 설정
HDFS 권한 설정
hadoop fs -chmod -R 777 /path/to/warehouse/on/hdfs
hadoop fs -chmod -R 777 /path/to/scratchdir/on/hdfs
스토리지 권한 설정
• 사용자가 HDFS상의 권한도 가지고 있어야 한다
대역 설정
<property>
<name>hive.server2.enable.doAs</name>
<value>true</value>
<description> Impersonate the connected user, default true</
description>
</property>
• true 설정하면 대역 기능 활성화
• false 로 설정하면 hive의 시스템 사용자를 사용자로 지정한다
• 여러 사용자의 권한을 사용하기 위해서는 대역기능이 필요하므로 true로 설
정되어 있어야 한다
현재 하이브의 권한은 ..
• 전통적인 RDBMS 방식과 스토리지 방식의 한계
• 악의적 사용자에게서 메타데이터를 완벽하게 보호하
지 못함
• 하지만 사용자의 오사용을 방지를 위해서 필요
• 새로운 권한 모델 제안
- http://www.slideshare.net/thejasmn/hive-authorization-
models by Thejas Nair at Hadoop Summit 2013
- https://issues.apache.org/jira/browse/HIVE-3720
참고 자료
• https://cwiki.apache.org/confluence/display/
Hive/LanguageManual+Authorization
• https://github.com/apache/hive
BRANCH-0.11 브랜치
• 하이브 완벽 가이드, O’REILLY, 한빛 미디어
• http://www.slideshare.net/thejasmn/hive-
authorization-models , Hadoop Summit 2013

More Related Content

What's hot

Best practices for MySQL/MariaDB Server/Percona Server High Availability
Best practices for MySQL/MariaDB Server/Percona Server High AvailabilityBest practices for MySQL/MariaDB Server/Percona Server High Availability
Best practices for MySQL/MariaDB Server/Percona Server High AvailabilityColin Charles
 
MySQL_SQL_Tunning_v0.1.3.docx
MySQL_SQL_Tunning_v0.1.3.docxMySQL_SQL_Tunning_v0.1.3.docx
MySQL_SQL_Tunning_v0.1.3.docxNeoClova
 
[2018] MySQL 이중화 진화기
[2018] MySQL 이중화 진화기[2018] MySQL 이중화 진화기
[2018] MySQL 이중화 진화기NHN FORWARD
 
Mastering PostgreSQL Administration
Mastering PostgreSQL AdministrationMastering PostgreSQL Administration
Mastering PostgreSQL AdministrationEDB
 
Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안
Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안
Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안SANG WON PARK
 
Operating PostgreSQL at Scale with Kubernetes
Operating PostgreSQL at Scale with KubernetesOperating PostgreSQL at Scale with Kubernetes
Operating PostgreSQL at Scale with KubernetesJonathan Katz
 
Distributed Locking in Kubernetes
Distributed Locking in KubernetesDistributed Locking in Kubernetes
Distributed Locking in KubernetesRafał Leszko
 
MySQL/MariaDB Proxy Software Test
MySQL/MariaDB Proxy Software TestMySQL/MariaDB Proxy Software Test
MySQL/MariaDB Proxy Software TestI Goo Lee
 
Presto User & Admin Guide
Presto User & Admin GuidePresto User & Admin Guide
Presto User & Admin GuideJEONGPHIL HAN
 
Introduction and Overview of Apache Kafka, TriHUG July 23, 2013
Introduction and Overview of Apache Kafka, TriHUG July 23, 2013Introduction and Overview of Apache Kafka, TriHUG July 23, 2013
Introduction and Overview of Apache Kafka, TriHUG July 23, 2013mumrah
 
Understanding PostgreSQL LW Locks
Understanding PostgreSQL LW LocksUnderstanding PostgreSQL LW Locks
Understanding PostgreSQL LW LocksJignesh Shah
 
Fundamentals of Apache Kafka
Fundamentals of Apache KafkaFundamentals of Apache Kafka
Fundamentals of Apache KafkaChhavi Parasher
 
[오픈소스컨설팅] 스카우터 사용자 가이드 2020
[오픈소스컨설팅] 스카우터 사용자 가이드 2020[오픈소스컨설팅] 스카우터 사용자 가이드 2020
[오픈소스컨설팅] 스카우터 사용자 가이드 2020Ji-Woong Choi
 
Data warehouse on Kubernetes - gentle intro to Clickhouse Operator, by Robert...
Data warehouse on Kubernetes - gentle intro to Clickhouse Operator, by Robert...Data warehouse on Kubernetes - gentle intro to Clickhouse Operator, by Robert...
Data warehouse on Kubernetes - gentle intro to Clickhouse Operator, by Robert...Altinity Ltd
 
Apache Kafka Architecture & Fundamentals Explained
Apache Kafka Architecture & Fundamentals ExplainedApache Kafka Architecture & Fundamentals Explained
Apache Kafka Architecture & Fundamentals Explainedconfluent
 
Hive 3 a new horizon
Hive 3  a new horizonHive 3  a new horizon
Hive 3 a new horizonArtem Ervits
 
Understanding of Apache kafka metrics for monitoring
Understanding of Apache kafka metrics for monitoring Understanding of Apache kafka metrics for monitoring
Understanding of Apache kafka metrics for monitoring SANG WON PARK
 
Aggregated queries with Druid on terrabytes and petabytes of data
Aggregated queries with Druid on terrabytes and petabytes of dataAggregated queries with Druid on terrabytes and petabytes of data
Aggregated queries with Druid on terrabytes and petabytes of dataRostislav Pashuto
 

What's hot (20)

Best practices for MySQL/MariaDB Server/Percona Server High Availability
Best practices for MySQL/MariaDB Server/Percona Server High AvailabilityBest practices for MySQL/MariaDB Server/Percona Server High Availability
Best practices for MySQL/MariaDB Server/Percona Server High Availability
 
MySQL_SQL_Tunning_v0.1.3.docx
MySQL_SQL_Tunning_v0.1.3.docxMySQL_SQL_Tunning_v0.1.3.docx
MySQL_SQL_Tunning_v0.1.3.docx
 
[2018] MySQL 이중화 진화기
[2018] MySQL 이중화 진화기[2018] MySQL 이중화 진화기
[2018] MySQL 이중화 진화기
 
Mastering PostgreSQL Administration
Mastering PostgreSQL AdministrationMastering PostgreSQL Administration
Mastering PostgreSQL Administration
 
Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안
Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안
Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안
 
Operating PostgreSQL at Scale with Kubernetes
Operating PostgreSQL at Scale with KubernetesOperating PostgreSQL at Scale with Kubernetes
Operating PostgreSQL at Scale with Kubernetes
 
Distributed Locking in Kubernetes
Distributed Locking in KubernetesDistributed Locking in Kubernetes
Distributed Locking in Kubernetes
 
MySQL/MariaDB Proxy Software Test
MySQL/MariaDB Proxy Software TestMySQL/MariaDB Proxy Software Test
MySQL/MariaDB Proxy Software Test
 
Presto User & Admin Guide
Presto User & Admin GuidePresto User & Admin Guide
Presto User & Admin Guide
 
Introduction and Overview of Apache Kafka, TriHUG July 23, 2013
Introduction and Overview of Apache Kafka, TriHUG July 23, 2013Introduction and Overview of Apache Kafka, TriHUG July 23, 2013
Introduction and Overview of Apache Kafka, TriHUG July 23, 2013
 
Understanding PostgreSQL LW Locks
Understanding PostgreSQL LW LocksUnderstanding PostgreSQL LW Locks
Understanding PostgreSQL LW Locks
 
Fundamentals of Apache Kafka
Fundamentals of Apache KafkaFundamentals of Apache Kafka
Fundamentals of Apache Kafka
 
[오픈소스컨설팅] 스카우터 사용자 가이드 2020
[오픈소스컨설팅] 스카우터 사용자 가이드 2020[오픈소스컨설팅] 스카우터 사용자 가이드 2020
[오픈소스컨설팅] 스카우터 사용자 가이드 2020
 
Data warehouse on Kubernetes - gentle intro to Clickhouse Operator, by Robert...
Data warehouse on Kubernetes - gentle intro to Clickhouse Operator, by Robert...Data warehouse on Kubernetes - gentle intro to Clickhouse Operator, by Robert...
Data warehouse on Kubernetes - gentle intro to Clickhouse Operator, by Robert...
 
Apache Kafka Architecture & Fundamentals Explained
Apache Kafka Architecture & Fundamentals ExplainedApache Kafka Architecture & Fundamentals Explained
Apache Kafka Architecture & Fundamentals Explained
 
Hive 3 a new horizon
Hive 3  a new horizonHive 3  a new horizon
Hive 3 a new horizon
 
Vert.x vs akka
Vert.x vs akkaVert.x vs akka
Vert.x vs akka
 
What's New in Apache Hive
What's New in Apache HiveWhat's New in Apache Hive
What's New in Apache Hive
 
Understanding of Apache kafka metrics for monitoring
Understanding of Apache kafka metrics for monitoring Understanding of Apache kafka metrics for monitoring
Understanding of Apache kafka metrics for monitoring
 
Aggregated queries with Druid on terrabytes and petabytes of data
Aggregated queries with Druid on terrabytes and petabytes of dataAggregated queries with Druid on terrabytes and petabytes of data
Aggregated queries with Druid on terrabytes and petabytes of data
 

Viewers also liked

Apache Hive Hook
Apache Hive HookApache Hive Hook
Apache Hive HookMinwoo Kim
 
Hbasecon2013 Wrap Up
Hbasecon2013 Wrap UpHbasecon2013 Wrap Up
Hbasecon2013 Wrap UpMinwoo Kim
 
Couchbase Usecase : Mobile Game Cookierun
Couchbase Usecase : Mobile Game CookierunCouchbase Usecase : Mobile Game Cookierun
Couchbase Usecase : Mobile Game CookierunMinwoo Kim
 
KGC 2014 가볍고 유연하게 데이터 분석하기 : 쿠키런 사례 중심 , 데브시스터즈
KGC 2014 가볍고 유연하게 데이터 분석하기 : 쿠키런 사례 중심 , 데브시스터즈KGC 2014 가볍고 유연하게 데이터 분석하기 : 쿠키런 사례 중심 , 데브시스터즈
KGC 2014 가볍고 유연하게 데이터 분석하기 : 쿠키런 사례 중심 , 데브시스터즈Minwoo Kim
 
플러스21 회사소개서 version 2016.02_company brief about Plus 21 Co.Ltd
플러스21 회사소개서 version 2016.02_company brief about Plus 21 Co.Ltd플러스21 회사소개서 version 2016.02_company brief about Plus 21 Co.Ltd
플러스21 회사소개서 version 2016.02_company brief about Plus 21 Co.LtdPlus21 Co.ltd
 
Apache Hive authorization models
Apache Hive authorization modelsApache Hive authorization models
Apache Hive authorization modelsThejas Nair
 
하이브 최적화 방안
하이브 최적화 방안하이브 최적화 방안
하이브 최적화 방안Teddy Choi
 
FRENDS 발표자료 - 취미 개발기
FRENDS 발표자료 - 취미 개발기FRENDS 발표자료 - 취미 개발기
FRENDS 발표자료 - 취미 개발기Daegeun Kim
 
Facebook Presto presentation
Facebook Presto presentationFacebook Presto presentation
Facebook Presto presentationCyanny LIANG
 
Presto, Zeppelin을 이용한 초간단 BI 구축 사례
Presto, Zeppelin을 이용한 초간단 BI 구축 사례Presto, Zeppelin을 이용한 초간단 BI 구축 사례
Presto, Zeppelin을 이용한 초간단 BI 구축 사례Hyoungjun Kim
 
Spark overview 이상훈(SK C&C)_스파크 사용자 모임_20141106
Spark overview 이상훈(SK C&C)_스파크 사용자 모임_20141106Spark overview 이상훈(SK C&C)_스파크 사용자 모임_20141106
Spark overview 이상훈(SK C&C)_스파크 사용자 모임_20141106SangHoon Lee
 
Presto - Hadoop Conference Japan 2014
Presto - Hadoop Conference Japan 2014Presto - Hadoop Conference Japan 2014
Presto - Hadoop Conference Japan 2014Sadayuki Furuhashi
 

Viewers also liked (14)

Apache Hive Hook
Apache Hive HookApache Hive Hook
Apache Hive Hook
 
Hbasecon2013 Wrap Up
Hbasecon2013 Wrap UpHbasecon2013 Wrap Up
Hbasecon2013 Wrap Up
 
Couchbase Usecase : Mobile Game Cookierun
Couchbase Usecase : Mobile Game CookierunCouchbase Usecase : Mobile Game Cookierun
Couchbase Usecase : Mobile Game Cookierun
 
KGC 2014 가볍고 유연하게 데이터 분석하기 : 쿠키런 사례 중심 , 데브시스터즈
KGC 2014 가볍고 유연하게 데이터 분석하기 : 쿠키런 사례 중심 , 데브시스터즈KGC 2014 가볍고 유연하게 데이터 분석하기 : 쿠키런 사례 중심 , 데브시스터즈
KGC 2014 가볍고 유연하게 데이터 분석하기 : 쿠키런 사례 중심 , 데브시스터즈
 
플러스21 회사소개서 version 2016.02_company brief about Plus 21 Co.Ltd
플러스21 회사소개서 version 2016.02_company brief about Plus 21 Co.Ltd플러스21 회사소개서 version 2016.02_company brief about Plus 21 Co.Ltd
플러스21 회사소개서 version 2016.02_company brief about Plus 21 Co.Ltd
 
Apache Hive authorization models
Apache Hive authorization modelsApache Hive authorization models
Apache Hive authorization models
 
하이브 최적화 방안
하이브 최적화 방안하이브 최적화 방안
하이브 최적화 방안
 
HiveServer2
HiveServer2HiveServer2
HiveServer2
 
FRENDS 발표자료 - 취미 개발기
FRENDS 발표자료 - 취미 개발기FRENDS 발표자료 - 취미 개발기
FRENDS 발표자료 - 취미 개발기
 
Facebook Presto presentation
Facebook Presto presentationFacebook Presto presentation
Facebook Presto presentation
 
Presto, Zeppelin을 이용한 초간단 BI 구축 사례
Presto, Zeppelin을 이용한 초간단 BI 구축 사례Presto, Zeppelin을 이용한 초간단 BI 구축 사례
Presto, Zeppelin을 이용한 초간단 BI 구축 사례
 
Spark overview 이상훈(SK C&C)_스파크 사용자 모임_20141106
Spark overview 이상훈(SK C&C)_스파크 사용자 모임_20141106Spark overview 이상훈(SK C&C)_스파크 사용자 모임_20141106
Spark overview 이상훈(SK C&C)_스파크 사용자 모임_20141106
 
Presto - Hadoop Conference Japan 2014
Presto - Hadoop Conference Japan 2014Presto - Hadoop Conference Japan 2014
Presto - Hadoop Conference Japan 2014
 
WTF?
WTF? WTF?
WTF?
 

Similar to Hive Authorization

DB2 authorization & priviliege
DB2 authorization & priviliegeDB2 authorization & priviliege
DB2 authorization & priviliegeSeok-joon Yun
 
제13장 사용자 권한
제13장 사용자 권한제13장 사용자 권한
제13장 사용자 권한sang doc Lee
 
Word camp seoul-2012-track3-3
Word camp seoul-2012-track3-3Word camp seoul-2012-track3-3
Word camp seoul-2012-track3-3082net
 
vine webdev
vine webdevvine webdev
vine webdevdcfc1997
 
Resource Governor in sql server 2008
Resource Governor in sql server 2008Resource Governor in sql server 2008
Resource Governor in sql server 2008Bora Choi
 
Digging into helm
Digging into helmDigging into helm
Digging into helm상준 윤
 
Migration to Azure Database for MySQL
Migration to Azure Database for MySQLMigration to Azure Database for MySQL
Migration to Azure Database for MySQLrockplace
 
[오픈소스컨설팅] Atlassian webinar 기본 트러블슈팅(1 of 2)
[오픈소스컨설팅] Atlassian webinar 기본 트러블슈팅(1 of 2)[오픈소스컨설팅] Atlassian webinar 기본 트러블슈팅(1 of 2)
[오픈소스컨설팅] Atlassian webinar 기본 트러블슈팅(1 of 2)Osc Osc
 
02.실전! 시스템 관리자를 위한 Ansible
02.실전! 시스템 관리자를 위한 Ansible02.실전! 시스템 관리자를 위한 Ansible
02.실전! 시스템 관리자를 위한 AnsibleOpennaru, inc.
 

Similar to Hive Authorization (11)

DB2 authorization & priviliege
DB2 authorization & priviliegeDB2 authorization & priviliege
DB2 authorization & priviliege
 
제13장 사용자 권한
제13장 사용자 권한제13장 사용자 권한
제13장 사용자 권한
 
Word camp seoul-2012-track3-3
Word camp seoul-2012-track3-3Word camp seoul-2012-track3-3
Word camp seoul-2012-track3-3
 
vine webdev
vine webdevvine webdev
vine webdev
 
Resource Governor in sql server 2008
Resource Governor in sql server 2008Resource Governor in sql server 2008
Resource Governor in sql server 2008
 
03.Ansible 소개
03.Ansible 소개03.Ansible 소개
03.Ansible 소개
 
Apache hive
Apache hiveApache hive
Apache hive
 
Digging into helm
Digging into helmDigging into helm
Digging into helm
 
Migration to Azure Database for MySQL
Migration to Azure Database for MySQLMigration to Azure Database for MySQL
Migration to Azure Database for MySQL
 
[오픈소스컨설팅] Atlassian webinar 기본 트러블슈팅(1 of 2)
[오픈소스컨설팅] Atlassian webinar 기본 트러블슈팅(1 of 2)[오픈소스컨설팅] Atlassian webinar 기본 트러블슈팅(1 of 2)
[오픈소스컨설팅] Atlassian webinar 기본 트러블슈팅(1 of 2)
 
02.실전! 시스템 관리자를 위한 Ansible
02.실전! 시스템 관리자를 위한 Ansible02.실전! 시스템 관리자를 위한 Ansible
02.실전! 시스템 관리자를 위한 Ansible
 

Hive Authorization

  • 1. Hive Authorization July 2nd 2013 Minwoo Kim michael.kim@nexr.com
  • 2. 이 문서는 • Hive 0.11.0 버전을 기준으로 작성 (하둡 1.1.2) • 인증에 관한 자세한 내용은 포함하지 않음 • 다음을 참고하여 작성됨 - https://cwiki.apache.org/confluence/display/Hive/ LanguageManual+Authorization - https://github.com/apache/hive BRANCH-0.11 브랜치 - 하이브 완벽 가이드, O’REILLY, 한빛 미디어 - http://www.slideshare.net/thejasmn/hive-authorization-models , Hadoop Summit 2013
  • 3. 권한 활성화 <property> <name>hive.security.authorization.enabled</name> <value>true</value> <description>하이브 클라이언트 권환을 활성화 또는 비활성화하 한다 </description> </property> hive> set hive.security.authorization.enabled=true; hive-site.xml CLI
  • 4. 권한 대상 • 하이브는 사용자user, 그룹group, 역할role에 퍼미션을 부여하거 나 회수할 수 있다 - 하이브의 사용자는 시스템 사용자 - 그룹은 사용자의 첫번째 POSIX 그룹과 동일 - HiveServer2의 경우에는 사용자를 지정하여 접속 할 수 있다
  • 5. 사용자user, 그룹group • 사용자user와 그룹group은 hive.security.authenticator.manager가 관리 org.apache.hadoop.hive.ql.security.HadoopDefaultAuthenticator 기본 구현체 - job configuration에서 hadoop.job.ugi 값으로 username과 group을 결정
  • 6. HiveAuthenticationProvider public interface HiveAuthenticationProvider extends Configurable{ public String getUserName(); public List<String> getGroupNames(); public void destroy() throws HiveException; }
  • 7. 권한 관리 구현체 • 권한은 hive.security.authorization.manager가 관리 org.apache.hadoop.hive.ql.security.authorization.DefaultHiveAu thorizationProvider 기본 구현체
  • 8. HiveAuthenticationProvider public interface HiveAuthorizationProvider extends Configurable{ public void init(Configuration conf) throws HiveException; public HiveAuthenticationProvider getAuthenticator(); public void setAuthenticator(HiveAuthenticationProvider authenticator); public void authorize(Privilege[] readRequiredPriv, Privilege[] writeRequiredPriv) throws HiveException, AuthorizationException; public void authorize(Database db, Privilege[] readRequiredPriv, Privilege[] writeRequiredPriv) throws HiveException, AuthorizationException; public void authorize(Table table, Privilege[] readRequiredPriv, Privilege[] writeRequiredPriv) throws HiveException, AuthorizationException; public void authorize(Partition part, Privilege[] readRequiredPriv, Privilege[] writeRequiredPriv) throws HiveException, AuthorizationException; public void authorize(Table table, Partition part, List<String> columns, Privilege[] readRequiredPriv, Privilege[] writeRequiredPriv) throws HiveException, AuthorizationException; }
  • 9. 역할 role • 역할role은 사용자user와 그룹group과 달리 사용자가 생성할 수 있다 CREATE ROLE role_name DROP ROLE role_name 역할 생성 GRANT ROLE role_name TO USER user1, user2 GRANT ROLE role_name TO GROUP group1 GRANT ROLE role_name TO ROLE role1 REVOKE ROLE role_name FROM USER user1 REVOKE ROLE role_name FROM GROUP group1, group2 역할 부여 / 파기
  • 10. 특권 Privileges 이름 설명 ALL 모든 퍼미션을 한번에 부여 ALTER 테이블 변경 가능 UPDATE 테이블이나 파티션에 로드 또는 삽입 가능 CREATE 테이블 생성 가능 DROP 테이블이나 파티션 삭제 가능 INDEX 색인 생성 가능 LOCK 동시성을 활성화인 경우 테이블을 잠그거나 잠금을 푼다 SELECT 테이블이나 파티션 쿼리 가능 SHOW_DATABASE 이용 가능한 데이터베이스 조회 가능
  • 11. 권한 부여/ 회수 GRANT priv_type [(column_list)] [, priv_type [(column_list)]] ... [ON object_type] TO principal_specification [, principal_specification] ... [WITH GRANT OPTION] REVOKE priv_type [(column_list)] [, priv_type [(column_list)]] ... [ON object_type priv_level] FROM principal_specification [, principal_specification] ... REVOKE ALL PRIVILEGES, GRANT OPTION FROM user [, user] ... object_type: TABLE | DATABASE priv_level: db_name | tbl_name principal_specification : USER user | GROUP group | ROLE role priv_type: ALL, ALTER, UPDATE, CREATE, DROP, INDEX, LOCK, SELECT, SHOW_DATABASE
  • 12. 권한 부여/ 회수 -- 테이블에 사용자 권한 부여 / 회수 grant select on table src_autho_test to user hive_test_user; revoke select on table src_autho_test from user hive_test_user; -- 컬럼에 사용자 권한 부여 / 회수 grant select(key) on table src_autho_test to user hive_test_user; -- 테이블에 그룹 권한 부여 / 회수 grant select on table src_autho_test to group hive_test_group1; revoke select on table src_autho_test from group hive_test_group1;
  • 13. 권한 보기 show grant user test_user on table src_autho_test; show grant user test_user on table src_autho_test(key); show grant group test_group1 on table src_autho_test; show grant group test_group1 on table src_autho_test(key); show grant role test_role1 on table src_autho_test; show grant role test_role1 on table src_autho_test(key);
  • 14. 파티션 수준의 권한 • 파티션 단위로 퍼미션을 부여하려면 PARTITION_LEVEL_PRIVILEGE를 true로 설정해야 한다 CREATE TABLE authorize_part (key INT, value STRING) PARTITIONED BY (ds STRING); -- 기존 테이블에 파티션 퍼미션 설정 ALTER TABLE authorization_part SET TBLPROPERTIES (‘PARTITION_LEVEL_PRIVILEGE’=‘TRUE’); -- 사용자에게 select 권한 파기 REVOKE SELECT ON TABLE authorization_part PARTITION (ds=’3’) FROM USER admin; -- 사용자에게 select 권한 부여 GRANT SELECT ON TABLE authorization_part PARTITION (ds=’3’) TO USER admin;
  • 15. 자동 권한 부여 <property> <name>hive.security.authorization.createtable.owner.grants</name> <value>ALL</value> <description>테이블이 생성될 때 소유자에게 자동으로 퍼미션을 설정한다. select, drop이 라 설정하면 select와 drop 퍼미션이 테이블 소유자에게 자동으로 부여된다. </description> </property> • 기타 자동 권한 부여 설정들 - hive.security.authorization.createtable.user.grant - hive.security.authorization.createtable.group.grant - hive.security.authorization.createtable.role.grant
  • 16. 자동 권한 부여 예 <property> <name>hive.security.authorization.createtable.user.grants</name> <value>admin1,michael:select;user1:create</value> </property> • 특정 사용자는 생성한 테이블에 대한 퍼미션을 자동 으로 부여 받을 수 있다
  • 18. beeline로 hs2 접근 hive --service beeline beeline 실행 • hiveserver2 를 위한 새로운 CLI beeline 접속 !connect jdbc:hive2://localhost:10000 user password org.apache.hive.jdbc.HiveDriver
  • 19. JDBC로 hs2 접근 Connection con = DriverManager.getConnection("jdbc:hive2:// localhost:10000/default", "user", "password"); Statement stmt = con.createStatement(); String sql = "select * from dual"; System.out.println("Running: " + sql); ResultSet res = stmt.executeQuery(sql); while (res.next()) { System.out.println(String.valueOf(res.getInt(1))); }
  • 20. HDFS 권한 설정 <property> <name>hive.metastore.warehouse.dir</name> <value>/user/hive/warehouse</value> <description>location of default database for the warehouse</description> </property> 기본 warehouse 위치 설정 <property> <name>hive.exec.scratchdir</name> <value>/tmp/hive-${user.name}</value> <description>Scratch space for Hive jobs</description> </property> 기본 scratchdir 위치 설정
  • 21. HDFS 권한 설정 hadoop fs -chmod -R 777 /path/to/warehouse/on/hdfs hadoop fs -chmod -R 777 /path/to/scratchdir/on/hdfs 스토리지 권한 설정 • 사용자가 HDFS상의 권한도 가지고 있어야 한다
  • 22. 대역 설정 <property> <name>hive.server2.enable.doAs</name> <value>true</value> <description> Impersonate the connected user, default true</ description> </property> • true 설정하면 대역 기능 활성화 • false 로 설정하면 hive의 시스템 사용자를 사용자로 지정한다 • 여러 사용자의 권한을 사용하기 위해서는 대역기능이 필요하므로 true로 설 정되어 있어야 한다
  • 23. 현재 하이브의 권한은 .. • 전통적인 RDBMS 방식과 스토리지 방식의 한계 • 악의적 사용자에게서 메타데이터를 완벽하게 보호하 지 못함 • 하지만 사용자의 오사용을 방지를 위해서 필요 • 새로운 권한 모델 제안 - http://www.slideshare.net/thejasmn/hive-authorization- models by Thejas Nair at Hadoop Summit 2013 - https://issues.apache.org/jira/browse/HIVE-3720
  • 24. 참고 자료 • https://cwiki.apache.org/confluence/display/ Hive/LanguageManual+Authorization • https://github.com/apache/hive BRANCH-0.11 브랜치 • 하이브 완벽 가이드, O’REILLY, 한빛 미디어 • http://www.slideshare.net/thejasmn/hive- authorization-models , Hadoop Summit 2013