当前位置:网站首页>利用ADG Standby克隆PDB
利用ADG Standby克隆PDB
2022-06-12 21:30:00 【dingdingfish】
本文参考了文章:How to Clone a PDB from a Standby Database in a Data Guard Environment,并完成了整个实验过程。
首先需要一个ADG的环境,比较好的方式是用Oracle Vagrant Projects的OracleDG项目。
这个项目会创建1主1备的ADG环境,版本为19.3。基于64GB内存,4 OCPU的宿主机,创建时间30分钟左右,非常快。
在数据库备机上再创建一个CDB,用来承载克隆的PDB。用dbca静默模式创建,时间在22分钟左右。
目前的架构如下,PDB1是需要克隆的库:
上面标准的DB193H1和DB193H1_STDBY是DB_UNIQUE_NAME,实际的数据库名为DB193H1。
为了表述清楚,后续我们将DB193H1称为主库,DB193H1_STDBY称为备库,ORCLCDB2称为测试库。
首先,我们需要将备库改为只读状态:
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
3 ORCLPDB1 MOUNTED
SQL> alter pluggable database orclpdb1 open read only;
Pluggable database altered.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
3 ORCLPDB1 READ ONLY NO
正是由于备库最多只能为只读,因此我们才需要额外建立一个数据库来承载克隆出来的PDB。如果直接用备库上的CDB来作为克隆的目标容器,则会报错如下:
SQL> create pluggable database PDBCLONE from ORCLPDB1;
create pluggable database PDBCLONE from ORCLPDB1
*
ERROR at line 1:
ORA-16000: database or pluggable database open for read-only access
我们在主库上创建一个克隆管理员clone_admin,是common user,后续将通过他来做克隆操作,此用户建立后会通过ADG传播到备库。
create user c##clone_admin identified by Welcome1;
grant create session, resource to c##clone_admin container=all;
grant create pluggable database to c##clone_admin container=all;
grant sysoper to c##clone_admin container=all;
alter user c##clone_admin set container_data=ALL container=current;
grant select on cdb_pdbs to c##clone_admin;
-- 在参考文档1中,使用了另一种方法,但我没有试过
grant create session, sysoper to C##SYSOPER identified by SysOperPw__199 container=all;
然后在测试库上建立Database link,注意,此Database link是指向备库而非主库,目的是为了减轻对主库的影响,以及避免网络的延迟。
SQL> create public database link clone_link connect to c##clone_admin identified by Welcome1 using 'DB193H1_STDBY';
SQL> select pdb_name from cdb_pdbs@clone_link;
PDB_NAME
--------------------------------------------------------------------------------
PDB1
PDB$SEED
目前我们的备库(克隆的源库)状态如下:
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB1 READ WRITE NO
目前我们的测试库(克隆的目标库)状态如下:
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
在测试库中启动克隆:
SQL> create pluggable database PDBCLONE from PDB1@clone_link;
create pluggable database PDBCLONE from PDB1@clone_link
*
ERROR at line 1:
ORA-00600: internal error code, arguments: [3647], [19], [16400], [], [], [],
[], [], [], [], [], []
好了,这正是我们期待的错误。因为是从备库克隆,所以会出现此错误。如果从主库克隆,则不会出错,但这并不是我们今天测试的场景。
MOS的这篇文档Create Pluggable Database From ADG errors out with ORA-600 [3647] (Doc ID 2072550.1),详细介绍了原因和解决方法。这篇文档的适用数据库版本范围为12.1.0.2 to 21.1。
简单来说,解决方法是先需要停止redo apply再做克隆,克隆完成后,即可启动redo apply。
注意,上一个克隆虽然失败,但是仍然产生了一个PDB的条目,我们需要先删除他:
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDBCLONE MOUNTED
SQL> drop pluggable database PDBCLONE including datafiles;
Pluggable database dropped.
可以在数据库或DGMGRL中停止redo apply:
-- 数据库中
alter database recover managed standby database cancel ;
-- DGMGRL中
edit database db193h1_stdby set state = 'apply-off';
这一回成功了:
SQL> create pluggable database PDBCLONE from PDB1@clone_link;
Pluggable database created.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
4 PDBCLONE MOUNTED
SQL> alter pluggable database pdbclone open;
Pluggable database altered.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
4 PDBCLONE READ WRITE NO
现在可以恢复redo apply了:
-- 数据库中
alter database recover managed standby database disconnect ;
-- DGMGRL中
edit database db193h1_stdby set state = 'apply-on';
为了进一步确认,我又在主库中安装了Sample Schema,重复以上过程,数据确实克隆到测试库了。
以下是几点说明:
- 原文中最后一张图,清晰的说明了执行操作的顺序以及在何处执行。其中对于备库中的PDB,是先stop redo apply,然后open readonly; 执行完克隆后,是先close PDB(克隆源),然后再start redo apply。我虽然没有执行close的动作也成功了,但还是按照他的流程来。
- Refreshable PDB 克隆不支持基于ADG standby创建,这个就不试了。详见Doc ID 2765472.1
参考
边栏推荐
- 在同花顺开户安全么,买股票怎么网上开户
- 阅读笔记 Deep Hough Voting for 3D Object Detection in Point Clouds
- C language learning notes (II)
- USB机械键盘改蓝牙键盘
- pytorch transforms. Use of lambda
- zgc 并发标识和并发转移阶段的多视图地址映射
- Graphics2d class basic use
- The year of the outbreak of financial innovation! All dtinsight products of kangaroo cloud data stack have passed the special test of Xinchuang of ICT Institute
- To delete a character from a string
- 二分查找
猜你喜欢
![[target detection] |dive detector into box for object detection new training method based on fcos](/img/ac/c54c2733dceffea086b772f35f128a.png)
[target detection] |dive detector into box for object detection new training method based on fcos

@loadbalance annotation of resttemplate

Data visualization - biaxial comparison effect

Graphics2D类基本使用

Composer version degradation

Access control system based on RFID

Teambition 协作应用心得分享|社区征文

MySql主从复制

nn. PReLU(planes)

GNS安装与配置
随机推荐
zgc的垃圾收集的主要階段
初步了解認識正則錶達式(Regex)
China hydraulic cylinder linear position sensor market trend report, technical dynamic innovation and market forecast
Digital intelligence data depth | Bi goes down the altar? It's not that the market has declined, it's that the story has changed
DRF receives nested data and creates objects. Solution: DRF not NULL constraint failed
Access control system based on RFID
GPU giant NVIDIA suffered a "devastating" network attack, and the number one malware shut down its botnet infrastructure | global network security hotspot on February 28
Lombok package is successfully installed, but the runtime prompts that get, set method and constructor solution cannot be found
Experiment 7-2-6 print Yanghui triangle (20 points)
Integrated monitoring solution for power environment of small and medium-sized computer rooms
Data visualization - biaxial comparison effect
pytorch transforms. Use of lambda
Smart management of green agriculture: a visual platform for agricultural product scheduling
The year of the outbreak of financial innovation! All dtinsight products of kangaroo cloud data stack have passed the special test of Xinchuang of ICT Institute
GNS安装与配置
Research Report on market supply and demand and strategy of hydraulic operating table industry in China
torch. nn. Linear() function
RestTemplate的@LoadBalance注解
Can tonghuashun open an account? Is it safe to open an account in tonghuashun
ASCII 码对照表