示例: 通过使用 Kerberos 认证方法为 Hive 目标生成上载命令来卸载数据
执行报告:
[i1055@quickstart ~]$ db2hpu -i i1055 --debug -f sysin
INZM031I Optim High Performance Unload for Db2 06.01.00.001(160126)
64 bits 01/29/2016 (Linux quickstart.cloudera 2.6.32-358.el6.x86_64 #1 SMP Fri Feb 22 00:31:26 UTC 2013 x86_64)
INZI473I Memory limitations: 'unlimited' for virtual memory and 'unlimited' for data segment
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+
000001 GLOBAL CONNECT TO SAMPLE;
000002 UNLOAD TABLESPACE
000003 SELECT EMPNO, FIRSTNME, LASTNAME FROM EMPLOYEE;
000004 OUTFILE("outfile")
000005 LOADFILE("loadfile")
000006 LOADDEST (HADOOP HIVE WITH KERBEROS AUTH)
000007 FORMAT DEL;
INZU462I HPU control step start: 01/29/2016 11:18:11.138.
INZU463I HPU control step end : 01/29/2016 11:18:11.213.
INZU464I HPU run step start : 01/29/2016 11:18:11.253.
INZU410I HPU utility has unloaded 42 rows on quickstart host for I1055.EMPLOYEE in outfile.
INZU684I HPU utility has generated an upload command for the HIVE destination in the loadfile file.
INZU465I HPU run step end : 01/29/2016 11:18:11.760.
INZI441I HPU successfully ended: Real time -> 0m0.621900s
User time -> 0m0.637902s : Parent -> 0m0.634903s, Children -> 0m0.002999s
Syst time -> 0m0.025995s : Parent -> 0m0.020996s, Children -> 0m0.004999s
db2hpu.dest 文件中的关联 Hive 部分:
[Hive]
url=jdbc:hive2://quickstart.cloudera:10000/default;principal=hive/quickstart.cloudera@CLOUDERA
hdfspath=/tmp
user=foo/quickstart.cloudera@CLOUDERA
keytab=/tmp/foo.keytab
抽取生成的输出文件:
[i1055@quickstart ~]$ cat outfile
"000010","CHRISTINE","HAAS"
"000020","MICHAEL","THOMPSON"
,,,
"200330","HELENA","WONG"
"200340","ROY","ALONZO"
已生成上载命令:
[i1055@quickstart ~]$ cat loadfile
#!/bin/sh
kinit -k -t "/tmp/foo.keytab" "foo/quickstart.cloudera@CLOUDERA" > "EMPLOYEE.msg" 2>&1
RC=$?
if [ $RC -ne 0 ]
then
echo "Error while getting Kerberos credential. The 'EMPLOYEE.msg' file
contains the error encountered."
else
rm -f "EMPLOYEE.msg"
echo Start uploading …
hdfs dfs -put -f "outfile" "/tmp/" > "EMPLOYEE.msg" 2>&1
beeline -u
"jdbc:hive2://quickstart.cloudera:1/default;principal=hive/quickstart.cloudera@CLOUDERA"
-e "LOAD DATA INPATH '/tmp/outfile' INTO TABLE EMPLOYEE;" >> "EMPLOYEE.msg" 2>&1
RC=$?
if [ $RC -ne 0 ]
then
echo "An error occurred while processing the 'outfile' file. The
'EMPLOYEE.msg' file contains the associated execution report."
else
echo "The 'outfile' file has been processed successfully. The
'EMPLOYEE.msg' file contains the associated execution report."
fi
fi
exit $RC