This post demonstrates how to create a new database using the Database Configuration Assistant (DBCA) in silent mode. In addition to creating databases, the DBCA can be used to modify or delete them, as well as managing templates and pluggable databases in Oracle 12c. All these actions are also possible in silent mode, but they are not the subject of this post.
Response File
Response files provide all the answers to the questions normally asked by the Database Configuration Assistant (DBCA). You can find a sample DBCA response file under the ORACLE_HOME ($ORACLE_HOME/assistants/dbca/dbca.rsp). This dbca.rsp file is an example from Oracle 12c, used to create a container database (cdb2) with a single pluggable database (pdb2).
Once you have amended the response file to your satisfaction, simply reference it when running the DBCA in silent mode.
$ dbca -silent -responseFile ./dbca.rsp
Copying database files
1% complete
2% complete
8% complete
13% complete
19% complete
27% complete
Creating and starting Oracle instance
29% complete
32% complete
33% complete
34% complete
38% complete
42% complete
43% complete
45% complete
Completing Database Creation
48% complete
51% complete
53% complete
62% complete
70% complete
72% complete
Creating Pluggable Databases
78% complete
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/cdb2/cdb2.log" for further details.
$
The DBCA response file looks really big and complicated. The same response file can be used to perform multiple actions against the database. The response file contains several sections, each dealing with different actions.
◉ [CREATEDATABASE]
◉ [createTemplateFromDB]
◉ [createCloneTemplate]
◉ [DELETEDATABASE]
◉ [generateScripts]
◉ [CONFIGUREDATABASE]
◉ [ADDINSTANCE]
◉ [DELETEINSTANCE]
◉ [CREATEPLUGGABLEDATABASE]
◉ [UNPLUGDATABASE]
◉ [DELETEPLUGGABLEDATABASE]
◉ [CONFIGUREPLUGGABLEDATABASE]
You only have to amend the section relevant to the action you want to perform, so you can ignore most of the file if you are only performing a single action.
Command Line
An alternative to the response file approach is to specify all the parameter values directly on the command line. For simple actions, this looks a lot clearer as you only have to specify non-default values for the action you are trying to perform. The following example creates a new container database (cdb3) with a single pluggable database (pdb1). The memory and redo log sizes are specified in megabytes.
$ dbca -silent -createDatabase \
-templateName General_Purpose.dbc \
-gdbname cdb3 -sid cdb3 -responseFile NO_VALUE \
-characterSet AL32UTF8 \
-sysPassword OraPasswd1 \
-systemPassword OraPasswd1 \
-createAsContainerDatabase true \
-numberOfPDBs 1 \
-pdbName pdb3 \
-pdbAdminPassword OraPasswd1 \
-databaseType MULTIPURPOSE \
-memoryMgmtType auto_sga \
-totalMemory 1536 \
-storageType FS \
-datafileDestination "/u01/app/oracle/oradata/" \
-redoLogFileSize 50 \
-emConfiguration NONE \
-ignorePreReqs
Copying database files
1% complete
2% complete
8% complete
13% complete
19% complete
27% complete
Creating and starting Oracle instance
29% complete
32% complete
33% complete
34% complete
38% complete
42% complete
43% complete
45% complete
Completing Database Creation
48% complete
51% complete
53% complete
62% complete
70% complete
72% complete
Creating Pluggable Databases
78% complete
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/cdb3/cdb3.log" for further details.
$
Prior to 12.2, "-memoryMgmtType auto_sga" should be replaced by "-automaticMemoryManagement false", as shown in the 12.1 docs.
The following commands will delete the databases we created earlier.
$ dbca -silent -deleteDatabase -sourceDB cdb2 -sysDBAUserName sys -sysDBAPassword OraPasswd1
Connecting to database
4% complete
9% complete
14% complete
19% complete
23% complete
28% complete
47% complete
Updating network configuration files
48% complete
52% complete
Deleting instance and datafiles
76% complete
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/cdb2.log" for further details.
$
$ dbca -silent -deleteDatabase -sourceDB cdb3 -sysDBAUserName sys -sysDBAPassword OraPasswd1
Connecting to database
4% complete
9% complete
14% complete
19% complete
23% complete
28% complete
47% complete
Updating network configuration files
48% complete
52% complete
Deleting instance and datafiles
76% complete
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/cdb3.log" for further details.
Oracle Managed Files (OMF) in 18c
In Oracle 18c (18.4) you can use the -useOMF flag to indicate you want to enable Oracle Managed Files (OMF) during the database creation with the Database Configuration Assistant (DBCA).
$ dbca -silent -createDatabase \
-templateName General_Purpose.dbc \
-gdbname cdb3 -sid cdb3 -responseFile NO_VALUE \
-characterSet AL32UTF8 \
-sysPassword OraPasswd1 \
-systemPassword OraPasswd1 \
-createAsContainerDatabase true \
-numberOfPDBs 1 \
-pdbName pdb3 \
-pdbAdminPassword OraPasswd1 \
-databaseType MULTIPURPOSE \
-memoryMgmtType auto_sga \
-totalMemory 1536 \
-storageType FS \
-datafileDestination "/u01/app/oracle/oradata/" \
-useOMF true \
-redoLogFileSize 50 \
-emConfiguration NONE \
-ignorePreReqs
0 comments:
Post a Comment