DBCA静默方式建立数据库实例

这两天装了几套开发环境的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日志中能够看到以下图的日志

wKiom1jH6afz00z2AABlramsDW8333.png从上图能够看出数据文件是被从copy中恢复出来的,而不是新建立的,这也能够解释为何建立实例时第一行的日志是“Copying database files”的缘由了。

说到这里也要说一下建立实例的三种类型,以下图:

wKioL1jH6nahrNxJAAGjjkvOvwQ138.png从图中能够看出建立实例的三种类型,其中“General Purpose or Transaction processiong”和“Data Warehose”分别对应的是OLTP系统和数据仓库,它们后面的“Includes Datafiles”为Yes说明使用这两种方式建立时是用数据文件的备份来恢复出来的。最后修改字符集就能够 了。以下图alert日志

wKiom1jH6_7z3vdkAAAJcZm5eAc771.png

而“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

相关文章
相关标签/搜索