Oracle12c手工创建多租户容器数据库(手工建库CDB)

Oracle12c手工创建多租户容器数据库(手工建库CDB)

本文介绍如何在Oracle数据库12.2中手工创建CDB容器数据库

1、创建密码文件

bash 复制代码
cd $ORACLE_HOME/dbs/
orapwd file=orapwnewcdb password=oracle format=12 entries=10

2、创建目录

bash 复制代码
mkdir -p /u01/app/oracle/oradata/newcdb/pdbseed

3、创建静态参数文件

建议的最小初始化参数文件:db_name,control_files,memory_target

bash 复制代码
cd $ORACLE_HOME/dbs/
vim initnewcdb.ora
bash 复制代码
db_name=newcdb
control_files=('/u01/app/oracle/oradata/newcdb/control01.ctl','/u01/app/oracle/oradata/newcdb/control02.ctl','/u01/app/oracle/oradata/newcdb/control03.ctl')
memory_target=800m
enable_pluggable_database=TRUE

4、切换环境并启动到 nomount

bash 复制代码
export ORACLE_SID=newcdb
sqlplus / as sysdba
create spfile from pfile;
startup nomount;

5、执行建库语句

bash 复制代码
CREATE DATABASE newcdb
USER SYS IDENTIFIED BY oracle
USER SYSTEM IDENTIFIED BY oracle
LOGFILE GROUP 1 ('/u01/app/oracle/oradata/newcdb/redo01a.log','/u01/app/oracle/oradata/newcdb/redo01b.log')
SIZE 100M BLOCKSIZE 512,
GROUP 2 ('/u01/app/oracle/oradata/newcdb/redo02a.log','/u01/app/oracle/oradata/newcdb/redo02b.log')
SIZE 100M BLOCKSIZE 512,
GROUP 3 ('/u01/app/oracle/oradata/newcdb/redo03a.log','/u01/app/oracle/oradata/newcdb/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/newcdb/system01.dbf'
SIZE 700M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED
SYSAUX DATAFILE '/u01/app/oracle/oradata/newcdb/sysaux01.dbf'
SIZE 550M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED
DEFAULT TABLESPACE USERS
DATAFILE '/u01/app/oracle/oradata/newcdb/users01.dbf'
SIZE 500M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
DEFAULT TEMPORARY TABLESPACE TEMP
TEMPFILE '/u01/app/oracle/oradata/newcdb/temp01.dbf'
SIZE 20M REUSE AUTOEXTEND ON NEXT 640K MAXSIZE UNLIMITED
UNDO TABLESPACE UNDOTBS1
DATAFILE '/u01/app/oracle/oradata/newcdb/undotbs01.dbf'
SIZE 200M REUSE AUTOEXTEND ON NEXT 5120K MAXSIZE UNLIMITED
ENABLE PLUGGABLE DATABASE
SEED
FILE_NAME_CONVERT = ('/u01/app/oracle/oradata/newcdb/',
'/u01/app/oracle/oradata/newcdb/pdbseed/')
LOCAL UNDO ON;

数据库创建完成,检查数据库的状态是:OPEN

bash 复制代码
SYS@newcdb> select status from v$instance;
OPEN

6、后续工作,执行脚本:

6.1、第一步:修改$ORACLE_HOME/rdbms/admin/catcdb.pl

bash 复制代码
[oracle@enmoedu1 admin]$vi $ORACLE_HOME/rdbms/admin/catcdb.pl
把util修改为Util
use Term::ReadKey; # to not echo password
use Getopt::Long;
use Cwd;
use File::Spec;
use Data::Dumper;
use Util qw(trim, splitToArray);
use catcon qw(catconSqlplus);

6.2、第二步:设置环境perl的环境变量:

bash 复制代码
[oracle@enmoedu1 ~]$ vi .bash_profile

添加如下的环境变量:

bash 复制代码
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$ORACLE_HOME/perl/bin:$ORACLE_HOME/jdk/bin:$PATH

[oracle@enmoedu1 ~]$ source .bash_profile

6.3、第三步:执行脚本:

首先切换到perl的目录下:

bash 复制代码
[oracle@enmoedu1 ~]$cd $ORACLE_HOME/perl/lib/5.22.0/x86_64-linux-thread-multi/Hash
[oracle@enmoedu1 ~]sqlplus / as sysdba
SYS@newcdb>@?/rdbms/admin/catcdb.sql
SQL> host perl -I &&rdbms_admin &&rdbms_admin_catcdb --logDirectory &&1 --logFilename &&2
Enter value for 1: /u01/app/oracle/product/12.2.0/dbhome_1/rdbms/admin
Enter value for 2: /u01/app/oracle/product/12.2.0/dbhome_1/rdbms/admin/catcdb.pl
Enter new password for SYS: oracle
Enter new password for SYSTEM: oracle
Enter temporary tablespace name: temp
No options to container mapping specified, no options will be installed in any containers
catcon: ALL catcon-related output will be written to [/U01/app/oracle/product/12.2/rdbms/admin/catalog_catcon_46984.lst]
catcon: See [/U01/app/oracle/product/12.2/rdbms/admin/catalog*.log] files for output generated by s
catcon: See [/U01/app/oracle/product/12.2/rdbms/admin/catalog_*.lst] files for spool files, if any

然后就是一段时间的等待,可以从日志看到会关联调用catalog.sql,catproc.sql等脚本文件。

6.4、第四步:使用SYSTEM用户执行SQL*Plus相关脚本

bash 复制代码
SYS@newcdb>conn system/oracle
SYS@newcdb>@?/sqlplus/admin/pupbld.sql

6.5、第五步:验证结果

bash 复制代码
SYS@newcdb> show parameter pluggable

NAME TYPE VALUE

enable_pluggable_database boolean TRUE

SYS@newcdb> show pdbs

CON_ID CON_NAME                       OPEN MODE  RESTRICTED
     2 PDB$SEED                       READ ONLY  NO
SYS@newcdb> select name from v$datafile where con_id=1;

/u01/app/oracle/oradata/newcdb/system01.dbf
/u01/app/oracle/oradata/newcdb/sysaux01.dbf
/u01/app/oracle/oradata/newcdb/undotbs01.dbf
/u01/app/oracle/oradata/newcdb/USERS01.dbf

SYS@newcdb> select name from v$datafile where con_id=2;

/u01/app/oracle/oradata/newcdb/pdbseed/system01.dbf
/u01/app/oracle/oradata/newcdb/pdbseed/sysaux01.dbf
/u01/app/oracle/oradata/newcdb/pdbseed/undotbs01.dbf
/u01/app/oracle/oradata/newcdb/pdbseed/USERS01.dbf

SYS@newcdb> select name from v$tempfile;

/u01/app/oracle/oradata/newcdb/temp01.dbf
/u01/app/oracle/oradata/newcdb/pdbseed/temp01.dbf

SYS@newcdb>
相关推荐
计算机毕设定制辅导-无忧学长6 分钟前
Redis 初相识:开启缓存世界大门
数据库·redis·缓存
Rverdoser42 分钟前
redis延迟队列
数据库·redis·缓存
weisian1511 小时前
Redis篇--常见问题篇6--缓存一致性1(Mysql和Redis缓存一致,更新数据库删除缓存策略)
数据库·redis·缓存
中草药z2 小时前
【Spring】深入解析 Spring 原理:Bean 的多方面剖析(源码阅读)
java·数据库·spring boot·spring·bean·源码阅读
地球资源数据云2 小时前
全国30米分辨率逐年植被覆盖度(FVC)数据集
大数据·运维·服务器·数据库·均值算法
Ahern_3 小时前
Oracle 普通表至分区表的分区交换
大数据·数据库·sql·oracle
夜半被帅醒3 小时前
MySQL 数据库优化详解【Java数据库调优】
java·数据库·mysql
不爱学习的啊Biao3 小时前
【13】MySQL如何选择合适的索引?
android·数据库·mysql
破 风3 小时前
SpringBoot 集成 MongoDB
数据库·mongodb
Rverdoser4 小时前
MySQL-MVCC(多版本并发控制)
数据库·mysql