在备库节点上数据库实例取消恢复管理模式
alter database recover managed standby database cancel;
在主库节点上创建logical standby的数据字典
EXECUTE DBMS_LOGSTDBY.BUILD;
注意
这一步必须执行成功,且必须在其他操作之前执行,否则后面将执行的操作 alter database recover to logical standby webread; 会一直等待。
在执行这个操作过程中,该会话会处于等待状态,等待事件为 enq: TX - contention
在备库节点上将物理备库转换为逻辑备库,数据库名称从webdb修改为webread
alter database recover to logical standby webread;
SQL> alter database recover to logical standby webread;
alter database recover to logical standby webread
*
ERROR at line 1:
ORA-20000: File /u01/app/oratt/webdb/temp01.dbf has wrong dbid or dbname,
remove or restore the offending file.
提示临时文件错误。可以忽略,加alter database open resetlogs重启数据库
SQL> startup open
Oracle instance started.
Total System Global Area 5.1540E+10 bytes
Fixed Size 2179936 bytes
Variable Size 6425676960 bytes
Database Buffers 4.5097E+10 bytes
Redo Buffers 14594048 bytes
Database mounted.
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
SQL> alter database open resetlogs;
Database altered.
增加临时文件
alter tablespace temp add tempfile '/u01/app/oratt/webdb/temp02.dbf' size 1024M;
ALTER DATABASE TEMPFILE '/u01/app/oratt/webdb/temp01.dbf' DROP INCLUDING DATAFILES;
调整主库上log_archive_dest_2的参数值
在物理standby模式下,这个参数的service值是指向webdb_standby的,现在在逻辑standby模式下,它需要修改为指向webdb_reader。
主库的初始化参数文件initofdb.ora配置项也需要手工修改。
内存中修改操作为:
alter system set log_archive_dest_2='service=webdb_reader lgwr sync affirm valid_for=(online_logfiles,primary_role) db_unique_name=webdg';
启动备库
alter database stop logical standby apply;
alter database start logical standby apply immediate;
--查看等待事件
select * from dba_logstdby_events t where t.event_time > sysdate - 1 / 2;
select event_time,
xidusn,
xidslt,
xidsqn,
status,
status_code,
event,
'exec dbms_logstdby.skip_transaction(' || xidusn || ',' || xidslt || ',' ||
xidsqn || ');' as exec_sql,
a.*
from dba_logstdby_events a
where event_time = (select max(event_time) from dba_logstdby_events);
select * from dba_logstdby_skip;
select * from dba_logstdby_skip_transaction;
--查看进程
select * from v$logstdby_process;
--查看运行状态
select * from v$logstdby_state;
-- the end
