ORACLE12.2 升級之路 之 08(11.2.0.4本機升級12.2.0.1后插入PDB)

-----ORACLE12.2 升級之路 之 08(11.2.0.4本機升級12.2.0.1后插入PDB)-----

#升级后数据库信息

SQL> select cdb,NAME,dbid from v$database;

CDB   NAME     DBID

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

NO   MPACC       3165604684

CDB数据库信息

SQL> startup

SQL> select * from v$version;

Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production              0

CORE    12.1.0.1.0      Production                                                        0

SQL> show pdbs;

SQL> select con_id,dbid,NAME,OPEN_MODE from v$pdbs;

no rows selected

二、查看表空间及数据文件信息:

SQL> select * from v$tablespace;

         0 SYSTEM YES NO YES 0

        1 SYSAUX YES NO YES 0

        2 UNDOTBS1 YES NO YES 0

        4 USERS YES NO YES 0

        3 TEMP NO NO YES 0

SQL>

set line 300

col file_name format a40

col tablespace_name format a10

select tablespace_name,file_name from dba_data_files;

TABLESPACE FILE_NAME

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

SYSTEM   /u01/app/oracle/oradata/MPACC/system01.dbf

UNDOTBS1  /u01/app/oracle/oradata/MPACC/undotbs01.dbf

SYSAUX   /u01/app/oracle/oradata/MPACC/sysaux01.dbf

USERS   /u01/app/oracle/oradata/MPACC/users01.dbf

TABLESPACE FILE_NAME

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

三、创建用于生成PDB的XML文件

SQL>

shutdown immediate

startup mount

alter database open read only;

SQL> exec dbms_pdb.describe(pdb_descr_file => '/home/oracle/mpacc.xml');

SQL> host ls -rtl /home/oracle/mpacc.xml

-rw-r--r-- 1 oracle oinstall 7237 Aug 31 17:34 /home/oracle/mpacc.xml

SQL> set serveroutput on;

SQL>

declare

  compat boolean := FALSE;

  begin

      compat := dbms_pdb.check_plug_compatibility(pdb_descr_file => '/home/oracle/mpacc.xml');

      if compat then

          dbms_output.put_line('YES');

      else

          dbms_output.put_line('No');

      end if;

  end;

 /

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

ERROR at line 1:

ORA-65090: operation only allowed in a container database

ORA-06512: at "SYS.DBMS_PDB", line 24

ORA-06512: at line 4

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

SQL> select name from v$database;

NAME

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

MPACC

SQL> shutdown immediate;

创建CDB数据库

  5.1 执行dbca创建cdb数据库

查看当前pdb信息

[oracle@db01 ~]$ export ORACLE_SID=MPCDB

SQL> show pdbs;

2 PDB$SEED   READ ONLY  NO

3 PDB01   READ WRITE NO

SQL> select con_id,dbid,NAME,OPEN_MODE from v$pdbs;

2     1952393588  PDB$SEED READ ONLY

3     3441784768  PDB01 READ WRITE

SQL> set serveroutput on;

SQL>

declare

  compat boolean := FALSE;

  begin

      compat := dbms_pdb.check_plug_compatibility(pdb_descr_file => '/home/oracle/mpacc.xml');

      if compat then

          dbms_output.put_line('YES');

      else

          dbms_output.put_line('No');

      end if;

  end;

  /

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

No

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

七、将non-cdb数据库插入到cdb中成为一个pdb

SQL> show parameter compatible;

NAME     TYPE VALUE

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

compatible     string 12.2.0

noncdb_compatible boolean FALSE

SQL> alter system set compatible='12.2.0.1.0' scope=spfile;

重啟db

SQL> CREATE PLUGGABLE DATABASE MPACC USING '/home/oracle/mpacc.xml' NOCOPY;

CREATE PLUGGABLE DATABASE MPACC USING '/home/oracle/mpacc.xml' NOCOPY

*

ERROR at line 1:

ORA-27038: created file already exists

ORA-01119: error in creating database file

'/u01/app/oracle/oradata/MPACC/temp01.dbf'

[oracle@XAG140 ~]$ rm /u01/app/oracle/oradata/MPACC/temp01.dbf;

SQL> CREATE PLUGGABLE DATABASE MPACC USING '/home/oracle/mpacc.xml' NOCOPY;

九、插入完成后查看pdbs信息

SQL> show pdbs;

SQL> select NAME,OPEN_MODE from v$pdbs;

PDB$SEED READ ONLY

PDB01 MOUNTED

MPACC MOUNTED

SQL> alter pluggable database MPACC open;

Warning: PDB altered with errors.

SQL> show pdbs;

2 PDB$SEED   READ ONLY  NO

3 PDB1   MOUNTED

4 MPACC   READ WRITE YES

十、执行noncdb_pdb脚本

SQL> alter session set container=MPACC;

SQL>  show pdbs;

    CON_ID CON_NAME   OPEN MODE  RESTRICTED

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

4 MPACC   READ WRITE YES

SQL> shutdown immediate;

SQL> @$ORACLE_HOME/rdbms/admin/noncdb_to_pdb.sql

更新完之后需要同步pdb信息

SQL> show pdbs;

    CON_ID CON_NAME                      OPEN MODE  RESTRICTED

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

        5 MPACC                          MOUNTED

SQL> alter pluggable database open restricted;

SQL> show pdbs;

    CON_ID CON_NAME                      OPEN MODE  RESTRICTED

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

        5 MPACC                          READ WRITE YES


SQL> exec dbms_pdb.sync_pdb();

SQL>  alter pluggable database close immediate;

SQL> alter pluggable database open;

确定no-cdb plug cdb 成功

[oracle@XAG140 database]$ sqlplus / as sysdba

SQL> show pdbs;

2 PDB$SEED   READ ONLY  NO

3 PDB01   MOUNTED

5 MPACC   READ WRITE NO

到这里已经完全完成了11.2.0.4数据库插入到12.1.0.1中,实现把11GR2转化为CDB数据库中的一个PDB

說明:臨時表空間需要重新整理(默認添加的比較小)

你可能感兴趣的:(ORACLE12.2 升級之路 之 08(11.2.0.4本機升級12.2.0.1后插入PDB))