datagard設定

經過3天空閑時間的仔細測試,終于完成了dataguard功能:
 
一:架設dataguard
sqlplus / as sysdba
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select * from v$option where parameter='Managed Standby';
PARAMETER
----------------------------------------------------------------
VALUE
----------------------------------------------------------------
Managed Standby
TRUE

SQL> archive log list
Database log mode        Archive Mode
Automatic archival        Enabled
Archive destination        /oraarc/lsmesdb
Oldest online log sequence     2807
Next log sequence to archive   0
Current log sequence        2808
SQL>alter database force logging;
注:強制設定歸檔時間
alter system set archive_lag_target=900
1.設定主庫
SQL>alter system set log_archive_dest_1='location=e:\oracle\oraarc\test' scope=spfile;
SQL>alter system set log_archive_dest_1='service=standby optional reopen=60' scope=spfile;
SQL>alter system set log_archive_dest_state_1=enable scope=spfile;
SQL>alter system set log_archive_dest_state_2=enable scope=spfile;
SQL>alter system set remote_login_passwordfile=excluse scope=spfile;
--以下做switch DB時的設定
SQL>alter system set fal_server=standby scope=spfile;
SQL>alter system set fal_client=primary scope=spfile;
SQL>alter system set standby_file_management=auto scope=spfile;
SQL>alter system set standby_archive_dest='e:\oracle\oraarc\test' scope=file;
--有了以上參數設定,無論該庫充當主庫是備庫都無需修改。
2.備份主庫
rman target /
RMAN>backup full database format 'e:\oracle\backup\backup_%T_%s_%p.bak';
RMAN>sql "alter system archive log current";
RMAN>backup archivelog all format 'e:\oracle\backup\arch_%T_%s_%p.bak';
3.在主庫上建立備庫控制文件
SQL>alter database create standby controlfile as 'e:\oracle\backup\CONTROL01.CTL';
SQL>alter database create standby controlfile as 'e:\oracle\backup\CONTROL02.CTL';
SQL>alter database create standby controlfile as 'e:\oracle\backup\CONTROL03.CTL';
4.在主庫建立備庫用的init參數文件
SQL>create pfile='e:\oracle\backup\initteststdby' from spfile;
5.修改init參數
fal_client='standby'
fal_server='primary'
6.新增備庫(netca或者oradim)
oradim -new -sid teststdby -startmode manual(刪除oradim -delete -sid teststdby)
--將文件夾新增成一樣(admin和oradata內子文件夾及歸檔目錄)
--生成密碼文件,且sys密碼與主庫得一致
orapwd file=$oracle_home/dbs/orapwteststdby password=12345678 entries=5
--建立監聽和tnsnames
7.將前面主庫為備庫產生的pfile及control文件及備份資料全部copy到備庫的對應目錄
8.還原備庫
RMAN>RESTORE DATABASE;
RMAN>RESTORE ARCHIVELOG ALL;
--做完后,db會自動在mount狀態(或者shutdown->startup nomount->alter database mount standby database;)
9.啟動備庫,做redo apply  (recover standby database until cancel)
SQL>ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
10.查看同步情況(在主庫上可用alter system archive log current歸檔)
SQL>select sequence#,applied from archived_log;
二.switch作業
1.關閉備庫的log_archive_dest_state_2=defer
2.原主備進行切換
SQL>select switchover_status from v$database;
SQL>select username,status,process,type from v$session where type='USER';
SQL>alter database commit to switchover to physical standby with shutdown;
3.啟用新主機
alter system set log_archive_dest_state_2=ENABLE;
alter database open;
4.啟用新備庫
SQL>shutdown
SQL>startup nomount
SQL>alter database mount standby database;
SQL>alter database recover managed standby database disconnect from session;
 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/784441/viewspace-671479/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/784441/viewspace-671479/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值