您好,登錄后才能下訂單哦!
本文文檔結構:
這里配置的過程中需要注意的一項是多看看rac1和rac2以及dg的告警日志會對配置過程有更深刻的理解。。。配置oracle rac的dg環境說白了首先將主庫的數據恢復到從庫上,然后在主從庫上配置一些DG需要用到的參數
注意:
該步驟主要是① 將rac主庫修改為歸檔+forcelogging模式 ② 利用rman備份db、archivelog、control file 、pfile 和口令文件
和下一步一起做
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>
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;
}
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'
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>
最好是將其中一個口令文件復制到另外一個節點上,最后復制到dg下,確保口令文件是一樣的
將備份文件全部傳遞到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
上一步已做,不需要創建了
----------dg
[oracle@dg rman_backup]$ cp initphydb.ora $ORACLE_HOME/dbs/
[oracle@dg rman_backup]$ cd $ORACLE_HOME/dbs
這個是比較重要的步驟,我把行號弄出來了,當然寫的時候是沒有前邊的行號的
物理備庫初始化參數文件修改:
[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>
將以下內容復制到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個庫可以連接
startup nomount
[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>
SQL> alter database mount;
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>
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';
[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>
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
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
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成功!
注意: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;
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;
select tablespace_name, file_name from dba_data_files;
create tablespace dg_tbs datafile size 5m;
drop tablespace dg_tbs including contents and datafiles;
①主庫創建測試表:
② 備庫查看測試表同步:
Create table tmp_test(id number);
Insert into tmp_test values(1);
Commit;
Select * from tmp_test;
即rac主庫切換為物理備庫,物理備庫切換為rac主庫。
首先需要確保主庫采用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='*';
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。