签到成功

知道了

CNDBA社区CNDBA社区

Orcle 12c 新特性---Near Zero Downtime PDB Relocation

2017-08-08 15:01 2313 0 原创 Oracle 12C
作者: Expect-乐

 说明

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中这个新特性通过利用克隆功能将可插入的数据库(PDB)从一个多租户容器数据库(CDB)迁移到另一个CDB,大大减少了停机时间。当实际克隆操作发生时,源PDB仍然是打开的并且所有功能都是可用的。应用程序只会有短暂的停机窗口,在最后应用增量日志时。

1 迁移一个PDB


http://www.cndba.cn/Expect-le/article/2076

1.1   elocate pdb必须满足以下条件

The current user must have the CREATE PLUGGABLE DATABASE system privilege in the root of the CDB to which the PDB is being relocated.http://www.cndba.cn/Expect-le/article/2076

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.   --要处于归档模式,如果是非归档模式,那么源PDB只能以只读模式打开。

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 PDBs 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 PDBs current CDB must have the CREATE PLUGGABLE DATABASE system privilege.http://www.cndba.cn/Expect-le/article/2076

The user that the database link connects with in the PDBs current CDB must have the SYSDBA or SYSOPER administrative privilege.

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

The platforms of the PDBs 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 PDBs 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.

实验

2.1   环境

远端PDB:192.168.1.55 cndba_pdb --relocate pdbhttp://www.cndba.cn/Expect-le/article/2076

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:192.168.1.110 cndba_pdb_re  --用于存放新PDB

2.2   远端CDB创建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   检查远端CDB undo模式和归档模式

--undo模式

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

--归档模式

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   本地CDB配置tns,指向远端CDB

tnsnames.ora中添加如下内容,一定要包括 "(SERVER = DEDICATED)"

CDB55=

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.55)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = zhixin)

    )

  )

--测试一下

[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)

http://www.cndba.cn/Expect-le/article/2076

2.5   检查本地CDB undo模式和归档模式

--undo模式

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

--归档模式

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   在本地CDB创建dblink,指向远端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.

--测试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.

如果你启动了OMF,那么就不需要红色部分。

2.8   查看新的PDB

CNDBA_PDB_REMOUNT状态

http://www.cndba.cn/Expect-le/article/2076

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

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

--当前状态是RELOCATINGhttp://www.cndba.cn/Expect-le/article/2076

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进行一些DML操作

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.

--创建表,并插入数据

http://www.cndba.cn/Expect-le/article/2076

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

2.10   完成relocate

当你打开新的PDB,那么表示relocate完成了

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   查看后面的数据是否传输过来

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

没有问题。

2.12   确认远端的PDB是否删除了

http://www.cndba.cn/Expect-le/article/2076

SQL> show pdbs;

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

可以看到,CNDBA_PDB已经没了。

参考文章:

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

http://www.cndba.cn/Expect-le/article/2076

https://oracle-base.com/articles/12c/multitenant-relocate-pdb-12cr2

版权声明:本文为博主原创文章,未经博主允许不得转载。

Relocate PDB

用户评论
* 以下用户言论只代表其个人观点,不代表CNDBA社区的观点或立场
Expect-乐

Expect-乐

关注

Without the continuous bitter cold, there can be no fragrant plum blossom

  • 336
    原创
  • 6
    翻译
  • 100
    转载
  • 41
    评论
  • 访问:1569686次
  • 积分:1957
  • 等级:核心会员
  • 排名:第4名
精华文章
    最新问题
    查看更多+
    热门文章
      热门用户
      推荐用户
        Copyright © 2016 All Rights Reserved. Powered by CNDBA · 皖ICP备2022006297号-1·

        QQ交流群

        注册联系QQ