orcl是NON-CDB
[oracle@12cr2 dbs]$ export ORACLE_SID=orcl
[oracle@12cr2 dbs]$ sqlplus / as sysdba
SQL*Plus: Release 12.2.0.1.0 Production on Sun Jun 4 18:08:15 2017
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 1610612736 bytes
Fixed Size 8621232 bytes
Variable Size 1040188240 bytes
Database Buffers 553648128 bytes
Redo Buffers 8155136 bytes
Database mounted.
Database opened.
SQL> show pdbs;
SQL> select name,cdb,con_id from v$database;
NAME CDB CON_ID
--------- --- ----------
ORCL NO 0
1. 配置目标端的监听
[oracle@12cr2 admin]$ vi tnsnames.ora
ORCL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.16.81)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
[oracle@12cr2 admin]$ tnsping orcl
TNS Ping Utility for Linux: Version 12.2.0.1.0 - Production on 04-JUN-2017 18:12:24
Copyright (c) 1997, 2016, Oracle. All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.16.81)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = orcl)))
OK (30 msec)
[oracle@12cr2 admin]$ sqlplus system/Highgo123@orcl
SQL*Plus: Release 12.2.0.1.0 Production on Sun Jun 4 18:14:07 2017
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL>
2. 目标端创建DBLINK
[oracle@12cr2 admin]$ export ORACLE_SID=newcdb
[oracle@12cr2 admin]$ sqlplus / as sysdba
SQL*Plus: Release 12.2.0.1.0 Production on Sun Jun 4 18:16:27 2017
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL> create public database link orcl_link connect to system identified by Highgo123 using 'orcl';
Database link created.
SQL> select name,cdb,con_id from v$database@orcl_link;
NAME CDB CON_ID
--------- --- ----------
ORCL NO 0
3. 远程克隆NON-CDB
SQL> CREATE PLUGGABLE DATABASE noncdb_new FROM orcl@orcl_link
2 file_name_convert=('/u01/app/oracle/oradata/orcl','/u01/app/oracle/oradata/newcdb/noncdb_new');
Pluggable database created.
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 TESTPDB_NEWCDB MOUNTED
4 NONCDB_NEW MOUNTED
SQL> alter session set container=NONCDB_NEW;
Session altered.
SQL> @?/rdbms/admin/noncdb_to_pdb.sql