How to Create a 19c Database by DBCA with Silent Mode

  • by

After installing Oracle 19c software only with silent mode, you may like to create a database by Database Configuration Assistant (DBCA) with silent mode, too.

Please make sure that the listener is configured and running.

A. Create Database with Response File

First of all, let's take a look at the content of the response file.

[oracle@primary-19c ~]$ vi dbca-compdb-primdb.rsp
responseFileVersion=/oracle/assistants/rspfmt_dbca_response_schema_v12.2.0
gdbName=COMPDB
databaseConfigType=SI
policyManaged=false
createServerPool=false
force=false
createAsContainerDatabase=false
numberOfPDBs=0
useLocalUndoForPDBs=true
templateName=/u01/app/oracle/product/19.0.0/dbhome_1/assistants/dbca/templates/General_Purpose.dbc
sysPassword=welcome1
systemPassword=welcome1
emConfiguration=DBEXPRESS
emExpressPort=5500
runCVUChecks=FALSE
omsPort=0
dvConfiguration=false
olsConfiguration=false
datafileJarLocation={ORACLE_HOME}/assistants/dbca/templates/
datafileDestination={ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/
recoveryAreaDestination={ORACLE_BASE}/fast_recovery_area/{DB_UNIQUE_NAME}
storageType=FS
characterSet=AL32UTF8
nationalCharacterSet=AL16UTF16
registerWithDirService=false
listeners=LISTENER
variables=ORACLE_BASE_HOME=/u01/app/oracle/product/19.0.0/dbhome_1,ORACLE_BASE=/u01/app/oracle,PDB_NAME=,DB_NAME=COMPDB,ORACLE_HOME=/u01/app/oracle/product/19.0.0/dbhome_1
initParams=undo_tablespace=UNDOTBS1,db_block_size=8192BYTES,nls_language=AMERICAN,dispatchers=(PROTOCOL=TCP) (SERVICE=PRIMDBXDB),diagnostic_dest={ORACLE_BASE},control_files=("{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/control01.ctl", "{ORACLE_BASE}/fast_recovery_area/{DB_UNIQUE_NAME}/control02.ctl"),remote_login_passwordfile=EXCLUSIVE,audit_file_dest={ORACLE_BASE}/admin/{DB_UNIQUE_NAME}/adump,processes=500,nls_territory=AMERICA,memory_target=1470MB,db_recovery_file_dest_size=50GB,open_cursors=300,log_archive_format=%t_%s_%r.dbf,compatible=19.0.0,db_name=COMPDB,db_recovery_file_dest={ORACLE_BASE}/fast_recovery_area/{DB_UNIQUE_NAME},audit_trail=db
sampleSchema=true
memoryPercentage=40
databaseType=MULTIPURPOSE
automaticMemoryManagement=true
totalMemory=0
redoLogFileSize=1024

Please note that, redoLogFileSize is the parameter that can set redo log size. In this case, we set them as 1024MB. On the other side, you can also change redo log size in DBCA or OUI interactive mode.

Next, we create a 19c database with silent mode.

[oracle@primary-19c ~]$ dbca -silent -createDatabase -initParams db_unique_name=PRIMDB -responseFile ./dbca-compdb-primdb.rsp
Prepare for db operation
10% complete
Copying database files
40% complete
Creating and starting Oracle instance
42% complete
46% complete
50% complete
54% complete
58% complete
60% complete
Completing Database Creation
66% complete
70% complete
Executing Post Configuration Actions
100% complete
Database creation complete. For details check the logfiles at:
 /u01/app/oracle/cfgtoollogs/dbca/PRIMDB.
Database Information:
Global Database Name:PRIMDB
System Identifier(SID):PRIMDB
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/PRIMDB/PRIMDB.log" for further details.

Please note that, in this case, DB_UNIQUE_NAME is PRIMDB and DB_NAME is COMPDB. They are different. If your DB_UNIQUE_NAME and DB_NAME are the same, you don't have to specify -initParams in the command.

Please note that, although I set sampleSchema=true, OUI installed only HR schema, if you want the rest sample schemas, you have to know how to install complete sample schemas.

B. Create Database with Command Line

Without response file, we have to put all arguments in the command line in order to use DBCA with silent mode. Of course, we can mix response file and command line to formulate a more controllable result, but the rule is that arguments in command line override any other settings.

The following is the copy-able command.

dbca \
-silent \
-createDatabase \
-gdbName COMPDB \
-databaseConfigType SI \
-numberOfPDBs 0 \
-useLocalUndoForPDBs true \
-templateName /u01/app/oracle/product/19.0.0/dbhome_1/assistants/dbca/templates/General_Purpose.dbc \
-sysPassword welcome1 \
-systemPassword welcome1 \
-emConfiguration DBEXPRESS \
-emExpressPort 5500 \
-omsPort 0 \
-datafileJarLocation {ORACLE_HOME}/assistants/dbca/templates/ \
-datafileDestination {ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/ \
-recoveryAreaDestination {ORACLE_BASE}/fast_recovery_area/{DB_UNIQUE_NAME} \
-storageType FS \
-characterSet AL32UTF8 \
-nationalCharacterSet AL16UTF16 \
-listeners LISTENER \
-variables ORACLE_BASE_HOME=/u01/app/oracle/product/19.0.0/dbhome_1,ORACLE_BASE=/u01/app/oracle,PDB_NAME=,DB_NAME=COMPDB,ORACLE_HOME=/u01/app/oracle/product/19.0.0/dbhome_1 \
-initParams db_unique_name=PRIMDB,undo_tablespace=UNDOTBS1,db_block_size=8192BYTES,nls_language=AMERICAN,dispatchers=\(PROTOCOL=TCP\) \(SERVICE=PRIMDBXDB\),diagnostic_dest={ORACLE_BASE},control_files=\("{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/control01.ctl", "{ORACLE_BASE}/fast_recovery_area/{DB_UNIQUE_NAME}/control02.ctl"\),remote_login_passwordfile=EXCLUSIVE,audit_file_dest={ORACLE_BASE}/admin/{DB_UNIQUE_NAME}/adump,processes=500,nls_territory=AMERICA,memory_target=1470MB,db_recovery_file_dest_size=50GB,open_cursors=300,log_archive_format=%t_%s_%r.dbf,compatible=19.0.0,db_name=COMPDB,db_recovery_file_dest={ORACLE_BASE}/fast_recovery_area/{DB_UNIQUE_NAME},audit_trail=db \
-sampleSchema true \
-memoryPercentage 40 \
-databaseType MULTIPURPOSE \
-automaticMemoryManagement true \
-redoLogFileSize 1024

The execution result is as following:

[oracle@primary-19c ~]$ dbca \
> -silent \
> -createDatabase \
> -gdbName COMPDB \
> -databaseConfigType SI \
> -numberOfPDBs 0 \
> -useLocalUndoForPDBs true \
> -templateName /u01/app/oracle/product/19.0.0/dbhome_1/assistants/dbca/templates/General_Purpose.dbc \
> -sysPassword welcome1 \
> -systemPassword welcome1 \
> -emConfiguration DBEXPRESS \
> -emExpressPort 5500 \
> -omsPort 0 \
> -datafileJarLocation {ORACLE_HOME}/assistants/dbca/templates/ \
> -datafileDestination {ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/ \
> -recoveryAreaDestination {ORACLE_BASE}/fast_recovery_area/{DB_UNIQUE_NAME} \
> -storageType FS \
> -characterSet AL32UTF8 \
> -nationalCharacterSet AL16UTF16 \
> -listeners LISTENER \
> -variables ORACLE_BASE_HOME=/u01/app/oracle/product/19.0.0/dbhome_1,ORACLE_BASE=/u01/app/oracle,PDB_NAME=,DB_NAME=COMPDB,ORACLE_HOME=/u01/app/oracle/product/19.0.0/dbhome_1 \
> -initParams db_unique_name=PRIMDB,undo_tablespace=UNDOTBS1,db_block_size=8192BYTES,nls_language=AMERICAN,dispatchers=\(PROTOCOL=TCP\) \(SERVICE=PRIMDBXDB\),diagnostic_dest={ORACLE_BASE},control_files=\("{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/control01.ctl", "{ORACLE_BASE}/fast_recovery_area/{DB_UNIQUE_NAME}/control02.ctl"\),remote_login_passwordfile=EXCLUSIVE,audit_file_dest={ORACLE_BASE}/admin/{DB_UNIQUE_NAME}/adump,processes=500,nls_territory=AMERICA,memory_target=1470MB,db_recovery_file_dest_size=50GB,open_cursors=300,log_archive_format=%t_%s_%r.dbf,compatible=19.0.0,db_name=COMPDB,db_recovery_file_dest={ORACLE_BASE}/fast_recovery_area/{DB_UNIQUE_NAME},audit_trail=db \
> -sampleSchema true \
> -memoryPercentage 40 \
> -databaseType MULTIPURPOSE \
> -automaticMemoryManagement true \
> -redoLogFileSize 1024
Prepare for db operation
10% complete
Copying database files
40% complete
Creating and starting Oracle instance
42% complete
46% complete
50% complete
54% complete
58% complete
60% complete
Completing Database Creation
66% complete
70% complete
Executing Post Configuration Actions
100% complete
Database creation complete. For details check the logfiles at:
 /u01/app/oracle/cfgtoollogs/dbca/PRIMDB.
Database Information:
Global Database Name:PRIMDB
System Identifier(SID):PRIMDB
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/PRIMDB/PRIMDB.log" for further details.

Please note that, DB_UNIQUE_NAME and SID configured in VARIABLE is useless. We should set it in initParam if you want a different DB_UNIQUE_NAME from DB_NAME.

If you still have the problem to set a different DB_UNIQUE_NAME during database creation, you can also change DB_UNIQUE_NAME after the database created.

Oracle talks about the problem of naming a different DB_UNIQUE_NAME in the document: DBCA Silent Mode Is Not Setting DB_UNIQUE_NAME Even Though It Is Specified In DBCA Template File. (Doc ID 1508337.1).

It means that parameter in command line takes precedence over template file and response file.

C. Modify Template File Optionally

If you want a more controllable database creation, you may additionally modify the template too. For example, if you want more redo groups 4, 5, and 6, you can add some elements before database creation:

[oracle@primary-19c ~]$ vi $ORACLE_HOME/assistants/dbca/templates/General_Purpose.dbc
...
      <RedoLogGroupAttributes id="4">
         <reuse>false</reuse>
         <fileSize unit="KB">1024000</fileSize>
         <Thread>1</Thread>
         <member ordinal="0" memberName="redo04.log" filepath="{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/"/>
      </RedoLogGroupAttributes>
      <RedoLogGroupAttributes id="5">
         <reuse>false</reuse>
         <fileSize unit="KB">1024000</fileSize>
         <Thread>1</Thread>
         <member ordinal="0" memberName="redo05.log" filepath="{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/"/>
      </RedoLogGroupAttributes>
      <RedoLogGroupAttributes id="6">
         <reuse>false</reuse>
         <fileSize unit="KB">1024000</fileSize>
         <Thread>1</Thread>
         <member ordinal="0" memberName="redo06.log" filepath="{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/"/>

In my opinion, to use silent mode, you have to know every meaning of each parameters, furthermore, the interaction between parameters. So, silent mode is suitable for mass database creation only.

For single or few times creation, interactive mode is a reliable way to create databases, all variables are grouped into steps, which is more understandable and less error-prone, especially when we are in an unclear, doubtful or controversial environment.

Further Readings

I think maybe you would like to know the differences between DB_NAME and DB_UNIQUE_NAME?

Next, I'll talk about how to duplicate a 19c physical standby database for building a data guard environment.

Leave a Reply

Your email address will not be published. Required fields are marked *