[20210723]adrci show 'No ADR base is set' 解決辦法.txt

lfree發表於2021-07-23

[20210723]adrci show 'No ADR base is set' 解決辦法.txt

--//在自己的測試環境下模擬測試.參考連結

$ xxd -c 16 $ORACLE_HOME/log/diag/adrci_dir.mif
0000000: 2f75 3031 2f61 7070 2f6f 7261 636c 6500  /u01/app/oracle.

--//注意這個檔案相當奇特,實際上最後的字元是00.沒有回車換行之類的字元.

$ cat -vs $ORACLE_HOME/log/diag/adrci_dir.mif ; echo
/u01/app/oracle^@

1.環境:
SCOTT@book> @ ver1
PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

$ mv $ORACLE_HOME/log/diag/adrci_dir.mif $ORACLE_HOME/log/diag/adrci_dir.mif.ORG
`/u01/app/oracle/product/11.2.0.4/dbhome_1/log/diag/adrci_dir.mif' -> `/u01/app/oracle/product/11.2.0.4/dbhome_1/log/diag/adrci_dir.mif.ORG'

2.測試:
$ rladrci
ADRCI: Release 11.2.0.4.0 - Production on Fri Jul 23 10:02:01 2021
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
No ADR base is set
adrci>

3.分析:
$ strace -f -o aa.txt adrci

--//檢查aa.txt,可以發現如下:
23825 times({tms_utime=0, tms_stime=1, tms_cutime=0, tms_cstime=0}) = 1834869394
23825 lstat("/u01/app/oracle/product/11.2.0.4/dbhome_1/log/diag/adrci_dir.mif", 0x7fff6930c440) = -1 ENOENT (No such file or directory)
23825 stat("/u01/app/oracle/product/11.2.0.4/dbhome_1/log/diag/adrci_dir.mif", 0x7fff6930c4f0) = -1 ENOENT (No such file or directory)
23825 close(3)                          = 0

--// 嘗試建立新的adrci_dir.mif在目錄/u01/app/oracle/product/11.2.0.4/dbhome_1/log/diag/,注意我使用vim結尾0a.

$ xxd -c 16  adrci_dir.mif
0000000: 2f75 3031 2f61 7070 2f6f 7261 636c 650a  /u01/app/oracle.

$ strace -f -o bb.txt adrci
ADRCI: Release 11.2.0.4.0 - Production on Fri Jul 23 10:13:08 2021
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
No ADR base is set
adrci>

--//檢查bb.txt,可以發現如下:
24088 lstat("/u01/app/oracle/product/11.2.0.4/dbhome_1/log/diag/adrci_dir.mif", {st_mode=S_IFREG|0644, st_size=16, ...}) = 0
24088 stat("/u01/app/oracle/product/11.2.0.4/dbhome_1/log/diag/adrci_dir.mif", {st_mode=S_IFREG|0644, st_size=16, ...}) = 0
24088 open("/u01/app/oracle/product/11.2.0.4/dbhome_1/log/diag/adrci_dir.mif", O_RDONLY) = 7
24088 fcntl(7, F_SETFD, FD_CLOEXEC)     = 0
24088 read(7, "/u01/app/oracle\n", 512) = 16

--//實際上vim也可以編輯比較麻煩,使用vim -b開啟,:%!xxd; :%xxd -r.再保持就ok了.

$ xxd -c 16  adrci_dir.mif
0000000: 2f75 3031 2f61 7070 2f6f 7261 636c 65    /u01/app/oracle
--//實際上還是實際檔案差別最後沒有\0.

$ strace -f -o cc.txt adrci
ADRCI: Release 11.2.0.4.0 - Production on Fri Jul 23 10:20:06 2021
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
ADR base = "/u01/app/oracle"

--//OK,問題解決.
--//檢查cc.txt,可以發現如下:
24193 lstat("/u01/app/oracle/product/11.2.0.4/dbhome_1/log/diag/adrci_dir.mif", {st_mode=S_IFREG|0644, st_size=15, ...}) = 0
24193 stat("/u01/app/oracle/product/11.2.0.4/dbhome_1/log/diag/adrci_dir.mif", {st_mode=S_IFREG|0644, st_size=15, ...}) = 0
24193 open("/u01/app/oracle/product/11.2.0.4/dbhome_1/log/diag/adrci_dir.mif", O_RDONLY) = 7
24193 fcntl(7, F_SETFD, FD_CLOEXEC)     = 0
24193 read(7, "/u01/app/oracle", 512)   = 15

--//還原使用原來檔案呢?
$ mv $ORACLE_HOME/log/diag/adrci_dir.mif.ORG $ORACLE_HOME/log/diag/adrci_dir.mif
/bin/mv: overwrite `/u01/app/oracle/product/11.2.0.4/dbhome_1/log/diag/adrci_dir.mif'? y
`/u01/app/oracle/product/11.2.0.4/dbhome_1/log/diag/adrci_dir.mif.ORG' -> `/u01/app/oracle/product/11.2.0.4/dbhome_1/log/diag/adrci_dir.mif'

strace -f -o dd.txt adrci
ADRCI: Release 11.2.0.4.0 - Production on Fri Jul 23 10:23:19 2021
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
ADR base = "/u01/app/oracle"
adrci> quit

--//檢查dd.txt,可以發現如下:
24222 lstat("/u01/app/oracle/product/11.2.0.4/dbhome_1/log/diag/adrci_dir.mif", {st_mode=S_IFREG|0640, st_size=16, ...}) = 0
24222 stat("/u01/app/oracle/product/11.2.0.4/dbhome_1/log/diag/adrci_dir.mif", {st_mode=S_IFREG|0640, st_size=16, ...}) = 0
24222 open("/u01/app/oracle/product/11.2.0.4/dbhome_1/log/diag/adrci_dir.mif", O_RDONLY) = 7
24222 fcntl(7, F_SETFD, FD_CLOEXEC)     = 0
24222 read(7, "/u01/app/oracle\0", 512) = 16

4.補充:
--//實際上即使不使用vim來編輯也可以使用echo,tr之類命令完成.

$ xxd -c 16 adrci_dir.mif
0000000: 2f75 3031 2f61 7070 2f6f 7261 636c 650a  /u01/app/oracle.

$ cat adrci_dir.mif | tr -d '\n' | xxd -c 16
0000000: 2f75 3031 2f61 7070 2f6f 7261 636c 65    /u01/app/oracle

$ cat adrci_dir.mif | tr  '\n' '\000' | xxd -c 16
0000000: 2f75 3031 2f61 7070 2f6f 7261 636c 6500  /u01/app/oracle.

$ echo -n "/u01/app/oracle" | xxd -c 16
0000000: 2f75 3031 2f61 7070 2f6f 7261 636c 65    /u01/app/oracle

$ echo -en "/u01/app/oracle\0" | xxd -c 16
0000000: 2f75 3031 2f61 7070 2f6f 7261 636c 6500  /u01/app/oracle.

--//我就是沒想到printf,^_^.總之方法還有很多.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2782862/,如需轉載,請註明出處,否則將追究法律責任。

相關文章