在工作环境中我们可能没有机会使用SQL命令手工创建12c CDB,但是学习一下手工建库对熟悉其安装步骤和所需条件还是有帮助的。下面开始手工建库。
1,配置环境变量
[oracle@snow ~]$ cat /home/oracle/.bash_profile
export ORACLE_SID=CDB
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/12.1.0/db_1
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
2,配置初始换参数文件,只需要两个参数就可以。一个是必要参数db_name,另一个是针对插拔数据库。如果创建不同的数据库就不需要第二个参数enable_pluggable_database
[oracle@snow ~]$ cat $ORACLE_HOME/dbs/initCDB.ora
db_name='CDB'
enable_pluggable_database=true
3,创建建库脚本createdb.sql
创建语句参考12c官方文档,文档路径为
Database Administrator's Guide -->
2 Creating and Configuring an Oracle Database —>
Creating a Database with the CREATE DATABASE Statement —>
Step 9: Issue the CREATE DATABASE Statement
注意脚本最后才会用到“;“前面的都是”,“号。
[oracle@snow ~]$ cat /home/oracle/createdb.sql
CREATE DATABASE
CDB
USER SYS IDENTIFIED BY oracle
USER SYSTEM IDENTIFIED BY oracle
LOGFILE GROUP 1 ('/u01/app/oracle/oradata/CDB/redo01a.log','/u02/app/oracle/oradata/CDB/redo01b.log') SIZE 100M BLOCKSIZE 512,
GROUP 2 ('/u01/app/oracle/oradata/CDB/redo02a.log','/u02/app/oracle/oradata/CDB/redo02b.log') SIZE 100M BLOCKSIZE 512,
GROUP 3 ('/u01/app/oracle/oradata/CDB/redo03a.log','/u02/app/oracle/oradata/CDB/redo03b.log') SIZE 100M BLOCKSIZE 512
MAXLOGHISTORY 1
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 1024
CHARACTER SET AL32UTF8
NATIONAL CHARACTER SET AL16UTF16
EXTENT MANAGEMENT LOCAL
DATAFILE '/u01/app/oracle/oradata/CDB/system01.dbf'
SIZE 700M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED
SYSAUX DATAFILE '/u01/app/oracle/oradata/CDB/sysaux01.dbf'
SIZE 550M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED
DEFAULT TABLESPACE users
DATAFILE '/u01/app/oracle/oradata/CDB/users01.dbf'
SIZE 500M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
DEFAULT TEMPORARY TABLESPACE tempts1
TEMPFILE '/u01/app/oracle/oradata/CDB/temp01.dbf'
SIZE 20M REUSE AUTOEXTEND ON NEXT 640K MAXSIZE UNLIMITED1
UNDO TABLESPACE undotbs1
DATAFILE '/u01/app/oracle/oradata/CDB/undotbs01.dbf'
SIZE 200M REUSE AUTOEXTEND ON NEXT 5120K MAXSIZE UNLIMITED
USER_DATA TABLESPACE usertbs
DATAFILE '/u01/app/oracle/oradata/CDB/usertbs01.dbf'
SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
ENABLE PLUGGABLE DATABASE
SEED FILE_NAME_CONVERT=('/u01/app/oracle/oradata/CDB','/u01/app/oracle/oradata/CDB/pdbseed');
4,确保创建数据库涉及到的目录都存在
[oracle@snow oradata]$ pwd
/u01/app/oracle/oradata
[oracle@snow oradata]$ mkdir -p CDB/pdbseed
5,启动数据库到nomount状态下,执行建库脚本
[oracle@snow ~]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.1.0 Production on Sun Feb 8 20:00:49 2015
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to an idle instance.
SQL>
startup nomount;
ORACLE instance started.
Total System Global Area 217157632 bytes
Fixed Size 2286656 bytes
Variable Size 159386560 bytes
Database Buffers 50331648 bytes
Redo Buffers 5152768 bytes
SQL>
@/home/oracle/createdb.sql
Database created.
6,为CDB创建数据字典,根据官方文档提示执行下面的3个sql语句
使用sys用户执行下面两个sql语句,执行时间会很长
SQL> @?/rdbms/admin/catalog.sql
SQL> @?/rdbms/admin/catproc.sql
切换到system用户下执行下面的语句
SQL> conn system/oracle
Connected.
SQL> @?/sqlplus/admin/pupbld.sql
所有脚本执行完后,CDB数据库正式创建完成。
SQL> select open_mode from v$database;
OPEN_MODE
--------------------
READ WRITE
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED MOUNTED
SQL> col file_name for a60
SQL> select con_id,file_name from cdb_data_files;
CON_ID FILE_NAME
---------- ------------------------------------------------------------
1 /u01/app/oracle/oradata/CDB/system01.dbf
1 /u01/app/oracle/oradata/CDB/sysaux01.dbf
1 /u01/app/oracle/oradata/CDB/undotbs01.dbf
1 /u01/app/oracle/oradata/CDB/users01.dbf
全文完。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29047826/viewspace-1437483/,如需转载,请注明出处,否则将追究法律责任。