我的编程空间,编程开发者的网络收藏夹
学习永远不晚

oracle 12c中怎么搭建PDB refresh

短信预约 -IT技能 免费直播动态提醒
省份

北京

  • 北京
  • 上海
  • 天津
  • 重庆
  • 河北
  • 山东
  • 辽宁
  • 黑龙江
  • 吉林
  • 甘肃
  • 青海
  • 河南
  • 江苏
  • 湖北
  • 湖南
  • 江西
  • 浙江
  • 广东
  • 云南
  • 福建
  • 海南
  • 山西
  • 四川
  • 陕西
  • 贵州
  • 安徽
  • 广西
  • 内蒙
  • 西藏
  • 新疆
  • 宁夏
  • 兵团
手机号立即预约

请填写图片验证码后获取短信验证码

看不清楚,换张图片

免费获取短信验证码

oracle 12c中怎么搭建PDB refresh

这篇文章主要讲解了“oracle 12c中怎么搭建PDB refresh”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“oracle 12c中怎么搭建PDB refresh”吧!

PDB Refresh是12C推出的新特性,可以对源端PDB进行增量同步,可以快速实现拷贝一份数据库镜像副本,有点类似运营商喜欢使用的EMC的BCV技术,存储层的复制功能。但是副本只能以read only打开,拷贝速度较慢,刷新走网络流量,实际应用场景较少。

PDB refresh源端与目标端可以在同一个cdb,也可以在不同的cdb中,刷新方式必须通过dblink。

PDB refresh搭建

数据库版本

SYS@cdbtest1(CDB$ROOT)> select banner   from v$version where rownum=1;

 

BANNER

--------------------------------------------------------------------------------

Oracle Database 12c Enterprise Edition   Release 12.2.0.1.0 - 64bit Production

 

pdb refresh有两个基本要求:归档和local undo

检查归档是否开启:

SYS@cdbtest1(CDB$ROOT)> archive log   list

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            /arch

Oldest online log sequence     42

Next log sequence to archive   45

Current log sequence           45

 

检查undo是否为local模式

SYS@cdbtest1(CDB$ROOT)> col   PROPERTY_NAME for a25

SYS@cdbtest1(CDB$ROOT)> col   PROPERTY_VALUE for a30

SYS@cdbtest1(CDB$ROOT)>  select PROPERTY_NAME,PROPERTY_VALUE from   database_properties where property_name='LOCAL_UNDO_ENABLED';

 

PROPERTY_NAME             PROPERTY_VALUE

-------------------------   ------------------------------

LOCAL_UNDO_ENABLED        TRUE

 

当前pdb信息

SYS@cdbtest1(CDB$ROOT)> show  pdbs

 

      CON_ID CON_NAME                         OPEN MODE  RESTRICTED

---------- ------------------------------   ---------- ----------

           2 PDB$SEED                         READ ONLY  NO

           3 CLONEMING                        READ WRITE NO

           4 MING                           READ WRITE NO

               

快速刷新pdb的数据文件存放位置跟普通pdb有点区别,dba_data_files是查不到的,需要用v$dbfile视图。

select name from v$dbfile;

 

NAME

----------------------------------------------------------------------------------------------------

/oradata/cdb/CDBTEST1/79C426B26B8C175BE053023DA8C0C3CA/datafile/o1_mf_system_fxvbwmck_.dbf

/oradata/cdb/CDBTEST1/79C426B26B8C175BE053023DA8C0C3CA/datafile/o1_mf_sysaux_fxvbwmcp_.dbf

/oradata/cdb/CDBTEST1/79C426B26B8C175BE053023DA8C0C3CA/datafile/o1_mf_test_fxvbwmcq_.dbf

/oradata/cdb/CDBTEST1/79C426B26B8C175BE053023DA8C0C3CA/datafile/o1_mf_test_fxvbwmcr_.dbf

/oradata/cdb/CDBTEST1/79C426B26B8C175BE053023DA8C0C3CA/datafile/o1_mf_undo_1_fxvbwmcr_.dbf

它的数据文件是放在cdb目录下的

               

以MING为源端pdb,需要创建到该cdb的dblink

SYS@cdbtest1(CDB$ROOT)> create   database link dblk_pdbming connect to system identified by "oracle"   using 'pdbming';

 

Database link created.

 

create database link dblk_pdbming connect   to system identified by "oracle" using 'pdbming';

 

SYS@cdbtest1(CDB$ROOT)>  select sysdate from dual@dblk_pdbming;

 

SYSDATE

------------

03-NOV-18

 

创建手动刷新refresh pdb

create pluggable   database mingdev1 from ming@dblk_pdbming refresh mode manual;

 

alert日志

create pluggable database mingdev1 from   ming@dblk_pdbming refresh mode manual

2018-11-03T22:07:14.174103+08:00

MING(4):Opatch XML is skipped for PDB   MING (conid=4)

MING(4): AUDSYS.AUD$UNIFIED (SQL_TEXT) -   CLOB populated

2018-11-03T22:07:15.368785+08:00

Opatch validation is skipped for PDB   MINGDEV1 (con_id=6)

2018-11-03T22:08:37.761704+08:00

MINGDEV1(6):Endian type of dictionary set   to little

****************************************************************

Pluggable Database MINGDEV1 with pdb id -   6 is created as UNUSABLE.

If any errors are encountered before the   pdb is marked as NEW,

then the pdb must be dropped

local undo-1,   localundoscn-0x0000000000a123e2

****************************************************************

2018-11-03T22:08:44.807546+08:00

Applying media recovery for pdb-4 from   SCN 10563994 to SCN 10564176

Remote log information: count-1

thr-1, seq-45,   logfile-/arch/parlog_1_45_839db4a4_967464795.arc, los-10555323,   nxs-18446744073709551615

MINGDEV1(6):Media Recovery Start

2018-11-03T22:08:44.933181+08:00

MINGDEV1(6):Serial Media Recovery started

2018-11-03T22:08:45.086257+08:00

MINGDEV1(6):Media Recovery Log   /arch/parlog_1_45_839db4a4_967464795.arc

2018-11-03T22:08:45.637158+08:00

MINGDEV1(6):Incomplete Recovery applied   until change 10564176 time 11/03/2018 22:08:39

2018-11-03T22:08:45.639481+08:00

MINGDEV1(6):Media Recovery Complete   (cdbtest1)

2018-11-03T22:08:45.958911+08:00

Completed: create pluggable database   mingdev1 from ming@dblk_pdbming refresh mode manual

 

SYS@cdbtest1(CDB$ROOT)> sho pdbs

 

      CON_ID CON_NAME                         OPEN MODE  RESTRICTED

---------- ------------------------------   ---------- ----------

           2 PDB$SEED                         READ ONLY  NO

         3 CLONEMING                      READ WRITE NO

           4 MING                             READ WRITE NO

           6 MINGDEV1                         MOUNTED

 

SYS@cdbtest1(CDB$ROOT)> alter   pluggable database mingdev1 open;

alter pluggable database mingdev1 open

*

ERROR at line 1:

ORA-65341: cannot open pluggable database   in read/write mode

 

后来发现报错

ORA-12012: ִҵ "SYS"."ORA$AT_OS_OPT_SY_101"

ORA-20001: Statistics Advisor: Invalid   task name for the current user

ORA-06512: SYS.DBMS_STATS", line   47207

ORA-06512: SYS.DBMS_STATS_ADVISOR",   line 882

ORA-06512: SYS.DBMS_STATS_INTERNAL",   line 20059

ORA-06512: SYS.DBMS_STATS_INTERNAL",   line 22201

ORA-06512: SYS.DBMS_STATS", line   47197

 

虽然不能open read write,但是可以以read only模式打开

SYS@cdbtest1(CDB$ROOT)> alter pluggable   database mingdev1 open read only;

 

Pluggable database altered.

 

SYS@cdbtest1(CDB$ROOT)> sho pdbs

 

      CON_ID CON_NAME                         OPEN MODE  RESTRICTED

---------- ------------------------------   ---------- ----------

           2 PDB$SEED                       READ ONLY  NO

           3 CLONEMING                        READ WRITE NO

           4 MING                             READ WRITE NO

           6 MINGDEV1                         READ ONLY  NO

 

sys用户登录目标pdb

SYS@mingdev1(MINGDEV1)> alter pluggable database mingdev1 refresh;

alter pluggable database mingdev1 refresh

*

ERROR at line 1:

ORA-65025: Pluggable database MINGDEV1 is   not closed on all instances.

刷新pdb必须将目标pdb先关闭或者mount

 

SYS@mingdev1(MINGDEV1)> alter   pluggable database mingdev1 close immediate;

 

Pluggable database altered.

 

SYS@mingdev1(MINGDEV1)> sho pdbs

 

      CON_ID CON_NAME                         OPEN MODE  RESTRICTED

---------- ------------------------------   ---------- ----------

           6 MINGDEV1                         MOUNTED

SYS@mingdev1(MINGDEV1)> alter   pluggable database mingdev1 refresh;

 

Pluggable database altered.

 

SYS@mingdev1(MINGDEV1)> sho pdbs

 

      CON_ID CON_NAME                         OPEN MODE  RESTRICTED

---------- ------------------------------   ---------- ----------

           6 MINGDEV1                         MOUNTED

SYS@mingdev1(MINGDEV1)> alter   pluggable database mingdev1 open;

alter pluggable database mingdev1 open

*

ERROR at line 1:

ORA-65341: cannot open pluggable database   in read/write mode

 

 

SYS@mingdev1(MINGDEV1)> alter pluggable   database mingdev1 open read only;

 

Pluggable database altered.

 

实际上刷新的过程就是一个介质恢复的过程

MINGDEV1(6):alter pluggable database   mingdev1 refresh

2018-11-04T09:05:44.122795+08:00

Applying media recovery for pdb-4 from   SCN 10564176 to SCN 10654056

Remote log information: count-4

thr-1, seq-47,   logfile-/arch/1_47_967464795.dbf, los-10621887, nxs-10641265

thr-1, seq-46,   logfile-/arch/1_46_967464795.dbf, los-10598476, nxs-10621887

thr-1, seq-45,   logfile-/arch/1_45_967464795.dbf, los-10555323, nxs-10598476

thr-1, seq-48,   logfile-/arch/parlog_1_48_839db4a4_967464795.arc, los-10641265,   nxs-18446744073709551615

MINGDEV1(6):Media Recovery Start

2018-11-04T09:05:44.172534+08:00

MINGDEV1(6):Serial Media Recovery started

2018-11-04T09:05:44.440066+08:00

MINGDEV1(6):Media Recovery Log   /arch/1_45_967464795.dbf

2018-11-04T09:05:49.927526+08:00

MINGDEV1(6):Media Recovery Log   /arch/1_46_967464795.dbf

2018-11-04T09:05:54.341779+08:00

MINGDEV1(6):Media Recovery Log   /arch/1_47_967464795.dbf

2018-11-04T09:05:58.832855+08:00

MINGDEV1(6):Media Recovery Log   /arch/parlog_1_48_839db4a4_967464795.arc

2018-11-04T09:06:02.365844+08:00

MINGDEV1(6):Incomplete Recovery applied   until change 10654056 time 11/04/2018 09:05:38

2018-11-04T09:06:02.367512+08:00

MINGDEV1(6):Media Recovery Complete   (cdbtest1)

MINGDEV1(6):Completed: alter pluggable   database mingdev1 refresh

 

增量同步

desc ming.tx

 Name                                        Null?    Type

 -----------------------------------------   -------- ----------------------------

 A                                                    NUMBER(38)

 

在源pdb内做一些DDL和DML操作:

alter table ming.tx add b int;

insert into ming.tx values(1,1);

commit;

select * from ming.tx;

           A          B

---------- ----------

           1          1

 

此时refresh pdb内还看不到

sho con_name

CON_NAME

------------------------------

MINGDEV1

PDB refresh必须在目标pdb中执行

alter pluggable database mingdev1   refresh;

SYS@cdbtest1(CDB$ROOT)> alter   pluggable database MINGDEV1 open read only;

 

Pluggable database altered.

 

 

desc ming.tx

 Name                                        Null?    Type

 -----------------------------------------   -------- ----------------------------

 A                                                  NUMBER(38)

 B                                                    NUMBER(38)

 

select * from ming.tx;

 

           A          B

---------- ----------

           1          1

 

SYS@cdbtest1(CDB$ROOT)> select   index_name from dba_indexes where table_name='TX';

 

INDEX_NAME

--------------------------------------------------------------------------------

TX_IDX_01

 

 

这种方式的实现方式是通过定时job的方式实现的,如下job详情:

begin dbms_scheduler.create_job(

job_name     =>'MINGDEV1_4131117117_refresh',                                       

job_type     => 'PLSQL_BLOCK',                                                   

job_action => 'begin                  

               execute immediate ''alter   session set container = MINGDEV1'';                    

               execute immediate ''alter   pluggable database refresh'';                                            end;',            

start_date => systimestamp,                                           

repeat_interval => 'FREQ = MINUTELY;   INTERVAL = 1',                           

enabled => TRUE,               

comments => 'MINGDEV1 refresh');                        

end;

 

手动refresh变为自动refresh

下面再看一下自动刷新,该动作需要在快速刷新pdb中执行

SYS@cdbtest1(CDB$ROOT)> @entdb   mingdev1

SYS@cdbtest1(MINGDEV1)> ALTER   PLUGGABLE DATABASE mingdev1 REFRESH MODE EVERY 1 MINUTES;

 

Pluggable database altered.

 

SELECT pdb_id, pdb_name, refresh_mode,   refresh_interval FROM  dba_pdbs;

 

查看:

SYS@cdbtest1(CDB$ROOT)> col pdb_name   for a30

SYS@cdbtest1(CDB$ROOT)> SELECT pdb_id,   pdb_name, refresh_mode, refresh_interval FROM    dba_pdbs;

 

      PDB_ID PDB_NAME                         REFRES REFRESH_INTERVAL

---------- ------------------------------   ------ ----------------

           2 PDB$SEED                         NONE

           3 CLONEMING                        NONE

           4 MING                             NONE

           6 MINGDEV1                         AUTO                  1

源pdb中插入一条数据

insert into ming.tx values(2,2);

commit;

select * from ming.tx;

 

           A          B

---------- ----------

           1          1

           2          2

alert日志中可以发现:     

MINGDEV1(6):ALTER PLUGGABLE DATABASE   mingdev1 REFRESH MODE EVERY 1 MINUTES

MINGDEV1(6):Completed: ALTER PLUGGABLE   DATABASE mingdev1 REFRESH MODE EVERY 1 MINUTES

2018-12-09T12:03:55.230825+08:00

MINGDEV1(6):alter pluggable database   refresh

MINGDEV1(6):Completed: alter pluggable   database refresh

2018-12-09T12:04:54.144791+08:00

MINGDEV1(6):alter pluggable database   refresh

MINGDEV1(6):Completed: alter pluggable   database refresh

2018-12-09T12:05:54.347415+08:00

MINGDEV1(6):alter pluggable database   refresh

MINGDEV1(6):Completed: alter pluggable   database refresh

 

但是refresh pdb中的数据并没有变化

SYS@cdbtest1(MINGDEV1)> select * from   ming.tx;

 

           A          B

---------- ----------

           1          1

 

那是因为refresh pdb是read only状态,read only模式下不会自动刷新,需要将pdb关闭或者mount

SYS@cdbtest1(MINGDEV1)> shutdown   immediate

Pluggable Database closed.

SYS@cdbtest1(CDB$ROOT)>  alter pluggable database MINGDEV1 open read   only;

 

Pluggable database altered.

 

再次查看

SYS@cdbtest1(MINGDEV1)> select * from   ming.tx;

 

           A          B

---------- ----------

           1          1

           2          2

 

自动刷新转变为手动刷新

SYS@cdbtest1(MINGDEV1)> alter pluggable database MINGDEV1 refresh mode manual;

 

Pluggable database altered.

refresh PDB转变为普通PDB

SYS@cdbtest1(CDB$ROOT)> sho pdbs

 

      CON_ID CON_NAME                         OPEN MODE  RESTRICTED

---------- ------------------------------   ---------- ----------

           2 PDB$SEED                         READ ONLY  NO

           3 CLONEMING                        READ WRITE NO

           4 MING                           READ WRITE NO

           6 MINGDEV1                         READ ONLY  NO

SYS@cdbtest1(CDB$ROOT)> alter   pluggable database MINGDEV1 close immediate;

 

Pluggable database altered.

SYS@cdbtest1(MINGDEV1)> alter pluggable database MINGDEV1 refresh mode none;

 

Pluggable database altered.

SYS@cdbtest1(CDB$ROOT)> alter   pluggable database MINGDEV1 open;

 

Pluggable database altered.

 

注意:此过程不可逆,一旦完成转换,就不能再实现refresh了

感谢各位的阅读,以上就是“oracle 12c中怎么搭建PDB refresh”的内容了,经过本文的学习后,相信大家对oracle 12c中怎么搭建PDB refresh这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是亿速云,小编将为大家推送更多相关知识点的文章,欢迎关注!

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

oracle 12c中怎么搭建PDB refresh

下载Word文档到电脑,方便收藏和打印~

下载Word文档

猜你喜欢

Linux中怎么搭建XAMPP

这篇文章主要介绍“Linux中怎么搭建XAMPP”,在日常操作中,相信很多人在Linux中怎么搭建XAMPP问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”Linux中怎么搭建XAMPP”的疑惑有所帮助!接下来
2023-06-27

CentOS中怎么搭建K8S

这篇文章将为大家详细讲解有关CentOS中怎么搭建K8S,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。环境: 操作系统:win10 虚拟机:virtual box linux发行版:Cent
2023-06-15

Linux中怎么搭建svn

这篇文章主要介绍“Linux中怎么搭建svn”的相关知识,小编通过实际案例向大家展示操作过程,操作方法简单快捷,实用性强,希望这篇“Linux中怎么搭建svn”文章能帮助大家解决问题。SVN是一个开源的版本控制系统,可以达到多人同时开发一个
2023-06-28

oracle分布式数据库怎么搭建

要搭建Oracle分布式数据库,可以按照以下步骤进行操作:确保已经安装了Oracle数据库软件,并且有适当的许可证。创建数据库实例:使用Oracle创建数据库实例的命令。配置监听器:使用Oracle Net Configuration As
2023-10-25

php Zend中怎么搭建MVC

小编给大家分享一下php Zend中怎么搭建MVC,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!php有什么特点1、执行速度快。2、具有很好的开放性和可扩展性。3
2023-06-14

Ubuntu中怎么搭建网桥

本篇文章为大家展示了Ubuntu中怎么搭建网桥,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。网桥化的网络示例在这个例子中,eth0 和 eth2 是物理网络接口。eth0 连接着局域网,eth2 连
2023-06-13

在centos中怎么搭建vps

要在CentOS中搭建VPS(Virtual Private Server),你可以按照以下步骤进行:1. 安装CentOS操作系统:将CentOS操作系统安装到你的服务器上。你可以选择CentOS 7或CentOS 8版本。2. 更新系统
2023-08-11

Linux中怎么搭建Python2.7环境

这篇“Linux中怎么搭建Python2.7环境”文章的知识点大部分人都不太理解,所以小编给大家总结了以下内容,内容详细,步骤清晰,具有一定的借鉴价值,希望大家阅读完这篇文章能有所收获,下面我们一起来看看这篇“Linux中怎么搭建Pytho
2023-06-27

编程热搜

目录