查看SPFILE参数信息:parameter
SQL> desc v$parameter;
Name Null? Type
----------------------------------------- -------- ----------------------------
NUM NUMBER
NAME VARCHAR2(80)
TYPE NUMBER
VALUE VARCHAR2(4000)
DISPLAY_VALUE VARCHAR2(4000)
ISDEFAULT VARCHAR2(9)
ISSES_MODIFIABLE VARCHAR2(5)
ISSYS_MODIFIABLE VARCHAR2(9)
ISINSTANCE_MODIFIABLE VARCHAR2(5)
ISMODIFIED VARCHAR2(10)
ISADJUSTED VARCHAR2(5)
ISDEPRECATED VARCHAR2(5)
ISBASIC VARCHAR2(5)
DESCRIPTION VARCHAR2(255)
UPDATE_COMMENT VARCHAR2(255)
HASH NUMBER
SQL> show parameter sga;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
lock_sga boolean FALSE
pre_page_sga boolean FALSE
sga_max_size big integer 800M
sga_target big integer 0
=======================================================================
初始化参数文件PFILE(静态参数文件) & SPFILE(永久参数文件) ,数据库startup的时候需要读取该文件
PFILE ==>initSID.ora
1)是一个TEXT文件;
2)可以用系统文本编辑器编辑;
3)可以手动修改;
4)修改后在下一次重启数据库后才生效;
5)缺省所在目录:$ORACLE_HOME/dbs
[oracle@server01 dbs]$ env | grep ORACLE_HOME
ORACLE_HOME=/opt/oracle/product/10.2.0/db_1
[oracle@server01 dbs]$ ll
total 9544
-rw-rw---- 1 oracle oinstall 1544 Mar 8 22:21 hc_ora1.dat
-rw-rw---- 1 oracle oinstall 1544 Mar 13 2013 hc_orcl.dat
-rw-r--r-- 1 oracle oinstall 2851 May 15 2009 init.ora
-rw-r----- 1 oracle oinstall 24 Jul 16 2013 lkORA1
-rw-r----- 1 oracle oinstall 1536 Jul 16 2013 orapwora1
-rw-r----- 1 oracle oinstall 9748480 Mar 14 2013 snapcf_ora1.f
-rw-r----- 1 oracle oinstall 2560 Mar 10 22:00 spfileora1.ora
[oracle@server01 dbs]$ env | grep ORACL
ORACLE_SID=ora1
ORACLE_BASE=/opt/oracle
ORACLE_HOME=/opt/oracle/product/10.2.0/db_1
=======================================================================
spfile
1)二进制文件
2)需要用oracle SQL维护,较pfile安全性高;
3)一直存在于oracle数据库服务器端;(pfile可以存在客户端,spfile更集中管理)
4)关闭和启动oracle状态都可以修改该文件;
5)RMAN可以备份spfile。
从pfile创建spfile:
SQL> create spfile from pfile;
SQL> create spfile ='ddddd' from pfile='ddddd'; #可以指定路径
eg:
QL> shutdown abort
ORACLE instance shut down.
SQL> create spfile from pfile;
File created.
SQL> !
[oracle@server01 dbs]$ ll
total 24
-rw-rw---- 1 oracle oinstall 1544 Mar 21 12:21 hc_ora1.dat
-rw-r--r-- 1 oracle oinstall 919 Mar 21 12:19 initora1.ora
-rw-r----- 1 oracle oinstall 24 Mar 21 12:18 lkORA1
drwxr-xr-x 2 oracle oinstall 4096 Mar 21 12:13 old
-rw-r----- 1 oracle oinstall 1536 Mar 21 12:15 orapwora1
-rw-r----- 1 oracle oinstall 2560 Mar 21 12:21 spfileora1.ora
[oracle@server01 dbs]$ exit
exit
SQL> startup
ORACLE instance started.
Total System Global Area 835104768 bytes
Fixed Size 2232960 bytes
Variable Size 612371840 bytes
Database Buffers 218103808 bytes
Redo Buffers 2396160 bytes
Database mounted.
Database opened.
修改SPFILE参数:
alter system set
SQL> show parameter undo
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
undo_management string AUTO
undo_retention integer 900
undo_tablespace string UNDOTBS1
SQL> alter system set undo_retention=901 scope=both sid='ora1'; #####scope=[memory|spfile|both],重置回默认值则用reset
System altered.
SQL>
SQL>
SQL> show parameter undo
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
undo_management string AUTO
undo_retention integer 901
undo_tablespace string UNDOTBS1
====================================================
PFILE和SPFILE区别:
1.SPFILE可以被RMAN备份;
2.修改SPFILE比修改PFILE更安全,减少手工修改错误;
3.SPFILE文件只在服务器端,提高安全性;
==================================================================================================
startup顺序:
->spfileSID.ora
->spfile.ora
->initSID.ora
->默认pfile(需要再SQL手动指定pfile路径启动)
注:startup pfile='ddddd';
不能指定从spfile启动
====================================================================
测试从指定的pfile启动
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> !
[oracle@server01 dbs]$ ll
total 24
-rw-rw---- 1 oracle oinstall 1544 Mar 21 12:40 hc_ora1.dat
-rw-r--r-- 1 oracle oinstall 919 Mar 21 12:19 initora1.ora
-rw-r----- 1 oracle oinstall 24 Mar 21 12:18 lkORA1
drwxr-xr-x 2 oracle oinstall 4096 Mar 21 12:13 old
-rw-r----- 1 oracle oinstall 1536 Mar 21 12:15 orapwora1
-rw-r----- 1 oracle oinstall 2560 Mar 21 12:21 spfileora1.ora
[oracle@server01 dbs]$ rm -rf spfileora1.ora
[oracle@server01 dbs]$ ps -ef | grep oracle
oracle 4135 1 0 11:04 ? 00:00:00 /opt/oracle/product/10.2.0/db_1/bin/tnslsnr LISTENER -inherit
root 4213 4189 0 11:05 pts/0 00:00:00 su - oracle
oracle 4214 4213 0 11:05 pts/0 00:00:00 -bash
oracle 4244 4214 0 11:06 pts/0 00:00:00 sqlplus
root 5596 5572 0 12:12 pts/1 00:00:00 su - oracle
oracle 5597 5596 0 12:12 pts/1 00:00:00 -bash
oracle 5629 5597 0 12:12 pts/1 00:00:00 sqlplus
oracle 5630 5629 0 12:12 ? 00:00:00 oracleora1 (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
oracle 5641 5629 0 12:12 pts/1 00:00:00 /bin/bash
oracle 6586 5641 0 12:40 pts/1 00:00:00 sqlplus
oracle 6594 6586 0 12:40 ? 00:00:00 oracleora1 (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
oracle 6596 6586 0 12:40 pts/1 00:00:00 /bin/bash
oracle 6616 6596 3 12:41 pts/1 00:00:00 ps -ef
oracle 6617 6596 0 12:41 pts/1 00:00:00 grep oracle
[oracle@server01 dbs]$ rm -rf initora1.ora
[oracle@server01 dbs]$ cp old/spfileora1.ora spfile123.ora
[oracle@server01 dbs]$ more 123.ora
spfile=$ORACLE_HOME/dbs/spfile123.ora
[oracle@server01 dbs]$ ll
total 24
-rw-r--r-- 1 oracle oinstall 38 Mar 21 12:42 123.ora
-rw-rw---- 1 oracle oinstall 1544 Mar 21 12:40 hc_ora1.dat
-rw-r----- 1 oracle oinstall 24 Mar 21 12:18 lkORA1
drwxr-xr-x 2 oracle oinstall 4096 Mar 21 12:13 old
-rw-r----- 1 oracle oinstall 1536 Mar 21 12:15 orapwora1
-rw-r----- 1 oracle oinstall 2560 Mar 21 12:41 spfile123.ora
[oracle@server01 dbs]$ exit
exit
SQL> startup pfile=$ORACLE_HOME/dbs/123.ora;
ORACLE instance started.
Total System Global Area 835104768 bytes
Fixed Size 2232960 bytes
Variable Size 612371840 bytes
Database Buffers 218103808 bytes
Redo Buffers 2396160 bytes
Database mounted.
Database opened.
========================================
数据库启动阶段过程:
shutdown 关闭数据库 ####关闭过程:close the database -->umount a database -->shutdown a instance
nomount 启动instance,并分配了SGA内存,但是database还为挂载
mount 使database挂载,ctrol files可用
open 使database正常打开, datafiles和redolog files都可用,正常运行
==================================================
数据库启动过程:
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 835104768 bytes
Fixed Size 2232960 bytes
Variable Size 612371840 bytes
Database Buffers 218103808 bytes
Redo Buffers 2396160 bytes
SQL> alter database mount;
Database altered.
SQL> alter database open; ###alter database open read only 变为只读状态,数据库不能提供写入操作
Database altered.
=============================================================================
诊断文件(diagnostic files):用于诊断和分析问题
1.alert_SID.log
SQL> show parameter dump;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
background_core_dump string partial
background_dump_dest string /opt/oracle/diag/rdbms/ora1/ora1/trace #记录了alert_SID.log的路径
core_dump_dest string /opt/oracle/diag/rdbms/ora1/ora1/cdump
max_dump_file_size string unlimited
shadow_core_dump string partial
user_dump_dest string /opt/oracle/diag/rdbms/ora1/ora1/trace ###user trace files路径
SQL> !
[oracle@server01 trace]$ pwd
/opt/oracle/diag/rdbms/ora1/ora1/trace
[oracle@server01 trace]$ ll
total 1192
-rw-r----- 1 oracle oinstall 222728 Mar 21 16:33 alert_ora1.log
-rw-r----- 1 oracle oinstall 9159 Mar 20 12:23 ora1_mmon_5186.trc #backgroud trace files
-rw-r----- 1 oracle oinstall 891 Mar 20 12:23 ora1_mmon_5186.trm
-rw-r----- 1 oracle oinstall 918 Mar 21 12:18 ora1_mmon_5855.trc
-rw-r----- 1 oracle oinstall 60 Mar 21 12:18 ora1_mmon_5855.trm
-rw-r----- 1 oracle oinstall 1282 Mar 21 12:36 ora1_mmon_6164.trc
-rw-r----- 1 oracle oinstall 104 Mar 21 12:36 ora1_mmon_6164.trm
-rw-r----- 1 oracle oinstall 1063 Mar 21 12:48 ora1_mmon_6761.trc
-rw-r----- 1 oracle oinstall 72 Mar 21 12:48 ora1_mmon_6761.trm
-rw-r----- 1 oracle oinstall 3611 Mar 21 14:39 ora1_mmon_7072.trc
-rw-r----- 1 oracle oinstall 348 Mar 21 14:39 ora1_mmon_7072.trm
-rw-r----- 1 oracle oinstall 4339 Mar 21 17:07 ora1_mmon_9636.trc
-rw-r----- 1 oracle oinstall 404 Mar 21 17:07 ora1_mmon_9636.trm
-rw-r----- 1 oracle oinstall 1582 Mar 20 12:23 ora1_ora_11709.trc
.................
-rw-r----- 1 oracle oinstall 1582 Mar 20 12:23 ora1_ora_11709.trc #user trace files
-rw-r----- 1 oracle oinstall 133 Mar 20 12:23 ora1_ora_11709.trm
-rw-r----- 1 oracle oinstall 1141 Mar 20 14:38 ora1_ora_18113.trc
-rw-r----- 1 oracle oinstall 71 Mar 20 14:38 ora1_ora_18113.trm
-rw-r----- 1 oracle oinstall 653 Mar 20 14:41 ora1_ora_18560.trc
-rw-r----- 1 oracle oinstall 60 Mar 20 14:41 ora1_ora_18560.trm
-rw-r----- 1 oracle oinstall 653 Mar 20 14:45 ora1_ora_18693.trc
-rw-r----- 1 oracle oinstall 60 Mar 20 14:45 ora1_ora_18693.trm
-rw-r----- 1 oracle oinstall 653 Mar 20 14:46 ora1_ora_18750.trc
-rw-r----- 1 oracle oinstall 60 Mar 20 14:46 ora1_ora_18750.trm
-rw-r----- 1 oracle oinstall 835 Mar 20 14:48 ora1_ora_18852.trc
-rw-r----- 1 oracle oinstall 71 Mar 20 14:48 ora1_ora_18852.trm
alert_SID.log有关于关闭和启动的信息记录,还可以根据alert log file信息新建PFILE文件
[oracle@server01 trace]$vi alert_ora1.log
...
Picked latch-free SCN scheme 3
Using LOG_ARCHIVE_DEST_1 parameter default value as USE_DB_RECOVERY_FILE_DEST
System parameters with non-default values:
processes = 500
sessions = 772
memory_target = 800M
control_files = "/database/ora1/control01.ctl"
control_files = "/opt/oracle/fast_recovery_area/ora1/control02.ctl"
db_block_size = 8192
compatible = "11.2.0.0.0"
log_archive_format = "%t_%s_%r.dbf"
db_recovery_file_dest = "/opt/oracle/fast_recovery_area"
db_recovery_file_dest_size= 4122M
_no_recovery_through_resetlogs= TRUE
undo_tablespace = "UNDOTBS1"
remote_login_passwordfile= "EXCLUSIVE"
db_domain = ""
dispatchers = "(PROTOCOL=TCP) (SERVICE=ora1XDB)"
audit_file_dest = "/opt/oracle/admin/ora1/adump"
audit_trail = "DB"
db_name = "ora1"
open_cursors = 300
diagnostic_dest = "/opt/oracle"
.........
复制红色部分
[oracle@server01 dbs]$ vi msp.ora (把双引号改为单引号,并在control_files新增括号)
processes = 500
sessions = 772
memory_target = 800M
control_files = ('/database/ora1/control01.ctl')
control_files = ('/opt/oracle/fast_recovery_area/ora1/control02.ctl')
db_block_size = 8192
compatible = '11.2.0.0.0'
log_archive_format = '%t_%s_%r.dbf'
db_recovery_file_dest = '/opt/oracle/fast_recovery_area'
db_recovery_file_dest_size= 4122M
_no_recovery_through_resetlogs= TRUE
undo_tablespace = 'UNDOTBS1'
remote_login_passwordfile= 'EXCLUSIVE'
db_domain = ''
dispatchers = '(PROTOCOL=TCP) (SERVICE=ora1XDB)'
audit_file_dest = '/opt/oracle/admin/ora1/adump'
audit_trail = 'DB'
db_name = 'ora1'
open_cursors = 300
diagnostic_dest = '/opt/oracle'
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup pfile=$ORACLE_HOME/dbs/msp.ora
ORACLE instance started.
Total System Global Area 835104768 bytes
Fixed Size 2232960 bytes
Variable Size 490737024 bytes
Database Buffers 339738624 bytes
Redo Buffers 2396160 bytes
Database mounted.
Database opened.
SQL> create spfile='$ORACLE_HOME/dbs/spfilemsp.ora' from pfile='$ORACLE_HOME/dbs/msp.ora'; ####从新建的pfile创建spfile (注:路径要加单引号)
File created.
SQL> !
[oracle@server01 dbs]$ ll
total 32
-rw-rw---- 1 oracle oinstall 1544 Mar 21 17:48 hc_ora1.dat
-rw-r--r-- 1 oracle oinstall 2851 Mar 21 12:47 initora1.ora
-rw-r----- 1 oracle oinstall 24 Mar 21 12:18 lkORA1
-rw-r--r-- 1 oracle oinstall 845 Mar 21 17:47 msp.ora
drwxr-xr-x 2 oracle oinstall 4096 Mar 21 12:13 old_bk
-rw-r----- 1 oracle oinstall 1536 Mar 21 12:15 orapwora1
-rw-r----- 1 oracle oinstall 2560 Mar 21 17:57 spfilemsp.ora
-rw-r----- 1 oracle oinstall 2560 Mar 21 14:44 spfileora1.ora
[oracle@server01 dbs]$ strings spfilemsp.ora
mC<2
*._no_recovery_through_resetlogs=TRUE
*.audit_file_dest='/opt/oracle/admin/ora1/adump'
*.audit_trail='DB'
*.compatible='11.2.0.0.0'
*.control_files='/database/ora1/control01.ctl','/opt/oracle/fast_recovery_area/ora1/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='ora1'
*.db_recovery_file_dest='/opt/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=4122M
*.diagnostic_dest='/opt/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=ora1XDB)'
*.log_archive_format='%t_%s_%r.
dbf'
*.memory_target=800M
*.open_cursors=300
*.processes=500
*.remote_login_passwordfile='EXCLUSIVE'
*.sessions=772
*.undo_tablespace='UNDOTBS1'
总结:在pfile或者spfile损坏或丢失时候,可以从alert log文件中找到参数信息,重构pfile和spfile文件。
========================================================
2.backgroud trace files 服务进程错误
3.user trace files 单个用户访问数据库时候产生的错误
阅读(1302) | 评论(0) | 转发(0) |