您好,登錄后才能下訂單哦!
這兩天裝了幾套開發環境的Oracle數據庫,其中有11.2.0.4的版本也有12.2.0.1的版本。由于網絡環境復雜,沒有辦法使用圖形界面的方式安裝,只能使用靜默方式安裝,之前也寫過關于靜默安裝數據庫軟件和創建實例的博客http://hbxztc.blog.51cto.com/1587495/1884833有興趣的可以參考,這兩天用的也是這樣的方法,但是之前看到有人在分享中使用過dbca的靜默方法來創建數據庫實例,還沒有做過嘗試,趁安裝空閑的時間研究了一下,在此也做一個簡單的分享。
dbca有兩種靜默的安裝實例的方式:一種是使用responseFile,另一種是直接使用命令行的方式。本次測試是用responseFile的方式。
使用responseFile方式自然需要有responseFile文件了,這個文件可以到database解壓包目錄下的response目錄中找到,還可以在$ORACLE_HOME/assistants/dbca/目錄下找到。文件名叫dbca.rsp。
創建流程:
1、復制一個dbca.rsp文件進行修改,來做為創建實例時使用。
[oracle@rhel6 dbca]$ pwd
/u01/app/oracle/product/11.2/db1/assistants/dbca
[oracle@rhel6 dbca]$ cp dbca.rsp /home/oracle
2、修改剛復制的dbca.rsp文件
這里解釋部分文件中的參數
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文件中還有很多其他的參數,如果有進一步的需求可以自行修改相應的需求
3、開始創建數據庫實例
執行下面的命令幾分鐘就可以創建一個實例:
[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.
4、檢查實例是否正常
[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
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。