首先创建物理备库
参考:http://blog.csdn.net/leishifei/archive/2011/04/08/6308758.aspx
创建物理备库后,最好创建各自的spfile
物理备库上停止redo应用:
alter database recover managed STANDBY database cancel;
主库上生成logminer会发生几次切换日志报错忽略
execute dbms_logstdby.build;
物理备库上转化为逻辑备用库:
alter database recover to logical standby orcl; -- db_name 参数
shutdown immediate
startup mount
SELECT db_unique_name,open_mode, database_role,switchover_status,guard_status,protection_mode FROM V$DATABASE;
备库上重建逻辑standby的密码文件:
orapwd file=$ORACLE_HOME/dbs/orapwstby password=oracle entries=5 ignorecase=y force=y
备库上修改参数:
alter system set log_archive_dest_1='location=/u01/oradata/arch/stby valid_for=(online_logfiles,all_roles) db_unique_name=stby';
alter system set log_archive_dest_2='location=/u01/oradata/arch valid_for=(standby_logfiles,standby_roles) db_unique_name=stby';
备库上创建备用日志:
alter database add standby logfile group 4 ('/u01/oradata/stby/standbylj01.log') size 20M reuse;
alter database add standby logfile group 5 ('/u01/oradata/stby/standbylj02.log') size 20M reuse;
alter database add standby logfile group 6 ('/u01/oradata/stby/standbylj03.log') size 20M reuse;
select member from v$logfile;
备库上打开逻辑standby:
alter database open resetlogs;
alter database start logical standby apply immediate;
备库上检查:
select instance_name,status from v$instance;
SELECT db_unique_name,open_mode, database_role,switchover_status,guard_status,protection_mode FROM V$DATABASE;
select group#,sequence#,used,status from v$standby_log;
测试:
在主库上创建:
create table scott.t4 (id int);
insert into scott.t4 values(4);
commit;
alter system switch logfile;
过一会儿 在逻辑备用库上查询:
select * from scott.t4;
检查是否有相应的记录产生,有则表示成功。