這兩天裝了幾套開發環境的Oracle數據庫,其中有11.2.0.4的版本也有12.2.0.1的版本。因爲網絡環境複雜,沒有辦法使用圖形界面的方式安裝,只能使用靜默方式安裝,以前也寫過關於靜默安裝數據庫軟件和建立實例的博客http://hbxztc.blog.51cto.com/1587495/1884833有興趣的能夠參考,這兩天用的也是這樣的方法,可是以前看到有人在分享中使用過dbca的靜默方法來建立數據庫實例,尚未作過嘗試,趁安裝空閒的時間研究了一下,在此也作一個簡單的分享。node
dbca有兩種靜默的安裝實例的方式:一種是使用responseFile,另外一種是直接使用命令行的方式。本次測試是用responseFile的方式。sql
使用responseFile方式天然須要有responseFile文件了,這個文件能夠到database解壓包目錄下的response目錄中找到,還能夠在$ORACLE_HOME/assistants/dbca/目錄下找到。文件名叫dbca.rsp。數據庫
建立流程:bash
一、複製一個dbca.rsp文件進行修改,來作爲建立實例時使用。網絡
[oracle@rhel6 dbca]$ pwdoracle
/u01/app/oracle/product/11.2/db1/assistants/dbcaapp
[oracle@rhel6 dbca]$ cp dbca.rsp /home/oracleide
二、修改剛複製的dbca.rsp文件測試
這裏解釋部分文件中的參數spa
RESPONSEFILE_VERSION = "11.2.0" #指定版本號
OPERATION_TYPE = "createDatabase" #指定使用dbca要作的操做,這裏要建立實例就選擇createDatabase,若是要刪除實例則爲deleteDatabase
#建立實例有隻須要修改建立實例部分的參數就能夠了,看到#-----------------------*** End of CREATEDATABASE section ***------------------------部分就算是配置完了
[CREATEDATABASE]
GDBNAME = "dbs" #數據庫的Global database name
SID = "dbs" #數據庫的實例名
SYSPASSWORD = "123456" #指定sys用戶密碼
SYSTEMPASSWORD = "123456" #指定system用戶密碼
DATAFILEDESTINATION =/home/oracle/11201/dbs #指定數據文件存放的目錄
CHARACTERSET = "ZHS16GBK" #指定字符集
NATIONALCHARACTERSET= "AL16UTF16" #指定國家字符集
DATABASETYPE = "OLTP" #指定實例的類型
AUTOMATICMEMORYMANAGEMENT = "TRUE" #指定使用自動內存管理
TOTALMEMORY = "800" #指定使用內存的大小,單位是MB
上面的參數是建立單實例時用到的參數,dbca.rsp文件中還有不少其餘的參數,若是有進一步的需求能夠自行修改相應的需求
三、開始建立數據庫實例
執行下面的命令幾分鐘就能夠建立一個實例:
[oracle@rhel6 11201]$ dbca -silent -responseFile /home/oracle/dbca.rsp
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/dbs/dbs1.log" for further details.
四、檢查實例是否正常
[oracle@rhel6 11201]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Tue Mar 14 20:55:55 2017
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
sys@DBS>select status from v$instance;
STATUS
------------------------------------
OPEN
sys@DBS>select name from v$datafile;
NAME
---------------------------------------------------
/home/oracle/11201/dbs/dbs/system01.dbf
/home/oracle/11201/dbs/dbs/sysaux01.dbf
/home/oracle/11201/dbs/dbs/undotbs01.dbf
/home/oracle/11201/dbs/dbs/users01.dbf
這裏簡單說一下爲何這麼快的緣由,從alert日誌中能夠看到以下圖的日誌
從上圖能夠看出數據文件是被從copy中恢復出來的,而不是新建立的,這也能夠解釋爲何建立實例時第一行的日誌是「Copying database files」的緣由了。
說到這裏也要說一下建立實例的三種類型,以下圖:
從圖中能夠看出建立實例的三種類型,其中「General Purpose or Transaction processiong」和「Data Warehose」分別對應的是OLTP系統和數據倉庫,它們後面的「Includes Datafiles」爲Yes說明使用這兩種方式建立時是用數據文件的備份來恢復出來的。最後修改字符集就能夠 了。以下圖alert日誌
而「Custom Database」自定義模式則沒有對應的數據文件來恢復,而是全新建立的數據文件,所以這種方式建立實例時耗費的時間也相對較長,由於須要跑數據字典。
上面簡單介紹了使用responseFile方式建立實例的方法,另一種方法是直接使用命令行,能夠用dbca -h命令查看命令參數
[oracle@rhel6 trace]$ dbca -h dbca [-silent | -progressOnly | -customCreate] {<command> <options> } | { [<command> [options] ] -responseFile <response file > } [-continueOnNonFatalErrors <true | false>] 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 <name of an existing template> [-cloneTemplate] -gdbName <global database name> [-policyManaged | -adminManaged <Policy managed or Admin managed Database, default is Admin managed database>] [-createServerPool <To create ServerPool which will be used by the database to be created>] [-force <To create serverpool by force when adequate free servers are not available. This may affect already running database>] -serverPoolName <One serverPool Name in case of create server pool and comma separated list of serverPool name in case of use serverpool> -[cardinality <Specify cardinality for new serverPool to be created, default is the number of qualified nodes>] [-sid <database system identifier>] [-sysPassword <SYS user password>] [-systemPassword <SYSTEM user password>] [-emConfiguration <CENTRAL|LOCAL|ALL|NOBACKUP|NOEMAIL|NONE> -dbsnmpPassword <DBSNMP user password> -sysmanPassword <SYSMAN user password> [-hostUserName <Host user name for EM backup job> -hostUserPassword <Host user password for EM backup job> -backupSchedule <Daily backup schedule in the form of hh:mm>] [-smtpServer <Outgoing mail (SMTP) server for email notifications> -emailAddress <Email address for email notifications>] [-centralAgent <Enterprise Manager central agent home>]] [-disableSecurityConfiguration <ALL|AUDIT|PASSWORD_PROFILE|NONE> [-datafileDestination <destination directory for all database files> | -datafileNames <a text file containing database objects such as controlfiles, tablespaces, redo log files and spfile to th eir corresponding raw device file names mappings in name=value format.>] [-redoLogFileSize <size of each redo log file in megabytes>] [-recoveryAreaDestination <destination directory for all recovery files>] [-datafileJarLocation <location of the data file jar, used only for clone database creation>] [-storageType < FS | ASM > [-asmsnmpPassword <ASMSNMP password for ASM monitoring>] -diskGroupName <database area disk group name> -recoveryGroupName <recovery area disk group name> [-characterSet <character set for the database>] [-nationalCharacterSet <national character set for the database>] [-registerWithDirService <true | false> -dirServiceUserName <user name for directory service> -dirServicePassword <password for directory service > -walletPassword <password for database wallet >] [-listeners <list of listeners to configure the database with>] [-variablesFile <file name for the variable-value pair for variables in the template>]] [-variables <comma seperated list of name=value pairs>] [-initParams <comma seperated list of name=value pairs>] [-memoryPercentage <percentage of physical memory for Oracle>] [-automaticMemoryManagement ] [-totalMemory <memory allocated for Oracle in MB>] [-databaseType <MULTIPURPOSE|DATA_WAREHOUSING|OLTP>]]
官方文檔:http://docs.oracle.com/cd/E11882_01/install.112/e47689/app_nonint.htm#LADBI1353