DBCA静默创建CDB容器数据库
创建CDB数据库的几种方式
在Oracle 19c中,若要创建CDB容器数据库环境,可以使用如下几种办法:
1、DBCA静默创建CDB
2、DBCA图形化界面创建CDB
3、手动创建CDB,即使用create database来创建CDB
4、duplicate a CDB
5、Using DBCA to Duplicate a CDB
在OCP的课件中,Oracle给我们提供了如下图的几种方式:
从本节开始,麦老师将依次讲解使用DBCA静默创建CDB 、DBCA图形化界面创建CDB、手动创建CDB,即使用create database来创建CDB 、duplicate a CDB、Using DBCA to Duplicate a CDB这5种方式来创建CDB。
使用DBCA静默创建CDB的几种情况
麦老师觉得,这种方式创建数据库,是一个DBA必须要会的技能。想起曾几何时,领导让我创建一个数据库,而我还傻傻的向领导去申请Xmanager Enterprise软件,还告诉领导,有这个软件才能把图形界面调出来,进而才能创建数据库,哎,,,
静默删库:
dbca -silent -deleteDatabase -sourceDB lhr19cdb -sysDBAUserName sys -sysDBAPassword lhr -forceArchiveLogDeletion
创建存储为磁盘组的CDB单实例数据库:
dbca -silent -ignorePreReqs -ignorePrereqFailure -createDatabase -templateName General_Purpose.dbc -responseFile NO_VALUE \
-gdbname lhr19cdb -sid lhr19cdb \
-createAsContainerDatabase TRUE \
-sysPassword lhr -systemPassword lhr -pdbAdminPassword lhr -dbsnmpPassword lhr \
-datafileDestination '+DATA' -recoveryAreaDestination '+FRA' \
-redoLogFileSize 50 \
-storageType ASM \
-characterset AL32UTF8 \
-sampleSchema true \
-totalMemory 1024 \
-databaseType MULTIPURPOSE \
-emConfiguration NONE
创建rac类型的CDB数据库:
dbca -silent -ignorePreReqs -ignorePrereqFailure -createDatabase -templateName General_Purpose.dbc -responseFile NO_VALUE \
-gdbname rac19c -sid rac19c \
-createAsContainerDatabase TRUE \
-sysPassword lhr -systemPassword lhr -pdbAdminPassword lhr -dbsnmpPassword lhr \
-datafileDestination '+DATA' -recoveryAreaDestination '+FRA' \
-redoLogFileSize 50 \
-storageType ASM \
-characterset AL32UTF8 \
-sampleSchema true \
-totalMemory 1024 \
-databaseType MULTIPURPOSE \
-emConfiguration none \
-nodeinfo raclhr-19c-n1,raclhr-19c-n2
创建FS存储方式的单实例(不含PDB)数据库:
dbca -silent -createDatabase -templateName General_Purpose.dbc -responseFile NO_VALUE \
-gdbname CDBLHR -sid CDBLHR \
-createAsContainerDatabase TRUE \
-sysPassword lhr -systemPassword lhr \
-datafileDestination '/u01/app/oracle/oradata' \
-recoveryAreaDestination '/u01/app/oracle/flash_recovery_area' \
-redoLogFileSize 50 \
-storageType FS \
-characterset ZHS16GBK -nationalCharacterSet AL16UTF16 \
-sampleSchema true \
-totalMemory 1024 \
-databaseType OLTP \
-emConfiguration NONE
创建FS存储方式的单实例(含一个PDB)数据库:
dbca -silent -createDatabase -templateName General_Purpose.dbc -responseFile NO_VALUE \
-gdbname CDBLHR3 -sid CDBLHR3 \
-createAsContainerDatabase TRUE \
-numberOfPDBs 1 \
-pdbName pdb2 \
-pdbAdminPassword lhr \
-sysPassword lhr -systemPassword lhr \
-datafileDestination '/u01/app/oracle/oradata' \
-recoveryAreaDestination '/u01/app/oracle/flash_recovery_area' \
-redoLogFileSize 50 \
-storageType FS \
-characterset ZHS16GBK -nationalCharacterSet AL16UTF16 \
-sampleSchema true \
-totalMemory 1024 \
-databaseType OLTP \
-emConfiguration NONE
静默方式创建一个非CDB数据库:
dbca -silent -ignorePreReqs -ignorePrereqFailure -createDatabase -templateName General_Purpose.dbc -responseFile NO_VALUE \
-gdbname lhrdb -sid lhrdb \
-createAsContainerDatabase FALSE \
-sysPassword lhr -systemPassword lhr -dbsnmpPassword lhr \
-datafileDestination '/u01/app/oracle/oradata' -recoveryAreaDestination '/u01/app/oracle/flash_recovery_area' \
-storageType FS \
-characterset ZHS16GBK \
-sampleSchema true \
-totalMemory 600 \
-databaseType MULTIPURPOSE \
-emConfiguration NONE
创建CDB数据库示例
麦老师不能把所有情况都演示一次,我这里只演示其中的一种,其它情况大家自行测试。
接下来创建的是一个文件系统存储的CDB数据库,默认包含一个PDB,脚本如下所示:
dbca -silent -createDatabase -templateName General_Purpose.dbc -responseFile NO_VALUE \
-gdbname CDBLHR -sid CDBLHR \
-createAsContainerDatabase TRUE \
-numberOfPDBs 1 \
-pdbName pdb2 \
-pdbAdminPassword lhr \
-sysPassword lhr -systemPassword lhr \
-datafileDestination '/u01/app/oracle/oradata' \
-recoveryAreaDestination '/u01/app/oracle/flash_recovery_area' \
-redoLogFileSize 50 \
-storageType FS \
-characterset AL32UTF8 -nationalCharacterSet AL16UTF16 \
-sampleSchema true \
-totalMemory 1024 \
-databaseType OLTP \
-emConfiguration NONE
执行过程:
[oracle@lhrora19c ~]$ sqlplus -v
SQL*Plus: Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
[oracle@lhrora19c ~]$ dbca -silent -createDatabase -templateName General_Purpose.dbc -responseFile NO_VALUE \
> -gdbname CDBLHR -sid CDBLHR \
> -createAsContainerDatabase TRUE \
> -numberOfPDBs 1 \
> -pdbName pdb2 \
> -pdbAdminPassword lhr \
> -sysPassword lhr -systemPassword lhr \
> -datafileDestination '/u01/app/oracle/oradata' \
> -recoveryAreaDestination '/u01/app/oracle/flash_recovery_area' \
> -redoLogFileSize 50 \
> -storageType FS \
> -characterset AL32UTF8 -nationalCharacterSet AL16UTF16 \
> -sampleSchema true \
> -totalMemory 1024 \
> -databaseType OLTP \
> -emConfiguration NONE
[WARNING] [DBT-06208] The 'SYS' password entered does not conform to the Oracle recommended standards.
CAUSE:
a. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9].
b.The password entered is a keyword that Oracle does not recommend to be used as password
ACTION: Specify a strong password. If required refer Oracle documentation for guidelines.
[WARNING] [DBT-06208] The 'SYSTEM' password entered does not conform to the Oracle recommended standards.
CAUSE:
a. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9].
b.The password entered is a keyword that Oracle does not recommend to be used as password
ACTION: Specify a strong password. If required refer Oracle documentation for guidelines.
[WARNING] [DBT-06208] The 'PDBADMIN' password entered does not conform to the Oracle recommended standards.
CAUSE:
a. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9].
b.The password entered is a keyword that Oracle does not recommend to be used as password
ACTION: Specify a strong password. If required refer Oracle documentation for guidelines.
Prepare for db operation
8% complete
Copying database files
31% complete
Creating and starting Oracle instance
32% complete
36% complete
40% complete
43% complete
46% complete
Completing Database Creation
51% complete
53% complete
54% complete
Creating Pluggable Databases
58% complete
77% complete
Executing Post Configuration Actions
100% complete
Database creation complete. For details check the logfiles at:
/opt/oracle/cfgtoollogs/dbca/CDBLHR.
Database Information:
Global Database Name:CDBLHR
System Identifier(SID):CDBLHR
Look at the log file "/opt/oracle/cfgtoollogs/dbca/CDBLHR/CDBLHR.log" for further details.
这样我们就创建完一个CDB数据库,不用做其他交互式操作,是不是非常简单?我们进入数据库就可以做基本的操作了。
[oracle@lhrora19c ~]$ ORACLE_SID=CDBLHR
[oracle@lhrora19c ~]$ sas
SQL*Plus: Release 19.0.0.0.0 - Production on Fri Oct 23 16:20:12 2020
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
SYS@CDBLHR> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB2 READ WRITE NO
有关每个参数的详细含义和静默建库的常见故障处理请参考:【DB笔试面试852】在Oracle中,什么是静默建库?
DBCA静默建库如何创建归档模式的数据库
DBCA静默建库默认创建的是一个非归档的数据库,这是由配置文件$ORACLE_HOME/assistants/dbca/templates/General_Purpose.dbc决定的,如下:
[oracle@lhrora19c ~]$ strings $ORACLE_HOME/assistants/dbca/templates/General_Purpose.dbc | grep -i arch
<archiveLogMode>false</archiveLogMode>
[oracle@lhrora19c ~]$
所以,若想创建一个归档模式的数据库,可以将该值修改为true,后续所有DBCA创建的数据库都是一个归档模式的数据库。
DBCA静默建库的日志在哪里?
11g开始:$ORACLE_BASE/cfgtoollogs/dbca
10g:$ORACLE_HOME/cfgtoollogs/dbca
从该日志中可以找到DBCA静默建库的详细过程,值得我们深入分析。
本文结束。
- 点赞
- 收藏
- 关注作者
评论(0)