Oracle 12c系列(九) | 通过unplug与plug方式升级pdb数据库

本文详细介绍了如何通过unplug/plug方式升级Oracle 12c的PDB数据库。在升级过程中,涉及数据字典升级、Oracle APEX的卸载与安装,以及拔出插入操作,最终成功将12.1.0.2.0版本的pdb1升级到12.2.0.1.0。
摘要由CSDN通过智能技术生成

对于Oracle数据库升级操作,每个版本之间的升级步骤均相似,首先升级Oracle软件,然后升级数据库内的数据字典表。

在Oracle12c中,当我们通过容器的方式对数据库进行整合后,其升级方式变得更加灵活,整合后我可以选择对容器中的所有PDB数据库进行升级,也可以通过克隆/移动以及unplug/plug的方式对其中的某一个PDB数据库进行升级从而不影响容器中的其他PDB数据库。

如下将演示如何通过unplug/plug的方式升级pdb数据库。

原环境为:

目标环境:

这里将12.1版本的容器oradb中pdb1通过unplug/plug方式插入到容器ora12c中,以此方式完成对pdb1数据库的升级。

过程如下:

1.原平台测试数据准备

sys. oradb>alter session set container=pdb1;

Session altered.

Elapsed: 00:00:00.05
sys. oradb>create tablespace tbs01 datafile size 200M;

Tablespace created.

Elapsed: 00:00:03.68
sys. oradb>create user yyh identified by yyh default tablespace tbs01;

User created.

Elapsed: 00:00:00.10
sys. oradb>grant dba to yyh;

Grant succeeded.

Elapsed: 00:00:00.06
sys. >conn yyh/yyh@pdb1
Connected.
yyh. pdb1>create table t(id number, name varchar2(20));

Table created.

Elapsed: 00:00:00.06
yyh. pdb1>insert into t values(0,'QData');

1 row created.

Elapsed: 00:00:00.05
yyh. pdb1>commit;

Commit complete.

Elapsed: 00:00:00.01
yyh. pdb1>select * from t;

    ID NAME
---------- ------------------------------
     0 QData

Elapsed: 00:00:00.00
yyh. pdb1>

2.卸载Oracle APEX

Oracle APEX在12.1.0.2.0中默认安装,而在12.2.0.1.0未默认安装,如果不进行APEX卸载,在12.2.0.1.0中plug 12.1.0.2.0版本的pdb将报如下ORA-65346错误:

当然,如果您有使用到APEX,需要在12.2.0.1.0中安装APEX,而无需卸载12.1.0.2.0中的APEX。

卸载方式:

03:50:39 sys. oradb>select COMP_ID, STATUS from DBA_REGISTRY where COMP_ID='APEX'; 

COMP_ID                        STATUS
------------------------------ --------------------------------------------
APEX                           VALID

Elapsed: 00:00:00.02
03:50:41 sys. oradb>


03:53:56 sys. oradb>conn /as sysdba
Connected.
03:53:58 sys. oradb>@?/apex/apxremov_con.sql

PL/SQL procedure successfully completed.

Elapsed: 00:00:00.01
Performing installation in multitenant container database in the background.
The installation progress is spooled into apxremov*_con*.log files.

Please wait...

catcon: ALL catcon-related output will be written to apxremov1_con_catcon_12393.lst
catcon: See apxremov1_con*.log files for output generated by scripts
catcon: See apxremov1_con_*.lst files for spool files, if any

catcon.pl: completed successfully

catcon: ALL catcon-related output will be written to apxremov2_con_catcon_12512.lst
catcon: See apxremov2_con*.log files for output generated by scripts
catcon: See apxremov2_con_*.lst files for spool files, if any

catcon.pl: completed successfully


Installation completed. Log files for each container can be found in:

apxremov*_con*.log

You can quickly scan for ORA errors or compilation errors by using a utility
like grep:

grep ORA- *.log
grep PLS- *.log

03:57:42 sys. oradb>03:57:42 sys. oradb>03:57:42 sys. oradb>
03:59:32 sys. oradb>select COMP_ID, STATUS from DBA_REGISTRY where COMP_ID='APEX'; 

no rows selected

Elapsed: 00:00:00.12
04:00:35 sys. oradb>select COMP_ID, STATUS from DBA_REGISTRY where COMP_ID='APEX'; 

no rows selected

Elapsed: 00:00:00.02
04:00:36 sys. oradb>

3.unplug生成pdb1的xml文件

sys. oradb>alter pluggable database pdb1 close;

Pluggable database altered.

Elapsed: 00:00:01.16
sys. oradb>alter pluggable database pdb1 unplug into '/tmp/pdb1.xml';

Pluggable database altered.

Elapsed: 00:00:17.88
sys. oradb>select pdb_id, pdb_name, status from dba_pdbs;

PDB_ID PDB_NAME                       STATUS
---------- ------------------------------ ---------
     3 PDB1                           UNPLUGGED
     2 PDB$SEED                       NORMAL

Elapsed: 00:00:00.04
sys. oradb>DROP PLUGGABLE DATABASE pdb1 KEEP DATAFILES;

Pluggable database dropped.

Elapsed: 00:00:00.32
sys. oradb>show pdbs

CON_ID CON_NAME                       OPEN MODE  RESTRIC
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值