-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathlecture_01
92 lines (81 loc) · 4.47 KB
/
lecture_01
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# lecture #1
############################################################################################################################
############################################################################################################################
Hive 테이블 생성하기
----------------------------------------------------------------------------------------------------------------------------
[root@sandbox-hdp lecture_01]# beeline
beeline> !connect jdbc:hive2://localhost:10000/default (id : hive / pwd : hive)
0: jdbc:hive2://sandbox-hdp.hortonworks.com:1> CREATE DATABASE lecture;
0: jdbc:hive2://sandbox-hdp.hortonworks.com:1> CREATE EXTERNAL TABLE `lecture.u_data` (
userid INT,
movieid INT,
rating INT,
unixtime STRING)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '\t'
STORED AS TEXTFILE
LOCATION
'hdfs://sandbox-hdp.hortonworks.com:8020/user/hive/warehouse/lecture.db/u_data';
############################################################################################################################
############################################################################################################################
chown stage-data files
----------------------------------------------------------------------------------------------------------------------------
[root@sandbox-hdp lecture_01]# sudo -u hdfs hadoop fs -chown -R hive /stage-data/ml-100k
############################################################################################################################
############################################################################################################################
File : workflow.xml
----------------------------------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<workflow-app name="lecture_01" xmlns="uri:oozie:workflow:0.5" xmlns:sla="uri:oozie:sla:0.2">
<global/>
<start to="hive_action_1"/>
<kill name="Kill">
<message>Action Failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
</kill>
<action name="hive_action_1">
<hive2 xmlns="uri:oozie:hive2-action:0.2">
<job-tracker>${jobTracker}</job-tracker>
<name-node>${nameNode}</name-node>
<prepare/>
<configuration>
<property>
<name>mapred.job.queue.name</name>
<value>${queueName}</value>
</property>
</configuration>
<jdbc-url>jdbc:hive2://localhost:10000/lecture</jdbc-url>
<password>hive</password>
<script>lib/load_datafile.hql</script>
</hive2>
<ok to="end"/>
<error to="Kill"/>
</action>
<end name="end"/>
</workflow-app>
----------------------------------------------------------------------------------------------------------------------------
############################################################################################################################
############################################################################################################################
File : lib/load_datafile.hql
----------------------------------------------------------------------------------------------------------------------------
LOAD DATA INPATH '/stage-data/ml-100k/u.data' INTO TABLE lecture.u_data;
----------------------------------------------------------------------------------------------------------------------------
############################################################################################################################
############################################################################################################################
File : job.properties
----------------------------------------------------------------------------------------------------------------------------
user.name=mapred
TODAY_YMD=20180507
oozie.use.system.libpath=true
oozie.wf.application.path=${nameNode}/user/oozie/workflow/lecture_01
queueName=default
nameNode=hdfs://sandbox-hdp.hortonworks.com:8020
oozie.libpath=
jobTracker=sandbox-hdp.hortonworks.com\:8032
----------------------------------------------------------------------------------------------------------------------------
### oozie job 실행 방법
1. workflow 경로를 HDFS 로 복사
hadoop fs -put (-f) lecture_01 /user/oozie/workflow/.
2. job.properties 파일이 있는 경로로 이동.
cd lecture_01
3. oozie CLI command 실행
oozie job -config job.properties -run