oracle 逻辑备用库环境搭建
首先创建物理备用库创建物理备用库后最好创建各自的spfile
物理备库上 停止redo应用
alter database recover managed STANDBY database cancel;
主库上生成logminer 会发生几次切换日志 报错忽略
execute dbms_logstdbybuild;
物理备库上 转化为逻辑备用库
alter database recover to logical standby orcl; < db_name 参数
shutdown immediate
startup mount
SELECT db_unique_nameopen_mode database_roleswitchover_statusguard_statusprotection_mode FROM V$DATABASE;
备库上 重建逻辑standby的密码文件
orapwd file=$ORACLE_HOME/dbs/orapwstby password=oracle entries= ignorecase=y force=y
备库上 修改参数
alter system set log_archive_dest_=location=/u/oradata/arch/stby valid_for=(online_logfilesall_roles) db_unique_name=stby;
alter system set log_archive_dest_=location=/u/oradata/arch valid_for=(standby_logfilesstandby_roles) db_unique_name=stby;
备库上 创建备用日志
alter database add standby logfile group (/u/oradata/stby/standbyljlog) size M reuse;
alter database add standby logfile group (/u/oradata/stby/standbyljlog) size M reuse;
alter database add standby logfile group (/u/oradata/stby/standbyljlog) size M reuse;
select member from v$logfile;
备库上 打开逻辑standby
alter database open resetlogs;
alter database start logical standby apply immediate;
备库上 检查
select instance_namestatus from v$instance;
SELECT db_unique_nameopen_mode database_roleswitchover_statusguard_statusprotection_mode FROM V$DATABASE;
select group#sequence#usedstatus from v$standby_log;
测试
在主库上 创建
create table scottt (id int);
insert into scottt values();
commit;
alter system switch logfile;
过一会儿 在逻辑备用库上查询
select * from scottt;