一步一步搭建11gR2 rac+dg之配置單例項的DG(八)

達芬奇的夢發表於2018-03-13




  1. RAC主庫配置單例項ActiveDataguard

本文文件結構:


這裡配置的過程中需要注意的一項是多看看rac1和rac2以及dg的告警日誌會對配置過程有更深刻的理解。。。配置oracle rac的dg環境說白了首先將主庫的資料恢復到從庫上,然後在主從庫上配置一些DG需要用到的引數


注意:

  1. 由於DG是以DB_UNIQUE_NAME作為區分資料庫標識的,因此主從庫的該引數一定要不同以做區分。但是資料庫名db_name必須一致以便主從切換時方便
  2. Standby庫只需要安裝資料庫軟體,不必建立資料庫
  3. 主從庫的資料庫軟體大版本必須一致,且必須是企業版資料庫EE


  1. RAC主庫準備工作

該步驟主要是① 將rac主庫修改為歸檔+forcelogging模式 ② 利用rman備份db、archivelog、control file 、pfile 和口令檔案

  1. ①RAC主庫必須置為歸檔模式:

和下一步一起做

  1. ②RAC主庫必須置為ForceLogging模式:

alter database force logging;

alter database archivelog; ---歸檔模式下修改




SQL> alter database force logging;


Database altered.



SQL> select name , open_mode, log_mode,force_logging from gv$database;


NAME     OPEN_MODE     LOG_MODE FOR

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

RACDB     READ WRITE     NOARCHIVELOG YES

RACDB     READ WRITE     NOARCHIVELOG YES


SQL> exit





[oracle@rac1 ~]$ sqlplus / as sysdba


SQL*Plus: Release 11.2.0.3.0 Production on Fri Oct 3 15:30:17 2014


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


Connected to an idle instance.


SQL> startup mount

ORACLE instance started.


Total System Global Area 784998400 bytes

Fixed Size         2232472 bytes

Variable Size         532680552 bytes

Database Buffers     247463936 bytes

Redo Buffers         2621440 bytes

Database mounted.

SQL> select name , open_mode, log_mode,force_logging from gv$database;


NAME     OPEN_MODE     LOG_MODE FOR

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

RACDB     MOUNTED     NOARCHIVELOG YES


SQL> alter database archivelog;


Database altered.


SQL> shutdown immediate;

ORA-01109: database not open



Database dismounted.

ORACLE instance shut down.

SQL>




SQL> select name , open_mode, log_mode,force_logging from gv$database;


NAME     OPEN_MODE     LOG_MODE FOR

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

RACDB     READ WRITE     ARCHIVELOG YES

RACDB     READ WRITE     ARCHIVELOG YES


SQL>


  1. ③RAC主庫執行RMAN全備:

run {

allocate channel c1 type disk;

allocate channel c2 type disk;

allocate channel c3 type disk;

allocate channel c4 type disk;

backup database format '/rman_backup/FULL_%U.bak';

backup archivelog all format '/rman_backup/ARC_%U.bak';

release channel c1;

release channel c2;

release channel c3;

release channel c4;

}





  1. ④RAC主庫執行建立物理備庫控制檔案:

Rman下:backup device type disk format '/rman_backup/standby_%U.ctl' current controlfile for standby;


或:SQL>alter database create standby controlfile as '/dats/backup/standby.ctl'



  1. ⑤RAC主庫建立物理備庫初始化引數檔案:


create pfile ='/rman_backup/initphydb.ora' from spfile;



SQL> show parameter spfile


NAME                 TYPE     VALUE

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

spfile                 string     +DATA/racdb/spfileracdb.ora

SQL>


SQL> show parameter cluster_database


NAME                 TYPE     VALUE

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

cluster_database         boolean     TRUE

cluster_database_instances     integer     2

SQL>




  1. ⑥RAC主庫修改口令檔案,使雙節點SYS使用者口令一致:


最好是將其中一個口令檔案複製到另外一個節點上,最後複製到dg下,確保口令檔案是一樣的



  1. 物理備庫準備工作

    1. ①FTP主庫備份檔案+備庫控制檔案+備庫引數檔案至物理備庫伺服器:


將備份檔案全部傳遞到dg庫:


----rac1

scp /rman_backup/*.bak oracle@192.168.59.140:/rman_backup/

scp /u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwracdb1 oracle@192.168.59.140:/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwphydb




  1. ②物理備庫建立口令檔案:

上一步已做,不需要建立了

  1. ③物理備庫初始化引數檔案修改:



----------dg

[oracle@dg rman_backup]$ cp initphydb.ora $ORACLE_HOME/dbs/

[oracle@dg rman_backup]$ cd $ORACLE_HOME/dbs


這個是比較重要的步驟,我把行號弄出來了,當然寫的時候是沒有前邊的行號的


物理備庫初始化引數檔案修改:


  1. phydb.__db_cache_size=255852544
  2. phydb.__java_pool_size=4194304
  3. phydb.__large_pool_size=4194304
  4. phydb.__oracle_base='/u01/app/oracle'#ORACLE_BASE environment from set
  5. phydb.__pga_aggregate_target=419430400
  6. phydb.__sga_target=423624704
  7. phydb.__shared_io_pool_size=0
  8. phydb.__shared_pool_size=146800640
  9. phydb.__streams_pool_size=0
  10. *.audit_file_dest='/u01/app/oracle/admin/phydb/adump'
  11. *.audit_trail='db'
  12. *.cluster_database=false
  13. *.compatible='11.2.0.0.0'
  14. *.control_files='+DATA/phydb/controlfile/cont.ctl'
  15. *.core_dump_dest='/u01/app/oracle/diag/rdbms/phydb/cdump'
  16. *.db_block_size=8192
  17. *.db_create_file_dest='+DATA'
  18. *.db_domain=''
  19. *.db_file_name_convert='+DATA/racdb/','+DATA/phydb/'
  20. *.db_name='racdb'
  21. *.db_recovery_file_dest='+FRA'
  22. *.db_recovery_file_dest_size=4070572032
  23. *.db_unique_name='phydb'
  24. *.diagnostic_dest='/u01/app/oracle'
  25. *.dispatchers='(PROTOCOL=TCP)(SERVICE=phydbXDB)'
  26. *.fal_client='phydb'
  27. *.fal_server='racdb1','racdb2'
  28. *.log_archive_config='dg_config=(racdb,phydb)'
  29. *.log_archive_dest_1='location=USE_DB_RECOVERY_FILE_DEST valid_for=(all_logfiles,all_roles) db_unique_name=phydb'
  30. *.log_archive_dest_2='service=racdb1 valid_for=(online_logfiles,primary_role) db_unique_name=racdb'
  31. *.log_archive_format='ARC_%t_%S_%r.arc'
  32. *.log_file_name_convert='+DATA/racdb/','+DATA/phydb/'
  33. *.memory_target=842006528
  34. *.open_cursors=300
  35. *.processes=150
  36. *.remote_login_passwordfile='exclusive'
  37. *.service_names='phydb'
  38. *.standby_file_management='auto'
  39. *.thread=1
  40. *.undo_management='auto'
  41. *.undo_tablespace='UNDOTBS1'





[oracle@dg dbs]$ mkdir -p /u01/app/oracle/admin/phydb/adump

[oracle@dg dbs]$ mkdir -p /u01/app/oracle/diag/rdbms/phydb/cdump

[oracle@dg dbs]$


[grid@dg ~]$ asmcmd

ASMCMD> ls

DATA/

FRA/

GRIDDG/

ASMCMD> cd DATA

ASMCMD> ls

ASMCMD> mkdir phydb

ASMCMD> ls

phydb/

ASMCMD>



  1. ④配置RAC主庫,物理備庫的tnsnames.ora檔案:

將以下內容複製到rac1,rac2和dg庫:

racdb =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.59.139)(PORT = 1521))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = racdb.lhr.com)

)

)


racdb1 =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.59.135)(PORT = 1521))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = racdb.lhr.com)

(INSTANCE_NAME = racdb1)

)

)


racdb2 =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.59.136)(PORT = 1521))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = racdb.lhr.com)

(INSTANCE_NAME = racdb2)

)

)


phydb =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.59.140)(PORT = 1521))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = phydb)

)

)


驗證一下:

分別在3個庫上執行:

sqlplus sys/lhr@racdb as sysdba

sqlplus sys/lhr@racdb1 as sysdba

sqlplus sys/lhr@racdb2 as sysdba


確保3個庫可以連線

  1. 建立物理備庫

    1. ①物理備庫啟動NOMOUNT狀態:

startup nomount

  1. ②RMAN恢復備庫控制檔案:

[oracle@dg dbs]$ rman target /


Recovery Manager: Release 11.2.0.3.0 - Production on Fri Oct 3 19:06:52 2014


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


connected to target database: RACDB (not mounted)


RMAN> restore standby controlfile from '/rman_backup/standby_0tpk53jq_1_1.ctl';


Starting restore at 2014-10-03 19:06:55

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=16 device type=DISK


channel ORA_DISK_1: restoring control file

channel ORA_DISK_1: restore complete, elapsed time: 00:00:25

output file name=+DATA/phydb/controlfile/cont.ctl

Finished restore at 2014-10-03 19:07:22


RMAN>



  1. ③MOUNT物理備庫:

SQL> alter database mount;

  1. ④RMAN restore物理備庫:

run {

allocate channel c1 type disk;

allocate channel c2 type disk;

allocate channel c3 type disk;

allocate channel c4 type disk;

restore database ;

release channel c1;

release channel c2;

release channel c3;

release channel c4;

}



RMAN> restore database ;


Starting restore at 2014-10-03 19:13:48

Starting implicit crosscheck backup at 2014-10-03 19:13:48

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=32 device type=DISK

Crosschecked 6 objects

Finished implicit crosscheck backup at 2014-10-03 19:13:49


Starting implicit crosscheck copy at 2014-10-03 19:13:49

using channel ORA_DISK_1

Finished implicit crosscheck copy at 2014-10-03 19:13:49


searching for all files in the recovery area

cataloging files...

no files cataloged


using channel ORA_DISK_1


channel ORA_DISK_1: starting datafile backup set restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_DISK_1: restoring datafile 00001 to +DATA/phydb/datafile/system.256.859849357

channel ORA_DISK_1: restoring datafile 00004 to +DATA/phydb/datafile/users.259.859849357

channel ORA_DISK_1: restoring datafile 00005 to +DATA/phydb/datafile/example.264.859849549

channel ORA_DISK_1: reading from backup piece /rman_backup/FULL_0npk5395_1_1.bak

channel ORA_DISK_1: piece handle=/rman_backup/FULL_0npk5395_1_1.bak tag=TAG20141003T164524

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:04:23

channel ORA_DISK_1: starting datafile backup set restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_DISK_1: restoring datafile 00002 to +DATA/phydb/datafile/sysaux.257.859849357

channel ORA_DISK_1: restoring datafile 00003 to +DATA/phydb/datafile/undotbs1.258.859849357

channel ORA_DISK_1: restoring datafile 00006 to +DATA/phydb/datafile/undotbs2.265.859849971

channel ORA_DISK_1: reading from backup piece /rman_backup/FULL_0opk53c4_1_1.bak

channel ORA_DISK_1: piece handle=/rman_backup/FULL_0opk53c4_1_1.bak tag=TAG20141003T164524

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:01:45

Finished restore at 2014-10-03 19:20:01


RMAN>



  1. ⑤備庫上建立standbylogfile:

SQL> select name from v$datafile

2 union

3 select name from v$controlfile

4 union

5 select member from v$logfile;


NAME

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

+DATA/phydb/controlfile/cont.ctl

+DATA/phydb/datafile/example.258.860008433

+DATA/phydb/datafile/sysaux.260.860008695

+DATA/phydb/datafile/system.257.860008433

+DATA/phydb/datafile/undotbs1.261.860008697

+DATA/phydb/datafile/undotbs2.262.860008697

+DATA/phydb/datafile/users.259.860008435

+DATA/phydb/onlinelog/group_1.261.859849493

+DATA/phydb/onlinelog/group_2.262.859849495

+DATA/phydb/onlinelog/group_3.266.859850179

+DATA/phydb/onlinelog/group_4.267.859850183

+FRA/racdb/onlinelog/group_1.257.859849493

+FRA/racdb/onlinelog/group_2.258.859849495

+FRA/racdb/onlinelog/group_3.259.859850181

+FRA/racdb/onlinelog/group_4.260.859850187


15 rows selected.


SQL>


建立standbylogfile,這裡的大小應根據主庫的v$log中的bytes列來計算:



alter database add standby logfile thread 1 group 5 size 50M ,group 6 size 50M ,group 7 size 50M ;

alter database add standby logfile thread 2 group 8 size 50M ,group 9 size 50M ,group 10 size 50M ;


建立完成後查詢:

select * from v$standby_log;


SQL> set linesize 1200

SQL> select * from v$standby_log;


GROUP# DBID                  THREAD#    SEQUENCE# BYTES BLOCKSIZE USED ARC STATUS     FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME LAST_CHANGE# LAST_TIME

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

     5 UNASSIGNED                     1        0 52428800     512      0 NO UNASSIGNED

     6 UNASSIGNED                     1        0 52428800     512      0 NO UNASSIGNED

     7 UNASSIGNED                     1        0 52428800     512      0 YES UNASSIGNED

     8 UNASSIGNED                     2        0 52428800     512      0 NO UNASSIGNED

     9 UNASSIGNED                     2        0 52428800     512      0 NO UNASSIGNED

    10 UNASSIGNED                     2        0 52428800     512      0 YES UNASSIGNED


6 rows selected.


SQL>

SQL> col member for a50

SQL> select * from v$logfile;


GROUP# STATUS TYPE MEMBER                     IS_

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

     2     ONLINE +DATA/phydb/onlinelog/group_2.270.860171617     NO

     2     ONLINE +FRA/phydb/onlinelog/group_2.294.860171767     YES

     1     ONLINE +DATA/phydb/onlinelog/group_1.269.860171391     NO

     1     ONLINE +FRA/phydb/onlinelog/group_1.293.860171601     YES

     3     ONLINE +DATA/phydb/onlinelog/group_3.271.860171811     NO

     3     ONLINE +FRA/phydb/onlinelog/group_3.295.860171893     YES

     4     ONLINE +DATA/phydb/onlinelog/group_4.272.860171905     NO

     4     ONLINE +FRA/phydb/onlinelog/group_4.296.860172007     YES

     5     STANDBY +DATA/phydb/onlinelog/group_5.263.860014755     NO

     5     STANDBY +FRA/phydb/onlinelog/group_5.256.860014769     YES

     6     STANDBY +DATA/phydb/onlinelog/group_6.264.860014775     NO

     6     STANDBY +FRA/phydb/onlinelog/group_6.257.860014789     YES

     7     STANDBY +DATA/phydb/onlinelog/group_7.265.860014795     NO

     7     STANDBY +FRA/phydb/onlinelog/group_7.258.860014811     YES

     8     STANDBY +DATA/phydb/onlinelog/group_8.266.860090543     NO

     8     STANDBY +FRA/phydb/onlinelog/group_8.259.860090581     YES

     9     STANDBY +DATA/phydb/onlinelog/group_9.267.860090607     NO

     9     STANDBY +FRA/phydb/onlinelog/group_9.260.860090659     YES

    10     STANDBY +DATA/phydb/onlinelog/group_10.268.860090669 NO

    10     STANDBY +FRA/phydb/onlinelog/group_10.261.860090715     YES


20 rows selected.


SQL>


這裡可能會報一個錯誤:

ORA-15041: diskgroup "DATA" space exhausted

就是磁碟不足,具體大家上網搜吧,解決辦法就是新增磁碟,不詳解了:



alter diskgroup DATA add disk '/dev/raw/raw5';




  1. ⑥主庫引數調整:

[oracle@rac2 ~]$ sqlplus / as sysdba


SQL*Plus: Release 11.2.0.3.0 Production on Fri Oct 10 15:59:46 2014


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



Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,

Data Mining and Real Application Testing options


SQL> show parameter spfile


NAME                 TYPE     VALUE

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

spfile                 string     +DATA/racdb/spfileracdb.ora

SQL>


--rac1

alter system set log_archive_dest_2='service=phydb lgwr sync valid_for=(online_logfiles,primary_role) db_unique_name=phydb' sid='*';

alter system set log_archive_config='dg_config=(racdb,phydb)' sid='*';


配置後的結果:

SQL> show parameter log_archive_dest_2


NAME                 TYPE     VALUE

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

log_archive_dest_2         string     service=phydb lgwr sync valid_

                         for=(online_logfiles,primary_r

                         ole) db_unique_name=phydb


SQL> show parameter log_archive_config


NAME                 TYPE     VALUE

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

log_archive_config         string     dg_config=(racdb,phydb)

SQL>



  1. ⑦備庫接收主庫日誌:

SQL> select sequence#,name,applied from v$archived_log;


SEQUENCE# NAME                                                 APPLIED

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

    39 +FRA/phydb/archivelog/2014_10_10/thread_2_seq_39.327.860599799                    NO

    40 +FRA/phydb/archivelog/2014_10_10/thread_2_seq_40.328.860599799                    NO

    41 +FRA/phydb/archivelog/2014_10_10/thread_2_seq_41.329.860599953                    NO

    49 +FRA/phydb/archivelog/2014_10_10/thread_1_seq_49.330.860600751                    NO

    50 +FRA/phydb/archivelog/2014_10_10/thread_1_seq_50.331.860600755                    NO

    51 +FRA/phydb/archivelog/2014_10_10/thread_1_seq_51.332.860600869                    NO

    42 +FRA/phydb/archivelog/2014_10_10/thread_2_seq_42.333.860601127                    NO

    43 +FRA/phydb/archivelog/2014_10_10/thread_2_seq_43.334.860601131                    NO

    44 +FRA/phydb/archivelog/2014_10_10/thread_2_seq_44.335.860601415                    NO


9 rows selected.


SQL>


這裡如果備庫無法順利接收主庫日誌,則主庫的alert日誌中有如下提示:

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

Check that the primary and standby are using a password file

and remote_login_passwordfile is set to SHARED or EXCLUSIVE,

and that the SYS password is same in the password files.

returning error ORA-16191

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

PING[ARC2]: Heartbeat failed to connect to standby 'phydb'. Error is 16191.

Process J000 died, see its trace file

kkjcre1p: unable to spawn jobq slave process

Errors in file /u01/app/oracle/diag/rdbms/racdb/racdb2/trace/racdb2_cjq0_14236.trc:

Process NSS2 died, see its trace file

Process J000 died, see its trace file

kkjcre1p: unable to spawn jobq slave process

Errors in file /u01/app/oracle/diag/rdbms/racdb/racdb2/trace/racdb2_cjq0_14236.trc:

Error 443 for archive log file 3 to 'phydb'

LGWR: Failed to archive log 3 thread 2 sequence 25 (443)

Process O000 died, see its trace file


該節點的使用者口令和備庫的口令不一致,最好的辦法是生成一份口令檔案之後,然後將該口令檔案複製到其它節點,重新生成口令有的時候也報錯的


---- 3 個節點

orapwd file=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwracdb2 password=lhr force=y



  1. ⑧備庫開始應用日誌:


SQL> alter database recover managed standby database using current logfile disconnect from session;


Database altered.


過幾分鐘後:



SQL> select sequence#,name,applied from v$archived_log;


SEQUENCE# NAME                                                                     APPLIED

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

39 +FRA/phydb/archivelog/2014_10_10/thread_2_seq_39.327.860599799                    YES

    40 +FRA/phydb/archivelog/2014_10_10/thread_2_seq_40.328.860599799                    YES

    41 +FRA/phydb/archivelog/2014_10_10/thread_2_seq_41.329.860599953                    YES

    49 +FRA/phydb/archivelog/2014_10_10/thread_1_seq_49.330.860600751                    YES

    50 +FRA/phydb/archivelog/2014_10_10/thread_1_seq_50.331.860600755                    YES

    51 +FRA/phydb/archivelog/2014_10_10/thread_1_seq_51.332.860600869                    YES

    42 +FRA/phydb/archivelog/2014_10_10/thread_2_seq_42.333.860601127                    NO

    43 +FRA/phydb/archivelog/2014_10_10/thread_2_seq_43.334.860601131                    NO

    44 +FRA/phydb/archivelog/2014_10_10/thread_2_seq_44.335.860601415                    NO


  1. ⑨備庫以READONLY方式開啟:


alter database recover managed standby database cancel;

alter database open;

alter database recover managed standby database using current logfile disconnect from session;


SQL> col name for a30

SQL> select dbid,name,current_scn,protection_mode,database_role,force_logging,open_mode,switchover_status from v$database;


DBID NAME              CURRENT_SCN PROTECTION_MODE     DATABASE_ROLE FOR OPEN_MODE     SWITCHOVER_STATUS

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

857466254 RACDB             1871595 MAXIMUM PERFORMANCE PHYSICAL STANDBY YES READ ONLY WITH APPLY NOT ALLOWED


SQL>


至此,我們已經順利的給RAC主庫配置ActivePhysicalDataguard成功!

  1. 其它附加內容

    1. 11g rman duplicate命令

注意:11g以前的版本在執行復制命令dupilicate時,必須在備庫上存在有備份檔案,即在主庫上備份完成後將檔案拷到備庫相同目錄下

但是在11g一切都變的簡單,只需要在複製命令後加上FROM ACTIVE DATABASE引數即可。

例如為實現資料庫的檔案回覆,可以執行命令:

$ rman target / auxiliary sys/herenit@racheren_standby

RMAN>duplicate target database for standby from active database;

如果原目錄下有對應檔案已經刪除,但是資料字典中存在,可以使用nofilenamecheck引數取消對檔名的檢查

RMAN>duplicate target database for standby from active database nofilenamecheck;

恢復完成以後,檢查備庫狀態

SQL> select status from v$instance;

STATUS$dEQ5b/C#x22494861------------ITPUB個人空間 T c:v_y!RMOUNTED

SQL> select open_mode from v$database;

OPEN_MODEITPUB個人空間FU?tN2FE5v:_wU}----------ITPUB個人空間1R_G@5k/kMOUNTED

SQL> select member from v$logfile;

SQL> select name from v$datafile;

SQL> select name from v$tempfile;

  1. 建立standby redo log 日誌

DATA Guard在最大保護和最高可用性模式下,Standby資料庫必須配置 Standby Redo Log

備庫建立並配置 Standby Redo Log 是為了能夠接收到主庫傳過來的日誌,用作恢復.

主庫建立並配置 Standby Redo Log 是為了在主備切換之後,能夠接收到原備庫(切換之後的主庫)傳過來的日誌

注意:為了主備切換後能正常,主備庫都必須建立standby redo log


建立原則:建議Standby Redologs日誌組數量基於Primary資料庫的執行緒數來確定(這裡的執行緒數可以理解為RAC環境中的節點數)。

有一個推薦的公式可供參考:(每執行緒的日誌組數+1)×最大執行緒數。

使用這個公式可以降低Primary資料庫例項LGWR程式鎖住的可能性。

建立原則和單例項一樣,大小相等,但是日誌組數量要比primary資料庫多一組,比如在我的環境中,有2個節點,每個節點有4組redo,那麼現在要建立的standby redo log組數為:(4+1)*2=10個

Standby Redologs的操作方式與Online Redologs幾乎一模一樣,只不過在建立或刪除時需要多指定一個Standby關鍵字

SQL>alter database add standby logfile thread 1 group 5 '+ORAFLASH/racheren/onlinelog/group_5.log' size 50M;

SQL>alter database add standby logfile thread 2 group 6 '+ORAFLASH/racheren/onlinelog/group_6.log' size 50M;

單例項上不需要thread標識

SQL>alter database add standby logfile group 6 '/oradata/racheren/onlinelog/group_6.log' size 50M;

刪除方式:

SQL>alter database drop standby logfile grop 6

查詢方式:

SQL>select group#,thread#,sequence#,archived,status from v$standby_log;


ERROR at line 1:

ORA-01156: recovery or flashback in progress may need access to files

--在備庫新增standby redo log需要先停MRP

SQL> alter database recover managed standby database cancel;



  1. 測試物理備庫功能

    1. 測試檔案同步

      1. 檢視主備庫的表空間資訊

select tablespace_name, file_name from dba_data_files;


  1. 主庫建立表空間檢視備庫是否同步

create tablespace dg_tbs datafile size 5m;



  1. 主庫刪除表空間檢視備庫是否同步


drop tablespace dg_tbs including contents and datafiles;


  1. 測試資料同步

①主庫建立測試表:

② 備庫檢視測試表同步:

Create table tmp_test(id number);

Insert into tmp_test values(1);

Commit;


Select * from tmp_test;


  1. 測試DATAGUARDSWITCHOVER功能

    1. RAC主庫、ActiveDataguard角色切換

即rac主庫切換為物理備庫,物理備庫切換為rac主庫。

  1. ①主庫修改相關引數fal_client、fal_server:

首先需要確保主庫採用spfile啟動,然後

Rac1上:

alter system set fal_client='rac1' sid='rac1';

Rac2上:

alter system set fal_client='rac2' sid='rac2';



alter system set fal_server='phydb' sid='*';






  1. ②主庫建立standbylogfile:


  1. ③主庫修改相關引數standby_file_management、db_file_name_convert 、log_filename_convert


  1. ④停止RAC節點2:





  1. 單例項主庫,RAC備庫角色切換

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

相關文章