この記事は約22分22秒で読むことができます。

sql oracle clone pluggable database


[oracle@609a69bc0b21 ~]$ cd $ORACLE_BASE
[oracle@609a69bc0b21 oracle]$ ll
total 40
drwxr-x---. 3 oracle oinstall   18 Dec 23 13:11 admin
drwxr-x---. 2 oracle oinstall    6 Dec 23 13:11 audit
drwxr-x---. 4 oracle oinstall   34 Dec 23 13:22 cfgtoollogs
-rwxrwxrwx. 1 oracle dba      1148 Dec  8 00:58 checkDBStatus.sh
drwxr-xr-x. 2 oracle dba         6 Dec 23 08:52 checkpoints
-rwxrwxrwx. 1 oracle dba      2953 Dec  8 00:58 createDB.sh
-rwxrwxrwx. 1 oracle dba      9204 Dec  8 00:58 dbca.rsp.tmpl
drwxrwxr-x. 1 oracle dba        34 Dec 23 08:52 diag
drwxrwx---. 1 oracle dba        89 Dec 23 08:52 oraInventory
drwxr-xr-x. 4 oracle dba        34 Dec 23 13:29 oradata
drwxr-xr-x. 1 oracle dba        22 Dec 23 08:20 product
-rwxrwxrwx. 1 oracle dba      6526 Dec  8 00:58 runOracle.sh
-rwxrwxrwx. 1 oracle dba      1015 Dec  8 00:58 runUserScripts.sh
drwxr-xr-x. 1 oracle dba        34 Dec 23 08:20 scripts
-rwxrwxrwx. 1 oracle dba       758 Dec  8 00:58 setPassword.sh
-rwxrwxrwx. 1 oracle dba       678 Dec  8 00:58 startDB.sh
[oracle@609a69bc0b21 oracle]$ cd oradata
[oracle@609a69bc0b21 oradata]$ ll
total 0
drwxr-x---. 5 oracle oinstall 239 Dec 25 12:14 ORCL
drwxr-xr-x. 3 oracle oinstall  18 Dec 23 13:29 dbconfig
[oracle@609a69bc0b21 oradata]$ cd ORCL
[oracle@609a69bc0b21 ORCL]$ ll
total 2263508
drwxr-x---. 2 oracle oinstall       104 Dec 23 13:29 PDB1
drwxr-x---. 2 oracle oinstall       104 Dec 25 12:14 PDB2
-rw-r-----. 1 oracle oinstall  18726912 Dec 25 14:29 control01.ctl
-rw-r-----. 1 oracle oinstall  18726912 Dec 25 14:29 control02.ctl
drwxr-x---. 2 oracle oinstall       111 Dec 23 13:18 pdbseed
-rw-r-----. 1 oracle oinstall 209715712 Dec 25 00:05 redo01.log
-rw-r-----. 1 oracle oinstall 209715712 Dec 25 14:28 redo02.log
-rw-r-----. 1 oracle oinstall 209715712 Dec 24 22:06 redo03.log
-rw-r-----. 1 oracle oinstall 597696512 Dec 25 14:25 sysaux01.dbf
-rw-r-----. 1 oracle oinstall 849354752 Dec 25 14:27 system01.dbf
-rw-r-----. 1 oracle oinstall 137371648 Dec 25 00:45 temp01.dbf
-rw-r-----. 1 oracle oinstall  73408512 Dec 25 14:27 undotbs01.dbf
-rw-r-----. 1 oracle oinstall   5251072 Dec 25 00:10 users01.dbf
[oracle@609a69bc0b21 ORCL]$ pwd
/opt/oracle/oradata/ORCL
[oracle@609a69bc0b21 ORCL]$ sqlplus sys/ORACLE_PWD as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Tue Dec 25 14:30:43 2018

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

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

SYS@ORCL> show con_name

CON_NAME
------------------------------
CDB$ROOT
SYS@ORCL> show pdbs

CON_ID CON_NAME                       OPEN MODE  RESTRICTED
------------- ------------------------------ ---------- ----------
2 PDB$SEED                       READ ONLY  NO
3 PDB1                           READ WRITE NO
4 PDB2                           READ WRITE NO
SYS@ORCL> create pluggable database PDB3 from PDB1 FILE_NAME_CONVERT=('/opt/oracle/oradata/ORCL/PDB1','/opt/oracle/oradata/ORCL/PDB3');

Pluggable database created.

Elapsed: 00:00:09.26
SYS@ORCL> create pluggable database PDB4 from PDB1 FILE_NAME_CONVERT=('/opt/oracle/oradata/ORCL/PDB1','/opt/oracle/oradata/ORCL/PDB4');

Pluggable database created.

Elapsed: 00:00:10.38
SYS@ORCL> show pdbs

CON_ID CON_NAME                       OPEN MODE  RESTRICTED
------------- ------------------------------ ---------- ----------
2 PDB$SEED                       READ ONLY  NO
3 PDB1                           READ WRITE NO
4 PDB2                           READ WRITE NO
5 PDB3                           MOUNTED
6 PDB4                           MOUNTED
SYS@ORCL> alter pluggable database all open;

Pluggable database altered.

Elapsed: 00:00:25.74
SYS@ORCL> show pdbs

CON_ID CON_NAME                       OPEN MODE  RESTRICTED
------------- ------------------------------ ---------- ----------
2 PDB$SEED                       READ ONLY  NO
3 PDB1                           READ WRITE NO
4 PDB2                           READ WRITE NO
5 PDB3                           READ WRITE NO
6 PDB4                           READ WRITE NO
SYS@ORCL> Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
[oracle@609a69bc0b21 ORCL]$ sqlplus sys/ORACLE_PWD@pdb3 as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Tue Dec 25 14:37:14 2018

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

ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified

Enter user-name: [oracle@609a69bc0b21 ORCL]$
[oracle@609a69bc0b21 ORCL]$ find / -name tnsnames.ora -type f 2>/dev/null
/opt/oracle/product/12.2.0.1/dbhome_1/network/admin/samples/tnsnames.ora
/opt/oracle/oradata/dbconfig/ORCL/tnsnames.ora
[oracle@609a69bc0b21 ORCL]$ vim /opt/oracle/product/12.2.0.1/dbhome_1/network/admin/tnsnames.ora

ORCL=localhost:1521/ORCL
PDB1=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = PDB1)
)
)
PDB2=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = PDB2)
)
)
PDB3=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = PDB3)
)
)
PDB4=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = PDB4)
)
)

[oracle@609a69bc0b21 ORCL]$ sqlplus sys/ORACLE_PWD@pdb3 as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Tue Dec 25 14:40:02 2018

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

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

SYS@pdb3> show con_name

CON_NAME
------------------------------
PDB3
SYS@pdb3> Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
[oracle@609a69bc0b21 ORCL]$ sqlplus sys/ORACLE_PWD@pdb4 as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Tue Dec 25 14:40:30 2018

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

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

SYS@pdb4> show con_name

CON_NAME
------------------------------
PDB4
SYS@pdb4> Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
[oracle@609a69bc0b21 ORCL]$ sqlplus aine/ORACLE_PWD@pdb3

SQL*Plus: Release 12.2.0.1.0 Production on Tue Dec 25 14:41:10 2018

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

Last Successful login time: Tue Dec 25 2018 11:50:03 +00:00

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

AINE@pdb3> select * from warehouse_mst;

WAREHOUSE_CODE           SHIPPING_PERMISSION_OVER_DAYS
------------------------ -----------------------------
w_BS98                                              25
w_DIX4                                              28
w_C5MN                                              29

3 rows selected.

Elapsed: 00:00:00.07
AINE@pdb3> Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
[oracle@609a69bc0b21 ORCL]$ sqlplus aine/ORACLE_PWD@pdb4

SQL*Plus: Release 12.2.0.1.0 Production on Tue Dec 25 14:41:38 2018

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

Last Successful login time: Tue Dec 25 2018 11:50:03 +00:00

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

AINE@pdb4> select * from warehouse_mst;

WAREHOUSE_CODE           SHIPPING_PERMISSION_OVER_DAYS
------------------------ -----------------------------
w_BS98                                              25
w_DIX4                                              28
w_C5MN                                              29

3 rows selected.

Elapsed: 00:00:00.06
AINE@pdb4> Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
[oracle@609a69bc0b21 ORCL]$ ll
total 2263564
drwxr-x---. 2 oracle oinstall       104 Dec 23 13:29 PDB1
drwxr-x---. 2 oracle oinstall       104 Dec 25 12:14 PDB2
drwxr-x---. 2 oracle oinstall       104 Dec 25 14:33 PDB3
drwxr-x---. 2 oracle oinstall       104 Dec 25 14:33 PDB4
-rw-r-----. 1 oracle oinstall  18726912 Dec 25 14:41 control01.ctl
-rw-r-----. 1 oracle oinstall  18726912 Dec 25 14:41 control02.ctl
drwxr-x---. 2 oracle oinstall       111 Dec 23 13:18 pdbseed
-rw-r-----. 1 oracle oinstall 209715712 Dec 25 00:05 redo01.log
-rw-r-----. 1 oracle oinstall 209715712 Dec 25 14:41 redo02.log
-rw-r-----. 1 oracle oinstall 209715712 Dec 24 22:06 redo03.log
-rw-r-----. 1 oracle oinstall 597696512 Dec 25 14:41 sysaux01.dbf
-rw-r-----. 1 oracle oinstall 849354752 Dec 25 14:41 system01.dbf
-rw-r-----. 1 oracle oinstall 137371648 Dec 25 14:36 temp01.dbf
-rw-r-----. 1 oracle oinstall  73408512 Dec 25 14:41 undotbs01.dbf
-rw-r-----. 1 oracle oinstall   5251072 Dec 25 00:10 users01.dbf
[oracle@609a69bc0b21 ORCL]$

Leave a Reply

Your email address will not be published. Required fields are marked *