【Database 12c】手动创建CDB Container Database容器数据库

手动建库几乎是每个DBA都需要掌握的技能,而Database 12c中手动创建Container Database容器数据库的过程是如何的呢?

目前12c创建容器数据库Container Database和普通Database存在一点点小的区别,需要指定enable pluggable database,已创建的数据库目前无法转换为容器数据库。

创建必要的目录

mkdir -p /stage/oradata
mkdir -p /stage/fr
mkdir -p /u01/app/oracle/admin/MACLEANCDB/adump

我们创建 实例初始化文件,并创建DB:

 

 

1、 INIT.ORA

##############################################################################
# Copyright (c) 1991, 2001, 2002 by Oracle Corporation
##############################################################################

###########################################
# 
###########################################
_enable_pluggable_database=true

###########################################
# Cache and I/O
###########################################
db_block_size=8192

###########################################
# Cursors and Library Cache
###########################################
open_cursors=300

###########################################
# Database Identification
###########################################
db_domain=""
db_name="MACLEANC"

###########################################
# File Configuration
###########################################
db_create_file_dest="/stage/oradata"
db_recovery_file_dest="/stage/fr"
db_recovery_file_dest_size=5061476352

###########################################
# Miscellaneous
###########################################
compatible=12.0.0.0.0
db_unique_name="MACLEANCDB"
diagnostic_dest=/u01/app/oracle

###########################################
# Network Registration
###########################################
#local_listener=LISTENER_MACLEANCDB

###########################################
# Processes and Sessions
###########################################
processes=300

###########################################
# SGA Memory
###########################################
sga_target=1022361600

###########################################
# Security and Auditing
###########################################
audit_file_dest="/u01/app/oracle/admin/MACLEANCDB/adump"
audit_trail=db
remote_login_passwordfile=EXCLUSIVE

###########################################
# Shared Server
###########################################
dispatchers="(PROTOCOL=TCP) (SERVICE=MACLEANCDBXDB)"

###########################################
# Sort, Hash Joins, Bitmap Indexes
###########################################
pga_aggregate_target=340787200

###########################################
# System Managed Undo and Rollback Segments
###########################################
undo_tablespace=UNDOTBS1

 

 

 

2、 创建密码文件

 

 

oracle@localhost:~$ /u01/app/oracle/product/12.1.0/dbhome_1/bin/orapwd file=/u01/app/oracle/product/12.1.0/dbhome_1/dbs/orapwMACLEANCDB force=y extended=y

Enter password for SYS:

 

 

3、 正式创建DB

 

 

oracle@localhost:~$ export ORACLE_SID=MACLEANCDB
oracle@localhost:~$ sqlplus / as sysdba

SQL> startup nomount pfile='init.ora';
ORACLE instance started.

Total System Global Area 1018830848 bytes
Fixed Size                  2268040 bytes
Variable Size             268436600 bytes
Database Buffers          742391808 bytes
Redo Buffers                5734400 bytes

CREATE DATABASE "MACLEANC"
MAXINSTANCES 8
MAXLOGHISTORY 1
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 1024
DATAFILE SIZE 700M AUTOEXTEND ON NEXT  10240K MAXSIZE UNLIMITED
EXTENT MANAGEMENT LOCAL
SYSAUX DATAFILE SIZE 550M AUTOEXTEND ON NEXT  10240K MAXSIZE UNLIMITED
SMALLFILE DEFAULT TEMPORARY TABLESPACE TEMP TEMPFILE SIZE 20M AUTOEXTEND ON NEXT  640K MAXSIZE UNLIMITED
SMALLFILE UNDO TABLESPACE "UNDOTBS1" DATAFILE  SIZE 200M AUTOEXTEND ON NEXT  5120K MAXSIZE UNLIMITED
CHARACTER SET AL32UTF8
NATIONAL CHARACTER SET UTF8
LOGFILE GROUP 1  SIZE 51200K,
GROUP 2  SIZE 51200K,
GROUP 3  SIZE 51200K
USER SYS IDENTIFIED BY "oracle" USER SYSTEM IDENTIFIED BY "oracle"
enable pluggable database;

Database created.

set linesize 2048;
column ctl_files NEW_VALUE ctl_files;
select concat('control_files=''', concat(replace(value, ', ', ''','''), '''')) ctl_files from v$parameter where name ='control_files';
host echo &ctl_files >> /u01/app/oracle/admin/MACLEANCDB/scripts/init.ora;
spool off

将控制文件信息写入到中==》 echo &ctl_files >> /u01/app/oracle/admin/MACLEANCDB/scripts/init.ora;

 

 

4、创建默认使用的USERS表空间

 

SQL> CREATE SMALLFILE TABLESPACE "USERS" LOGGING  DATAFILE  SIZE 5M AUTOEXTEND ON NEXT  1280K MAXSIZE UNLIMITED  EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT  AUTO;

Tablespace created.

SQL> ALTER DATABASE DEFAULT TABLESPACE "USERS";

Database altered.

 

 

 

5、 执行必要的数据字典创建脚本

 

 

 

alter session set "_oracle_script"=true;
alter pluggable database pdb$seed close;
alter pluggable database pdb$seed open;
host perl /u01/app/oracle/product/12.1.0/dbhome_1/rdbms/admin/catcon.pl -l /u01/app/oracle/admin/MACLEANCDB/scripts -b catalog /u01/ap
p/oracle/product/12.1.0/dbhome_1/rdbms/admin/catalog.sql;
host perl /u01/app/oracle/product/12.1.0/dbhome_1/rdbms/admin/catcon.pl -l /u01/app/oracle/admin/MACLEANCDB/scripts -b catblock /u01/a
pp/oracle/product/12.1.0/dbhome_1/rdbms/admin/catblock.sql;
host perl /u01/app/oracle/product/12.1.0/dbhome_1/rdbms/admin/catcon.pl -l /u01/app/oracle/admin/MACLEANCDB/scripts -b catproc /u01/ap
p/oracle/product/12.1.0/dbhome_1/rdbms/admin/catproc.sql;
host perl /u01/app/oracle/product/12.1.0/dbhome_1/rdbms/admin/catcon.pl -l /u01/app/oracle/admin/MACLEANCDB/scripts -b catoctk /u01/ap
p/oracle/product/12.1.0/dbhome_1/rdbms/admin/catoctk.sql;
host perl /u01/app/oracle/product/12.1.0/dbhome_1/rdbms/admin/catcon.pl -l /u01/app/oracle/admin/MACLEANCDB/scripts -b owminst /u01/ap
p/oracle/product/12.1.0/dbhome_1/rdbms/admin/owminst.plb;
host perl /u01/app/oracle/product/12.1.0/dbhome_1/rdbms/admin/catcon.pl -l /u01/app/oracle/admin/MACLEANCDB/scripts -b pupbld -u SYSTE
M/&&systemPassword /u01/app/oracle/product/12.1.0/dbhome_1/sqlplus/admin/pupbld.sql;
connect "SYSTEM"/"&&systemPassword"
set echo on
spool /u01/app/oracle/admin/MACLEANCDB/scripts/sqlPlusHelp.log append
host perl /u01/app/oracle/product/12.1.0/dbhome_1/rdbms/admin/catcon.pl -l /u01/app/oracle/admin/MACLEANCDB/scripts -b hlpbld -u SYSTE
M/&&systemPassword -a 1  /u01/app/oracle/product/12.1.0/dbhome_1/sqlplus/admin/help/hlpbld.sql 1helpus.sql;
@/u01/app/oracle/product/12.1.0/dbhome_1/sqlplus/admin/help/hlpbld.sql helpus.sql;

 

 

 

6、 创建一个PDB

 

 

cp init.ora  /u01/app/oracle/product/12.1.0/dbhome_1/dbs/initMACLEANCDB.ora 

startup force;

CREATE PLUGGABLE DATABASE MACLEANCDB ADMIN USER MACadmin IDENTIFIED BY oracle
 FILE_NAME_CONVERT=(
  '/stage/oradata/MACLEANCDB/DC36ED41771D435CE0430100007FA00B/datafile/o1_mf_system_8rns0lxf_.dbf', '/stage/oradata/PDB1/datafile/system01.clone',
  '/stage/oradata/MACLEANCDB/DC36ED41771D435CE0430100007FA00B/datafile/o1_mf_sysaux_8rns13dk_.dbf', '/stage/oradata/PDB1/datafile/sysaux1.dbf.clone',
  '/stage/oradata/MACLEANCDB/DC36ED41771D435CE0430100007FA00B/datafile/o1_mf_temp_8rns1d89_.tmp', '/stage/oradata/PDB1/datafile/temp1.tmp.clone'
  )
 STORAGE UNLIMITED;

Comment

*

沪ICP备14014813号-2

沪公网安备 31010802001379号