Beispiel: Datenentladung mit der Generierung eines BLOB-Hochladebefehls für ein Azure -Ziel basierend auf der Verwendung des Tools cURL
Ausführungsbericht:
[i1156@lat111 ~]$ db2hpu -i i1156 -f sysin_azure
INZM031I Optim High Performance Unload for Db2 06.05.00.003.01(230710)
64 bits 07/10/2023 (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
000003 UNLOAD TABLESPACE
000004
000005 SELECT * FROM EMPLOYEE;
000006
000007 OUTFILE("outfile")
000008 LOADFILE("loadfile")
000009 LOADDEST("OBJECT_STORAGE AZURE "AZURE_CURL_ALIAS")
000010
000011 FORMAT DEL;
INZU462I HPU control step start: 07/10/2023 13:27:28.925.
INZU463I HPU control step end : 07/10/2023 13:27:29.264.
INZU464I HPU run step start : 07/10/2023 13:27:29.879.
INZU410I HPU utility has unloaded 42 rows on lat111 host for I1156.EMPLOYEE in outfile.
INZU684I HPU utility has generated an upload command for the AZURE destination in the loadfile file.
INZU465I HPU run step end : 07/10/2023 13:27:29.888.
INZI441I HPU successfully ended: Real time -> 0m0.962261s
User time -> 0m0.074943s : Parent -> 0m0.074943s, Children -> 0m0.000000s
Syst time -> 0m0.037471s : Parent -> 0m0.037471s, Children -> 0m0.000000s
Zugehöriger Abschnitt Azure in der Datei db2hpu.dest :
[Azure]
alias=AZURE_CURL_ALIAS
account=my_azure_account
curl=yes
sastoken=sv=my_sas_token
Auszug aus der generierten Ausgabedatei:
[i1156@lat111 ~]$ cat outfile
"000010","CHRISTINE","I","HAAS","A00","3978",19950101,"PRES ",18,"F",19630824,+0152750.00,+0001000.00,+0004220.00
...
"200340","ROY","R","ALONZO","E21","5698",19970705,"FIELDREP",16,"M",19560517,+0031840.00,+0000500.00,+0001907.00
Generierter Hochladebefehl:
[i1156@lat111 ~]$ cat loadfile
#!/bin/sh
echo Start uploading ...
curl --write-out "%{http_code}" -X PUT -H "x-ms-version: 2023-01-03" -H "x-ms-blob-type: BlockBlob"
-H "Content-Type: text/plain; charset=UTF-8" -H "x-ms-content-length: 4888" -T "outfile"
"https://my_azure_account.blob.core.windows.net/container1/outfile?my_sas_token" -o "EMPLOYEE.msg"
> "EMPLOYEE.msg.http" 2> "EMPLOYEE.msg.err"
RC=$?
if [ $RC -eq 0 ]
then
RC=$(cat "EMPLOYEE.msg.http")
if [ $RC -ge 300 -o $RC -lt 100 ]
then
RC=1
else
RC=0
rm -f "EMPLOYEE.msg.err"
fi
else
RC=1
fi
rm -f "EMPLOYEE.msg.http" >/dev/null 2>&1
if [ $RC -ne 0 ]
then
echo "An error occurred while processing the 'outfile' file. The 'EMPLOYEE.msg' and 'EMPLOYEE.msg.err' files
contain the associated execution reports."
else
echo "The 'outfile' file has been processed successfully. The 'EMPLOYEE.msg' file contains the associated execution report."
fi
exit $RC