目录结构
注:提前言明 本文借鉴了以下博主、书籍或网站的内容,其列表如下:
1、参考书籍:《Oracle Database SQL Language Reference》
2、参考书籍:《PostgreSQL中文手册》
3、EDB Postgres Advanced Server User Guides,点击前往
4、PostgreSQL数据库仓库链接,点击前往
5、PostgreSQL中文社区,点击前往
6、Oracle Real Application Testing 官网首页,点击前往
7、Oracle 21C RAT Testing Guide,点击前往
8、测试指南 Setting Up Replay Clients,点击前往
9、swingbench-免费的oracle性能压测工具,点击前往
10、使用免费负载生成器swingbench对oracle数据库进行压力测试(测试Oracle的功能或评估性能),点击前往
11、牛刀小试–Oracle Swingbench 压力测试,点击前往
12、创建可插拔数据库PDB,点击前往
1、本文内容全部来源于开源社区 GitHub和以上博主的贡献,本文也免费开源(可能会存在问题,评论区等待大佬们的指正)
2、本文目的:开源共享 抛砖引玉 一起学习
3、本文不提供任何资源 不存在任何交易 与任何组织和机构无关
4、大家可以根据需要自行 复制粘贴以及作为其他个人用途,但是不允许转载 不允许商用 (写作不易,还请见谅 💖)
Oracle数据库可插拔数据库PDB的创建及删除
- 文章快速说明索引
- 从种子PDB来创建
- 从本地PDB来克隆
- PDB数据库的删除
- PDB进行数据负载
文章快速说明索引
学习目标:
目的:接下来这段时间我想做一些兼容Oracle数据库Real Application Testing (即:RAT)上的一些功能开发,本专栏这里主要是学习以及介绍Oracle数据库功能的使用场景、原理说明和注意事项等,基于PostgreSQL数据库的功能开发等之后 由新博客进行介绍和分享!
学习内容:(详见目录)
1、Oracle数据库可插拔数据库PDB的创建及删除
学习时间:
2023年04月18日 20:06:34
学习产出:
1、Oracle数据库可插拔数据库PDB的创建及删除
2、CSDN 技术博客 1篇
注:下面我们所有的学习环境是Centos7+PostgreSQL15.0+Oracle19c+MySQL5.7
postgres=# select version();
version
-----------------------------------------------------------------------------
PostgreSQL 15.0 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 7.1.0, 64-bit
(1 row)
postgres=#
#-----------------------------------------------------------------------------#
SQL> select * from v$version;
BANNER BANNER_FULL BANNER_LEGACY CON_ID
--------------------------------------------------------------------------- --------------------------------------------------------------------------- --------------------------------------------------------------------------- ----------
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production 0
Version 19.3.0.0.0
SQL>
#-----------------------------------------------------------------------------#
mysql> select version();
+-----------+
| version() |
+-----------+
| 5.7.19 |
+-----------+
1 row in set (0.06 sec)
mysql>
从种子PDB来创建
第一步,查看pdb状态,如下:
[oracle@dbserver ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Wed Apr 19 10:10:28 2023
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup;
ORACLE instance started.
Total System Global Area 1157624440 bytes
Fixed Size 9134712 bytes
Variable Size 486539264 bytes
Database Buffers 654311424 bytes
Redo Buffers 7639040 bytes
Database mounted.
Database opened.
SQL>
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 ORCLPDB READ WRITE NO
SQL>
如上,seed pdb 在数据库cdb启动时处于read only的状态!
第二步,查看其数据文件,如下:
SQL> set line 1000
SQL> col name format a100
SQL> select name, con_id from v$datafile order by con_id;
NAME CON_ID
---------------------------------------------------------------------------------------------------- ----------
/home/oracle/oracle19c/oradata/ORCL/system01.dbf 1
/home/oracle/oracle19c/oradata/ORCL/sysaux01.dbf 1
/home/oracle/oracle19c/oradata/ORCL/undotbs01.dbf 1
/home/oracle/oracle19c/oradata/ORCL/users01.dbf 1
/home/oracle/oracle19c/oradata/ORCL/pdbseed/sysaux01.dbf 2
/home/oracle/oracle19c/oradata/ORCL/pdbseed/undotbs01.dbf 2
/home/oracle/oracle19c/oradata/ORCL/pdbseed/system01.dbf 2
/home/oracle/oracle19c/oradata/ORCL/orclpdb/soe.dbf 3
/home/oracle/oracle19c/oradata/ORCL/orclpdb/system01.dbf 3
/home/oracle/oracle19c/oradata/ORCL/orclpdb/sysaux01.dbf 3
/home/oracle/oracle19c/oradata/ORCL/orclpdb/undotbs01.dbf 3
NAME CON_ID
---------------------------------------------------------------------------------------------------- ----------
/home/oracle/oracle19c/oradata/ORCL/orclpdb/users01.dbf 3
12 rows selected.
SQL> select name, con_id from v$tempfile order by con_id;
NAME CON_ID
---------------------------------------------------------------------------------------------------- ----------
/home/oracle/oracle19c/oradata/ORCL/temp01.dbf 1
/home/oracle/oracle19c/oradata/ORCL/pdbseed/temp012021-02-02_16-06-33-641-PM.dbf 2
/home/oracle/oracle19c/oradata/ORCL/orclpdb/temp01.dbf 3
SQL>
-- PDB$SEED 数据存放的位置
[oracle@dbserver ~]$ tree /home/oracle/oracle19c/oradata/ORCL/pdbseed/
/home/oracle/oracle19c/oradata/ORCL/pdbseed/
├── sysaux01.dbf
├── system01.dbf
├── temp012021-02-02_16-06-33-641-PM.dbf
└── undotbs01.dbf
0 directories, 4 files
[oracle@dbserver ~]$ tree /home/oracle/oracle19c/oradata/ORCL/orclpdb/
/home/oracle/oracle19c/oradata/ORCL/orclpdb/
├── addmrpt_1_1124_1125.txt
├── ashrpt_1_0406_1304.html
├── awrrpt_1_1124_1125.html
├── soe.dbf
├── sysaux01.dbf
├── system01.dbf
├── temp01.dbf
├── undotbs01.dbf
└── users01.dbf
0 directories, 9 files
[oracle@dbserver ~]$
第三步,创建新的PDB目录,如下:
-- mkdir capturepdb
-- mkdir replaypdb
[oracle@dbserver ~]$ cd /home/oracle/oracle19c/oradata/ORCL/
[oracle@dbserver ORCL]$ ls
capturepdb control01.ctl control02.ctl orclpdb pdbseed redo01.log redo02.log redo03.log replaypdb sysaux01.dbf system01.dbf temp01.dbf undotbs01.dbf users01.dbf
[oracle@dbserver ORCL]$
[oracle@dbserver ORCL]$ ls capturepdb/
[oracle@dbserver ORCL]$
[oracle@dbserver ORCL]$ ls replaypdb/
[oracle@dbserver ORCL]$
第四步,创建capturepdb,如下:
SQL> create pluggable database capturepdb admin user sysdba identified by 123456 roles=(connect) file_name_convert=('/home/oracle/oracle19c/oradata/ORCL/pdbseed','/home/oracle/oracle19c/oradata/ORCL/capturepdb');
Pluggable database created.
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 ORCLPDB READ WRITE NO
4 CAPTUREPDB MOUNTED
SQL>
[oracle@dbserver ORCL]$ ll capturepdb/
总用量 716880
-rw-rw---- 1 oracle oracle 346038272 4月 19 10:19 sysaux01.dbf
-rw-rw---- 1 oracle oracle 283123712 4月 19 10:19 system01.dbf
-rw-rw---- 1 oracle oracle 37756928 4月 19 10:19 temp012021-02-02_16-06-33-641-PM.dbf
-rw-rw---- 1 oracle oracle 104865792 4月 19 10:19 undotbs01.dbf
[oracle@dbserver ORCL]$
SQL> col name format a100
SQL> select name, con_id from v$datafile order by con_id;
NAME CON_ID
---------------------------------------------------------------------------------------------------- ----------
/home/oracle/oracle19c/oradata/ORCL/system01.dbf 1
/home/oracle/oracle19c/oradata/ORCL/sysaux01.dbf 1
/home/oracle/oracle19c/oradata/ORCL/undotbs01.dbf 1
/home/oracle/oracle19c/oradata/ORCL/users01.dbf 1
/home/oracle/oracle19c/oradata/ORCL/pdbseed/system01.dbf 2
/home/oracle/oracle19c/oradata/ORCL/pdbseed/sysaux01.dbf 2
/home/oracle/oracle19c/oradata/ORCL/pdbseed/undotbs01.dbf 2
/home/oracle/oracle19c/oradata/ORCL/orclpdb/system01.dbf 3
/home/oracle/oracle19c/oradata/ORCL/orclpdb/soe.dbf 3
/home/oracle/oracle19c/oradata/ORCL/orclpdb/users01.dbf 3
/home/oracle/oracle19c/oradata/ORCL/orclpdb/sysaux01.dbf 3
NAME CON_ID
---------------------------------------------------------------------------------------------------- ----------
/home/oracle/oracle19c/oradata/ORCL/orclpdb/undotbs01.dbf 3
/home/oracle/oracle19c/oradata/ORCL/capturepdb/sysaux01.dbf 4
/home/oracle/oracle19c/oradata/ORCL/capturepdb/system01.dbf 4
/home/oracle/oracle19c/oradata/ORCL/capturepdb/undotbs01.dbf 4
15 rows selected.
SQL> col file_name for a100;
SQL> col tablespace_name for a20;
SQL> select file_id, file_name, tablespace_name from cdb_data_files;
FILE_ID FILE_NAME TABLESPACE_NAME
---------- ---------------------------------------------------------------------------------------------------- --------------------
7 /home/oracle/oracle19c/oradata/ORCL/users01.dbf USERS
4 /home/oracle/oracle19c/oradata/ORCL/undotbs01.dbf UNDOTBS1
1 /home/oracle/oracle19c/oradata/ORCL/system01.dbf SYSTEM
3 /home/oracle/oracle19c/oradata/ORCL/sysaux01.dbf SYSAUX
9 /home/oracle/oracle19c/oradata/ORCL/orclpdb/system01.dbf SYSTEM
10 /home/oracle/oracle19c/oradata/ORCL/orclpdb/sysaux01.dbf SYSAUX
11 /home/oracle/oracle19c/oradata/ORCL/orclpdb/undotbs01.dbf UNDOTBS1
12 /home/oracle/oracle19c/oradata/ORCL/orclpdb/users01.dbf USERS
17 /home/oracle/oracle19c/oradata/ORCL/orclpdb/soe.dbf SOE
9 rows selected.
SQL>
第五步,打开上面创建的pdb,如下:
SQL> alter session set container = capturepdb;
Session altered.
SQL> alter pluggable database capturepdb open;
Pluggable database altered.
SQL>
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
4 CAPTUREPDB READ WRITE NO
SQL> select name, con_id from v$datafile order by con_id;
NAME CON_ID
---------------------------------------------------------------------------------------------------- ----------
/home/oracle/oracle19c/oradata/ORCL/capturepdb/system01.dbf 4
/home/oracle/oracle19c/oradata/ORCL/capturepdb/undotbs01.dbf 4
/home/oracle/oracle19c/oradata/ORCL/capturepdb/sysaux01.dbf 4
SQL> select file_id, file_name, tablespace_name from cdb_data_files;
FILE_ID FILE_NAME TABLESPACE_NAME
---------- ---------------------------------------------------------------------------------------------------- --------------------
21 /home/oracle/oracle19c/oradata/ORCL/capturepdb/system01.dbf SYSTEM
22 /home/oracle/oracle19c/oradata/ORCL/capturepdb/sysaux01.dbf SYSAUX
23 /home/oracle/oracle19c/oradata/ORCL/capturepdb/undotbs01.dbf UNDOTBS1
SQL>
此时再新建一个会话,如下:
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 ORCLPDB READ WRITE NO
4 CAPTUREPDB READ WRITE NO
SQL> col file_name for a100;
SQL> col tablespace_name for a20;
SQL> select file_id, file_name, tablespace_name from cdb_data_files;
FILE_ID FILE_NAME TABLESPACE_NAME
---------- ---------------------------------------------------------------------------------------------------- --------------------
7 /home/oracle/oracle19c/oradata/ORCL/users01.dbf USERS
4 /home/oracle/oracle19c/oradata/ORCL/undotbs01.dbf UNDOTBS1
1 /home/oracle/oracle19c/oradata/ORCL/system01.dbf SYSTEM
3 /home/oracle/oracle19c/oradata/ORCL/sysaux01.dbf SYSAUX
9 /home/oracle/oracle19c/oradata/ORCL/orclpdb/system01.dbf SYSTEM
10 /home/oracle/oracle19c/oradata/ORCL/orclpdb/sysaux01.dbf SYSAUX
11 /home/oracle/oracle19c/oradata/ORCL/orclpdb/undotbs01.dbf UNDOTBS1
12 /home/oracle/oracle19c/oradata/ORCL/orclpdb/users01.dbf USERS
17 /home/oracle/oracle19c/oradata/ORCL/orclpdb/soe.dbf SOE
21 /home/oracle/oracle19c/oradata/ORCL/capturepdb/system01.dbf SYSTEM
22 /home/oracle/oracle19c/oradata/ORCL/capturepdb/sysaux01.dbf SYSAUX
FILE_ID FILE_NAME TABLESPACE_NAME
---------- ---------------------------------------------------------------------------------------------------- --------------------
23 /home/oracle/oracle19c/oradata/ORCL/capturepdb/undotbs01.dbf UNDOTBS1
12 rows selected.
SQL>
第六步,配置tnsnames.ora,并建立连接,如下:
[oracle@dbserver ~]$ vim ./oracle19c/product/19c/dbhome_1/network/admin/tnsnames.ora
[oracle@dbserver ~]$
[oracle@dbserver ~]$ cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 oracle
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 oracle
[oracle@dbserver ~]$
[oracle@dbserver ~]$ cat ./oracle19c/product/19c/dbhome_1/network/admin/tnsnames.ora
# tnsnames.ora Network Configuration File: /home/oracle/oracle19c/product/19c/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
LISTENER_ORCL =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle)(PORT = 1521))
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
PDBORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ORCLPDB)
)
)
CAPTUREPDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = capturepdb)
)
)
[oracle@dbserver ~]$ cat /home/oracle/oracle19c/product/19c/dbhome_1/network/admin/listener.ora
# listener.ora Network Configuration File: /home/oracle/oracle19c/product/19c/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
ORCL =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orcl)
(SID_NAME = orcl)
)
)
[oracle@dbserver ~]$
然后重启了一下监听,如下:
[oracle@dbserver ~]$ lsnrctl stop ; lsnrctl start
...
[oracle@dbserver ~]$ lsnrctl status
...
[oracle@dbserver ~]$ sqlplus sys/123456@capturepdb as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Wed Apr 19 11:20:01 2023
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
4 CAPTUREPDB READ WRITE NO
-- 查看用户
SQL> select username,common,con_id from cdb_users where account_status = 'OPEN';
USERNAME COM CON_ID
--------------- --- ----------
SYS YES 4
SYSTEM YES 4
C##ORACLE YES 4
SYSDBA NO 4
C##SPA123 YES 4
C##USER1 YES 4
WMSYS YES 4
7 rows selected.
SQL>
第七步,创建并指定默认表空间,如下:
SQL> col file_name for a100;
SQL> col tablespace_name for a20;
SQL>
SQL> select file_name, tablespace_name from cdb_data_files;
FILE_NAME TABLESPACE_NAME
---------------------------------------------------------------------------------------------------- --------------------
/home/oracle/oracle19c/oradata/ORCL/capturepdb/system01.dbf SYSTEM
/home/oracle/oracle19c/oradata/ORCL/capturepdb/sysaux01.dbf SYSAUX
/home/oracle/oracle19c/oradata/ORCL/capturepdb/undotbs01.dbf UNDOTBS1
SQL> create tablespace users datafile '/home/oracle/oracle19c/oradata/ORCL/capturepdb/user.dbf' size 50M autoextend on next 1G maxsize 5G;
Tablespace created.
SQL> select file_name, tablespace_name from cdb_data_files;
FILE_NAME TABLESPACE_NAME
---------------------------------------------------------------------------------------------------- --------------------
/home/oracle/oracle19c/oradata/ORCL/capturepdb/system01.dbf SYSTEM
/home/oracle/oracle19c/oradata/ORCL/capturepdb/sysaux01.dbf SYSAUX
/home/oracle/oracle19c/oradata/ORCL/capturepdb/undotbs01.dbf UNDOTBS1
/home/oracle/oracle19c/oradata/ORCL/capturepdb/user.dbf USERS
SQL>
从本地PDB来克隆
从容器数据库中克隆本地capturepdb来创建replaypdb,如下:
第一步,以只读方式打开capturepdb,如下:
[oracle@dbserver ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Wed Apr 19 11:33:47 2023
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 ORCLPDB READ WRITE NO
4 CAPTUREPDB READ WRITE NO
SQL>
SQL> conn sys/123456@capturepdb as sysdba
Connected.
SQL>
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
4 CAPTUREPDB READ WRITE NO
SQL> shutdown immediate;
Pluggable Database closed.
SQL>
SQL> startup open read only;
Pluggable Database opened.
SQL>
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
4 CAPTUREPDB READ ONLY NO
SQL>
第二步,查看数据文件,并创建新的PDB目录,如下:
SQL> set line 1000;
SQL> col name format a100;
SQL>
SQL> select name, con_id from v$datafile where con_id = 4;
NAME CON_ID
---------------------------------------------------------------------------------------------------- ----------
/home/oracle/oracle19c/oradata/ORCL/capturepdb/system01.dbf 4
/home/oracle/oracle19c/oradata/ORCL/capturepdb/sysaux01.dbf 4
/home/oracle/oracle19c/oradata/ORCL/capturepdb/undotbs01.dbf 4
/home/oracle/oracle19c/oradata/ORCL/capturepdb/user.dbf 4
SQL>
[oracle@dbserver ~]$ cd /home/oracle/oracle19c/oradata/ORCL/
[oracle@dbserver ORCL]$
[oracle@dbserver ORCL]$ ls replaypdb/
[oracle@dbserver ORCL]$
第三步,克隆 如下:
[oracle@dbserver ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Wed Apr 19 12:44:54 2023
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> create pluggable database replaypdb from capturepdb file_name_convert=('capturepdb','replaypdb');
Pluggable database created.
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 ORCLPDB READ WRITE NO
4 CAPTUREPDB READ ONLY NO
5 REPLAYPDB MOUNTED
SQL>
第四步,打开replaypdb数据库,如下:
SQL> conn /as sysdba
Connected.
SQL>
SQL> alter session set container = capturepdb;
Session altered.
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
4 CAPTUREPDB READ ONLY NO
SQL> alter pluggable database capturepdb close immediate;
Pluggable database altered.
SQL> alter pluggable database capturepdb open;
Pluggable database altered.
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
4 CAPTUREPDB READ WRITE NO
SQL>
SQL> conn /as sysdba
Connected.
SQL>
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 ORCLPDB READ WRITE NO
4 CAPTUREPDB READ WRITE NO
5 REPLAYPDB MOUNTED
SQL> alter session set container = replaypdb;
Session altered.
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
5 REPLAYPDB MOUNTED
SQL> alter pluggable database replaypdb open;
Pluggable database altered.
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
5 REPLAYPDB READ WRITE NO
SQL>
[oracle@dbserver ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Wed Apr 19 12:55:11 2023
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 ORCLPDB READ WRITE NO
4 CAPTUREPDB READ WRITE NO
5 REPLAYPDB READ WRITE NO
SQL>
PDB数据库的删除
alter pluggable database pdbname close;
drop pluggable database pdbname [including datafiles];
PDB进行数据负载
[oracle@dbserver ~]$ lsnrctl status
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 19-APR-2023 12:59:54
Copyright (c) 1991, 2019, Oracle. All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date 19-APR-2023 12:57:27
Uptime 0 days 0 hr. 2 min. 39 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /home/oracle/oracle19c/product/19c/dbhome_1/network/admin/listener.ora
Listener Log File /home/oracle/oracle19c/diag/tnslsnr/dbserver/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dbserver.localdomain)(PORT=1521)))
Services Summary...
Service "86b637b62fdf7a65e053f706e80a27ca" has 1 instance(s).
Instance "orcl", status READY, has 2 handler(s) for this service...
Service "ba57177fca292d25e055020c2946ed4e" has 1 instance(s).
Instance "orcl", status READY, has 2 handler(s) for this service...
Service "capturepdb" has 1 instance(s).
Instance "orcl", status READY, has 2 handler(s) for this service...
Service "f9a7f0e56dce0f4de0538477a8c06579" has 1 instance(s).
Instance "orcl", status READY, has 2 handler(s) for this service...
Service "f9aa168e2c4e38fde0538477a8c0bb32" has 1 instance(s).
Instance "orcl", status READY, has 2 handler(s) for this service...
Service "orcl" has 2 instance(s).
Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
Instance "orcl", status READY, has 2 handler(s) for this service...
Service "orclXDB" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclpdb" has 1 instance(s).
Instance "orcl", status READY, has 2 handler(s) for this service...
Service "replaypdb" has 1 instance(s).
Instance "orcl", status READY, has 2 handler(s) for this service...
The command completed successfully
[oracle@dbserver ~]$
[oracle@dbserver ~]$ sqlplus sys/123456@capturepdb as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Wed Apr 19 13:06:16 2023
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> select snap_id, begin_interval_time, end_interval_time from dba_hist_snapshot order by end_interval_time desc;
SNAP_ID BEGIN_INTERVAL_TIME END_INTERVAL_TIME
---------- --------------------------------------------------------------------------- ---------------------------------------------------------------------------
1132 19-APR-23 12.00.41.585 PM 19-APR-23 01.00.07.221 PM
1131 19-APR-23 11.00.30.577 AM 19-APR-23 12.00.41.585 PM
1130 19-APR-23 10.21.35.563 AM 19-APR-23 11.00.30.577 AM
1129 19-APR-23 10.11.09.000 AM 19-APR-23 10.21.35.563 AM
1128 18-APR-23 11.19.32.000 PM 18-APR-23 11.30.03.024 PM
1127 18-APR-23 06.31.53.000 PM 18-APR-23 06.42.35.592 PM
1126 12-APR-23 05.16.19.000 PM 12-APR-23 05.26.49.832 PM
7 rows selected.
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
4 CAPTUREPDB READ WRITE NO
SQL> exec dbms_workload_repository.create_snapshot();
PL/SQL procedure successfully completed.
SQL> select snap_id, begin_interval_time, end_interval_time from dba_hist_snapshot order by end_interval_time desc;
SNAP_ID BEGIN_INTERVAL_TIME END_INTERVAL_TIME
---------- --------------------------------------------------------------------------- ---------------------------------------------------------------------------
1 19-APR-23 10.11.09.000 AM 19-APR-23 01.09.22.022 PM
1132 19-APR-23 12.00.41.585 PM 19-APR-23 01.00.07.221 PM
1131 19-APR-23 11.00.30.577 AM 19-APR-23 12.00.41.585 PM
1130 19-APR-23 10.21.35.563 AM 19-APR-23 11.00.30.577 AM
1129 19-APR-23 10.11.09.000 AM 19-APR-23 10.21.35.563 AM
1128 18-APR-23 11.19.32.000 PM 18-APR-23 11.30.03.024 PM
1127 18-APR-23 06.31.53.000 PM 18-APR-23 06.42.35.592 PM
1126 12-APR-23 05.16.19.000 PM 12-APR-23 05.26.49.832 PM
8 rows selected.
SQL>
下面使用swingbench进行负载,如下:
[oracle@dbserver capturepdb]$ pwd
/home/oracle/oracle19c/oradata/ORCL/capturepdb
[oracle@dbserver capturepdb]$ ll
总用量 799160
-rw-rw---- 1 oracle oracle 377495552 4月 19 13:11 sysaux01.dbf
-rw-rw---- 1 oracle oracle 283123712 4月 19 13:11 system01.dbf
-rw-rw---- 1 oracle oracle 37756928 4月 19 13:03 temp012021-02-02_16-06-33-641-PM.dbf
-rw-rw---- 1 oracle oracle 104865792 4月 19 13:08 undotbs01.dbf
-rw-rw---- 1 oracle oracle 52436992 4月 19 13:08 user.dbf
[oracle@dbserver capturepdb]$
[oracle@dbserver capturepdb]$ ll
总用量 3761320
-rw-rw---- 1 oracle oracle 2603622400 4月 19 13:25 soe.dbf
-rw-rw---- 1 oracle oracle 387981312 4月 19 13:25 sysaux01.dbf
-rw-rw---- 1 oracle oracle 283123712 4月 19 13:24 system01.dbf
-rw-rw---- 1 oracle oracle 247472128 4月 19 13:24 temp012021-02-02_16-06-33-641-PM.dbf
-rw-rw---- 1 oracle oracle 277880832 4月 19 13:25 undotbs01.dbf
-rw-rw---- 1 oracle oracle 52436992 4月 19 13:24 user.dbf
[oracle@dbserver capturepdb]$
数据加载完成,开始负载,如下: