(读书笔记)12c:同一CDB中,通过克隆的方式创建PDB
源:PDBSHE
克隆后:PDBSHE2
创建需要的目录:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
[oracle@rhel7 ~]$ cd $ORACLE_BASE/oradata [oracle@rhel7 oradata]$ ls callah CALLAH CONME ORCL [oracle@rhel7 oradata]$ cd CONME [oracle@rhel7 CONME]$ ls 30D763092B949704E0539EE8A8C048AB controlfile datafile onlinelog [oracle@rhel7 CONME]$ cd datafile/ [oracle@rhel7 datafile]$ ls o1_mf_sysaux_ckdd02ss_.dbf o1_mf_system_ckdd1j94_.dbf o1_mf_temp_ckdd58lj_.tmp o1_mf_users_ckdd3vnj_.dbf pdbshe o1_mf_sysaux_ckdd5ds1_.dbf o1_mf_system_ckdd5ds2_.dbf o1_mf_undotbs1_ckdd3ws0_.dbf pdbseed_temp012016-04-19_09-21-32-PM.dbf [oracle@rhel7 datafile]$ [oracle@rhel7 datafile]$ mkdir pdbshe2 [oracle@rhel7 datafile]$ [oracle@rhel7 datafile]$ cd pdbshe2/ [oracle@rhel7 pdbshe2]$ [oracle@rhel7 pdbshe2]$ pwd /u01/app/oracle/oradata/CONME/datafile/pdbshe2 [oracle@rhel7 pdbshe2]$ [oracle@rhel7 pdbshe2]$ ls [oracle@rhel7 pdbshe2]$ |
将克隆的源库打开为“Read only”:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
[oracle@rhel7 pdbshe2]$ env | grep SID ORACLE_SID=conme [oracle@rhel7 pdbshe2]$ sqlplus / as sysdba SQL*Plus: Release 12.1.0.2.0 Production on Wed Apr 20 21:28:09 2016 Copyright (c) 1982, 2014, Oracle. All rights reserved. Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options SQL> show parameter db_name NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ db_name string conme SQL> SQL> show con_name CON_NAME ------------------------------ CDB$ROOT SQL> SQL> show user USER is "SYS" SQL> SQL> select con_id,name,open_mode from v$pdbs; CON_ID NAME OPEN_MODE ---------- ------------------------------ ---------- 2 PDB$SEED READ ONLY 3 PDBME READ WRITE 4 PDBSHE READ WRITE SQL> SQL> alter pluggable database pdbshe close; Pluggable database altered. SQL> SQL> select con_id,name,open_mode from v$pdbs; CON_ID NAME OPEN_MODE ---------- ------------------------------ ---------- 2 PDB$SEED READ ONLY 3 PDBME READ WRITE 4 PDBSHE MOUNTED SQL> SQL> alter pluggable database pdbshe open read only; Pluggable database altered. SQL> SQL> select con_id,name,open_mode from v$pdbs; CON_ID NAME OPEN_MODE ---------- ------------------------------ ---------- 2 PDB$SEED READ ONLY 3 PDBME READ WRITE 4 PDBSHE READ ONLY SQL> |
执行克隆:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
SQL> create pluggable database pdbshe2 from pdbshe create_file_dest='/u01/app/oracle/oradata/CONME/datafile/pdbshe2'; Pluggable database created. SQL> SQL> select con_id,name,open_mode from v$pdbs; CON_ID NAME OPEN_MODE ---------- ------------------------------ ---------- 2 PDB$SEED READ ONLY 3 PDBME READ WRITE 4 PDBSHE READ ONLY 5 PDBSHE2 MOUNTED SQL> SQL> !tree /u01/app/oracle/oradata/CONME/datafile/pdbshe2 /u01/app/oracle/oradata/CONME/datafile/pdbshe2 └── CONME └── 30EB9B5B884AE8FEE0539EE8A8C0A893 └── datafile ├── o1_mf_sysaux_ckh152vx_.dbf ├── o1_mf_system_ckh152vv_.dbf └── o1_mf_temp_ckh152vx_.dbf 3 directories, 3 files SQL> |
克隆完成后,PDB不会打开为“Read write”,需要手工设置:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
SQL> alter pluggable database pdbshe2 open read write; Pluggable database altered. SQL> SQL> select con_id,name,open_mode from v$pdbs; CON_ID NAME OPEN_MODE ---------- ------------------------------ ---------- 2 PDB$SEED READ ONLY 3 PDBME READ WRITE 4 PDBSHE READ ONLY 5 PDBSHE2 READ WRITE SQL> |
上面的命令,直接执行“alter pluggable database pdbshe2 open;”也是没问题的。
查看服务状态:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
SQL> !lsnrctl status LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 20-APR-2016 21:35:58 Copyright (c) 1991, 2014, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=rhel7)(PORT=1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 12.1.0.2.0 - Production Start Date 20-APR-2016 20:33:44 Uptime 0 days 1 hr. 2 min. 13 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /u01/app/oracle/product/12/db_1/network/admin/listener.ora Listener Log File /u01/app/oracle/diag/tnslsnr/rhel7/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rhel7)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=rhel7)(PORT=5500))(Security=(my_wallet_directory=/u01/app/oracle/admin/conme/xdb_wallet))(Presentation=HTTP)(Session=RAW)) Services Summary... Service "conme" has 1 instance(s). Instance "conme", status READY, has 1 handler(s) for this service... Service "conmeXDB" has 1 instance(s). Instance "conme", status READY, has 1 handler(s) for this service... Service "pdbme" has 1 instance(s). Instance "conme", status READY, has 1 handler(s) for this service... Service "pdbshe" has 1 instance(s). Instance "conme", status READY, has 1 handler(s) for this service... Service "pdbshe2" has 1 instance(s). Instance "conme", status READY, has 1 handler(s) for this service... The command completed successfully SQL> SQL> !lsnrctl services; LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 20-APR-2016 21:36:06 Copyright (c) 1991, 2014, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=rhel7)(PORT=1521))) Services Summary... Service "conme" has 1 instance(s). Instance "conme", status READY, has 1 handler(s) for this service... Handler(s): "DEDICATED" established:0 refused:0 state:ready LOCAL SERVER Service "conmeXDB" has 1 instance(s). Instance "conme", status READY, has 1 handler(s) for this service... Handler(s): "D000" established:0 refused:0 current:0 max:1022 state:ready DISPATCHER <machine: rhel7, pid: 50413> (ADDRESS=(PROTOCOL=tcp)(HOST=rhel7)(PORT=11915)) Service "pdbme" has 1 instance(s). Instance "conme", status READY, has 1 handler(s) for this service... Handler(s): "DEDICATED" established:0 refused:0 state:ready LOCAL SERVER Service "pdbshe" has 1 instance(s). Instance "conme", status READY, has 1 handler(s) for this service... Handler(s): "DEDICATED" established:0 refused:0 state:ready LOCAL SERVER Service "pdbshe2" has 1 instance(s). Instance "conme", status READY, has 1 handler(s) for this service... Handler(s): "DEDICATED" established:0 refused:0 state:ready LOCAL SERVER The command completed successfully SQL> SQL> |
————————————————————————————
Done。