RAC歸檔儲存方案:交叉互備

dbasdk發表於2014-07-08
RAC歸檔儲存方案:交叉互備


1、測試環境
    10.2.0.1.0  on 2.6.18-53.el5
    192.168.1.101        rac1        
    192.168.1.102        rac2
2、RAC歸檔一般放在所有節點都可以看到的地方,方便RMAN發現所有的歸檔日誌。
RMAN>backup archivelog all delete all input format '.......';
3、RAC歸檔方案有:
--使用OCFS共享儲存
--使用NFS共享儲存
--使用交叉互備(即本方案缺點:大量互傳歸檔,慎用)
--任何節點只有它自己的歸檔日誌,使用時再合併
4、本文演示的交叉互備方案需大量互傳歸檔,慎用
5、如發現錯誤歡迎立即提出,方便及時更正    


一、在一個非常大的檔案系統上建立目錄
1、在RAC1上建目錄,rac1-rac2路徑一致
$ mkdir /u01/arch
$ ll -d /u01/arch
drwxr-xr-x 2 oracle oinstall 4096 Jul  6 11:01 /u01/arch
2、在RAC2上建目錄,rac1-rac2路徑一致
[oracle@rac2 ~]$ mkdir /u01/arch
[oracle@rac2 ~]$ ll -d /u01/arch
drwxr-xr-x 2 oracle oinstall 4096 Jul  6 11:01 /u01/arch


1、本地歸檔設定
alter system set log_archive_dest_1='location=/u01/arch';

2、分別檢視tnsnames中針對另一節點的tnsnames.ora
[oracle@rac1 ~]$ head -12 $ORACLE_HOME/network/admin/tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
RACDB1 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = rac1-vip)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = RACDB)
      (INSTANCE_NAME = RACDB1)
    )
  )

[oracle@rac2 ~]$ head -12 $ORACLE_HOME/network/admin/tnsnames.ora
# tnsnames.ora.rac2 Network Configuration File: /u01/db_1/network/admin/tnsnames.ora.rac2
# Generated by Oracle configuration tools.
RACDB1 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = rac1-vip)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = RACDB)
      (INSTANCE_NAME = RACDB1)
    )
  )

2、交叉歸檔,這樣每個節點都可以讀到其他節點的歸檔
alter system set log_archive_dest_2='service=RACDB2' sid='RACDB1';
alter system set log_archive_dest_2='service=RACDB1' sid='RACDB2';
alter system set standby_archive_dest='/u01/arch';
3、確認引數設定生效
col value for a25
col name for a20
select inst_id,name,value from gv$parameter 
where name in ('standby_archive_dest','log_archive_dest_2','log_archive_dest_1');
   INST_ID NAME VALUE
---------- -------------------- -------------------------
1 log_archive_dest_1 location=/u01/arch
1 log_archive_dest_2 service=RACDB2
1 standby_archive_dest /u01/arch
2 log_archive_dest_1 location=/u01/arch
2 log_archive_dest_2 service=RACDB1
2 standby_archive_dest /u01/arch
6 rows selected.

4、典型錯誤演示:service=*設定錯誤,傳輸歸檔到對方節點時會有以下錯誤
alter system set log_archive_dest_2='service=rac2' sid='RACDB1';
alter system set log_archive_dest_2='service=rac1' sid='RACDB2';
alter system set standby_archive_dest='/u01/arch';
SYS@RACDB2> alter system archive log current;


$ tail -f  /u01/admin/RACDB/bdump/*.log
Mon Jul  7 17:42:46 2014
Thread 2 advanced to log sequence 32
  Current log# 4 seq# 32 mem# 0: +DG1/racdb/redo04.log
Mon Jul  7 17:42:46 2014
Error 12514 received logging on to the standby
Mon Jul  7 17:42:46 2014
Errors in file /u01/admin/RACDB/bdump/racdb2_arc1_5696.trc:
ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
PING[ARC1]: Heartbeat failed to connect to standby 'rac1'. Error is 12514.

三、調整歸檔日誌檔案命名方式
SYS@RACDB1>  alter system set log_archive_format ='arch_%S_%R_%T.arc' scope=spfile;
SYS@RACDB1>  select value from v$spparameter where name='log_archive_format';
--arch_%S_%R_%T.arc

%s: 日誌序列號
%S:日誌序列號(帶有前導0)。
%t: 重做執行緒編號。
%T: 重做執行緒編號(帶有前導0)
%a: %A:資料庫ID號
%d: 資料庫ID號
%r: RESETLOGS的id值

四、為RAC資料庫開啟歸檔
1、關閉所有節點資料庫例項
$ srvctl stop database -d RACDB
$ crs_stat -t
Name           Type           Target    State     Host        
------------------------------------------------------------
ora....B1.inst application    OFFLINE   OFFLINE               
ora....B2.inst application    ONLINE    OFFLINE               
ora.RACDB.db   application    OFFLINE   OFFLINE               
ora....SM1.asm application    ONLINE    ONLINE    rac1        
ora....C1.lsnr application    ONLINE    ONLINE    rac1        
ora.rac1.gsd   application    ONLINE    ONLINE    rac1        
ora.rac1.ons   application    ONLINE    ONLINE    rac1        
ora.rac1.vip   application    ONLINE    ONLINE    rac1        
ora....SM2.asm application    ONLINE    ONLINE    rac2        
ora....C2.lsnr application    ONLINE    ONLINE    rac2        
ora.rac2.gsd   application    ONLINE    ONLINE    rac2        
ora.rac2.ons   application    ONLINE    ONLINE    rac2        
ora.rac2.vip   application    ONLINE    ONLINE    rac2        

2、在其中一個節點上開歸檔
SYS@RACDB1> startup mount
SYS@RACDB1> alter database archivelog;
SYS@RACDB1> alter database open;
3、開啟所有節點資料庫例項
$ srvctl stop database -d RACDB
$ srvctl start database -d RACDB;sleep 60
4、驗證歸檔是否開啟
SYS@RACDB1> archive log list
Database log mode       Archive Mode
Automatic archival       Enabled
Archive destination       /u01/arch
Oldest online log sequence     26
Next log sequence to archive   27
Current log sequence       27

五、測試、確認以上配置達到目的
1、  當前無任何歸檔日誌
[oracle@rac1 ~]$ ls -1 /u01/arch/*
ls: /u01/arch/*: No such file or directory
[oracle@rac2 ~]$ ls -1 /u01/arch/*
ls: /u01/arch/*: No such file or directory

2、切換REDO生成歸檔
SYS@RACDB2> alter system archive log current;
3、注意事項、測試、確認以上配置達到目的
[oracle@rac1 ~]$ ls -1 /u01/arch/*
/u01/arch/arch_0000000033_0851859689_0001.arc
/u01/arch/arch_0000000038_0851859689_0002.arc
[oracle@rac2 ~]$ ls -1 /u01/arch/*
/u01/arch/arch_0000000033_0851859689_0001.arc
/u01/arch/arch_0000000038_0851859689_0002.arc


zcs0237 
2014.07.06
More cleaner and more efficient!


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

相關文章