1、备库相关参数设置:
SQL> show parameter db_create_file_dest;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_create_file_dest string
SQL> show parameter db_file_name_convert;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert string +DGDATA/SZTECH/, /u01/app/orac
le/oradata/DG_STANDBY
pdb_file_name_convert string
SQL> alter database recover managed standby database using current logfile disconnect from session;
Database altered.
SQL> select open_mode from v$database;
OPEN_MODE
--------------------
READ ONLY WITH APPLY
SQL>
2、主库创建pdb
SQL> create pluggable database orclpdb2 admin user test identified by test default tablespace users;
Pluggable database created.
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 ORCLPDB2 MOUNTED
4 ORCLPDB MOUNTED
SQL> alter system switch logfile;
System altered.
3、查看备库:
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 ORCLPDB2 MOUNTED
4 ORCLPDB MOUNTED
打开orclpdb2
SQL> alter pluggable database orclpdb2 open;
alter pluggable database orclpdb2 open
*
ERROR at line 1:
ORA-65085: cannot open pluggable database in read-only mode
这个报错是由于在主库中,新创建的pdb从未open过,在主库open并切换一次日志
SQL> alter pluggable database orclpdb2 open;
Pluggable database altered.
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 ORCLPDB2 READ WRITE NO
4 ORCLPDB MOUNTED
SQL> alter system switch logfile;
System altered.
备库再次open成功
SQL> alter pluggable database orclpdb2 open;
Pluggable database altered.
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 ORCLPDB2 READ ONLY NO
4 ORCLPDB MOUNTED
SQL>
作者: miss_puff 时间: 2017-8-28 18:40
主库删除PDB,备库同步测试。
主库删除pdb,查看备库是否同步:
1、主库删除pdb
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 ORCLPDB2 READ WRITE NO
4 ORCLPDB MOUNTED
SQL> alter pluggable database orclpdb2 close immediate;
Pluggable database altered.
SQL> drop pluggable database orclpdb2;
drop pluggable database orclpdb2
*
ERROR at line 1:
ORA-65179: cannot keep datafiles for a pluggable database that is not unplugged
SQL> drop pluggable database orclpdb2 including datafiles;
Pluggable database dropped.
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
4 ORCLPDB MOUNTED
SQL> alter system switch logfile;
System altered.
SQL> alter system switch logfile;
System altered.
SQL>
2、查看备库:
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 ORCLPDB2 READ ONLY NO
4 ORCLPDB MOUNTED
可以看到,备库的orclpdb2数据库还是存在,查看alter日志,如下:
2017-08-28T18:12:37.658705+08:00
transaction committed at 08/28/2017 18:09:46 on primary
Errors with log /u01/app/archivelog/1_160_949664067.dbf
MRP0: Background Media Recovery terminated with error 65112
2017-08-28T18:12:37.743264+08:00
Errors in file /u01/app/oracle/diag/rdbms/dg_standby/sztech/trace/sztech_mrp0_61787.trc:
ORA-65112: pluggable database ORCLPDB2 not closed on all instances of the standby database
Managed Standby Recovery not using Real Time Apply
Recovery interrupted!
Standby recovery stopped due to failure in applying recovery marker (opcode 17.35).
Datafiles are recovered to a consistent state at change 5983563 but controlfile is ahead at change 5983619.
Database remains open for continuous queries. Please continue recovery.
2017-08-28T18:12:37.879824+08:00
Errors in file /u01/app/oracle/diag/rdbms/dg_standby/sztech/trace/sztech_mrp0_61787.trc:
ORA-65112: pluggable database ORCLPDB2 not closed on all instances of the standby database
2017-08-28T18:12:37.879903+08:00
MRP0: Background Media Recovery process shutdown (sztech)
由于备库orclpdb2处于read only状态导致mrp进程关闭,此时查看数据库打开模式;
SQL> select open_mode from v$database;
OPEN_MODE
--------------------
READ ONLY
解决办法:
关闭orclpdb2并开启日志应用
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 ORCLPDB2 READ ONLY NO
4 ORCLPDB MOUNTED
SQL> alter pluggable database orclpdb2 close immediate;
Pluggable database altered.
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 ORCLPDB2 MOUNTED
4 ORCLPDB MOUNTED
SQL> select open_mode from v$database;
OPEN_MODE
--------------------
READ ONLY
SQL> alter database recover managed standby database using current logfile disconnect from session;
Database altered.
SQL> select open_mode from v$database;
OPEN_MODE
--------------------
READ ONLY WITH APPLY
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
4 ORCLPDB MOUNTED
SQL>