NBU在備份一臺AIX服務器上的DB2數據庫時,報6號錯誤。sql
報錯截圖:數據庫
在AIX服務器上運行備份腳本,具體報錯信息以下:服務器
Executing: db2 BACKUP DATABASE BJMOA4 ONLINE LOAD /usr/openv/netbackup/bin/nbdb2.sl64 OPEN 4 SESSIONS BUFFER 1024ide
SQL2071N An error occurred while accessing the shared library ui
"/usr/openv/netbackup/bin/nbdb2.sl64". Reason code: "2".spa
1、分析檢查unix
一、檢查SQL2071Ncode
$ db2 ? SQL2071Norm
SQL2071N An error occurred while accessing the shared library blog
"<shr-lib-name>". Reason code: "<reason-code>"
Explanation:
An unexpected error occurred while accessing a vendor shared
library during the processing of a database utility. The
following is a list of reason codes:
1 An invalid shared library path was encountered.
2 An attempt to load the backup shared library failed.
3 An error was encountered while unloading the shared library.
The utility stops processing.
User Response:
Ensure the shared library provided is valid and resubmit the
utility command or use another supported media.
二、分析共享庫的載入
# ldd /usr/openv/netbackup/bin/nbdb2.sl64
/usr/openv/netbackup/bin/nbdb2.sl64 needs:
/usr/openv/lib/libxbsa64.so
/usr/openv/lib/libVcvcomb64_noul.so
/usr/lib/libc.a(shr_64.o)
/usr/lib/libdl.a(shr_64.o)
/unix
/usr/lib/libcrypt.a(shr_64.o)
使用LDD命令可顯示所依賴的動態鏈接庫的儘量的詳細信息
根據提示去檢查列出的文件是否都存在,若是不存在能夠從其餘正常可備份的機器上拷貝。
三、分析CODE 2
#cat /usr/include/sys/errno.h
#define EPERM 1 /* Operation not permitted */
#define ENOENT 2 /* No such file or directory */
#define ESRCH 3 /* No such process */
#define EINTR 4 /* interrupted system call */
#define EIO 5 /* I/O error */
#define ENXIO 6 /* No such device or address */
#define E2BIG 7 /* Arg list too long */
#define ENOEXEC 8 /* Exec format error */
#define EBADF 9 /* Bad file descriptor */
#define ECHILD 10 /* No child processes */
#define EAGAIN 11 /* Resource temporarily unavailable */
#define ENOMEM 12 /* Not enough space */
#define EACCES 13 /* Permission denied */
#define EFAULT 14 /* Bad address */
#define ENOTBLK 15 /* Block device required */
根據提示,可推斷沒有找到相關文件或路徑不正確
四、分析DB2diag.log文件
DATA #3 : String, 265 bytes
0509-022 Cannot load module /usr/openv/netbackup/bin/nbdb2.sl64(shr.o).
0509-153 File /usr/openv/netbackup/bin/nbdb2.sl64 is not an archive or
the file could not be read properly.
FUNCTION: DB2 UDB, database utilities, sqlubcka, probe:140
MESSAGE : Backup Terminated.
根據以上的分析,可確知歸檔目錄讀取不正確
五、檢查當前數據庫是否開啓歸檔
$ db2 get db cfg for bjtt4|grep -i log
Log retain for recovery enabled (LOGRETAIN) = RECOVERY
User exit for logging enabled (USEREXIT) = OFF
HADR log write synchronization mode (HADR_SYNCMODE) = NEARSYNC
First log archive method (LOGARCHMETH1) = LOGRETAIN
發現設置了歸檔,但歸檔目錄沒指定
2、解決問題
First log archive method (LOGARCHMETH1) =DISK:/archivelog/db2log/
這個參數修改後,須要重啓數據庫才能生效。
重啓後,發現問題已解決,能夠從新正常備份了。
另外若是你是在作數據庫恢復時,遇到這樣的問題
例如:RESTORE DATABASE EPD FROM /db2 TAKEN AT 20130525112121 TO /db2/EPP INTO EPP NEWLOGPATH /db2/EPP/log_dir/ WITH 2
BUFFERS BUFFER 1024 REDIRECT
SQL2529W Warning! Restoring to an existing database that is different from the backup p_w_picpath database, and the alias name "EPP" of the existing database does not match the alias name "EPD" of the backup p_w_picpath, and the database name "EPP" of the existing database does not match the database name "EPD" of the backup p_w_picpath. The target database will be overwritten by the backup version. The Roll-forward recovery logs associated with the target database will be deleted.
Do you want to continue ? (y/n) y
SQL2071N An error occurred while accessing the shared library
"/db2/EPP/db2EPP/NODE0000/SQL00001/libdb2compr.a". Reason code: "2".
能夠在恢復腳本上增長如下參數便可:
COMPRLIB /db2/db2EPP/sqllib/lib/libdb2compr.a
補充:
SQL2071N An error occurred while accessing the shared library
"/usr/openv/netbackup/bin/nbdb2.sl64". Reason code: "2".
這個問題的另一種緣由就是你的服務器若是裝的是32位的NBU客戶端,則不能使用nbdb2.sl64這個文件,而應該在腳本中指明使用nbdb2.sl這個32位的文件。這個問題跟你的服務器是64位的無關。
(# Change MY_LIB to the correct NetBackup library name for your host:
# Solaris or Linux 32-bit = nbdb2.so
# Solaris 64-bit = nbdb2.so64
# AIX or HPUX 32-bit = nbdb2.sl
# AIX or HPUX 64-bit = nbdb2.sl64)