主庫RAC,備庫單節點ASM的dataguard搭建

lpwebnet發表於2014-02-08
易錯點:
1.listener.ora & tnsnames.ora 的配置,注意寫對sid_name和service_name。
2.密碼檔案要重新建立,並傳到主備庫每個節點上
準備
主庫:
SQL> select member from v$logfile;
 
MEMBER 
---------------------------------------------------------------------------------------------------- 
+LOGDG/ppm/redo_a/redo09_a.log 
+LOGDG/ppm/redo_b/redo09_b.log 
+LOGDG/ppm/redo_a/redo10_a.log 
+LOGDG/ppm/redo_b/redo10_b.log 
+LOGDG/ppm/redo_a/redo11_a.log 
+LOGDG/ppm/redo_b/redo11_b.log 
+LOGDG/ppm/redo_a/redo12_a.log 
+LOGDG/ppm/redo_b/redo12_b.log 
+LOGDG/ppm/redo_a/redo13_a.log 
+LOGDG/ppm/redo_b/redo13_b.log 
+LOGDG/ppm/redo_a/redo14_a.log 
+LOGDG/ppm/redo_b/redo14_b.log 
+LOGDG/ppm/redo_a/redo15_a.log 
+LOGDG/ppm/redo_b/redo15_b.log 
+LOGDG/ppm/redo_a/redo16_a.log 
+LOGDG/ppm/redo_b/redo16_b.log 
1.建立Standby Redo Log 
ALTER DATABASE ADD STANDBY LOGFILE GROUP 17 ('+LOGDG/ppm/redo_a/standby_redo17.log') SIZE 500M; 
ALTER DATABASE ADD STANDBY LOGFILE GROUP 18 ('+LOGDG/ppm/redo_a/standby_redo18.log') SIZE 500M; 
ALTER DATABASE ADD STANDBY LOGFILE GROUP 19 ('+LOGDG/ppm/redo_a/standby_redo19.log') SIZE 500M; 
ALTER DATABASE ADD STANDBY LOGFILE GROUP 20 ('+LOGDG/ppm/redo_a/standby_redo20.log') SIZE 500M; 
ALTER DATABASE ADD STANDBY LOGFILE GROUP 21 ('+LOGDG/ppm/redo_a/standby_redo21.log') SIZE 500M; 
ALTER DATABASE ADD STANDBY LOGFILE GROUP 22 ('+LOGDG/ppm/redo_a/standby_redo22.log') SIZE 500M; 
ALTER DATABASE ADD STANDBY LOGFILE GROUP 23 ('+LOGDG/ppm/redo_a/standby_redo23.log') SIZE 500M; 
ALTER DATABASE ADD STANDBY LOGFILE GROUP 24 ('+LOGDG/ppm/redo_a/standby_redo24.log') SIZE 500M; 
ALTER DATABASE ADD STANDBY LOGFILE GROUP 25 ('+LOGDG/ppm/redo_a/standby_redo25.log') SIZE 500M; 
用以下語句確認建立成功 
SELECT GROUP#,THREAD#,SEQUENCE#,ARCHIVED,STATUS FROM gv$STANDBY_LOG; 
2.在主庫上tnsnames.ora修改備庫的連線串,並傳到備庫上 
PPM = 
  (DESCRIPTION = 
    (LOAD_BALANCE = no) 
    (ADDRESS_LIST = 
        (LOAD_BALANCE = off) 
      (ADDRESS = (PROTOCOL = TCP)(HOST = 83.19.14.155)(PORT = 1521)) 
      (ADDRESS = (PROTOCOL = TCP)(HOST = 83.19.14.157)(PORT = 1521)) 
    ) 
    (CONNECT_DATA = 
      (SERVER = DEDICATED) 
      (SERVICE_NAME = ppm) 
    ) 
  ) 

PPM1 = 
  (DESCRIPTION = 
    (ADDRESS = (PROTOCOL = TCP)(HOST = 83.19.14.155)(PORT = 1521)) 
    (CONNECT_DATA = 
      (SERVER = DEDICATED) 
      (SERVICE_NAME = ppm) 
      (INSTANCE_NAME = ppm1) 
    ) 
  ) 
PPM_standby = 
  (DESCRIPTION = 
    (ADDRESS = (PROTOCOL = TCP)(HOST = 83.19.14.137)(PORT = 1521)) 
    (CONNECT_DATA = 
      (SERVER = DEDICATED) 
      (SERVICE_NAME = ppm) 
    ) 
  ) 
3.grid使用者到備庫的$ORACLE_HOME/network/admin(/oracle/app/grid/11.2.0/network/admin)下修改listener.ora 
SID_LIST_LISTENER = 
 (SID_LIST = 
  (SID_DESC = 
   (SID_NAME = ppm) 
   (ORACLE_HOME = /oracle/app/oracle/product/11.2.0) 
 ) 
) 
LISTENER = 
(DESCRIPTION_LIST = 
 (DESCRIPTION = 
  (ADDRESS_LIST = 
  (ADDRESS = (PROTOCOL = TCP)(HOST = 83.19.14.137)(PORT = 1521)(QUEUESIZE=300)) 
  ) 
 ) 
) 
4.修改主庫的引數檔案 
alter system set standby_file_management=auto; 
alter system set archive_lag_target=1200; 
alter system set fal_client='PPM'; 
alter system set fal_client='PPM_standby'; 
alter system set log_archive_dest_1='location=+LOGDG/ppm/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES)  db_unique_name=ppm'; 
alter system set log_archive_dest_state_2=defer; 
alter system set log_archive_dest_2='SERVICE=PPM_standby ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) reopen=60 db_unique_name=ppm_standby'; 
SQL> show parameter spfile; 
NAME                                 TYPE        VALUE 
------------------------------------ ----------- ------------------------------ 
spfile                               string      +DATA_DG/ppm/spfileppm.ora 
SQL> create pfile from spfile; 

5.開始rman備份 
準備好指令碼 
$ cat ppm.sh 
rman target / cmdfile=ppm.rcv log=ppm.log 
$ cat ppm.rcv 
run{ 
allocate channel d1 type disk; 
allocate channel d2 type disk; 
setlimit channel d1 kbytes 20480000; 
setlimit channel d2 kbytes 20480000; 
backup incremental level 0 format '/mnt/ppmdg/arch_%t_%s_%U.arc' database include current controlfile for standby; 
sql "alter system archive log current"; 
release channel d1; 
release channel d2; 
} 
在後臺執行 
sh ppm.sh & 
耗時7小時。 

準備備庫: 

1. hdisk2-6 hdisk12-16 磁碟組名:DATA_DG     hdisk11 磁碟組名:LOGDG 
brw-------    1 root     system       18,  0 Oct 31 09:15 hdisk0 
brw-------    1 root     system       18,  1 Nov 02 01:42 hdisk1 
brw-------    1 root     system       18,  4 Dec 24 04:41 hdisk10 
brw-------    1 root     system       18,  3 Dec 24 04:41 hdisk11 
brw-------    1 root     system       18,  7 Dec 24 04:41 hdisk12 
brw-------    1 root     system       18, 12 Dec 24 04:41 hdisk13 
brw-------    1 root     system       18,  5 Dec 24 04:41 hdisk14 
brw-------    1 root     system       18, 11 Dec 24 04:41 hdisk15 
brw-------    1 root     system       18, 16 Dec 24 04:41 hdisk16 
brw-------    1 root     system       18,  2 Dec 24 04:41 hdisk2 
brw-------    1 root     system       18,  9 Dec 24 04:41 hdisk3 
brw-------    1 root     system       18, 13 Dec 24 04:41 hdisk4 
brw-------    1 root     system       18, 10 Dec 24 04:41 hdisk5 
brw-------    1 root     system       18, 14 Dec 24 04:41 hdisk6 
brw-------    1 root     system       18,  8 Dec 24 05:20 hdisk7 
brw-------    1 root     system       18, 15 Dec 24 04:41 hdisk8 
brw-------    1 root     system       18,  6 Dec 24 04:41 hdisk9 
mknod /dev/orcl/datadisk02 c 18  2; 
mknod /dev/orcl/datadisk03 c 18  9; 
mknod /dev/orcl/datadisk04 c 18 13; 
mknod /dev/orcl/datadisk05 c 18 10; 
mknod /dev/orcl/datadisk06 c 18 14; 
mknod /dev/orcl/datadisk12 c 18  7; 
mknod /dev/orcl/datadisk13 c 18 12; 
mknod /dev/orcl/datadisk14 c 18  5; 
mknod /dev/orcl/datadisk15 c 18 11; 
mknod /dev/orcl/datadisk16 c 18 16; 
mknod /dev/orcl/logdg c 18 3;   
2. asmca有部分盤看不到,dd乾淨 
dd if=/dev/zero of=/dev/hdisk2 count=100 
dd if=/dev/zero of=/dev/hdisk3 count=100 
dd if=/dev/zero of=/dev/hdisk4 count=100 
dd if=/dev/zero of=/dev/hdisk5 count=100 
dd if=/dev/zero of=/dev/hdisk6 count=100 
dd if=/dev/zero of=/dev/hdisk11 count=100 
dd if=/dev/zero of=/dev/hdisk12 count=100 
再重新asmca建DATA_DG和LOGDG 
3.asmcmd進入後照著主庫的目錄結構建立目錄 

4.修改備庫的引數檔案initppm.ora: 
*.fal_client='PPM_standby' 
*.fal_server='PPM' 
*.db_unique_name=ppm_standby 
*.log_archive_dest_1='location=+LOGDG/ppm/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES)  db_unique_name=ppm_standby' 
*.log_archive_dest_2='SERVICE=PPM ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) reopen=60 db_unique_name=ppm' 
*.log_archive_dest_state_2='enable' 
*.log_archive_format='%t_%s_%r.dbf' 
log_file_name_convert='+LOGDG/ppm/redo_a','+LOGDG/ppm/redo_a' 
5.生成spfile檔案: 
create spfile='+DATA_DG/ppm/spfileppm.ora' from pfile; 
shutdown immediate; 
mv initppm.ora  initppm.ora.bak20131227 
vi initppm.ora 
spfile='+DATA_DG/ppm/spfileppm.ora' 
startup nomount 
6.在主庫備控制檔案 
backup device type disk format '/mnt/ppmdg/ctl%U' current controlfile for standby;     
7.然後在備庫恢復 
restore standby controlfile from '/mnt/dmp/ppmdg/ctl2eot2556_1_1';    
startup mount
 
8.恢復資料檔案 
run { 
restore database ; 
switch datafile all; 

9.等了8個小時恢完之後在主備庫分別執行 
alter system set log_archive_dest_state_2 = enable; 
10.並開啟實時應用,看到備庫沒有歸檔檔案傳過來。日誌報錯: 
------------------------------------------------------------ 
FAL[client, USER]: Error 16191 connecting to PPM for fetching gap sequence 
Sat Dec 28 07:58:43 2013 
Error 1017 received logging on to the standby 
------------------------------------------------------------ 
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 
------------------------------------------------------------ 
11.密碼檔案沒統一 。在主庫一節點重新生成一遍3個密碼檔案,並傳到二節點和備庫上。 重啟備庫。開啟實時應用 
alter database recover managed standby database using current logfile disconnect from session; 
12.看到歸檔傳ing ,最終兩邊查到的最大歸檔號一致。 切個日誌兩邊同步。
SQL> select max(sequence#) from v$log_history; 
MAX(SEQUENCE#) 
-------------- 
          4787       
done

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

相關文章