Special episode: PDB refresh management operation (how to switch PDB Switching Over)

Based on version: 19C (12.2.0.3)  AskScuti

Theme : How can refresh PDB switching operation

Description : This continuation of how to clone refreshable PDB (Refreshable PDB) a text, switch experiment.

Refer to " clone refreshable the PDB "

 

Content Overview

1. Environment Overview

2. How to refresh PDB

  2.1 PDB is connected to refresh the root container where

  2.2 Close To refresh the PDB

  2.3 refresh execution

  2.4 refreshable read-only mode opening the PDB (or leave off state) 

3. How to switch to refresh the PDB

  3.1 Check the target database environment

  3.2 target database to create user and authorization

  3.3 Source Library Editor TNS

  3.4 Source library created DBLink

  3.5 with a target handover source PDB PDB

4. ORA-12754 Description

 

1. Environment Overview

Refer to: how to clone refreshable PDB (Refreshable PDB) article.

 

2. How to refresh PDB

To refresh a PDB, provided: that the PDB must be to include REFRESH MODE MANUAL or REFRESH MODE EVERY minutes clause cloned out PDB.

2.1 PDB is connected to refresh the root container where

SQL> show pdbs

    CON_ID CON_NAME  OPEN MODE  RESTRICTED
---------- --------- ---------- ----------
     2 PDB$SEED      READ ONLY  NO
     3 PDB1          MOUNTED
     4 PDB_REF       READ ONLY  NO
     5 PDB_REFAUTO   MOUNTED

2.2 Close To refresh the PDB

SQL> alter pluggable database pdb_ref close immediate;

Pluggable database altered.

2.3 refresh execution

SQL> alter pluggable database pdb_ref refresh;

Pluggable database altered.

2.4 refreshable read-only mode opening the PDB (or leave off state) 

SQL> alter pluggable database pdb_ref open read only;

Pluggable database altered.

 

3. How to switch to refresh the PDB

You can switch the source PDB and refresh the PDB identity roles.

have to be aware of is

  • Handover command must be executed in the PDB source (ALTER PLUGGABLE DATABASE ... SWITCHOVER);
  • Source libraries and refresh the library is not when, two DBLink the CDB specified user and password must be exactly the same CDB;
  • DBLink string must point to the root of the container where the PDB.

3.1 Check the target database environment

[oracle@erp ~]$ rlwrap sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Sat Aug 31 21:10:03 2019
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.

Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

SQL> show pdbs

    CON_ID CON_NAME  OPEN MODE  RESTRICTED
---------- --------- ---------- ----------
     2 PDB$SEED      READ ONLY  NO
     3 PDB1          MOUNTED
     4 PDB_REF       READ ONLY  NO
     5 PDB_REFAUTO   MOUNTED

3.2 target database to create user and authorization

Note and consistent source library

SQL> create user c##u1 identified by oracle;

User created.

SQL> grant create session,create pluggable database,sysoper to c##u1 container=all;

Grant succeeded.

3.3 Source Library Editor TNS

CDB1 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.12)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = CDB1)
    )
  )

3.4 Source library created DBLink

SQL> create database link cdb1_dblink connect to c##u1 identified by oracle using 'CDB1';

Database link created.

SQL> select * from tab@cdb1_dblink;

no rows selected

3.5 with a target handover source PDB PDB

Before the handover, the source PDB state facie

SQL> show pdbs

    CON_ID CON_NAME  OPEN MODE  RESTRICTED
---------- --------- ---------- ----------
     3 ERP1          READ WRITE NO   <--- STATUS:READ WRITE

Before the handover, the target look PDB state

SQL> show pdbs

    CON_ID CON_NAME  OPEN MODE  RESTRICTED
---------- --------- ---------- ----------
     2 PDB$SEED      READ ONLY  NO
     3 PDB1          MOUNTED
     4 PDB_REF       READ ONLY  NO    <--- STATUS:READ ONLY 只读
     5 PDB_REFAUTO   MOUNTED

In the source database ERP1 performing handover command

SQL> alter session set container=erp1;

Session altered.

SQL> show pdbs

    CON_ID CON_NAME  OPEN MODE  RESTRICTED
---------- --------- ---------- ----------
     3 ERP1          READ WRITE NO

SQL
> alter pluggable database refresh mode manual from pdb_ref@cdb1_dblink switchover; Pluggable database altered.

After the handover, the source PDB state facie

SQL > Show PDBS 

    CON_ID CON_NAME    the OPEN the MODE RESTRICTED
 - -------- ---------- ---------- ---------- 
     3 ERP1 MOUNTED <--- Note: the write state before switching becomes the oFF state (becomes a source library ERP1 refresh PDB)

After the handover, the target look PDB state

SQL > Show PDBS 

    CON_ID CON_NAME    the OPEN the MODE RESTRICTED
 - -------- ---------- ---------- ---------- 
     2 $ the SEED PDB        the rEAD  ONLY   NO
      . 3 PDB1 MOUNTED
      . 4 PDB_REF         the rEAD the wRITE NO <--- Note: before the switching from the read-only status, changes the read state (becomes a target source PDB PDB)
      . 5 PDB_REFAUTO MOUNTED

Finally, in read-only mode on refresh PDB - ERP1

SQL> alter pluggable database erp1 open read only;

Pluggable database altered.

SQL> show pdbs

    CON_ID CON_NAME   OPEN MODE  RESTRICTED
---------- ---------- ---------- ----------
     3 ERP1           READ ONLY  NO

 

4. ORA-12754 Description

If the environment is non-Oracle Cloud use in the implementation of ALTER PLUGGABLE DATABASE refresh_mode FROM clonepdb @ dblink SWITCHOVER; command, it will prompt an error:

ERROR at line 1:
ORA-12754: Feature PDB REFRESH SWITCHOVER is disabled due to missing capability

Because the function is restricted to use as a learning test, you can yourself be resolved by some means, but do not infringe on Oracle software copyright.

Guess you like

Origin www.cnblogs.com/askscuti/p/11432599.html