12C中用CREATE DATABASE命令方式创建CDB
[p=16, null, left]1. 准备初始化参数文件:
[oracle@ghacctest2 con12c]$ cat init.ora[p=16, null, left]*.audit_file_dest='/u01/app/oracle/admin/con12c/adump'
*.audit_trail='db'
*.compatible='12.1.0.0.0'
*.control_files='/backup/con12c/oradata/control01.ctl','/backup/con12c/oradata/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='con12c'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=con12cXDB)'
*.enable_pluggable_database=true
*.pdb_file_name_convert=('/backup/con12c/oradata/root','/backup/con12c/oradata/seed')
#*.local_listener='LISTENER_CON12C'
*.open_cursors=300
*.pga_aggregate_target=360m
*.processes=300
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=1080m
*.undo_tablespace='UNDOTBS1'
~
2. 用前面准备好的初始化参数文件启动数据库到nomount状态:
[oracle@ghacctest2 con12c]$ sqlplus / as sysdba[p=16, null, left]SQL*Plus: Release 12.1.0.1.0 Production on Wed Sep 11 10:46:56 2013[p=16, null, left]Copyright (c) 1982, 2013, Oracle. All rights reserved.[p=16, null, left]Connected to an idle instance.[p=16, null, left]SQL> startup nomount pfile='init.ora';
ORACLE instance started.[p=16, null, left]Total System Global Area 1135747072 bytes
Fixed Size 2287528 bytes
Variable Size 452986968 bytes
Database Buffers 671088640 bytes
Redo Buffers 9383936 bytes[p=16, null, left]3. 用CREATE DATABASE创建CDB数据库(包括ROOT和SEED):
创建CBD数据库,必须要设置初始化参数enable_pluggable_database=true,以及在创建数据库时指定enable pluggable database。[p=16, null, left]在seed部分(或者以后创造新的PDB),system,sysaux和temp三个表空间的根据下列规则确定存放的位置:
1) 如果在seed部分设定FILE_NAME_CONVERT,那将优先考虑根据他的目录存放PDB数据文件。
2) 如果启用了OMF管理(通过初始化参数DB_CREATE_FILE_DEST启用),但又没有设定FILE_NAME_CONVERT。那将根据OMF管理自动确定存放目录。
3)如果没有启用OMF,也没有设定FILE_NAME_CONVERT,但设定了初始化参数pdb_file_name_convert,那将根据pdb_file_name_convert位置决定目录。[p=16, null, left]SQL> CREATE DATABASE con12c[p=16, null, left] 2 user sys identified by oracle
3 user system identified by oracle
4 logfile group 1 ('/backup/con12c/oradata/redo01.log') size 50M blocksize 512,
5 group 2 ('/backup/con12c/oradata/redo02.log') size 50M blocksize 512,
6 group 3 ('/backup/con12c/oradata/redo03.log') size 50M blocksize 512
7 MAXLOGHISTORY 1
8 MAXLOGFILES 16
9 MAXLOGMEMBERS 3
10 MAXDATAFILES 1024
11 CHARACTER SET AL32UTF8
12 NATIONAL CHARACTER SET AL16UTF16
13 EXTENT MANAGEMENT LOCAL
14 DATAFILE '/backup/con12c/oradata/root/system01.dbf' size 500M reuse autoextend on next 1024k maxsize unlimited
15 sysaux datafile '/backup/con12c/oradata/root/sysaux01.dbf' size 500M reuse autoextend on next 1024k maxsize unlimited
16 default tablespace users datafile '/backup/con12c/oradata/root/users01.dbf' size 50M reuse autoextend on next 1024k maxsize unlimited
17 default temporary tablespace temp tempfile '/backup/con12c/oradata/root/temp01.dbf' size 200M reuse autoextend on next 1024k maxsize unlimited
18 undo tablespace UNDOTBS1 datafile '/backup/con12c/oradata/root/undo01.dbf' size 200M reuse autoextend on next 1024k maxsize unlimited
19 enable pluggable database
20 seed
21 system datafiles size 125M
22 sysaux datafiles size 100M
23 user_data tablespace usertbs
24 datafile '/backup/con12c/oradata/seed/usertbs01.dbf' size 50M reuse autoextend on maxsize unlimited;[p=16, null, left]Database created.[p=16, null, left]4. 执行SQL脚本安装CDB所必须的组件(如动态视图等)
1) 在Oracle官方文档的管理员手册中提到,可以通过执行@?/rdbms/admin/catcdb.sql,但却发现根本没有这文件,估计是12c的Bug。
SQL> @?/rdbms/admin/catcdb.sql
SP2-0310: unable to open file "/u01/app/oracle/product/12.1.0/db_1/rdbms/admin/catcdb.sql"
SQL> /u01/app/oracle/product/12.1.0/db_1/rdbms/admin/catcdb.sql
SP2-0734: unknown command beginning "/u01/app/o..." - rest of line ignored.
SQL> exit
[oracle@ghacctest2 con12c]$ sqlplus system/oracle[p=16, null, left]SQL*Plus: Release 12.1.0.1.0 Production on Wed Sep 11 14:22:05 2013[p=16, null, left]Copyright (c) 1982, 2013, Oracle. All rights reserved.[p=16, null, left]ERROR:
ORA-06553: PLS-213: package STANDARD not accessible[p=16, null, left]
ERROR:
ORA-06553: PLS-213: package STANDARD not accessible[p=16, null, left]
Error accessing package DBMS_APPLICATION_INFO[p=16, null, left]Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options[p=16, null, left]SQL> select * from v$database;
select * from v$database
*
ERROR at line 1:
ORA-00942: table or view does not exist[p=16, null, left]
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
[p=16, null, left]2) 下面通过另外一种方式完成了安装。[p=16, null, left][oracle@ghacctest2 con12c]$ cd $ORACLE_HOME/rdbms/admin[p=16, null, left][oracle@ghacctest2 admin]$ pwd
/u01/app/oracle/product/12.1.0/db_1/rdbms/admin
[oracle@ghacctest2 admin]$ perl catcon
catcon.pl catcon.pm catcont.sql
[oracle@ghacctest2 admin]$ perl catcon.pl -d $ORACLE_HOME/rdbms/admin -b catalog catalog.sql
[oracle@ghacctest2 admin]$ perl catcon.pl -d $ORACLE_HOME/rdbms/admin -b catproc catproc.sql
[oracle@ghacctest2 admin]$ perl catcon.pl -u SYSTEM -d $ORACLE_HOME/rdbms/admin -b pupbld pupbld.sql