DBCA靜默方式建庫


使用DBCA的圖形方式建庫實在有諸多不便,但是使用靜默方式建庫就比較方便了,一個命令即可搞定。

使用dbca安裝oracle數據庫實例也有差不多兩種方法:
一種就是根據模板文件進行安裝,在上文中提到了在oracle安裝程序的安裝文件夾下的response目錄中有一個dbca.rsp文件就是dbca的模板文件。當然我們也可以通過復制這個模板文件來修改其中的內容來建立定制的數據庫,在這個模板文件中對於各個參數的說明非常詳細,對這個文件的內容在此不做說明。
另外一種就是根據oracle自身的數據庫模板來建立數據庫實例(模板文件位置:$ORACLE_HOME/assistants/dbca/templates/*.dbc

ORACLE為我們提供了幾個dbc模板:
Data Warehouse 數據倉庫
Transaction Processing 事務處理
General Purpose 一般用途
這幾個模板是比較易用的模板,oracle針對不同的數據庫用途做了專門的優化,當然我們也可以創建我們自己的模板(也是使用dbca命令),

首先說明一點,在安裝之前需要注意的幾個問題:
1、/etc/hosts文件中,本機的hostname必須和lo對應(如果你有改過hostname的話,需要修改該文件)
2、$ORACLE_HOME/network/admin/listener.ora文件必須配置服務器監聽,為了保險起見,將tnsnames和sqlnet文件都配置了吧
3、在dbca命令中出現的文件參數,必須使用全路徑
4、注意在使用dbca命令的時候各個同級別的參數的必要性,有些是必要的,有些是不必要的。具體可參考dbca -help

根據模版文件創建數據庫:
dbca -silent -cloneTemplate -gdbName orcl -sid orcl -datafileDestination /u01/oradata -responseFile /mnt/hgfs/software/oracle/database/response/dbca.rsp
一些參數的說明:
-silent 指定dbca的靜默安裝方式
-cloneTemplate 指定自模版文件創建
-gdbName Global Database Name
-sid 創建數據庫的sid
-datafileDestination 數據文件存放的目標路徑
-responseFIle 模版文件的路徑

根據Oracle提供的數據庫模版創建數據庫:
dbca -silent -createDatabase -templateName $ORACLE_HOME/assistants/dbca/template/Transaction_Processing.dbc -gdbName orcl -sid orcl -responseFile NO_VALUE -characterSet ZHS16GBK

Silent模式采用命令行方式一次將所有信息提供給DBCA完成數據庫的建立,在建立過程中不存在交互作用,所有的信息、錯誤和告警都寫到日志文件中,只在結束時屏幕上打印出日志文件的位置,除此以外,沒有其他的消息。

12c靜默方式建庫
[oracle@test ~]$ dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbname oradb.example.com -sid oradb -responseFile NO_VALUE -characterSet AL32UTF8 -memoryPercentage 30 -emConfiguration LOCAL

11g靜默方式建庫
[oracle@testdb ora11g]$ dbca -help
[oracle@testdb oracle]$ dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbname ora11g -sid ora11g -sysPassword lhr -systemPassword lhr -responseFile NO_VALUE -datafileDestination /u01/app/oracle/oradata/ -redoLogFileSize 50 -recoveryAreaDestination /u01/app/oracle/flash_recovery_area -storageType FS -characterSet ZHS16GBK -nationalCharacterSet AL16UTF16 -sampleSchema true -memoryPercentage 30 -totalMemory 200 -databaseType OLTP -emConfiguration NONE

10g靜默建庫
dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbname ora11g -sid ora11g -sysPassword lhr -systemPassword lhr -responseFile NO_VALUE -datafileDestination /u01/app/oracle/oradata/ -recoveryAreaDestination /u01/app/oracle/flash_recovery_area -storageType FS -characterSet ZHS16GBK -nationalCharacterSet AL16UTF16 -sampleSchema true -memoryPercentage 30 -databaseType OLTP -emConfiguration NONE

 

##################################

另一篇文檔

##################################

[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

以silent方式來刪除數據庫
[oracle@jyrac1 ~]$ dbca -silent -deleteDatabase -sourceDB ora11g -sysDBAUserName sys -sysDBAPassword zzh_2046

使用現有數據庫jycs來創建模板
[oracle@jyrac1 ~]$ dbca -silent -createTemplateFromDB -sourceDB jycs -templateName jycstemplate -sysDBAUserName sys -sysDBAPassword zzh_2046

使用現有數據庫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

利用帶數據文件的模板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

利用不帶數據文件的模板生成新的數據庫
[oracle@jyrac1 ~]$ dbca -silent -createDatabase -templateName New_Database.dbt -gdbname jytest -sid jytest -datafileDestination /u01/app/oracle/oradata -responseFile NO_VALUE -characterset ZHS16GBK


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM