Oracle備庫無法連線主庫的問題分析

jeanron100發表於2017-08-03

今天在搭建DG的時候碰到了一個蠻有意思的問題,耗費了不少腦細胞,簡單記錄一下。

首先主庫是Queuedb,備庫是s2queuedb,使用RMAN的duplicate來搭建,主備庫的網路配置listener.ora,tnsnames.ora都沒有問題。

但是使用RMAN命令的時候就丟擲了下面的錯誤,從錯誤資訊可以看出來,主庫是沒有啟動起來。

$ rman target sys@Queuedb auxiliary sys@s2queuedb nocatalog
connected to target database: QUEUEDB (not mounted)
using target database control file instead of recovery catalog
auxiliary database Password:
connected to auxiliary database: QUEUEDB (not mounted)

看到這裡,心裡咯噔一下,難道資料庫當機了?

趕緊連線到主庫去看,發現主庫的狀態都正常,鬆了一口氣,繼續在備庫看問題的緣由。
在備庫端使用TNS的方式連線,丟擲了錯誤,看起來資料庫是明顯連線到備庫了。

$ sqlplus xx/xx@queuedb
ERROR:
ORA-01033: ORACLE initialization or shutdown in progress
Process ID: 0
Session ID: 0 Serial number: 0

但是檢視tnsping的結果,和主庫的輸出一致,完全沒問題啊。

而換一個思路,直接連備庫,因為還沒有open,輸出肯定是01033的錯誤。

$ sqlplus xx/xx@s2queuedb
ERROR:
ORA-01033: ORACLE initialization or shutdown in progress
Process ID: 0
Session ID: 0 Serial number: 0

反反覆覆確認了主機名的配置,暫時都沒有發現問題。帶著疑惑也對比了ORACLE_HOME,依然無果。

[oracle@s2queuedb admin]$ ps -ef|grep smon
oracle    43186      1  0 11:15 ?        00:00:00 ora_smon_Queuedb
oracle    43277  43064  0 11:28 pts/0    00:00:00 grep smon
$ cat /proc/43188/environ|xargs -0 -n1|grep ORACLE_HOME
ORACLE_HOME=/U01/app/oracle/product/11.2.0.4
$ echo $ORACLE_HOME
/U01/app/oracle/product/11.2.0.4所以說上面的檢查就只能到這裡了,我們得換個思路來看待這個問題。
既然/etc/hosts裡面的配置沒問題,主機名Queuedb_ZS.test.com指向主庫,tnsping沒問題,拿我就使用ping來測試。

$ ping Queuedb_ZS.test.com
PING Queuedb_ZS.test.com (127.0.0.1) 56(84) bytes of data.
64 bytes from Queuedb_ZS.test.com (127.0.0.1): icmp_seq=1 ttl=64 time=0.019 ms
64 bytes from Queuedb_ZS.test.com (127.0.0.1): icmp_seq=2 ttl=64 time=0.008 ms
^C這個結果讓我有一種頓悟的感覺,我再次審視/etc/hosts檔案的配置。

$ cat /etc/hosts
127.0.0.1   Queuedb_ZS.test.com localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
10.127.xx.166  Queuedb_ZS.test.com
10.129.xx.190   s2queuedb.test.com

發現竟然在127.0.0.1的地方配置了一個主機名Queuedb_ZS.test.com,這樣就會優先去走這個訪問路徑了,果斷刪除,再次嘗試就沒有問題了。

   而如果你刪除不得當,直接把127.0.0.1的配置全刪除了,那麼啟動監聽肯定會丟擲下面的錯誤。

-bash-4.1$ lsnrctl start LISTENER_1528
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=s3nstatdb.test.com)(PORT=1528)))
TNS-12547: TNS:lost contact
 TNS-12560: TNS:protocol adapter error
  TNS-00517: Lost contact
   Linux Error: 104: Connection reset by peer

所以這些看起來瑣碎的配置還是尤其需要注意的。





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

相關文章