作者:尘世聚散 | 来源:互联网 | 2014-05-22 16:13
将记录从mysql导出到hdfs中01ConnectURLjdbc:mysql://localhost:3306/user_action0203UserNameroot0405PassWord1234560607OutputPath/hdfs/recommend/user_action/watch_record0809
01
COnnectURL=jdbc:mysql://localhost:3306/user_action
02
03
UserName=root
04
05
PassWord=123456
06
07
OutputPath=/hdfs/recommend/user_action/watch_record
08
09
TableName= watch_record
10
11
Columns=id,uid,mid,timestamp
12
13
14
IfJobCreated =`sqoop job list | grep import_ watch_record`
15
16
#检查import_ watch_record这个job是否已经创建 如果未创建则创建
17
18
if [ $IfJobCreated = ’’ ] then
19
20
sqoop job import_ watch_record /
21
22
--create --import /
23
24
--connect $ConnectURL/
25
26
--username $UserName/
27
28
--password $PassWord/
29
30
--target-dir $OutputPath/
31
32
--m 1/
33
34
--table $TableName/
35
36
–columns $Columns/
37
38
--incremental append/
39
40
--check-column id/
41
42
--last-value 0
43
44
fi
45
46
47
48
sqoop job --exec import_ watch_record