Orcle 12c new features --- almost 0 downtime migration PDB

1 说明
This new feature significantly reduces downtime by leveraging the clone functionality to relocate a pluggable database (PDB) from one multitenant container database (CDB) to another CDB. The source PDB is still open and fully functional while the actual cloning operation is taking place. The application outage is reduced to a very small window while the source PDB is quiesced and the destination PDB is brought online after applying the incremental redo. The source PDB is subsequently dropped.

12.2 This new feature function by using cloning insertable database (the PDB) to migrate from one container multi-tenant database (CDB) to another CDB, greatly reducing downtime. Cloning occurs when the actual operation, the source PDB is still open and that all functions are available. Applications will only have a short window of downtime, when the last incremental application log.

FIG 1 a PDB Migration
Here Insert Picture Description

1.1 elocate pdb must meet the following criteria

  • The current user must have the CREATE PLUGGABLE DATABASE system privilege in the root of the CDB to which the PDB is being relocated.

  • The CDB that contains the PDB before relocation must be in local undo mode. --必须是local undo

  • If the CDB to which the PDB is being relocated is not in ARCHIVELOG mode, then the PDB must be in open read-only mode during the operation. This requirement does not apply if the CDB to which the PDB is being relocated is in ARCHIVELOG mode - to be in archive mode, if a non-filing mode, then the source PDB only be opened in read-only mode.

  • The following prerequisites apply to the database link:

    • A database link must enable a connection from the CDB to which the PDB is being relocated to the PDB’s current CDB. The database link must connect to the root of the CDB. If the PDB is an application PDB, then the database link must connect to its application root.

    • The user that the database link connects with in the PDB’s current CDB must have the CREATE PLUGGABLE DATABASE system privilege.

    • The user that the database link connects with in the PDB’s current CDB must have the SYSDBA or SYSOPER administrative privilege.

    • If the database link connects to the CDB root in the PDB’s current CDB, then the user that the database link connects with must be a common user.

  • The platforms of the PDB’s current CDB and the CDB to which it is being relocated must meet these requirements:

    • They must have the same endianness.

    • The database options installed on the source platform must be the same as, or a subset of, the database options installed on the target platform.

  • If the character set of the CDB to which the PDB is being relocated is not AL32UTF8, then the PDB’s current CDB and the CDB to which it is being relocated must have compatible character sets and national character sets. To be compatible, the character sets and national character sets must meet all of the requirements specified in Oracle Database Globalization Support Guide. 默认字符集是AL32UTF8

  • If you are creating an application PDB, then the application name and version of the PDB being relocated must match the application name and version of the application container that will contain the application PDB after it is relocated.

Experiment 2

2.1 Environment

Distal PDB: 192.168.1.55 cndba_pdb - is relocate pdb

SQL> show pdbs;

CON_ID CON_NAME	OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
 2 PDB$SEED	  READ ONLY  NO

 3 PDB1   	MOUNTED

 4 CNDBA_PDB READ WRITE NO

Local PDB: 192.168.1.110 cndba_pdb_re - used to store new PDB

2.2 distal CDB user to create dblink

SQL> CREATE USER c##remote_clone_user IDENTIFIED BY remote_clone_user CONTAINER=ALL;

User created.


SQL> GRANT CREATE SESSION, SYSOPER, CREATE PLUGGABLE DATABASE TO c##remote_clone_user CONTAINER=ALL;

Grant succeeded.

2.3 Check remote mode and archival mode CDB undo

  • undo mode
COLUMN property_name FORMAT A30
COLUMN property_value FORMAT A30

SELECT property_name, property_value
FROM   database_properties
WHERE  property_name = 'LOCAL_UNDO_ENABLED';

PROPERTY_NAME	       PROPERTY_VALUE
------------------------------ ------------------------------
LOCAL_UNDO_ENABLED	       TRUE
  • Archive mode
SQL> archive log list;
Database log mode	       Archive Mode
Automatic archival	       Enabled
Archive destination	       USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     41
Next log sequence to archive   43
Current log sequence	       43

2.4 Local CDB configuration tns, distally directed CDB

Add the following in the tnsnames.ora, be sure to include "(SERVER = DEDICATED)"

CDB55=
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.55)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = zhixin)
    )
  )

-have a test

[oracle@db12CR2 backup]$ tnsping cdb55

TNS Ping Utility for Linux: Version 12.2.0.1.0 - Production on 08-AUG-2017 14:26:51

Copyright (c) 1997, 2016, Oracle.  All rights reserved.

Used parameter files:

Used TNSNAMES adapter to resolve the alias

Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.55)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = zhixin)))

OK (10 msec)

2.5 Check the local CDB undo mode and archive mode

-undo mode

COLUMN property_name FORMAT A30
COLUMN property_value FORMAT A30

SELECT property_name, property_value
FROM   database_properties
WHERE  property_name = 'LOCAL_UNDO_ENABLED';
PROPERTY_NAME	       PROPERTY_VALUE
------------------------------ ------------------------------
LOCAL_UNDO_ENABLED	      TRUE

- archive mode

SQL> archive log list;
Database log mode	       Archive Mode
Automatic archival	       Enabled
Archive destination	       USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     402
Next log sequence to archive   404
Current log sequence	       404

2.6 dblink created in the local CDB, distally directed CDB

SQL> CREATE PUBLIC DATABASE LINK clone_link
  CONNECT TO c##remote_clone_user IDENTIFIED BY remote_clone_user USING 'cdb55';  2  
Database link created.

- test whether normal dblink

SQL> select count(*) from user_tables@clone_link;
  COUNT(*)
----------
 0 --因为该用户下没有表

2.7 Relocate PDB

CREATE PLUGGABLE DATABASE cndba_pdb_re FROM cndba_pdb@clone_link
FILE_NAME_CONVERT = ('/u01/app/oracle/oradata/cndba_pdb/','/u01/app/oracle/oradata/orcl/cndba_pdb_re/')
RELOCATE;
Pluggable database created.

If you started the OMF, you do not need the red part.

2.8 View new PDB

MOUNT state is CNDBA_PDB_RE

SQL> SELECT name, open_mode FROM v$pdbs WHERE name = 'CNDBA_PDB_RE';

NAME	       OPEN_MODE
------------------------------ --------------------
CNDBA_PDB_RE	       MOUNTED

- The current state is RELOCATING

SQL> col pdb_name for a20
SQL> SELECT pdb_name, status FROM DBA_PDBS  WHERE pdb_name = 'CNDBA_PDB_RE';

PDB_NAME	     STATUS
--------------------   -----------------------
CNDBA_PDB_RE	     RELOCATING

2.9 PDB distal some DML operations

SQL> show pdbs;
    CON_ID CON_NAME	  OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
 2 PDB$SEED	  READ ONLY  NO
 3 PDB1   MOUNTED
 4 CNDBA_PDB	  READ WRITE NO --首先PDB为READ WRITE状态
 
SQL> alter session set container=cndba_pdb;

Session altered.

SQL> conn lei/lei@cndba_pdb

Connected.

- Create a table and insert data

SQL> create table test_relocate as select * from v$version;
Table created.

2.10 complete relocate

When you open a new PDB, it represents relocate completed.

SQL> alter pluggable database CNDBA_PDB_RE open;
Pluggable database altered.


SQL> SELECT name, open_mode FROM v$pdbs WHERE name = 'CNDBA_PDB_RE';

NAME	       OPEN_MODE
------------------------------ --------------------
CNDBA_PDB_RE	       READ WRITE

2.11 Check whether the data transmission over the back

SQL> select * from lei.test_relocate;

BANNER
--------------------------------------------------------------------------------
    CON_ID
----------
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
 0
PL/SQL Release 12.2.0.1.0 - Production
 0
CORE	12.2.0.1.0	Production
 0
BANNER
--------------------------------------------------------------------------------
    CON_ID
----------
TNS for Linux: Version 12.2.0.1.0 - Production
 0
NLSRTL Version

no problem.

2.12 confirm whether to delete the distal end of the PDB

SQL> show pdbs;

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

You can see, CNDBA_PDB has gone.

Reference article:
http://docs.oracle.com/database/122/ADMIN/creating-and-removing-pdbs-with-sql-plus.htm#ADMIN-GUID-F887DBA7-61A6-49FB-8400-40632765F1E1
HTTP: //docs.oracle.com/database/122/NLSPG/choosing-character-set.htm#NLSPG1035
https://oracle-base.com/articles/12c/multitenant-relocate-pdb-12cr2

Guess you like

Origin blog.csdn.net/qianglei6077/article/details/92795746