1.为什么Oracle的静默安装要比DBCA图形化界面安装速度快
首先我们来分析DBCA静默安装的日志
1.第一部分,从模板文件直接拷贝数据文件。
类似与备份恢复。
kcbztek_populate_tbskey: db key in controlfile and datafile 1 is inconsistent..
Full restore complete of datafile 4 to datafile copy /oracle/app/oracle/oradata/fermdb/users01.dbf. Elapsed time: 0:00:01
checkpoint is 925701
last deallocation scn is 3
Full restore complete of datafile 3 to datafile copy /oracle/app/oracle/oradata/fermdb/undotbs01.dbf. Elapsed time: 0:00:01
Full restore complete of datafile 2 to datafile copy /oracle/app/oracle/oradata/fermdb/sysaux01.dbf. Elapsed time: 0:00:46
checkpoint is 925701
last deallocation scn is 925426
Sun Oct 08 16:23:08 2023
Full restore complete of datafile 1 to datafile copy /oracle/app/oracle/oradata/fermdb/system01.dbf. Elapsed time: 0:01:03
checkpoint is 925701
last deallocation scn is 923796
Sun Oct 08 16:23:08 2023
2.第二部分,创建控制文件
Sun Oct 08 16:23:08 2023
Create controlfile reuse set database "fermdb"
MAXINSTANCES 8
MAXLOGHISTORY 1
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
Datafile
'/oracle/app/oracle/oradata/fermdb/system01.dbf',
'/oracle/app/oracle/oradata/fermdb/sysaux01.dbf',
'/oracle/app/oracle/oradata/fermdb/undotbs01.dbf',
'/oracle/app/oracle/oradata/fermdb/users01.dbf'
LOGFILE GROUP 1 ('/oracle/app/oracle/oradata/fermdb/redo01.log') SIZE 51200K,
GROUP 2 ('/oracle/app/oracle/oradata/fermdb/redo02.log') SIZE 51200K,
GROUP 3 ('/oracle/app/oracle/oradata/fermdb/redo03.log') SIZE 51200K RESETLOGS
WARNING: Default Temporary Tablespace not specified in CREATE DATABASE command
Default Temporary Tablespace will be necessary for a locally managed database in future release
Sun Oct 08 16:23:08 2023
Successful mount of redo thread 1, with mount id 1185671660
3.第三部分,重置日志
ALTER SYSTEM enable restricted session;
alter database "fermdb" open resetlogs
RESETLOGS after incomplete recovery UNTIL CHANGE 925701
4.设置数据库Incarnation
Setting recovery target incarnation to 2
Initializing SCN for created control file
Database SCN compatibility initialized to 3
5.添加临时文件,设置数据库字符集。
ALTER TABLESPACE TEMP ADD TEMPFILE '/oracle/app/oracle/oradata/fermdb/temp01.dbf' SIZE 20480K REUSE AUTOEXTEND ON NEXT 640K MAXSIZE UNLIMITED
Completed: ALTER TABLESPACE TEMP ADD TEMPFILE '/oracle/app/oracle/oradata/fermdb/temp01.dbf' SIZE 20480K REUSE AUTOEXTEND ON NEXT 640K MAXSIZE UNLIMITED
ALTER DATABASE DEFAULT TABLESPACE "USERS"
Completed: ALTER DATABASE DEFAULT TABLESPACE "USERS"
alter database character set INTERNAL_CONVERT ZHS16GBK
6.更新控制文件中的字符集
Updating character set in controlfile to ZHS16GBK
7.重启数据库
Starting up:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options.
ORACLE_HOME = /oracle/app/oracle/product/11.2.0/db_1
System name: Linux
Node name: oracle11g
Release: 3.10.0-1160.el7.x86_64
Version: #1 SMP Tue Aug 18 14:50:17 EDT 2020
Machine: x86_64
VM name: VMWare Version: 6
Using parameter settings in server-side spfile /oracle/app/oracle/product/11.2.0/db_1/dbs/spfilefermdb.ora
System parameters with non-default values:
.......
Starting background process QMNC
Sun Oct 08 16:25:01 2023
QMNC started with pid=20, OS id=5688
Completed: ALTER DATABASE OPEN;
总结:DBCA的步骤
1).从Oracle自带的模板文件中做不完全恢复,restore数据文件。
2).创建控制文件
3).重置在线日志 relogs;
4).设置数据库对应物Incarnation;
5).增加临时文件,设置数据库字符集
6).更新控制文件中字符集
7).重启数据库。
2.数据库对应物查询
RMAN> list incarnation;
using target database control file instead of recovery catalog
List of Database Incarnations
DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1 1 FERMDB 1185704947 PARENT 1 2013-08-24 11:37:30
2 2 FERMDB 1185704947 CURRENT 925702 2023-10-08 16:23:18
我们可看到,DBCA默认第一次创建出来的数据库SCN=1; resetlog重置后生成一个新的SCN;
对应的数据库的对应物等于2;
3.总结
DBCA静默安装之所以快是因为,它本身是从一个模板文件直接做文件拷贝的。而图形化界面是将所有的对象全部创建了一次。一般DBCA图形化安装需要40分钟-1个小时,但是DBCA静默安装2~3分钟就可以完成。原因就在于它没有创建对象,而是直接拷贝文件的。