2021/10/26

1주차: 하둡 스택 

- 스키마를 먼저 읽어오는 방식

- 프레임워크 

 1)Hive

 2)Hbase (Online NoSQL)

 3)Yarn (Manage resource manager)

: 클러스터를 효율적으로 관리

 4)Map reduce (scale data)

   -> Job tracker, Task Tracker로 구성

 5)HDFS 

   -> Namenode, datanode로 구성

 

자유노트:

- Hive를 실행하는 엔진은 Tez이다. MapReduce는 디폴트로 설정된 실행 엔진이고 이를 Tez가 대체한다.

- Hue 어플리케이션에서 Hive쿼리를 수행하면 수행 순서는 아래와 같다

1. Hive compile SQL

2. Tez가 쿼리를 execute

3. YARN이 리소스를 할당.

4. Hive updates the data in HDFS or the Hive warehouse

5. Hive returns query results over a JDBC connection

 

- Hue에서 데이터를 조회하기전, Hive에서는 메타데이터만 가지고 있음

- Hive는 mysql과 다르게 update, delete 수행을 할 수 없음. 대신에 drop partition으로 데이터를 날릴 수 있음.

- DROP TABLE external table을 하면, hive는 메타데이터(스키마)만 삭제하고 실제 데이터는 삭제하지 않음. 

- 실제로 hdfs에 데이터를 다 지우고 싶으면 

hadoop fs -rm -R -skipTrash /warehouse/tablespace/external/hive/db명/테이블명 으로 지운다.

- 그리고 나서 drop external table

 

+ 파일시스템에 파일데이터를 넣는 방법

1. sudo su -

2. mv fileexample.csv /home/hdfs

3. sudo su - hdfs

4. hdfs dfs -mkdir /user/example

5. hdfs dfs -chmod 777 /user/example

*chmod 777: readable, writable and executable by all users

 

6. hdfs dfs -put /home/hdfs/fileexample.csv /user/example

7. hdfs dfs -chmod 777 /user/example/fileexample.csv

- hdfs에 있는 데이터를 불러와서 external table schema로 만들어준다.

 

- 아래 명령어로 external table 을 managed table로 옮겨준다.

insert overwrite table (External table name)

 

Q. hive external table을 드롭하면 hdfs에서도 데이터가 지워질까?

drop external table을 하면, hdfs에 partition 디렉토리에 파일은 지워지지 않아 있다.

그래서 hadoop fs -rm -R -skipTrash /warehouse/tablespace/external/hive/db명/테이블명 으로 지운다. (위에 내용 참고)

 

- Sqoop

HDFS , RDB 사이에서 데이터를 전송해주는 툴 

Export: hive에서 생성된 테이블을 mysql로 옮겨준다.

그전에 mysql 에서 hive에서 export할 데이터를 담을 스키마를 생성해준다.

 

 

 

 

참고: https://docs.cloudera.com/HDPDocuments/HDP3/HDP-3.1.5/hive-overview/content/hive_whats_new_in_this_release_hive.html

 

What's new in this release: Apache Hive

HDP 3.x includes many Apache Hive 3 enhancements. HDP 3.x can help you improve query performance and comply with internet regulations. A few interfaces available in prior releases are unsupported in HDP 3.x. HDP 3.1.5 key features In HDP 3.1.5 and later, S

docs.cloudera.com

https://docs.cloudera.com/HDPDocuments/HDP3/HDP-3.1.5/using-hiveql/content/hive_create_an_external_table.html

 

Create, use, and drop an external table

You use an external table, which is a table that Hive does not manage, to import data from a file on a file system, into Hive. In contrast to the Hive managed table, an external table keeps its data outside the Hive metastore. Hive metastore stores only th

docs.cloudera.com

https://docs.cloudera.com/sqoop/1.4.7.7.1.6.0/user-guide/index.html#_literal_sqoop_export_literal

 

Sqoop User Guide (v1.4.7.7.1.6.0-297)

 

docs.cloudera.com

 

https://hadoop.apache.org/

 

Apache Hadoop

 

'Hadoop' 카테고리의 다른 글

Spark Concept 1)  (0) 2022.01.09
MySql DML  (0) 2017.02.27
python 데이터 - mysql 익숙해지기  (0) 2017.01.22
MySQL user 생성/권한주기 -> python연동  (0) 2017.01.22
MySQL 실행/기본  (0) 2017.01.22

+ Recent posts