Oracle 12c:Manual create CDB(手动创建CDB)
当前数据库版本:
1 2 3 4 5 |
[oracle@rhel7 ~]$ sqlplus -v SQL*Plus: Release 12.1.0.2.0 Production [oracle@rhel7 ~]$ |
打算创建的CDB名称:callah。
创建需要的目录结构:
1 2 3 4 5 6 7 8 9 10 11 12 |
[oracle@rhel7 ~]$ cd $ORACLE_BASE [oracle@rhel7 oracle]$ pwd /u01/app/oracle [oracle@rhel7 oracle]$ ls checkpoints diag product [oracle@rhel7 oracle]$ mkdir -p admin/callah/adump [oracle@rhel7 oracle]$ mkdir -p oradata/callah [oracle@rhel7 oracle]$ mkdir -p recovery_dest [oracle@rhel7 oracle]$ [oracle@rhel7 oracle]$ ls admin checkpoints diag oradata product recovery_dest [oracle@rhel7 oracle]$ |
创建参数文件:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
[oracle@rhel7 oracle]$ cd $ORACLE_HOME/dbs [oracle@rhel7 dbs]$ ls init.ora [oracle@rhel7 dbs]$ [oracle@rhel7 dbs]$ cat initcallah.ora _enable_pluggable_database=true db_block_size=8192 open_cursors=300 db_name="callah" db_create_file_dest="/u01/app/oracle/oradata" db_recovery_file_dest="/u01/app/oracle/recovery_dest" db_recovery_file_dest_size=5061476352 compatible=12.1.0.2.0 db_unique_name="callah" diagnostic_dest=/u01/app/oracle processes=300 audit_file_dest="/u01/app/oracle/admin/callah/adump" audit_trail=db [oracle@rhel7 dbs]$ |
根据上面的参数文件,启动数据库到nomount:
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 |
[oracle@rhel7 dbs]$ export ORACLE_SID=callah [oracle@rhel7 dbs]$ [oracle@rhel7 dbs]$ sqlplus / as sysdba SQL*Plus: Release 12.1.0.2.0 Production on Sat Apr 16 23:32:09 2016 Copyright (c) 1982, 2014, Oracle. All rights reserved. Connected to an idle instance. SQL> startup nomount; ORACLE instance started. Total System Global Area 251658240 bytes Fixed Size 2923096 bytes Variable Size 192939432 bytes Database Buffers 50331648 bytes Redo Buffers 5464064 bytes SQL> SQL> select instance_name,status from v$instance; INSTANCE_NAME STATUS ---------------- ------------ callah STARTED SQL> |
手动创建CDB:
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 |
SQL> create database callah 2 user sys identified by oracle 3 user system identified by oracle 4 logfile 5 group 1 ('/u01/app/oracle/oradata/callah/redo01a.log','/u01/app/oracle/oradata/callah/redo01b.log') size 100m, 6 group 2 ('/u01/app/oracle/oradata/callah/redo02a.log','/u01/app/oracle/oradata/callah/redo02b.log') size 100m, 7 group 3 ('/u01/app/oracle/oradata/callah/redo03a.log','/u01/app/oracle/oradata/callah/redo03b.log') size 100m 8 maxloghistory 1 9 maxlogfiles 16 10 maxlogmembers 3 11 maxdatafiles 1024 12 character set AL32UTF8 13 national character set AL16UTF16 14 extent management local 15 datafile '/u01/app/oracle/oradata/callah/system01.dbf' size 700m reuse autoextend on next 20m maxsize unlimited 16 sysaux datafile '/u01/app/oracle/oradata/callah/sysaux01.dbf' size 550m reuse autoextend on next 20m maxsize unlimited 17 default tablespace users datafile '/u01/app/oracle/oradata/callah/users01.dbf' size 500m reuse autoextend on maxsize unlimited 18 default temporary tablespace temptbs01 tempfile '/u01/app/oracle/oradata/callah/temptbs01a.dbf' size 200m reuse autoextend on next 20m maxsize unlimited 19 undo tablespace undotbs01 datafile '/u01/app/oracle/oradata/callah/undotbs01a.dbf' size 300m reuse autoextend on next 50m maxsize unlimited 20 enable pluggable database 21 seed file_name_convert=('/u01/app/oracle/oradata/callah/','/u01/app/oracle/oradata/callah/pdb_seed_data/'); Database created. SQL> SQL> |
上面的代码中,用于存放seed的路径“/u01/app/oracle/oradata/callah/pdb_seed_data/”,可能需要预创建。
创建完成后,数据库会处于OPEN:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
SQL> select instance_name,status from v$instance; INSTANCE_NAME STATUS ---------------- ------------ callah OPEN SQL> select dbid,name,cdb from v$database; DBID NAME CDB ---------- --------- --- 653000119 CALLAH YES SQL> |
运行脚本,创建需要的数据字典与视图:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
SQL> show con_name CON_NAME ------------------------------ CDB$ROOT SQL> SQL> show user USER is "SYS" SQL> SQL> @?/rdbms/admin/catalog.sql SQL> @?/rdbms/admin/catproc.sql SQL> SQL> conn system Enter password: Connected. SQL> show user USER is "SYSTEM" SQL> SQL> @?/sqlplus/admin/pupbld.sql |
其他的一些可选SQL:
SYS:
SQL> @?/rdbms/admin/catblock.sql
SQL> @?/rdbms/admin/catoctk.sql
SQL> @?/rdbms/admin/owminst.plb
SQL> @?/sqlplus/admin/help/hlpbld.sql
脚本执行完成后,通过数据字典,查看下当前数据库中的PDB的情况:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
SQL> select con_id,dbid,name,open_mode from v$pdbs; CON_ID DBID NAME OPEN_MODE ---------- ---------- ------------------------------ ---------- 2 3126348575 PDB$SEED READ ONLY 1 row selected. SQL> SQL> select con_id,dbid,name,open_mode from v$containers; CON_ID DBID NAME OPEN_MODE ---------- ---------- ------------------------------ ---------- 1 653000119 CDB$ROOT READ WRITE 2 3126348575 PDB$SEED READ ONLY 2 rows selected. SQL> |
——————————————————
Done。
上面文档中写的手工建库后的执行的脚本有为,上面说的那些脚本时适用于 非CDB的数据库的,对于CDB 的数据库来说,只需要执行一个脚本就可以了:@?/rdbms/admin/catcdb.sql。否则可能会在重启数据库实例的时候遭遇ORA-600的错误:internal error code, arguments: [kgskigetelt_subplan],