Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Migrate PDB between different CDB

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Test environment

Source environment

Target environment

Host operating system Oracle Linux 7.2

Hostname zhankys

Oracle version 11.2.0.1 x64

IP:172.16.171.214

CDB=orcl

Cloned PDB=orcl1

Host operating system Oracle Linux 7.2

Hostname zhanky2

Oracle version 11.2.0.1 x64

IP:172.16.171.215

CDB=cs

Cloned PDB=cs2

Test idea

1. Establish CP on the source side with the permissions of create pluggable database and create session (create users under PDB orcle1)

2. Set the source side to read-only mode (set in CDB mode)

3. Add the tnsnames of orcl1 on the destination side (in tnsnames.ora)

4. Create the dblink:cp_link of orcle1 on the target side (run in CDB mode)

5. Specify the db_create_file_dest path on the destination side (run in CDB mode, if the directory does not exist, you need to create it in advance)

6. Execute the clone PDB statement (run in CDB mode)

7. Check whether the data is correct (run in PDB mode)

Source end

[oracle@zhanky ~] $sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Fri Aug 3 16:21:35 2018

Copyright (c) 1982, 2016, Oracle. All rights reserved.

Connected to:

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

SQL > alter session set container=orcl1

SQL > select * from zky.aa

USERNAME

ZKY

1 rows selected.

SQL > create user cp identified by cp

User created.

SQL > grant create session,create pluggable database to cp

Grant succeeded.

SQL > alter session set container=CDB$ROOT

SQL > alter pluggable database orcl1 close

Pluggable database altered.

SQL > show pdbs

CON_ID CON_NAME OPEN MODE RESTRICTED

-

2 PDB$SEED READ ONLY NO

3 ORCL1 READ ONLY NO

4 ORCL2 READ WRITE NO

SQL >

Destination end

[oracle@zhanky2 ~] $vi / u01/app/oracle/product/12.2.0/db_1/network/admin/tnsnames.ora

[oracle@zhanky2 ~] $cat / u01/app/oracle/product/12.2.0/db_1/network/admin/tnsnames.ora

# tnsnames.ora Network Configuration File: / u01/app/oracle/product/12.2.0/db_1/network/admin/tnsnames.ora

# Generated by Oracle configuration tools.

LISTENER_CS =

(ADDRESS = (PROTOCOL = TCP) (HOST = 172.16.171215) (PORT = 1521))

CS1 =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP) (HOST = 172.16.171.215) (PORT = 1521))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = cs1.zhanky.com)

)

)

CS =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP) (HOST = 172.16.171.215) (PORT = 1521))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = cs.zhanky.com)

)

)

Orcl1 =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP) (HOST = 172.16.171.214) (PORT = 1521))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = orcl1.zhanky.com)

)

)

[oracle@zhanky2 ~] $

SQL > create database link cp_link connect to cp identified by cp using 'orcl1'

Database link created.

SQL > select count (*) from all_users@cp_link

COUNT (*)

-

forty-one

SQL > alter system set db_create_file_dest='/u01/app/oracle/oradata/cs/cs2'

System altered.

SQL > create pluggable database cs2 from orcl1@cp_link

Pluggable database created.

SQL > show pdbs

CON_ID CON_NAME OPEN MODE RESTRICTED

-

2 PDB$SEED READ ONLY NO

3 CS1 READ WRITE NO

4 CS2 MOUNTED

SQL > alter session set container=cs2

Session altered.

SQL > startup

Pluggable Database opened.

SQL > select * from zky.aa

USERNAME

ZKY

1 rows selected.

SQL >

Complete the test, because there is no detailed explanation for time reasons, let's take a look at it first.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report