示例:根据 AWS CLI工具的使用情况,在生成 IBM Cloud Object Storage 目标地址的上传命令的同时,进行数据卸载

在本例中、 Optim™ High Performance Unload 将根据 AWS CLI 工具的使用情况,为 IBM Cloud Object Storage 目的地生成一条上传命令,从而卸载数据。

执行报告:

[i1110@lat111 ~]$ db2hpu -i i1110 -f SYSIN
INZM031I Optim High Performance Unload for Db2 06.05.00.004.02(240430) 
         64 bits 05/03/2024 (Linux lat111 3.10.0-862.14.4.el7.x86_64 #1 SMP Fri Sep 21 09:07:21 UTC 2018 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 * FROM employee;
000004 LOADDEST(OBJECT_STORAGE IBM_COS "ibm_cos_aws")
000005 OUTFILE("outfile")
000006 LOADFILE("loadfile")
000007 FORMAT DEL;
      
INZU462I HPU control step start: 05/03/2024 15:48:57.636.
INZU463I HPU control step end  : 05/03/2024 15:48:57.915.
INZU464I HPU run step start    : 05/03/2024 15:48:57.956.
INZU410I HPU utility has unloaded 42 rows on lat111 host for I1110.EMPLOYEE in outfile.
INZU684I HPU utility has generated an upload command for the IBM COS destination in the loadfile file.
INZU465I HPU run step end      : 05/03/2024 15:48:58.391.
INZI441I HPU successfully ended: Real time -> 0m0.754764s
User time -> 0m0.086151s : Parent -> 0m0.081527s, Children -> 0m0.004624s
Syst time -> 0m0.039175s : Parent -> 0m0.029927s, Children -> 0m0.009248s

db2hpu.dest 文件中的IBM_COS关联部分:

[IBM_COS]
alias=ibm_cos_aws
ibmcloud=no
bucket=MYBUCKET
url=https://s3.eu-de.cloud-object-storage.appdomain.cloud
profile=ibm_cos

生成的输出文件摘录:

[i1110@lat111 ~]$ cat outfile
"000010","CHRISTINE","I","HAAS","A00","3978",19950101,"PRES   ",18,"F",19630824,+0152750.00,+0001000.00,+0004220.0
...
"200340","ROY","R","ALONZO","E21","5698",19970705,"FIELDREP",16,"M",19560517,+0031840.00,+0000500.00,+0001907.00

上传命令已生成:

[i1110@lat111 ~]$ cat loadfile
#!/bin/sh
      
echo Start uploading ...
aws s3 cp --content-type "text/plain; charset=UTF-8" --profile "ibm_cos" --endpoint-url "https://s3.eu-de.cloud-object-storage.appdomain.cloud" "outfile" s3://MYBUCKET > "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
exit $RC