您好,登錄后才能下訂單哦!
環(huán)境介紹:
windows 2012 R2*2臺
主庫:安裝oracle軟件、監(jiān)聽、實例
備庫:安裝oracle軟件、監(jiān)聽
數(shù)據(jù)庫版本:11.2.0.4
主庫:orcl
備庫:prod
1、主庫
create pfile='C:\Users\Administrator\Desktop\file\pfile.ora' from spfile;
alter database force logging;
alter system set log_archive_config='DG_CONFIG=(orcl,prod)' scope=spfile;
alter system set log_archive_dest_1='location=C:\app\archive valid_for=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=orcl' scope=both sid='';
alter system set log_archive_dest_2='service=prod LGWR ASYNC valid_for=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=prod' scope=both sid='';
alter system set log_archive_dest_state_1='enable' scope=both sid='';
alter system set log_archive_dest_state_2='enable' scope=both sid='';
alter system set fal_client='orcl' scope=both sid='';
alter system set fal_server='prod' scope=both sid='';
alter system set standby_file_management='AUTO' scope=both sid='';
alter system set db_file_name_convert='C:\app\datafiles\orcl\','C:\app\datafiles\prod\' scope=spfile sid='';
alter system set log_file_name_convert='C:\app\datafiles\orcl\','C:\app\datafiles\prod\' scope=spfile sid='*';
SQL> create pfile='C:\Users\Administrator\Desktop\file\pfilebak.ora' from spfile;
2、備庫創(chuàng)建目錄
歸檔目錄 C:\app\archive
數(shù)據(jù)文件目錄 C:\app\datafiles\prod\
adump目錄 C:\app\Administrator\admin\prod\adump
3、主庫備份
rman target /
run{
allocate channel a1 device type disk;
allocate channel a2 device type disk;
allocate channel a3 device type disk;
crosscheck archivelog all;
sql 'alter system archive log current';
sql 'alter system archive log current';
backup full database format='C:\Users\Administrator\Desktop\file\full%U%T' include current controlfile for standby;
backup current controlfile for standby format 'C:\Users\Administrator\Desktop\file\control01.ctl';
backup archivelog all format 'C:\Users\Administrator\Desktop\file\arch%d%T%U.arc';
release channel a1;
release channel a2;
release channel a3;
}
4、拷貝文件
密碼文件在$ORACLE_HOME/database
將密碼文件(需要改sid)、pfile、redo、temp、拷貝到備庫相應(yīng)目錄。
5、修改host文件
192.168.3.2 WIN-JP7MSEND1SD
192.168.3.3 WIN-KL9BBQ52F5R
6、主備庫tnsnames一致
7、修改備庫pfile文件
更改pfile文件
db_name='orcl'應(yīng)與主庫一致
.db_unique_name='prod'
.audit_file_dest='C:\app\Administrator\admin\prod\adump' 注意路徑
log_archive_dest_1='C:\app\archive'
.db_recovery_file_dest
oracle_base
刪除log_archive_dest_2、log_archive_dest_state_1
修改
fal_client='prod'
.fal_server='orcl'
.log_archive_config='DG_CONFIG=(orcl,prod)'
.log_archive_dest_1='location=C:\app\archive valid_for=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=prod'
*檢查文件中的路徑是否正確***
8、備庫添加服務(wù)
oradim -new -sid prod -startmode auto
set ORACLE_SID=prod
9、恢復(fù)備庫
sql>startup nomount pfile='C:\Users\Administrator\Desktop\file\pfilebak.ora';
sql>create spfile from pfile='C:\Users\Administrator\Desktop\file\pfilebak.ora';
若有需求更改數(shù)據(jù)文件目錄可通過
rman target / nocatalog
RMAN> restore standby controlfile from 'C:\Users\Administrator\Desktop\file\control01.ctl';
SQL>alter database mount;
catalog start with 'C:\Users\Administrator\Desktop\file\';
run
{
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
allocate channel c4 device type disk;
set newname for datafile 1 to 'C:\app\datafiles\prod\system01.dbf';
set newname for datafile 2 to 'C:\app\datafiles\prod\sysaux01.dbf';
set newname for datafile 3 to 'C:\app\datafiles\prod\undotbs01.dbf';
set newname for datafile 4 to 'C:\app\datafiles\prod\users01.dbf';
set newname for datafile 5 to 'C:\app\datafiles\prod\example01.dbf';
restore database;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}
recover database;
10、主備庫添加standby日志(比online log至少多一個)
主庫
alter database add standby logfile thread 1 group 4('C:\app\datafiles\orcl\standby04.log') size 50M;
alter database add standby logfile thread 1 group 5 ('C:\app\datafiles\orcl\standby05.log') size 50M;
alter database add standby logfile thread 1 group 6 ('C:\app\datafiles\orcl\standby06.log') size 50M;
alter database add standby logfile thread 1 group 7 ('C:\app\datafiles\orcl\standby07.log') size 50M;
alter database add standby logfile thread 1 group 8 ('C:\app\datafiles\orcl\standby08.log') size 50M;
備庫
alter database add standby logfile thread 1 group 4('C:\app\datafiles\prod\standby04.log') size 50M;
alter database add standby logfile thread 1 group 5 ('C:\app\datafiles\prod\standby05.log') size 50M;
alter database add standby logfile thread 1 group 6 ('C:\app\datafiles\prod\standby06.log') size 50M;
alter database add standby logfile thread 1 group 7 ('C:\app\datafiles\prod\standby07.log') size 50M;
alter database add standby logfile thread 1 group 8 ('C:\app\datafiles\prod\standby08.log') size 50M;
11、主庫重啟DB 因為log_archive_config重啟生效
啟動同步
SQL>alter database recover managed standby database disconnect from session;
SQL> recover managed standby database cancel;
SQL>alter database open read only;
SQL>alter database recover managed standby database using current logfile disconnect from session;
驗證
主庫 v$archived_log
SQL> select thread#,max(sequence#) from v$archived_log where applied='NO' group by thread#;
備庫 v$archived_log
SQL> select thread#,max(sequence#) from v$archived_log where applied='YES' group by thread#;
備庫 v$managed_standby;
select process,status,thread#,sequence# from v$managed_standby;
SQL> select process,status,thread#,sequence# from v$managed_standby;
PROCESS STATUS THREAD# SEQUENCE#
ARCH CONNECTED 0 0
ARCH CONNECTED 0 0
ARCH CLOSING 1 10
ARCH CLOSING 1 11
RFS IDLE 0 0
RFS IDLE 0 0
RFS IDLE 0 0
RFS IDLE 1 12
MRP0 APPLYING_LOG 1 12
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。