Orcle 12c 新特性---几乎0停机时间迁移PDB

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

图1 迁移一个PDB
在这里插入图片描述

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.

  • 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 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.

2 实验

2.1 环境

远端PDB:192.168.1.55 cndba_pdb --被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

本地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)
    )
  )

–测试一下

[[email protected] 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 检查本地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 [email protected]_link;
  COUNT(*)
----------
 0 --因为该用户下没有表

2.7 Relocate PDB

CREATE PLUGGABLE DATABASE cndba_pdb_re FROM [email protected]_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_RE是MOUNT状态

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

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

–当前状态是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进行一些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/[email protected]_pdb

Connected.

–创建表,并插入数据

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是否删除了

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
https://oracle-base.com/articles/12c/multitenant-relocate-pdb-12cr2

版权声明:本文为qianglei6077原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/qianglei6077/article/details/92795746

智能推荐

剑指offer 合并两个排序的链表

题目 链接:https://leetcode-cn.com/problems/he-bing-liang-ge-pai-xu-de-lian-biao-lcof/ 思路 我想的是,与合并两个有序数组一样的思维,新建一个链表,然后判断谁的值大,进而在新的链表上面进行插入。 看书思路 合并链表是一个递归问题:合并一个节点后可以转化为一个子问题。终止条件是其中一个链表为空 代码 链表反转也可以用递归解决...

Java编程思想 第三章:操作符

Java中的操作符和c/c++中的操作符基本一致,因为我之前学习过C语言和C++,所以本章的内容大部分都已熟知,下面只做简单的介绍。 Java操作符及优先级 Java中的操作符包括算术操作符,关系操作符,逻辑操作符,位运算符、自操作运算符、移位运算符、赋值运算符和其他运算符。 算术操作符:包括加减乘除和取余(%),优先级乘除取余高于加减,都是双元运算符,其中加法(+)可以用来连接两个字符串,比如:...

JetBrains 系列开发工具,如何配置 `SCSS` `File Watcher` ,相关输出配置参数详解:webStorm phpStorm IDEA

JetBrains 系列开发工具,如何配置 SCSS File Watcher ,相关输出配置参数详解:webStorm phpStorm IDEA 前言 你目前已经了解了如何使用 SCSS 进行开发,了解了该文章的内容:『 SCSS 日常用法 』 在 JetBrains 系列开发工具中通过 FileWatcher 进行编译的 SCSS 文件都是通过 sass 这个程序进行的。『 如何添加 Fil...

C语言小函数—二进制与十六进制

测试如下 “` int main() { long int num = 15; } “`...

仿微博或微信的文章多图显示(自定义MultiImageView)

按照一般的规矩,先上张图来供大伙看看 如果大致是大伙们需要实现的功能,不烦一观 自定义MultiImageView 工具类 具体使用 app.gradle中添加依赖 implementation 'com.github.bumptech.glide:glide:4.8.0' AndroidManifest.xml中配置联网权限 <uses-permission android:name=&q...

猜你喜欢

经典进程同步和互斥问题

经典进程同步与互斥问题 前言 一、生产者-消费者问题 1.问题描述 2.问题分析 3.代码 二、读者-写者问题 1.问题描述&&分析 2.代码 三、哲学家进餐问题 1.问题描述&&分析 2.代码 四、理发师问题 1.问题描述&&分析 2.代码 前言 在多道程序设计环境中,进程同步是一个非常重要的问题,下面讨论几个经典的进程同步问题。 一、生产者-消费...

java设计模式——ThreadLocal线程单例

1、定义一个ThreadLocal线程单例,代码如下: 2、定义一个多线程类,代码如下: 3、定义一个测试类,代码如下: 4、输出结果,如下图:...

【tensorflow】线性模型实战

线性模型:y = 1.477 * x + 0.089   1. 采样数据 采样噪声eps在均值0,方差0.01的高斯分布中,而后在均匀分布U(0,1)中,区间[-10,10]进行n=100次随机采样:   2. 计算误差 循环计算每个点的预测值与真是值之间差的平方并累加,从而获得训练集上的均芳误差损失值。   3. 计算梯度   4. 梯度更新 对权重w和偏...

常见损失函数和评价指标总结(附公式&代码)

网上看到一篇很实用的帖子关于常见损失函数和评价指标,收藏下来 本文转载于https://zhuanlan.zhihu.com/p/91511706 ------------------------------------------------------------------------------------------------------------------------------...

为什么 4G/5G 的直播延时依然很高

通信技术的发展促进了视频点播和直播业务的兴起,4G 和 5G 网络技术的进步也使得流媒体技术变得越来越重要,但是网络技术并不能解决流媒体直播的高延迟问题。 本文不会介绍网络对直播业务的影响,而是会分析直播中常见的现象 — 主播和观众之间能够感觉到的明显网络延迟。除了业务上要求的延迟直播之外,有哪些因素会导致视频直播的延迟这么高呢? live-streaming  图 1 - ...