12c多租户管理六(通过seed 容器创建pdb)

通过seed 创建pdb

目录结构

1.1、创建说明
1.2、创建选项
1.3、编写创建语句
1.4、执行创建
1.5、启动新建的pdb

一、通过seed 创建pdb

1.1、创建说明
1、通过 create pluggable database 语句创建。
2、确保当前 container 是 cdb root 或是应用程序 root
3、若当前容器是 cdb root,则 pdb 的创建使用的是 cdb seed
4、若当前容器是 application root 则 pdb 的创建使用的是应用程序 seed
5、如果不在根下创建pdb则会有如下报错
ERROR at line 1:ORA-16000: database or pluggable database open for read-only access

1.2、创建选项
ADMIN_USER 创建用于执行管理的本地用户,该用户会被赋予 PDB_DBA 角色
PATH_PREFIX 限定新创建 pdb 中新增数据文件必须存储在该目录或其子目录
DATAFILE 指定新创建 pdb 库中默认表空间数据文件的路径和名称
DEFAULT TABLESPACE 指定新创建 pdb 的默认用户表空间
MAX SIZE 限制新创建 pdb 库可使用空间最大值
FILE_NAME_CONVERT 指定新创建 pdb 库中数据文件的位置。
MAX_SHARED_TEMP_SIZE 指定 pdb 共用临时表空间的最大尺寸
TEMPFILE REUSE 若目的地无临时文件则创建,有则格式化临时文件后重新使用
USER_TABLESPACES 指定新 pdb 中哪个用户表空间是可用的,排除其它的

1.3、编写创建语句
1、登陆根容器
[oracle@oracle18c1 dbs]$ ps -ef |grep pmon
oracle 3330 1 0 17:13 ? 00:00:00 ora_pmon_mycdb
oracle 3979 3194 0 17:17 pts/0 00:00:00 grep --color=auto pmon
[oracle@oracle18c1 dbs]$ export ORACLE_SID=mycdb
[oracle@oracle18c1 dbs]$ sqlplus / as sysdba

SQL*Plus: Release 18.0.0.0.0 - Production on Thu May 21 17:18:13 2020
Version 18.3.0.0.0

Copyright (c) 1982, 2018, Oracle. All rights reserved.

Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.3.0.0.0

2、切换到seed容器查询seed数据文件路径
SQL> show pdbs;

CON_ID CON_NAME           OPEN MODE  RESTRICTED

 2 PDB$SEED           READ ONLY  NO
 3 MYPDB1             READ WRITE NO
 4 MYPDB2             READ WRITE NO
 5 YOUPDB             MOUNTED

SQL> alter session set container=PDB$SEED;

Session altered.

SQL> show con_name

CON_NAME

PDB$SEED
SQL> select name from v$datafile;

NAME

/opt/oracle/oradata/mycdb/pdbseed/system01.dbf
/opt/oracle/oradata/mycdb/pdbseed/sysaux01.dbf
/opt/oracle/oradata/mycdb/pdbseed/undotbs01.dbf

3、建新pdb得语句为
create pluggable database mypdb3 admin user pdb3admin identified by dhhzdhhz
FILE_NAME_CONVERT = (‘/opt/oracle/oradata/mycdb/pdbseed/‘,‘/opt/oracle/oradata/mycdb/mypdb3/‘);

1.4、执行创建

1、确保当前在根容器下
SQL> alter session set container=CDB$ROOT;

Session altered.

SQL> show pdbs;

CON_ID CON_NAME           OPEN MODE  RESTRICTED

 2 PDB$SEED           READ ONLY  NO
 3 MYPDB1             READ WRITE NO
 4 MYPDB2             READ WRITE NO
 5 YOUPDB             MOUNTED

SQL>

2、执行创建语句
SQL> create pluggable database mypdb3 admin user pdb3admin identified by dhhzdhhz
FILE_NAME_CONVERT = (‘/opt/oracle/oradata/mycdb/pdbseed/‘,‘/opt/oracle/oradata/mycdb/mypdb3/‘);

Pluggable database created.

1.5、启动新建的pdb(mypdb3)

1、启动新创建的pdb
SQL> show pdbs;

CON_ID CON_NAME           OPEN MODE  RESTRICTED

 2 PDB$SEED           READ ONLY  NO
 3 MYPDB1             READ WRITE NO
 4 MYPDB2             READ WRITE NO
 5 YOUPDB             MOUNTED
 6 MYPDB3             MOUNTED

SQL> alter pluggable database mypdb3 open;

Pluggable database altered.

SQL> show pdbs;

CON_ID CON_NAME           OPEN MODE  RESTRICTED

 2 PDB$SEED           READ ONLY  NO
 3 MYPDB1             READ WRITE NO
 4 MYPDB2             READ WRITE NO
 5 YOUPDB             MOUNTED
 6 MYPDB3             READ WRITE NO

2、保存pdb的启动状态,待下次重启cdb,让pdb自动启动

SQL> show pdbs;

CON_ID CON_NAME           OPEN MODE  RESTRICTED

 2 PDB$SEED           READ ONLY  NO
 3 MYPDB1             READ WRITE NO
 4 MYPDB2             READ WRITE NO
 5 YOUPDB             MOUNTED
 6 MYPDB3             READ WRITE NO

SQL> alter pluggable database mypdb3 save state;

Pluggable database altered.

SQL> select con_name, state from dba_pdb_saved_states;

CON_NAME STATE


MYPDB2 OPEN
MYPDB1 OPEN
MYPDB3 OPEN

12c多租户管理六(通过seed 容器创建pdb)

上一篇:使用webpack打包


下一篇:数据库-单表查询