Manage Instance & OMF & Parameter file

1. Initialization parameter file ( pfile , spfile )

To start an instance, the Oracle server must read the initialization parameter file . ( 在打开数据库时, 必须读取此参数文件 )

explicit / implicit

explicit : have an entry in the file ( 文件形式 )

implicit : no entry within the file , but assuming the oracle default values. ( 默认 )

parameter file 分pfile , spfile两种 ( explicit )

( pfile是文本文档, 可以在操作系统中修改, 下次启动数据库时生效, 默认目录是 ORACLE_HOME/dbs ) initsid.ora

  直接可以使用操作系统的 editor编辑. 在instance启动时, pfile是只读的.

( spfile 二进制文件, 只能通过oracle server修改, 改变是使用 alter system命令, 有三种改变方式, memory只改变内存, spfile只改变spfile, both( memory + spfile) spfilesid.ora

  在oracle系统中编辑, alter system set undo_tablespace = 'UNDO2' ;

create spfile[='spfile name'] from pfile[='pfile name'] ; ( spfile比pfile好, 更加安全可靠 )   ( 也可以 create pfile from spfile )

  alter system set parameter = value [comment=' text  ' ][ deffer ][SCOPE = MEMORY | SPFILE | BOTH][ sid = 'sid' ]

补充 : create pfile='asdf.ora' from spfile='spfilemoveofgod.ora';  ( 注意所有的名称要用全称, 并且有单引号 )

另外,spfine中的 *.parameter=value 这个 *. 表示该参数适用于所有的 instance , 将来高级的时候,可以多个instance对应一个database .

可以使用 linux 的 strings 命令来查看 spfile中的内容,spfile是个2进制文件。

alert system reset parameter = value sid = 'text' ( 恢复默认值 )

2. OMF ( oracle managed files )

~ control file : ora_%u.ctl

~ Red Log file : ora_%g_%u.log

~ data file : ora_%t_%u.dbf

~ temporary data file : ora_%t_%u.tmp

其中 %u表示唯一名称, %t表示table space名字, %g表示redo log file中的group 

补充 : datafile , control file , redo_log file 要放在不同的目录下 , 以上OMF文件指定好后, 就可以创建数据库, create database 命令.

3. Start database

谁可以启动数据库:

sysdba , sysoper 或者操作系统的管理员


启动数据库分 3 部分 :

第一步 : starting instance ( no mount ) ( 只是开启 instance , 没有跟数据库挂钩 )

第二步 : mount database ( 装备了数据库, 但是并没有打开数据库  )

第三步 : open database (  打开数据库 )


数据库启动文件查找情况 :

第一步包括的内容 : 阅读 initialization file

a.进入 $oracle_home/dbs , 首先寻找 spfileSID.ora

                                                                spfile.ora

                                                                 initSid.ora

b. 指定参数文件中的参数

c. 分配SGA

d. 启动后台进程

e. 打开 alertSID.log file 和 track files

ipcs 查看 ipc是资源 ( 虽然这是一个在 linux 环境下执行的命令(不是在SQLPLUS环境下执行),但是也必须的启动数据库之后才能执行,目的是查看内存分配情况 )

第二步包括的内容 :

a. 将数据库  database与刚刚的instance联系起

b. 找到control file ( 依照 parameter file中的内容 )

c. 读取 control file的内容, 找到 datafile , redo log file 的内容和权限等等 .

第三步包括的内容 :

a. 打开 online data file.

b. 打开 online redo log file .

open 以后 , SMON 会确认数据库的一致性 等等 .

STARTUP 例子 STARTUP PFILE=$ORACLE_HOME/dbs/initdb01.ora  

Mounting the database ( 装备数据库 )

    有一些数据库的维护操作, 是需要开始 instance 并且将数据库设置成 mount状态, 但是并不 open 数据库, 例如

  • Renaming data files
  • Enabling and disabling redo log archiving options
  • Performing full databse recovery

    Mounting a database includes the following tasks :

  • Associating a database with a previously started instance
  • Location and opening the control files specified in the parameter file
  • Reading the control files to obtain the names and status of the datafiles and redo log files.
Opening the database( 打开数据库 )
  • Opening the online data files
  • Opening the online redo log files'


STARTUP 语法

STARTUP [FORCE] [RESTRICT] [PFILE=filename]

                    [OPEN [RECOVER] [database ]

                    | MOUNT / NOMOUNT ]

    OPEN : enables users to access the databse

    MOUNT : mounts the database for certain DBA activities but does not provide user access to the database

    NOMOUNT : creates the SGA and starts up the background processes but does not provide access to the database ( 只是开始 instance )

    PFILE = filename : enables a nondefault parameter file to be used to configure the instance . ( 可以不使用默认的parameter file , startup pfile='asdf.ora' ,注意此时只能使用pfile , 而不能使用 spfile)

    FORCE : aborts the running instance before performing a normal startup ( 如果数据库已经打开,先强制关闭数据库, 再重新打开 )

    RESTRICT : enables only users with RESTRICTED SESSION privilege to access the databases

    RECOVER : begins media recovery when the databse starts. ( startup open recover moveofgod , 注意这个是必须放在 open 后边的, 同样, 如果要指定database name 也必须放在  open 后边 )

可以通过设置某些文件,使得数据库自动启动(  例如当系统重新启动时 )

v$session

alert system kill session 'sid,serial' ;

v$transaction 没有 commit 的事物sh



4. Changing the status of the Database & ALTER DATABAE 语法

alter database database_name mount ,

alter database open [ READ WRITE | READ ONLY ]

startup restrict ( 打开数据库使用 restrict模式 ) 也可以使用 alter system enable | disable restricted session ( 含义是, 向后登陆数据库的要确认是否有 restrict 权限,因为数据库已经打开)

SHUTDOWN [ NORAMAL | TRANSACTIONAL | IMMEDIATE | ABORT ]


5. Diagnostic Files ( 诊断文件 )
  • alertSID.log file : Information for day-to-day operation of the database ( 操作信息文件,第一个要确认的文件)$ORACLE_HOME/rdbms/log
    文件名 alertsid.log  它的location 是由 BACKGROUND_DUMP_DEST 这个参数决定的
  • Background trace files : Vital information when background processes, such as SMON, PMON, DBWn, and others fail.( 进程确认到的出错情况文件$ORACLE_HOME/rdbms/log)  文件名SID_processname_PID.trc  例如 wilson_qmn0_3783.trc 它的location 是由 BACKGROUND_DUMP_DEST 这个参数决定的
  • User trace files : Vital information for fatal user errors or user forced traced files .( 用户一些错误内容文件,当用户连接到oracle server process时$ORACLE_HOME/rdbms/log)  文件名SID_ora_PID.trc   例如 wilson_ora_3637.trc
    location is defined by user_dump_dest     size defined by max_dump_file_size   (alter session set sql_track = true 查看连接的用户而不是出现错误的用户,一般是要设置成 false ,  即只要知道有问题的用户就可以了 )

6. 数据库启动

数据库包括 instance + database , Instance 先启动,再配备database , startup nomount 启动可以不配备database , 那么, 在启动的第一步骤, oracle首先寻找参数文件(pfile/spfile), 然后根据参数文件中的设置, 创建实例, 分配内存, 启动后台进程, 所以 只要拥有了一个参数文件, 就可以凭借此文件启动实例, 这一步骤并不需要任何控制文件或数据文件参与.如果此时出现什么问题,那么可能是系统配置(内核参数等)存在问题,用户需要检查是否分配了足够的系统资源,等等.

show parameter spfile ( 可以观察到是否使用了spfile来启动 instance )

个人总结
 

1. parameter 的设置, 及内容介绍 alter system ...

2. oracle 各种文件应该命名的格式

3. 根据parameter oracle 的启动与关闭,

4. 相对应的状态 alter database open ...

5. 诊断文件, alertSID.log, /u01/admin/ora10g/bdump ( alert_ora10g.log )

    background trace file: /u01/admin/ora10g/bdump ( sid_processname_pid.trc) 跟上边是同一个文件夹

    user trace file: /u01/admin/ora10g/udump (sid_ora_pid.trc)

alert file, 一般可以看懂, 每天确认, 隔一段时间, 比如一个星期, 备份一下, 删除一下里边内容. (这个最重要, 貌似就看这一个就好了)

background trace file 中的内容, 目前看不懂, 但是里边的内容包括了比如你执行一条sql语句的解析过程.

 





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值