DG-duplicate操作注意事項(各種報錯應對方法)

germany006發表於2018-03-30



DG-duplicate 操作注意事項

 

1、duplicate時使用者必須使用sys使用者

2、to standby的指令碼

#!/bin/bash


LOG=duplicate_`date +%Y%m%d`.log

export TMP=/tmp

export TMPDIR=$TMP

export ORACLE_BASE=/u01/oracle/app

export ORACLE_HOME=$ORACLE_BASE/11.2.0

export ORACLE_TERM=xterm

export PATH=/usr/sbin:$PATH

export PATH=$ORACLE_HOME/bin:$PATH

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib64:/usr/lib64:/usr/local/lib64:/usr/x11R6/lib64

export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib

export ORACLE_SID=orcl


/u01/oracle/app/11.2.0/bin/rman target sys/password@orcldb auxiliary sys/password@orcldb_dg log=/home/oracle/$LOG append <<eof</eof<>

run{

duplicate target database for standby from active database dorecover;

}

exit;

EOF

在RAC端任意節點透過RMAN連線到目標例項和輔助例項,執行duplicate命令複製資料庫


3、備庫是nomount狀態

4、必須將密碼檔案進行同步

(注意密碼要以字母開頭數字結尾)

[oracle@OADB1 ~]$ /u01/oracle/app/11.2.0/bin/rman target sys/passwd@orcldb


Recovery Manager: Release 11.2.0.4.0 - Production on Tue Mar 20 09:51:16 2018


Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.


RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-00554: initialization of internal recovery manager package failed

RMAN-04005: error from target database:

ORA-01017: invalid username/password; logon denied


或者

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-00554: initialization of internal recovery manager package failed

RMAN-04006: error from auxiliary database: ORA-01017: invalid username/password; logon denied



遇到這種報錯,需重置sys密碼

Alter user sys identified by passwd;

再將密碼檔案複製到備庫


或者直接在備庫手動設定密碼檔案,如下

orapwd file=$ORACLE_HOME/dbs/orapwCPDR password=change_on_install



5、是否要刪除備庫的所有資料檔案?

(如果DBF檔案沒損壞就不需要刪除)

6、修改主庫的tnsname.ora

主庫:

vi tnsname.ora

orcldb_dg=

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = IP地址)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = orcldb_dg)

    )

  )



7、引數檔案的log_file_name_convert引數需要修改成對應的目錄(備庫)

可以參考主庫的目錄設定成一模一樣


8、控制檔案路徑control_files需要修改成對應的目錄(備庫)

可以參考主庫的目錄設定成一模一樣


9、設定log_file_name_convert為空或者和主庫一樣

設定為空即與主庫路徑一致

alter system set log_file_name_convert='' scope=spfile;

或者在引數檔案中設定和主庫一致的路徑

log_file_name_convert='+orcl_DATA/orcldb','+orcl_data/orcldb_dg2'



10、備庫的引數檔案要使用spfile


11、備庫監聽不定時重啟或自動關閉


如果備庫監聽總是不定時重啟或者自動關閉,修改LISTEN.ora檔案


如下

LISTENER =

  (DESCRIPTION_LIST =

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))

      (ADDRESS = (PROTOCOL = TCP)(HOST = orcldb-dg)(PORT = 1521))

    )

  )


ADR_BASE_LISTENER = /u01/app/grid


ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON  


SID_LIST_LISTENER = 

  (SID_LIST =  

    (SID_DESC = 

      (SID_NAME = orcl1db) 

      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1) 

      (GLOBAL_DBNAME=orcl1db_dg) 

    ) 

    (SID_DESC = 

      (SID_NAME = orcl2db) 

      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1) 

      (GLOBAL_DBNAME=orcl2db_dg) 

    )

    (SID_DESC = 

      (SID_NAME = orcl3db) 

      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1) 

      (GLOBAL_DBNAME=orcl3db_dg) 

    )

  )


如果備庫安裝的是單節點ASM,使用grid使用者執行以下命令重啟監聽

srvctl stop listener

srvctl start listener



12、備庫採用字元介面命令模式掛載ASM的裸裝置

檢視ASM磁碟的詳細資訊及狀態

select group_number,disk_number,header_status,mode_status,state,total_mb,name,failgroup,path from  v$asm_disk;

select name,state from v$asm_diskgroup;


-- 新增 ASM磁碟組


Create diskgroup  orcl1_DATA  external  redundancy  disk '/dev/asm_vdd';

Create diskgroup  orcl2_DATA  external  redundancy  disk '/dev/asm_vdb';

Create diskgroup  orcl3_DATA  external  redundancy  disk '/dev/asm_vdi';


給磁碟組新增磁碟

alter diskgroup data add disk '/dev/asm_vde';

alter diskgroup data add disk '/dev/asm_vdf';

alter diskgroup data add disk '/dev/asm_vdg';

alter diskgroup data add disk '/dev/asm_vdh';

alter diskgroup data add disk '/dev/asm_vdj';


--載入磁碟組

ALTER DISKGROUP DATA MOUNT;


13、備庫注意配置/etc/hosts

ip地址 orcldb-dg



14、duplicate後,同步日誌無法成功,主庫查詢出現報錯

SQL> select inst_id,dest_name,status,error from gv$archive_dest_status where dest_name='LOG_ARCHIVE_DEST_2';


   INST_ID

----------

DEST_NAME

--------------------------------------------------------------------------------

STATUS        ERROR

--------- -----------------------------------------------------------------

        1

LOG_ARCHIVE_DEST_2

ERROR   ORA-16191: ??????????????????


        2

LOG_ARCHIVE_DEST_2

ERROR   ORA-16191: ??????????????????


或者

        2

LOG_ARCHIVE_DEST_2

ERROR   ORA-16058: ??????????


        1

LOG_ARCHIVE_DEST_2

ERROR   ORA-16058: ??????????


這個時候需要去備庫重啟資料庫例項

Shutdown immediate

startup



15、duplicate時出現報錯

(1)

RMAN-00571: ===========================================================

RMAN-03002: failure of Duplicate Db command at 03/28/2018 19:36:20

RMAN-05501: aborting duplication of target database

RMAN-03015: error occurred in stored script Memory Script

RMAN-03009: failure of backup command on ORA_DISK_1 channel at 03/28/2018 19:36:20

ORA-00245: ????????; ?????????????


嘗試手動執行命令,不用指令碼



(2)

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of Duplicate Db command at 10/22/2020 14:22:24

RMAN-05501: aborting duplication of target database

RMAN-03015: error occurred in stored script Memory Script

RMAN-03009: failure of sql command on clone_default channel at 10/22/2020 14:22:24

RMAN-11003: failure during parse/execution of SQL statement: alter database mount standby database

ORA-01103: database name 'ORCLDB' in control file is not 'ORCLDG'


檢查備庫的引數檔案, db_name 必須設定為 limsdb ,重新使用該引數檔案 spfile 啟動即可



(3)

出現以下報錯:

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of Duplicate Db command at 10/23/2020 10:53:16

RMAN-05501: aborting duplication of target database

RMAN-05001: auxiliary file name +DATA/orcldb/datafile/undotbs3.352.1052653543 conflicts with a file used by the target database

RMAN-05001: auxiliary file name +DATA/ orcldb/datafile/cpwms_data.344.1052653263 conflicts with a file used by the target database

RMAN-05001: auxiliary file name +DATA/ orcldb/datafile/cpwms_data.348.1052653077 conflicts with a file used by the target database

RMAN-05001: auxiliary file name +DATA/ orcldb/datafile/cpwms_data.350.1052652903 conflicts with a file used by the target database

RMAN-05001: auxiliary file name +DATA/ orcldb/datafile/cpwms_data.342.1052652717 conflicts with a file used by the target database

RMAN-05001: auxiliary file name +DATA/ orcldb/datafile/cpwms_data.358.1052652541 conflicts with a file used by the target database

RMAN-05001: auxiliary file name +DATA/ orcldb/datafile/cpwms_data.357.1052652357 conflicts with a file used by the target database

RMAN-05001: auxiliary file name +DATA/ orcldb/datafile/cpwms_data.260.1052652161 conflicts with a file used by the target database

RMAN-05001: auxiliary file name +DATA/ orcldb/datafile/undotbs2.346.1052653483 conflicts with a file used by the target database

RMAN-05001: auxiliary file name +DATA/ orcldb/datafile/users.343.1052653585 conflicts with a file used by the target database

RMAN-05001: auxiliary file name +DATA/ orcldb/datafile/undotbs1.351.1052653519 conflicts with a file used by the target database

RMAN-05001: auxiliary file name +DATA/ orcldb/datafile/sysaux.345.1052653439 conflicts with a file used by the target database

RMAN-05001: auxiliary file name +DATA/ orcldb/datafile/system.353.1052653569 conflicts with a file used by the target database


檢查引數檔案

*.db_file_name_convert='+DATA/ orcldb/datafile','/home/orcldg/','+DATA/ orcldb/tempfile','/home/orcldg/'

*.log_file_name_convert='+DATA/ orcldb/onlinelog','/home/orcldg/'


 

遇到以下報錯,是因為在主庫執行 rman target sys/**** auxiliary sys/****@orcldg時,沒export ORACLE_SID

RMAN-00571: ===========================================================

RMAN-03002: failure of Duplicate Db command at 10/23/2020 10:00:59

RMAN-05501: aborting duplication of target database

RMAN-06403: could not obtain a fully authorized session

ORA-01034: ORACLE not available

ORA-27101: shared memory realm does not exist

Linux-x86_64 Error: 2: No such file or directory





16、安裝備庫單節點ASM後,需要手動啟動CRS服務

crsctl start resource ora.diskmon

crsctl status resource -t

crs_stat -p ora.cssd

crsctl modify resource "ora.cssd" -attr "AUTO_START=1"   --設定自動啟動

crs_stat -p ora.diskmon

crsctl modify resource "ora.diskmon" -attr "AUTO_START=1"   --設定自動啟動


注意:這裡採用圖形介面安裝GRID軟體,要選擇第二項安裝

如果選擇的是最後一項安裝軟體,可能會漏掉一些CRS服務,導致無法使用asmca命令開啟圖形介面



17、記得把備份停止了



18、duplicate後,同步日誌無法成功,主庫查詢出現報錯

SQL> select inst_id,dest_name,status,error from gv$archive_dest_status where dest_name='LOG_ARCHIVE_DEST_2';


   INST_ID

----------

DEST_NAME

--------------------------------------------------------------------------------

STATUS   ERROR

--------- -----------------------------------------------------------------

2

LOG_ARCHIVE_DEST_2

ERROR   ORA-01033: ORACLE initialization or shutdown in progress


1

LOG_ARCHIVE_DEST_2

ERROR   ORA-01033: ORACLE initialization or shutdown in progress


   INST_ID

----------

DEST_NAME

--------------------------------------------------------------------------------

STATUS   ERROR

--------- -----------------------------------------------------------------



解決方法:

1、檢查RAC節點的密碼檔案是否同步,可以直接複製覆蓋一下

2、檢查DG節點的密碼檔案是否同步, 可以直接複製RAC的密碼檔案到DG覆蓋

3、在主節點alter system set log_archive_dest_state_2=enable;

4、再次查詢狀態變成VALID正常

SQL>  select inst_id,dest_name,status,error from gv$archive_dest_status where dest_name='LOG_ARCHIVE_DEST_2';


   INST_ID

----------

DEST_NAME

--------------------------------------------------------------------------------

STATUS   ERROR

--------- -----------------------------------------------------------------

2

LOG_ARCHIVE_DEST_2

VALID


1

LOG_ARCHIVE_DEST_2

VALID


   INST_ID

----------

DEST_NAME

--------------------------------------------------------------------------------

STATUS   ERROR

--------- -----------------------------------------------------------------


注意:檢驗是否因密碼問題導致DG日誌不同步,也可以在alter.log裡面查詢驗證(主庫和備庫都看)




19、如果遇到下面的報錯, 可能你設定的路徑並不是LOG_ARCHIVE_DEST_2

也可能是LOG_ARCHIVE_DEST_3,所以要看清楚了。  select * from V$ARCHIVE_DEST_STATUS


SQL> select inst_id,dest_name,status,error from gv$archive_dest_status where dest_name='LOG_ARCHIVE_DEST_2';


   INST_ID

----------

DEST_NAME

--------------------------------------------------------------------------------

STATUS   ERROR

--------- -----------------------------------------------------------------

2

LOG_ARCHIVE_DEST_2

BAD PARAM


1

LOG_ARCHIVE_DEST_2

BAD PARAM


   INST_ID

----------

DEST_NAME

--------------------------------------------------------------------------------

STATUS   ERROR

--------- -----------------------------------------------------------------





20、在DG庫上設定同步後,發現日誌並沒有同步

SQL> select thread#,process,client_process,sequence#,status from v$managed_standby;


   THREAD# PROCESS   CLIENT_P  SEQUENCE# STATUS

---------- --------- -------- ---------- ------------

0 ARCH      ARCH        0 CONNECTED

0 ARCH      ARCH        0 CONNECTED

0 ARCH      ARCH        0 CONNECTED

0 ARCH      ARCH        0 CONNECTED

2 MRP0      N/A     2880 APPLYING_LOG



這個時候,檢視主庫狀態

SQL> select inst_id,dest_name,status,error from gv$archive_dest_status where dest_name='LOG_ARCHIVE_DEST_2';


   INST_ID

----------

DEST_NAME

--------------------------------------------------------------------------------

STATUS   ERROR

--------- -----------------------------------------------------------------

1

LOG_ARCHIVE_DEST_2

ERROR   ORA-03135: connection lost contact


2

LOG_ARCHIVE_DEST_2

ERROR   ORA-03135: connection lost contact


   INST_ID

----------

DEST_NAME

--------------------------------------------------------------------------------

STATUS   ERROR

--------- -----------------------------------------------------------------


在主庫重新enable也沒用

alter system set log_archive_dest_state_2=ENABLE;


檢查DG備庫監聽,發現監聽沒啟動

su - oracle

lsnrctl start



然後再次檢查,發現還是不同步

主庫查狀態

SQL> select inst_id,dest_name,status,error from gv$archive_dest_status where dest_name='LOG_ARCHIVE_DEST_2';


   INST_ID

----------

DEST_NAME

--------------------------------------------------------------------------------

STATUS   ERROR

--------- -----------------------------------------------------------------

1

LOG_ARCHIVE_DEST_2

ERROR   ORA-12543: TNS:destination host unreachable


2

LOG_ARCHIVE_DEST_2

ERROR   ORA-12543: TNS:destination host unreachable


   INST_ID

----------

DEST_NAME

--------------------------------------------------------------------------------

STATUS   ERROR

--------- -----------------------------------------------------------------




這個時候,檢查DG備庫,發現,iptables -L  發現防火牆阻攔了

iptables -F清除


問題解決


主庫報錯ORA-12541

   INST_ID

----------

DEST_NAME

--------------------------------------------------------------------------------

STATUS    ERROR

--------- -----------------------------------------------------------------

         1

LOG_ARCHIVE_DEST_3

ERROR     ORA-12541: TNS:no listener


         2

LOG_ARCHIVE_DEST_3

ERROR     ORA-12541: TNS:no listener


這個時候,檢查DG備庫,發現,備庫監聽沒啟動,lsnrctl start啟動監聽後問題解決


21、 在DG庫上設定同步後,發現日誌並沒有同步

SQL> select thread#,process,client_process,sequence#,status from v$managed_standby;


   THREAD# PROCESS   CLIENT_P  SEQUENCE# STATUS

---------- --------- -------- ---------- ------------

0 ARCH      ARCH        0 CONNECTED

0 ARCH      ARCH        0 CONNECTED

0 ARCH      ARCH        0 CONNECTED

0 ARCH      ARCH        0 CONNECTED

2 MRP0      N/A     2880 APPLYING_LOG



這個時候,檢視主庫狀態

SQL> select inst_id,dest_name,status,error from gv$archive_dest_status where dest_name='LOG_ARCHIVE_DEST_2';


   INST_ID

----------

DEST_NAME

--------------------------------------------------------------------------------

STATUS   ERROR

--------- -----------------------------------------------------------------

2

LOG_ARCHIVE_DEST_2

DISABLED  ORA-16057: server not in Data Guard configuration


1

LOG_ARCHIVE_DEST_2

DISABLED  ORA-16057: server not in Data Guard configuration


   INST_ID

----------

DEST_NAME

--------------------------------------------------------------------------------

STATUS   ERROR

--------- -----------------------------------------------------------------



看到這個報錯,就要去檢查log_archive_config了


主備庫兩個都要檢查,因為他們要一致


主庫檢視

SQL> show parameter log_archive_config


NAME      TYPE VALUE

------------------------------------ ----------- ------------------------------

log_archive_config      string DG_CONFIG=orcldb,orcldbdg3)




備庫檢視

SQL> show parameter log_archive_config


NAME      TYPE VALUE

------------------------------------ ----------- ------------------------------

log_archive_config      string DG_CONFIG=(orcldbdg3,orcldbdg)


果然不一致,修改它

SQL> alter system set log_archive_config='DG_CONFIG=(orcldbdg3,orcldb)';



去主庫重新enable一下

alter system set log_archive_dest_state_2=ENABLE;



回到備庫,發現已經開通同步日誌了


22、發現以下報錯,有可能設定的log_archive_dest不是這個,檢查是否是其他的,可以在PLSQL檢查

select * from V$ARCHIVE_DEST_STATUS


SQL> select inst_id,dest_name,status,error from gv$archive_dest_status where dest_name='LOG_ARCHIVE_DEST_2';


   INST_ID

----------

DEST_NAME

--------------------------------------------------------------------------------

STATUS    ERROR

--------- -----------------------------------------------------------------

         1

LOG_ARCHIVE_DEST_2

BAD PARAM ORA-16053: DB_UNIQUE_NAME  is not in the Data Guard Configuration


         2

LOG_ARCHIVE_DEST_2

BAD PARAM


   INST_ID

----------

DEST_NAME

--------------------------------------------------------------------------------

STATUS    ERROR

--------- -----------------------------------------------------------------


#########2022-11-08更新##############

23、配置log_archive_dest_*報錯

select inst_id,dest_name,status,error from gv$archive_dest_status where dest_name='LOG_ARCHIVE_DEST_4';

  INST_ID    DEST_NAME                  STATUS        ERROR

----------   -------------------           ---------      -----------

1      LOG_ARCHIVE_DEST_4   DISABLED      ORA-12154: TNS:could not resolve the connect identifier specified


解決方法:

1、檢查tnsnames.ora,主備庫都要配置互相的tns連線,且測試網路連線

2、檢查/etc/hosts,主備庫都要互相新增hosts

主庫IP地址   主庫主機名

備庫IP地址   備庫主機名

3、主庫備庫都要修改

alter system set log_archive_config='DG_CONFIG=(utest,ksdb)';

                                                                                  (主庫SID,備庫SID)


24、網路登入測試報錯

sqlplus sys/*****@utest as sysdba


SQL*Plus: Release 19.0.0.0.0 - Production on Wed Oct 26 13:21:13 2022

Version 19.3.0.0.0


Copyright (c) 1982, 2019, Oracle.  All rights reserved.


ERROR:

ORA-12504: TNS:listener was not given the SERVICE_NAME in CONNECT_DATA


出現這個報錯時,tnsping也是不正常的,SERVICE_NAME是空的。且出現Used EZCONNECT或者Used HOSTNAME,正常的情況應該是Used TNSNAMES

Used EZCONNECT adapter to resolve the alias

Attempting to contact (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=))(ADDRESS=(PROTOCOL=tcp)(HOST=10.32.213.40)(PORT=1521)))

OK (10 msec)

Used HOSTNAME adapter to resolve the alias

Attempting to contact (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=))(ADDRESS=(PROTOCOL=tcp)(HOST=10.32.213.40)(PORT=1521)))

OK (0 msec)


解決方法:

vi /home/oracle/.bash_profile

export TNS_ADMIN=$ORACLE_HOME/network/admin


25、資料庫啟動報錯:

ORA-01103: database name 'UTEST' in control file is not 'KSDB'


解決方法:

主備primary,standby庫的instance name不一致引起的

把備庫的db_name要和主庫一致,但*.db_unique_name='standby'應為備庫的SID




26、主庫查詢LOG_ARCHIVE_DEST報錯ORA-12504

報錯:

SQL> select inst_id,dest_name,status,error from gv$archive_dest_status where dest_name='LOG_ARCHIVE_DEST_4';


   INST_ID     DEST_NAME STATUS ERROR

----------     -------------------------------------    ----------------        ----------------------------------------------------------

       1              LOG_ARCHIVE_DEST_4               DISABLED              ORA-12504: TNS:listener was not given the SERVICE_NAME in  CONNECT_DATA



解決方法:

檢查主備庫tnsping兩邊都是通的,如果還是報錯,就要檢查兩邊資料庫的版本是否一致,注意!!!!小版本也必須一致,我這邊嘗試過主庫是19.0.0.0.0,備庫是19.17.0.0.0(打了最新補丁),就會出現該報錯,將主庫打上一樣的補丁後,問題解決



27、遇到報錯:(開啟主備同步alert.log)

2022-10-31T16:12:50.947025+08:00

ARC1 (PID:1531): Error 1017 received logging on to the standby

ARC1 (PID:1531): -------------------------------------------------------------------------

ARC1 (PID:1531): Check that the source and target databases are using a password file

ARC1 (PID:1531): and remote_login_passwordfile is set to SHARED or EXCLUSIVE,

ARC1 (PID:1531): and that the SYS password is same in the password files,

ARC1 (PID:1531): returning error ORA-16191

ARC1 (PID:1531): -------------------------------------------------------------------------

ARC1 (PID:1531): FAL: Error 16191 connecting to utest for fetching gap sequence

2022-10-31T16:12:50.978660+08:00



解決方法:

將主庫的密碼檔案複製到備庫,注意許可權,oracle.oinstall




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

相關文章