社区微信群开通啦,扫一扫抢先加入社区官方微信群
社区微信群
一般来说,我们在Oracle数据库上建立数据库实例之后,会自动创建以下文件
pfile文件(.ora),记录数据库的基本配置,明文,内容不多,一般以init开头,startup命令所必须的文件
spfile文件(.ora),二进制文件,作用同pfile类似,可以由pfile生成
表空间容器(.dbf),二进制文件,这个应该都比较熟,动辄几十几百GB
控制文件及备份,一般会在数据库实例默认目录和fast_recovery目录下,文件名一般为control01.ctl 和 control02.ctl
重做文件(.log)一般会在数据库实例安装目录,和上面.dbf文件在一起,文件名默认为redo01.log redo02.log redo03.log
上面这些文件是一个数据库最主要的文件,换句话说,如果我们把这些文件拷贝到另一台装有Oracle的服务器上,理论上是可以把这个数据库拉起来继续跑的。
上面的文件丢了任何一个都是灾难性的后果。都会导致数据库无法正常startup,当然不光局限于这些文件,如果你开了归档日志,那么归档日志的丢失也会导致数据库无法启动。
表空间文件丢了那数据就是真丢了,除非有备份,不然是不可能恢复过来的。
控制文件在新建实例的时候默认就会创建两个,如果丢了一个可以拷贝另一个过去,如果都丢了那么有表空间的备份也没有
pfile和spfile丢了虽然会导致数据库无法startup,但是pfile内容少,明文,是可以从别的实例拷贝一个过来借鉴的。而spfile可以通过sqlplus从pfile文件生成过来,所以这两个文件丢失并不一定会带来灾难性的后果。
pfile丢失之后或者被篡改,那么启动的时候往往会碰见"ora-03113 通信通道的文件结尾"错误或者ora-01507 database not mounted的错误
首先我们观察一下pfile文件的结构
#
# $Header: rdbms/admin/init.ora /main/23 2009/05/15 13:35:38 ysarig Exp $
#
# Copyright (c) 1991, 1997, 1998 by Oracle Corporation
# NAME
# init.ora
# FUNCTION
# NOTES
# MODIFIED
# ysarig 05/14/09 - Updating compatible to 11.2
# ysarig 08/13/07 - Fixing the sample for 11g
# atsukerm 08/06/98 - fix for 8.1.
# hpiao 06/05/97 - fix for 803
# glavash 05/12/97 - add oracle_trace_enable comment
# hpiao 04/22/97 - remove ifile=, events=, etc.
# alingelb 09/19/94 - remove vms-specific stuff
# dpawson 07/07/93 - add more comments regarded archive start
# maporter 10/29/92 - Add vms_sga_use_gblpagfile=TRUE
# jloaiza 03/07/92 - change ALPHA to BETA
# danderso 02/26/92 - change db_block_cache_protect to _db_block_cache_p
# ghallmar 02/03/92 - db_directory -> db_domain
# maporter 01/12/92 - merge changes from branch 1.8.308.1
# maporter 12/21/91 - bug 76493: Add control_files parameter
# wbridge 12/03/91 - use of %c in archive format is discouraged
# ghallmar 12/02/91 - add global_names=true, db_directory=us.acme.com
# thayes 11/27/91 - Change default for cache_clone
# jloaiza 08/13/91 - merge changes from branch 1.7.100.1
# jloaiza 07/31/91 - add debug stuff
# rlim 04/29/91 - removal of char_is_varchar2
# Bridge 03/12/91 - log_allocation no longer exists
# Wijaya 02/05/91 - remove obsolete parameters
#
##############################################################################
# Example INIT.ORA file
#
# This file is provided by Oracle Corporation to help you start by providing
# a starting point to customize your RDBMS installation for your site.
#
# NOTE: The values that are used in this file are only intended to be used
# as a starting point. You may want to adjust/tune those values to your
# specific hardware and needs. You may also consider using Database
# Configuration Assistant tool (DBCA) to create INIT file and to size your
# initial set of tablespaces based on the user input.
###############################################################################
# Change '<ORACLE_BASE>' to point to the oracle base (the one you specify at
# install time)
db_name='mydb'
memory_target=1G
processes = 150
audit_file_dest='/u01/oracle/admin/mydb/adump'
audit_trail ='db'
db_block_size=8192
db_domain=''
db_recovery_file_dest='/u01/oracle/flash_recovery_area'
db_recovery_file_dest_size=2G
diagnostic_dest='/db/oracle'
dispatchers='(PROTOCOL=TCP) (SERVICE=mydbXDB)'
open_cursors=300
remote_login_passwordfile='EXCLUSIVE'
undo_tablespace='UNDOTBS1'
# You may want to ensure that control files are created on separate physical
# devices
control_files = (control01.ctl,control02.ctl)
compatible ='11.2.0'
这个文件的字段并不多,大部分还都是固定的,比如数据库的版本,数据库恢复文件的位置,大小,连接协议等。不同实例之间变化的参数,除了名字和对应的存储路径之外,就剩块大小了。
db_block_size也就是我们建立数据库时候指定的块大小,决定了我们数据库表空间和缓冲池的最大大小及效能,默认8192。在8192下面,单个表空间文件最大只有32G,而这个值扩大到16384就能把单个表空间上限提高到64G,所以这个参数在不同数据库之间是不一样的,而且写错了会无法startup。
control_files 就是数据库的控制文件,可以写多个,用逗号分隔。这里写的就是控制文件的实际文件名,路径可以到startup的log中去找,(startup失败的时候会打印这个文件的完整路径),名称为log.xml,可以用locate log.xml来搜索这个文件,或者根据你oracle安装位置,路径大约为/oracle/diag/rdbms/ora11g/ora11g/alert/log.xml
观察日志,如果pfile文件写的有问题,那么会有下面的报错
ORA-00210: cannot open the specified control file
ORA-00202: control file: /opt/oracle/oradata/ora11g/control03.ctl;
可以参考这篇文章https://www.cnblogs.com/sparkbj/articles/6146247.html
spfile我们可以进入sqlplus之后进行生成,命令如下
sqlplus / as sysdba
create spfile from pfile='/u01/mydb/initmydb.ora';
最后,我们编写好新的pfile和spfile文件之后,就可以使用startup命令进行启动了
startup pfile='/u01/mydb/init.ora' mount
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!