oracle 11g使用DBCA以非互動(靜默)方式建立資料庫

eric0435發表於2014-04-08

使用DBCA以非互動(靜默)方式建立資料庫
透過執行dbca -h | -help來檢視幫助選項
[oracle@jyrac1 ~]$ dbca -help

dbca  [-silent | -progressOnly | -customCreate] {  }  | { [ [options] ] -responseFile   } [-continueOnNonFatalErrors ]
Please refer to the manual for details.
You can enter one of the following command:
建立資料庫的引數如下:
Create a database by specifying the following parameters:
        -createDatabase
                -templateName  現有模板的名稱
                [-cloneTemplate]
                -gdbName   全域性資料庫名
                [-policyManaged | -adminManaged ]
                        [-createServerPool ]
                        [-force ]
                        -serverPoolName 
                        -[cardinality ]
                [-sid ] 資料庫系統識別符號
                [-sysPassword ]
                [-systemPassword ]
                [-emConfiguration 
                        -dbsnmpPassword 
                        -sysmanPassword 
                        [-hostUserName 
                         -hostUserPassword 
                         -backupSchedule ]
                        [-smtpServer 
                         -emailAddress ]
                        [-centralAgent ]]
                [-disableSecurityConfiguration 
                [-datafileDestination  所有資料檔案的目標位置 |  -datafileNames ]
                [-redoLogFileSize ]
                [-recoveryAreaDestination ]
                [-datafileJarLocation  ] 資料檔案 jar 的位置, 只用於複製資料庫的建立
                [-storageType < FS | ASM >
                        [-asmsnmpPassword     ]
                         -diskGroupName   
                         -recoveryGroupName       
                [-characterSet ] 資料庫的字符集
                [-nationalCharacterSet  ] 資料庫的國家字符集
                [-registerWithDirService 
                        -dirServiceUserName     目錄服務的使用者名稱
                        -dirServicePassword     目錄服務的口令
                        -walletPassword    ]
                [-listeners  ] 監聽程式列表, 該列表用於配置具有如下物件的資料庫
                [-variablesFile   ]] 用於模板中成對變數和值的檔名
                [-variables  ]
                [-initParams ]
                [-memoryPercentage ]
                [-automaticMemoryManagement ]
                [-totalMemory ]
                [-databaseType ]]

Configure a database by specifying the following parameters:
        -configureDatabase
                -sourceDB    
                [-sysDBAUserName     
                 -sysDBAPassword     ]
                [-registerWithDirService|-unregisterWithDirService|-regenerateDBPassword 
                        -dirServiceUserName    
                        -dirServicePassword    
                        -walletPassword    ]
                [-disableSecurityConfiguration 
                [-enableSecurityConfiguration 
                [-emConfiguration 
                        -dbsnmpPassword 
                        -symanPassword 
                        [-hostUserName 
                         -hostUserPassword 
                         -backupSchedule ]
                        [-smtpServer 
                         -emailAddress ]
                        [-centralAgent ]]

使用現有資料庫建立模板的引數如下:
Create a template from an existing database by specifying the following parameters:
        -createTemplateFromDB
                -sourceDB    ::> < 服務採用 :: 格式
                -templateName         新的模板名
                -sysDBAUserName         具有SYSDBA許可權的使用者名稱
                -sysDBAPassword      具有SYSDBA許可權的使用者名稱的口令
                [-maintainFileLocations ]

使用現有資料庫建立複製模板的引數如下:
Create a clone template from an existing database by specifying the following parameters:
        -createCloneTemplate
                -sourceSID      源資料庫 sid
                -templateName        新的模板名
                [-sysDBAUserName      具有SYSDBA許可權的使用者名稱
                 -sysDBAPassword     ] 具有SYSDBA許可權的使用者名稱的口令
                [-maintainFileLocations ]
                [-datafileJarLocation       ] 存放壓縮格式資料檔案的目錄

Generate scripts to create database by specifying the following parameters:
        -generateScripts
                -templateName 
                -gdbName 
                [-scriptDest       ]
透過指定以下引數來刪除資料庫
Delete a database by specifying the following parameters:
        -deleteDatabase
                -sourceDB    
                [-sysDBAUserName     
                 -sysDBAPassword     ]

使用silent模式可以透過資料庫建立模析和透過模板來建立資料庫

透過模板來建立資料庫

[oracle@jyrac1 ~]$ dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbname ora11g -sid ora11g -responseFile NO_VALUE -characterSet AL32UTF8 -memoryPercentage 30 -emConfiguration LOCAL
Enter SYS user password:

Enter SYSTEM user password:

Enter DBSNMP user password:

Enter SYSMAN user password:

Copying database files
1% complete
3% complete
11% complete
18% complete
26% complete
37% complete
Creating and starting Oracle instance
40% complete
45% complete
50% complete
55% complete
56% complete
60% complete
62% complete
Completing Database Creation
66% complete
70% complete
73% complete
85% complete
96% complete
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/ora11g/ora11g.log" for further details.
[oracle@jyrac1 ~]$ cat /u01/app/oracle/cfgtoollogs/dbca/ora11g/ora11g.log
Copying database files
DBCA_PROGRESS : 1%
DBCA_PROGRESS : 3%
DBCA_PROGRESS : 11%
DBCA_PROGRESS : 18%
DBCA_PROGRESS : 26%
DBCA_PROGRESS : 37%
Creating and starting Oracle instance
DBCA_PROGRESS : 40%
DBCA_PROGRESS : 45%
DBCA_PROGRESS : 50%
DBCA_PROGRESS : 55%
DBCA_PROGRESS : 56%
DBCA_PROGRESS : 60%
DBCA_PROGRESS : 62%
Completing Database Creation
DBCA_PROGRESS : 66%
DBCA_PROGRESS : 70%
DBCA_PROGRESS : 73%
DBCA_PROGRESS : 85%
DBCA_PROGRESS : 96%
DBCA_PROGRESS : 100%
Database creation complete. For details check the logfiles at:
 /u01/app/oracle/cfgtoollogs/dbca/ora11g.
Database Information:
Global Database Name:ora11g
System Identifier(SID):ora11gThe Database Control URL is 

Management Repository has been placed in secure mode wherein Enterprise Manager data will be encrypted.  The encryption key has been placed in the file: /u01/app/oracle/11.2.0/db/jyrac1_ora11g/sysman/config/emkey.ora.   Please ensure this file is backed up as the encrypted data will become unusable if this file is lost.

資料庫建立成功執行下面命令檢視ora11g的程式資訊

[oracle@jyrac1 ~]$ ps -ef | grep ora11g
oracle    6014     1  0 09:42 pts/1    00:00:00 /u01/app/oracle/11.2.0/db/perl/bin/perl /u01/app/oracle/11.2.0/db/bin/emwd.pl dbconsole /u01/app/oracle/11.2.0/db/jyrac1_ora11g/sysman/log/emdb.nohup
oracle    6032  6014  4 09:42 pts/1    00:00:44 /u01/app/oracle/11.2.0/db/jdk/bin/java -server -Xmx384M -XX:MaxPermSize=400M -XX:MinHeapFreeRatio=20 -XX:MaxHeapFreeRatio=40 -DORACLE_HOME=/u01/app/oracle/11.2.0/db -Doracle.home=/u01/app/oracle/11.2.0/db/oc4j -Doracle.oc4j.localhome=/u01/app/oracle/11.2.0/db/jyrac1_ora11g/sysman -DEMSTATE=/u01/app/oracle/11.2.0/db/jyrac1_ora11g -Doracle.j2ee.dont.use.memory.archive=true -Djava.protocol.handler.pkgs=HTTPClient -Doracle.security.jazn.config=/u01/app/oracle/11.2.0/db/oc4j/j2ee/OC4J_DBConsole_jyrac1_ora11g/config/jazn.xml -Djava.security.policy=/u01/app/oracle/11.2.0/db/oc4j/j2ee/OC4J_DBConsole_jyrac1_ora11g/config/java2.policy -Djavax.net.ssl.KeyStore=/u01/app/oracle/11.2.0/db/sysman/config/OCMTrustedCerts.txt-Djava.security.properties=/u01/app/oracle/11.2.0/db/oc4j/j2ee/home/config/jazn.security.props -DEMDROOT=/u01/app/oracle/11.2.0/db/jyrac1_ora11g -Dsysman.md5password=true -Drepapi.oracle.home=/u01/app/oracle/11.2.0/db -Ddisable.checkForUpdate=true -Doracle.sysman.ccr.ocmSDK.websvc.keystore=/u01/app/oracle/11.2.0/db/jlib/emocmclnt.ks -Dice.pilots.html4.ignoreNonGenericFonts=true -Djava.awt.headless=true -jar /u01/app/oracle/11.2.0/db/oc4j/j2ee/home/oc4j.jar -config /u01/app/oracle/11.2.0/db/oc4j/j2ee/OC4J_DBConsole_jyrac1_ora11g/config/server.xml
oracle    6083     1  1 09:42 ?        00:00:11 oracleora11g (LOCAL=NO)
oracle    6132     1  0 09:42 ?        00:00:02 oracleora11g (LOCAL=NO)
oracle    6220     1  0 09:43 ?        00:00:00 oracleora11g (LOCAL=NO)
oracle    6466     1  0 09:43 ?        00:00:00 oracleora11g (LOCAL=NO)
oracle    6468     1  0 09:43 ?        00:00:00 oracleora11g (LOCAL=NO)
oracle    6480     1  0 09:43 ?        00:00:02 oracleora11g (LOCAL=NO)
oracle    6658     1  0 09:43 ?        00:00:01 oracleora11g (LOCAL=NO)
oracle    6664     1  1 09:43 ?        00:00:12 oracleora11g (LOCAL=NO)
oracle    6718     1  0 09:43 ?        00:00:00 oracleora11g (LOCAL=NO)
oracle    6720     1  0 09:43 ?        00:00:00 oracleora11g (LOCAL=NO)
oracle    8954     1  0 09:58 ?        00:00:00 ora_j000_ora11g
oracle    8956     1  0 09:58 ?        00:00:00 ora_j001_ora11g
oracle    8962 29918  0 09:59 pts/1    00:00:00 grep ora11g
oracle   31058     1  0 09:40 ?        00:00:00 ora_pmon_ora11g
oracle   31060     1  0 09:40 ?        00:00:00 ora_vktm_ora11g
oracle   31064     1  0 09:40 ?        00:00:00 ora_gen0_ora11g
oracle   31066     1  0 09:40 ?        00:00:00 ora_diag_ora11g
oracle   31068     1  0 09:40 ?        00:00:00 ora_dbrm_ora11g
oracle   31070     1  0 09:40 ?        00:00:00 ora_psp0_ora11g
oracle   31072     1  0 09:40 ?        00:00:00 ora_dia0_ora11g
oracle   31074     1  0 09:40 ?        00:00:00 ora_mman_ora11g
oracle   31076     1  0 09:40 ?        00:00:00 ora_dbw0_ora11g
oracle   31078     1  0 09:40 ?        00:00:00 ora_lgwr_ora11g
oracle   31080     1  0 09:40 ?        00:00:00 ora_ckpt_ora11g
oracle   31082     1  0 09:40 ?        00:00:00 ora_smon_ora11g
oracle   31084     1  0 09:40 ?        00:00:00 ora_reco_ora11g
oracle   31086     1  0 09:40 ?        00:00:00 ora_mmon_ora11g
oracle   31088     1  0 09:40 ?        00:00:00 ora_mmnl_ora11g
oracle   31090     1  0 09:40 ?        00:00:00 ora_d000_ora11g
oracle   31092     1  0 09:40 ?        00:00:00 ora_s000_ora11g
oracle   31161     1  0 09:40 ?        00:00:00 ora_qmnc_ora11g
oracle   31177     1  0 09:40 ?        00:00:00 ora_cjq0_ora11g
oracle   31262     1  0 09:40 ?        00:00:00 ora_q000_ora11g
oracle   31264     1  0 09:40 ?        00:00:00 ora_q001_ora11g
oracle   31344     1  0 09:41 ?        00:00:00 ora_smco_ora11g
oracle   31346     1  0 09:41 ?        00:00:00 ora_w000_ora11g

以silent方式來刪除資料庫

[oracle@jyrac1 ~]$ dbca -silent -deleteDatabase -sourceDB ora11g -sysDBAUserName sys -sysDBAPassword zzh_2046
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/ora11g.log" for further details.

[oracle@jyrac1 ~]$ cat /u01/app/oracle/cfgtoollogs/dbca/ora11g.log
The Database Configuration Assistant will delete the Oracle instance and datafiles for your database. All information in the database will be destroyed. Do you want to proceed?
Connecting to database
DBCA_PROGRESS : 4%
DBCA_PROGRESS : 9%
DBCA_PROGRESS : 14%
DBCA_PROGRESS : 19%
DBCA_PROGRESS : 23%
DBCA_PROGRESS : 28%
DBCA_PROGRESS : 47%
Updating network configuration files
DBCA_PROGRESS : 48%
DBCA_PROGRESS : 52%
Deleting instance and datafiles
DBCA_PROGRESS : 76%
DBCA_PROGRESS : 100%
Database deletion completed.

刪除資料庫後執行下面的命令來檢視ora11g程式資訊發現沒有了

[oracle@jyrac1 ~]$ ps -ef | grep ora11g
oracle   11194 29918  0 10:05 pts/1    00:00:00 grep ora11g



[oracle@jyrac1 ~]$ ps -ef | grep pmon
oracle    9288     1  0 Apr04 ?        00:00:07 ora_pmon_jycs
oracle   11285 29918  0 10:06 pts/1    00:00:00 grep pmon

使用現有資料庫jycs來建立模板

[oracle@jyrac1 ~]$ dbca -silent -createTemplateFromDB -sourceDB jycs -templateName jycstemplate -sysDBAUserName sys -sysDBAPassword zzh_2046
Creating a template from the database
10% complete
20% complete
30% complete
40% complete
50% complete
60% complete
70% complete
80% complete
90% complete
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/silent.log" for further details.
[oracle@jyrac1 ~]$ cat /u01/app/oracle/cfgtoollogs/dbca/silent.log
Creating a template from the database
DBCA_PROGRESS : 10%
DBCA_PROGRESS : 20%
DBCA_PROGRESS : 30%
DBCA_PROGRESS : 40%
DBCA_PROGRESS : 50%
DBCA_PROGRESS : 60%
DBCA_PROGRESS : 70%
DBCA_PROGRESS : 80%
DBCA_PROGRESS : 90%
DBCA_PROGRESS : 100%
The template "jycstemplate" creation completed.

[oracle@jyrac1 templates]$ cd /u01/app/oracle/11.2.0/db/assistants/dbca/templates
[oracle@jyrac1 templates]$ ls -lrt
total 285632
-rw-r--r-- 1 oracle oinstall     11492 Feb 25  2009 New_Database.dbt
-rw-r--r-- 1 oracle oinstall      5106 Aug 15  2009 Data_Warehouse.dbc
-rw-r--r-- 1 oracle oinstall      4986 Aug 15  2009 General_Purpose.dbc
-rwxr-xr-x 1 oracle oinstall 258654208 Aug 15  2009 Seed_Database.dfb
-rwxr-xr-x 1 oracle oinstall   9748480 Aug 15  2009 Seed_Database.ctl
-rwxr-xr-x 1 oracle oinstall   1179648 Aug 15  2009 example.dmp
-rwxr-xr-x 1 oracle oinstall  22544384 Aug 15  2009 example01.dfb
-rw-r----- 1 oracle oinstall      5124 Mar 24 13:31 jycs.dbc
-rw-r----- 1 oracle oinstall     13476 Apr  8 10:12 jycstemplate.dbt

使用現有資料庫jycs建立帶資料檔案的模板

[oracle@jyrac1 ~]$ dbca -silent -createCloneTemplate -sourceDB jycs -templateName jycsCloneTemplate -sysDBAUserName sys -sysDBAPassword  zzh_2046 -datafileJarLocation /u01/app/oracle/11.2.0/db/assistants/dbca/templates
Gathering information from the source database
4% complete
8% complete
13% complete
17% complete
22% complete
Backup datafiles
28% complete
88% complete
Creating template file
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/silent0.log" for further details.
[oracle@jyrac1 ~]$ cat /u01/app/oracle/cfgtoollogs/dbca/silent0.log
Gathering information from the source database
DBCA_PROGRESS : 4%
DBCA_PROGRESS : 8%
DBCA_PROGRESS : 13%
DBCA_PROGRESS : 17%
DBCA_PROGRESS : 22%
Backup datafiles
DBCA_PROGRESS : 28%
DBCA_PROGRESS : 88%
Creating template file
DBCA_PROGRESS : 100%
The generation of the clone database template "jycsCloneTemplate" is successful.

檢視生成的模板檔案

[oracle@jyrac1 templates]$ ls -lrt
total 621628
-rw-r--r-- 1 oracle oinstall     11492 Feb 25  2009 New_Database.dbt
-rw-r--r-- 1 oracle oinstall      5106 Aug 15  2009 Data_Warehouse.dbc
-rw-r--r-- 1 oracle oinstall      4986 Aug 15  2009 General_Purpose.dbc
-rwxr-xr-x 1 oracle oinstall 258654208 Aug 15  2009 Seed_Database.dfb
-rwxr-xr-x 1 oracle oinstall   9748480 Aug 15  2009 Seed_Database.ctl
-rwxr-xr-x 1 oracle oinstall   1179648 Aug 15  2009 example.dmp
-rwxr-xr-x 1 oracle oinstall  22544384 Aug 15  2009 example01.dfb
-rw-r----- 1 oracle oinstall      5124 Mar 24 13:31 jycs.dbc
-rw-r----- 1 oracle oinstall     13476 Apr  8 10:12 jycstemplate.dbt
-rw-r----- 1 oracle oinstall 333955072 Apr  8 10:24 jycsCloneTemplate.dfb
-rw-r----- 1 oracle oinstall   9748480 Apr  8 10:24 jycsCloneTemplate.ctl
-rw-r----- 1 oracle oinstall      4903 Apr  8 10:24 jycsCloneTemplate.dbc

利用帶資料檔案的模板jycsCloneTemplate生成克隆資料庫

[oracle@jyrac1 ~]$ dbca -silent -createDatabase -templateName jycsCloneTemplate.dbc -gdbName test -sid test -datafileJarLocation /u01/app/oracle/11.2.0/db/assistants/dbca/templates -datafileDestination /u01/app/oracle/oradata -responseFile NO_VALUE -characterset ZHS16GBK
Enter SYS user password:

Enter SYSTEM user password:

Copying database files
1% complete
3% complete
11% complete
18% complete
26% complete
37% complete
Creating and starting Oracle instance
40% complete
45% complete
50% complete
55% complete
56% complete
60% complete
62% complete
Completing Database Creation
66% complete
70% complete
73% complete
85% complete
96% complete
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/test/test.log" for further details.
[oracle@jyrac1 ~]$ cat /u01/app/oracle/cfgtoollogs/dbca/test/test.log
Copying database files
DBCA_PROGRESS : 1%
DBCA_PROGRESS : 3%
DBCA_PROGRESS : 11%
DBCA_PROGRESS : 18%
DBCA_PROGRESS : 26%
DBCA_PROGRESS : 37%
Creating and starting Oracle instance
DBCA_PROGRESS : 40%
DBCA_PROGRESS : 45%
DBCA_PROGRESS : 50%
DBCA_PROGRESS : 55%
DBCA_PROGRESS : 56%
DBCA_PROGRESS : 60%
DBCA_PROGRESS : 62%
Completing Database Creation
DBCA_PROGRESS : 66%
DBCA_PROGRESS : 70%
DBCA_PROGRESS : 73%
DBCA_PROGRESS : 85%
DBCA_PROGRESS : 96%
DBCA_PROGRESS : 100%
Database creation complete. For details check the logfiles at:
 /u01/app/oracle/cfgtoollogs/dbca/test.
Database Information:
Global Database Name:test
System Identifier(SID):test
[oracle@jyrac1 ~]$ ps -ef  | grep pmon
oracle   12381     1  0 10:22 ?        00:00:00 ora_pmon_jycs
oracle   14396     1  0 10:39 ?        00:00:00 ora_pmon_test
oracle   14689 29918  0 10:41 pts/1    00:00:00 grep pmon

利用不帶資料檔案的模板生成新的資料庫

[oracle@jyrac1 ~]$ dbca -silent -createDatabase -templateName New_Database.dbt -gdbname jytest  -sid jytest -datafileDestination /u01/app/oracle/oradata -responseFile NO_VALUE -characterset ZHS16GBK
Enter SYS user password:

Enter SYSTEM user password:

Creating and starting Oracle instance
1% complete
3% complete
Creating database files
4% complete
7% complete
Creating data dictionary views
8% complete
9% complete
10% complete
11% complete
12% complete
13% complete
14% complete
16% complete
17% complete
18% complete
19% complete
Adding Oracle JVM
25% complete
30% complete
36% complete
38% complete
Adding Oracle Text
40% complete
41% complete
Adding Oracle XML DB
43% complete
44% complete
45% complete
49% complete
Adding Oracle Multimedia
50% complete
60% complete
Adding Oracle OLAP
61% complete
62% complete
63% complete
64% complete
Adding Oracle Spatial
65% complete
66% complete
67% complete
71% complete
Adding Enterprise Manager Repository
73% complete
75% complete
Adding Oracle Application Express
78% complete
82% complete
Adding Oracle Warehouse Builder
86% complete
90% complete
Completing Database Creation
91% complete
92% complete
93% complete
96% complete
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/jytest/jytest.log" for further details.
[oracle@jyrac1 ~]$ cat /u01/app/oracle/cfgtoollogs/dbca/jytest/jytest.log
Creating and starting Oracle instance
DBCA_PROGRESS : 1%
DBCA_PROGRESS : 3%
Creating database files
DBCA_PROGRESS : 4%
DBCA_PROGRESS : 7%
Creating data dictionary views
DBCA_PROGRESS : 8%
DBCA_PROGRESS : 9%
DBCA_PROGRESS : 10%
DBCA_PROGRESS : 11%
DBCA_PROGRESS : 12%
DBCA_PROGRESS : 13%
DBCA_PROGRESS : 14%
DBCA_PROGRESS : 16%
DBCA_PROGRESS : 17%
DBCA_PROGRESS : 18%
DBCA_PROGRESS : 19%
Adding Oracle JVM
DBCA_PROGRESS : 25%
DBCA_PROGRESS : 30%
DBCA_PROGRESS : 36%
DBCA_PROGRESS : 38%
Adding Oracle Text
DBCA_PROGRESS : 40%
DBCA_PROGRESS : 41%
Adding Oracle XML DB
DBCA_PROGRESS : 43%
DBCA_PROGRESS : 44%
DBCA_PROGRESS : 45%
DBCA_PROGRESS : 49%
Adding Oracle Multimedia
DBCA_PROGRESS : 50%
DBCA_PROGRESS : 60%
Adding Oracle OLAP
DBCA_PROGRESS : 61%
DBCA_PROGRESS : 62%
DBCA_PROGRESS : 63%
DBCA_PROGRESS : 64%
Adding Oracle Spatial
DBCA_PROGRESS : 65%
DBCA_PROGRESS : 66%
DBCA_PROGRESS : 67%
DBCA_PROGRESS : 71%
Adding Enterprise Manager Repository
DBCA_PROGRESS : 73%
DBCA_PROGRESS : 75%
Adding Oracle Application Express
DBCA_PROGRESS : 78%
DBCA_PROGRESS : 82%
Adding Oracle Warehouse Builder
DBCA_PROGRESS : 86%
DBCA_PROGRESS : 90%
Completing Database Creation
DBCA_PROGRESS : 91%
DBCA_PROGRESS : 92%
DBCA_PROGRESS : 93%
DBCA_PROGRESS : 96%
DBCA_PROGRESS : 100%
Database creation complete. For details check the logfiles at:
 /u01/app/oracle/cfgtoollogs/dbca/jytest.
Database Information:
Global Database Name:jytest
System Identifier(SID):jytest

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26015009/viewspace-1137888/,如需轉載,請註明出處,否則將追究法律責任。

相關文章