您好,登錄后才能下訂單哦!
本篇內容介紹了“Oracle12c怎么創建與刪除CDB、PDBs”的有關知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領大家學習一下如何處理這些情況吧!希望大家仔細閱讀,能夠學有所成!
準備足夠的內存,磁盤空間;需要考慮的問題包括如下16個方面:
1. PDB數量(max 253) 與空間計劃
2. 后臺進程數量(processes參數):PDB+CDB用戶
3. DB_NAME,global db name
4. Spfile為CDB和PDB共用,pdb可單獨設置參數,操作spfile必須在root
5. 字符集為CDB和PDB共用,推薦al32utf8/al16utf16(國家字符集)
6. 時區可以CDB和PDB統一,也可以PDB單獨設置
7. Db_block_size為CDB內統一且不能修改
8. Online redo log 的block size,redo log和control file都是實例級共用
9. 設計合適的sysaux,分別計劃CDB和PDB的
10. 默認表空間,可分別計劃CDB和PDB默認表空間,共享臨時表空間
11. 默認臨時表空間,可為分別計劃CDB和PDB
12. Undo 表空間,每個實例只有一個active undo 表空間
13. 規劃Service
14. 熟悉CDB和PDB的啟動與關閉
15. 是否使用RAC環境
16. 不支持的特征需要計劃避開
DBCA(推薦)、create database
CREATE DATABASE必須包含ENABLE PLUGGABLE DATABASE從句,數據庫創建時會默認創建root和seed;
數據文件的位置和名字:
1. The SEED FILE_NAME_CONVERT clause
2. Oracle Managed Files
3. The PDB_FILE_NAME_CONVERT initialization parameter
創建CDB
CREATE DATABASE cdb_name
DATAFILE '/u01/app/oracle/oradata/newcdb/system01.dbf' SIZE 325M REUSE
SYSAUX DATAFILE '/u01/app/oracle/oradata/newcdb/sysaux01.dbf' SIZE 325M REUSE
SEED #seed container's tbs
SYSTEM DATAFILES SIZE 125M AUTOEXTEND ON NEXT 10M MAXSIZE UNLIMITED
SYSAUX DATAFILES SIZE 100M
Example 1: Creating a CDB Without Using Oracle Managed Files
CREATE DATABASE newcdb
USER SYS IDENTIFIED BY sys_password
USER SYSTEM IDENTIFIED BY system_password
LOGFILE GROUP 1 ('/u01/logs/my/redo01a.log','/u02/logs/my/redo01b.log')
SIZE 100M BLOCKSIZE 512,
GROUP 2 ('/u01/logs/my/redo02a.log','/u02/logs/my/redo02b.log')
SIZE 100M BLOCKSIZE 512,
GROUP 3 ('/u01/logs/my/redo03a.log','/u02/logs/my/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 deftbs
DATAFILE '/u01/app/oracle/oradata/newcdb/deftbs01.dbf'
SIZE 500M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
DEFAULT TEMPORARY TABLESPACE tempts1
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/pdbseed/')
SYSTEM DATAFILES SIZE 125M AUTOEXTEND ON NEXT 10M MAXSIZE UNLIMITED
SYSAUX DATAFILES SIZE 100M
USER_DATA TABLESPACE usertbs
DATAFILE '/u01/app/oracle/oradata/pdbseed/usertbs01.dbf'
SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;
Example 2: Creating a CDB Using Oracle Managed Files
parameter file:
DB_CREATE_FILE_DEST='/u01/app/oracle/oradata'
This example sets the parameter Oracle ASM storage:
DB_CREATE_FILE_DEST = +data
CREATE DATABASE newcdb
USER SYS IDENTIFIED BY sys_password
USER SYSTEM IDENTIFIED BY system_password
EXTENT MANAGEMENT LOCAL
DEFAULT TABLESPACE users
DEFAULT TEMPORARY TABLESPACE temp
UNDO TABLESPACE undotbs1
ENABLE PLUGGABLE DATABASE
SEED
SYSTEM DATAFILES SIZE 125M AUTOEXTEND ON NEXT 10M MAXSIZE UNLIMITED
SYSAUX DATAFILES SIZE 100M;
執行catcdb.sql,安裝CDB組件
@?/rdbms/admin/catcdb.sql
SYSDBA 執行如下腳本:
@?/rdbms/admin/catalog.sql
@?/rdbms/admin/catproc.sql
@?/rdbms/admin/utlrp.sql
SYSTEM 用戶執行:
@?/sqlplus/admin/pupbld.sql
SYSDBA 權限執行:
exec DBMS_XDB_CONFIG.SETHTTPPORT(http_port_number);
exec DBMS_XDB_CONFIG.SETHTTPSPORT(https_port_number);
每個container必須使用一個唯一的端口,訪問方法:
http://database_hostname:http_port_number/em/
https://database_hostname:https_port_number/em/
Figure 38-1 Options for Creating a PDB
Technique | Description |
Create a PDB by using the seed | Create a PDB in a CDB using the files of the seed. This technique copies the files associated with the seed to a new location and associates the copied files with the new PDB. |
Create a PDB by cloning an existing PDB or non-CDB | Create a PDB by cloning a source PDB or non-CDB and plugging the clone into the CDB. A source can be a PDB in the local CDB, a PDB in a remote CDB, or a non-CDB. This technique copies the files associated with the source to a new location and associates the copied files with the new PDB. |
Create a PDB by plugging an unplugged PDB into a CDB | Create a PDB by using the XML metadata file that describes the PDB and the files associated with the PDB to plug it into the CDB. |
Create a PDB by using a non-CDB | Create a PDB by moving a non-CDB into a PDB. You can use the |
a. 存儲限制
STORAGE (MAXSIZE 2G)
STORAGE (MAXSIZE UNLIMITED)
b. PDB文件位置
FILE_NAME_CONVERT
DB_CREATE_FILE_DEST
PDB_FILE_NAME_CONVERT
PATH_PREFIX #pdb
文件位置限制
SOURCE_FILE_NAME_CONVERT
、
SOURCE_FILE_DIRECTORY #
插拔
pdb
的
c. 其他
SERVICE_NAME_CONVERT #重命名服務名
TEMPFILE REUSE #
臨時文件重用
USER_TABLESPACES #move non-cdb to pdb時指定TBS,ALL /ALL EXCEPT /NONE/list('tbs1','tbs4','tbs5')
LOGGING/NOLOGGING #
表空間日志記錄
STANDBYS=ALL/NONE #standby CDB
NO DATA #克隆pdb時,指定不克隆數據
在創建PDB之前,必須滿足先決條件。確保在創建PDB之前滿足以下先決條件:
?CDB必須存在。參見創建和配置CDB。
?CDB必須處于讀/寫模式。
?當前用戶必須是root容器的Common User。
?當前用戶必須具有CREATE PLUGGABLE DATABASE系統權限。
?您必須為每個PDB確定唯一的PDB名稱。每個PDB名稱在單個CDB中必須是惟一的,并且每個PDB名稱在其實例通過特定偵聽器到達的所有CDBs的范圍內必須是惟一的。
在使用SNAPSHOT COPY子句時,源PDB的所有數據文件必須存儲在相同的存儲類型中。
當使用SNAPSHOT COPY子句創建源PDB的克隆且CLONEDB初始化參數設置為FALSE時,源PDB文件的底層文件系統必須支持存儲快照。這些文件系統包括Oracle自動存儲管理集群文件系統(Oracle ACFS)和直接NFS客戶端存儲。
當你使用SNAPSHOT COPY來創建一個克隆,CLONEDB初始化參數設置為TRUE,底層文件系統源碼PDB文件可以是任何的本地文件系統、網絡文件系統(NFS),或集群文件系統,直接啟用NFS。但是,只要存在克隆,源PDB必須保持開放只讀模式。
Example 38-18 Creating a PDB Using No Clauses
CREATE PLUGGABLE DATABASE salespdb ADMIN USER salesadm IDENTIFIED BY password;
Example 38-19 Creating a PDB and Granting Predefined Oracle Roles to the PDB Administrator
CREATE PLUGGABLE DATABASE salespdb ADMIN USER salesadm IDENTIFIED BY password
ROLES=(DBA);
Example 38-20 Creating a PDB Using the STORAGE, DEFAULT TABLESPACE, PATH_PREFIX, and FILE_NAME_CONVERT Clauses
CREATE PLUGGABLE DATABASE salespdb ADMIN USER salesadm IDENTIFIED BY password
STORAGE (MAXSIZE 2G)
DEFAULT TABLESPACE sales
DATAFILE '/disk1/oracle/dbs/salespdb/sales01.dbf' SIZE 250M AUTOEXTEND ON
PATH_PREFIX = '/disk1/oracle/dbs/salespdb/'
FILE_NAME_CONVERT = ('/disk1/oracle/dbs/pdbseed/', '/disk1/oracle/dbs/salespdb/');
A. 克隆Local PDB
Example 38-21 Cloning a Local PDB Using No Clauses
CREATE PLUGGABLE DATABASE pdb2 FROM pdb1;
Example 38-22 Cloning a Local PDB With the PATH_PREFIX, FILE_NAME_CONVERT, and SERVICE_NAME_CONVERT Clauses
CREATE PLUGGABLE DATABASE pdb2 FROM pdb1
PATH_PREFIX = '/disk2/oracle/pdb2'
FILE_NAME_CONVERT = ('/disk1/oracle/pdb1/', '/disk2/oracle/pdb2/')
SERVICE_NAME_CONVERT = ('salesrep','salesperson','orders','orderentry')
NOLOGGING;
Example 38-23 Cloning a Local PDB Using the FILE_NAME_CONVERT, STORAGE, and SERVICE_NAME_CONVERT Clauses
CREATE PLUGGABLE DATABASE pdb2 FROM pdb1
FILE_NAME_CONVERT = ('/disk1/oracle/pdb1/', '/disk2/oracle/pdb2/')
STORAGE (MAXSIZE 2G)
SERVICE_NAME_CONVERT = ('salesrep','salesperson','orders','orderentry');
Example 38-24 Cloning a Local PDB Without Cloning Its Data
ALTER PLUGGABLE DATABASE pdb1 OPEN READ ONLY;
CREATE PLUGGABLE DATABASE pdb2 FROM pdb1 NO DATA;
ALTER PLUGGABLE DATABASE pdb2 OPEN;
B. 克隆遠程PDB 或者non-CDB
Example 38-25 Creating a PDB by Cloning a Remote PDB Using No Clauses
CREATE PLUGGABLE DATABASE pdb2 FROM pdb1@pdb1_link;
Example 38-26 Creating a PDB by Cloning a Remote Non-CDB
CREATE PLUGGABLE DATABASE pdb2 FROM mydb@mydb_link;
@$ORACLE_HOME/rdbms/admin/noncdb_to_pdb.sql
BEGIN
DBMS_PDB.DESCRIBE(
pdb_descr_file => '/disk1/oracle/salespdb.xml',
pdb_name => 'SALESPDB');
END;
/
SET SERVEROUTPUT ON
DECLARE
compatible CONSTANT VARCHAR2(3) :=
CASE DBMS_PDB.CHECK_PLUG_COMPATIBILITY(
pdb_descr_file => '/disk1/usr/salespdb.xml',
pdb_name => 'SALESPDB')
WHEN TRUE THEN 'YES'
ELSE 'NO'
END;
BEGIN
DBMS_OUTPUT.PUT_LINE(compatible);
END;
/
Example 38-27 Plugging In an Unplugged PDB Using the NOCOPY Clause
CREATE PLUGGABLE DATABASE salespdb USING '/disk1/usr/salespdb.xml'
NOCOPY
TEMPFILE REUSE;
Example 38-28 Plugging In an Unplugged PDB Using the AS CLONE and NOCOPY Clauses
CREATE PLUGGABLE DATABASE salespdb AS CLONE USING '/disk1/usr/salespdb.xml'
NOCOPY
TEMPFILE REUSE;
Example 38-29 Plugging In an Unplugged PDB Using the SOURCE_FILE_NAME_CONVERT, NOCOPY, and STORAGE Clauses
CREATE PLUGGABLE DATABASE salespdb USING '/disk1/usr/salespdb.xml'
SOURCE_FILE_NAME_CONVERT = ('/disk1/oracle/sales/', '/disk2/oracle/sales/')
NOCOPY
STORAGE (MAXSIZE 2G)
TEMPFILE REUSE;
Example 38-30 Plugging In an Unplugged PDB With the COPY, PATH_PREFIX, and FILE_NAME_CONVERT Clauses
CREATE PLUGGABLE DATABASE salespdb USING '/disk1/usr/salespdb.xml'
COPY
PATH_PREFIX = '/disk2/oracle/sales/'
FILE_NAME_CONVERT = ('/disk1/oracle/sales/', '/disk2/oracle/sales/');
Example 38-31 Plugging In an Unplugged PDB Using the SOURCE_FILE_NAME_CONVERT, MOVE, FILE_NAME_CONVERT, and STORAGE Clauses
CREATE PLUGGABLE DATABASE salespdb USING '/disk1/usr/salespdb.xml'
SOURCE_FILE_NAME_CONVERT = ('/disk1/oracle/sales/', '/disk2/oracle/sales/')
MOVE
FILE_NAME_CONVERT = ('/disk2/oracle/sales/', '/disk3/oracle/sales/')
STORAGE (MAXSIZE 2G);
Example 38-32 Plugging In an Unplugged PDB Using the SOURCE_FILE_DIRECTORY, MOVE, FILE_NAME_CONVERT, and STORAGE Clauses
CREATE PLUGGABLE DATABASE salespdb USING '/disk1/usr/salespdb.xml'
SOURCE_FILE_DIRECTORY = '/disk2/oracle/sales/'
MOVE
FILE_NAME_CONVERT = ('/disk2/oracle/sales/', '/disk3/oracle/sales/')
STORAGE (MAXSIZE 2G);
BEGIN
DBMS_PDB.DESCRIBE(
pdb_descr_file => '/disk1/oracle/ncdb.xml');
END;
/
SET SERVEROUTPUT ON
DECLARE
compatible CONSTANT VARCHAR2(3) :=
CASE DBMS_PDB.CHECK_PLUG_COMPATIBILITY(
pdb_descr_file => '/disk1/oracle/ncdb.xml',
pdb_name => 'NCDB')
WHEN TRUE THEN 'YES'
ELSE 'NO'
END;
BEGIN
DBMS_OUTPUT.PUT_LINE(compatible);
END;
/
CREATE PLUGGABLE DATABASE ncdb USING '/disk1/oracle/ncdb.xml'
COPY
FILE_NAME_CONVERT = ('/disk1/oracle/dbs/', '/disk2/oracle/ncdb/')
USER_TABLESPACES=('tbs3');
@$ORACLE_HOME/rdbms/admin/noncdb_to_pdb.sql
Example 38-33 Unplugging PDB salespdb
ALTER PLUGGABLE DATABASE salespdb UNPLUG INTO '/oracle/data/salespdb.xml';
刪除PDB時,將修改CDB的控制文件,以消除對刪除的PDB的所有引用。與PDB關聯的歸檔重做日志文件和備份不會被刪除,但是您可以使用Oracle Recovery Manager (RMAN)刪除它們。
Example 38-34 Dropping PDB salespdb While Keeping Its Data Files
DROP PLUGGABLE DATABASE salespdb KEEP DATAFILES;
Example 38-35 Dropping PDB salespdb and Its Data Files
DROP PLUGGABLE DATABASE salespdb INCLUDING DATAFILES;
“Oracle12c怎么創建與刪除CDB、PDBs”的內容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業相關的知識可以關注億速云網站,小編將為大家輸出更多高質量的實用文章!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。