这两天装了几套开发环境的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 -hdbca [-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
本文出自 “DBA Fighting!” 博客,请务必保留此出处http://hbxztc.blog.51cto.com/1587495/1906532