Oracle数据库中主要配置文件解析

2010-11-03  张林 

Oracle数据库中主要配置文件解析

1. os env
/etc/etc/profile
~/.bash_profile
ORACLE_BASE=/opt/oracle/product
export ORACLE_BASE
ORACLE_SID=pdhptlt10g
ORAENV_ASK=NO
. oraenv
ORAENV_ASK=YES

ORAENV_HOME=/opt/oracle/product/10.2.0.4.0.as
如: 定义 ORACLE_HOME时 用 到 了 ORACLE_BASE,那 么 ORACLE_HOME 的 定 义 应 该 在ORACLE_BASE之后

2) oratab
/etc/oratab 文件描述目前系统中创建的数据库实例 以及是否通过 dbstart 和dbshut 来控制该实例的启动与关闭 如下所示 忽略以#开头的注释部分 :
cams:/u01/app/oracle/product/8.1.7:Y
其中 cams 为实例 ID /u01/app/oracle/product/8.1.7为 ORACLE_HOME目录 Y表示允许使用 dbstart和 dbshut 启动和关闭该实例数据库 如果设置为N 表示不通过 dbstart 和 dbshut 启动和关闭实例数据库 CAMS 系统要求在安装完 ORACLE 后要求将该参数修改为 Y 以保证 ORACLE 数据库自启动和关闭


3) oracle spfile和pfile
a. spfile${ORACLE_SID}.ora
b. spfile.ora
c. init${ORACLESID}.ora

查看系统是以pfile还是spfile启动
 Select isspecified,count(*) from v$spparameter group by isspecified;
 如果isspecified里有true,表明用spfile进行了指定配置
 如果全为false,则表明用pfile启动
 
使用SPfile的好处
 Spfile改正了pfile管理混乱的问题,在多结点的环境里,pfile会有多个image
    启动时候需要跟踪最新的image。这是个烦琐的过程。
 用spfile以后,所有参数改变都写到spfile里面(只要定义scope=spfile或both),参数配置有个权威的来源。

查看spfile location
 show parameter spfile

从spfile获取pfile
 Create pfile='d:pfileSID.ora' from spfile;
 Create pfile='d:pfileSID.ora' from spfile='spfile_location';

从pfile获取spfile
 Create spfile from pfile='Your_pfile_location'
 Create spfile='spfile_location' from pfile='Your_pfile_location'
  e.g.(windows2003)
Create spfile='F:\ngenpbt\db\dbdump\spfile\spfilengenpbt.ora' from pfile='F:\ngenpbt\db\dbdump\pfile\initngenpbt.ora'

动态修改参数
 alter system set parameter=Value scope=spfile|both|memory
 
Startup nomount的时候需要读去spfile或pfile,两者共存,spfile优先

强制用pfile启动
 SQL>startup pfile='Your_Pfile.ora'
 startup spfile='/data/oracle/product/10.2.0/db_1/dbs/dbs/spfile_mqq.ora' force

通过pfile连接到spfile启动
    修改pfile文件

fyi,
http://www.cnblogs.com/jacktu/archive/2008/02/27/1083232.html
http://www.orafaq.com/node/5
http://www.eygle.com/archives/2005/10/oracle9i_feature_spfile01.html

Checking:
select decode(count(*), 1, 'spfile', 'pfile' ) USED
from v$spparameter
where rownum=1 and isspecified='TRUE'
4) listener.ora
Configuring the Listener

Configuring the listener is easy enough. The listener are configured in the $ORACLE_HOME/network/admin/listener.ora configuration file. Here is a basic configuration:

LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.10.0.130)(PORT = 1521))
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(ORACLE_HOME = /u01/app/oracle/product/10.1.0/db_1)
(SID_NAME = test)
)
)

The first section is labeled "LISTENER", this is the name of the listener itself, and can be anything you like although "LISTENER" is the traditional name. Then we have some nested configuration parameters, the most important of which is the address section, which in this case specifies the listener to use TCP, on host address 10.10.0.130 port 1521. Port 1521 is the traditional default port, but again you can use anything you like.

The SID_LIST_LISTENER defines our essential parameters, namely the SID_NAME (same as $ORACLE_SID) and ORACLE_HOME (same as $ORACLE_HOME). The name "SID_LIST_LISTENER" actually is derived from the LISTENER name, so if you did actually change the listeners name to "MYLISTENER", for instance, your second section would be "SID_LIST_MYLISTENER".

If you wanted to have multiple databases specified you could nest more SID_DESC parameters in the SID_LIST. In the same way, if you wanted to listen on diffrent IP addresses you could use multiple DESCRIPTION sections in the DESCRIPTION_LIST. For example:

LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.10.0.130)(PORT = 1521))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.20.0.10)(PORT = 1522))
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(ORACLE_HOME = /u01/app/oracle/product/10.1.0/db_1)
(SID_NAME = test)
)
(SID_DESC =
(ORACLE_HOME = /u01/app/oracle/product/10.1.0/db_1)
(SID_NAME = anotherdb)
)
)

fyi, http://www.cuddletech.com/articles/oracle/node1.html
5) sqlnet.ora
sqlnet.ora 文件的存放路径为 $ORACLE_HOME/network/admin
以下是一个示例
NAMES.DEFAULT_DOMAIN = localdomain
NAMES.DIRECTORY_PATH= (TNSNAMES, ONAMES, HOSTNAME)
说明 NAMES.DEFAULT_DOMAIN 指定网络域名 NAMES.DIRECTORY_PATH指定当解析客户端连接标识符时命名方法 naming metthods 采用的优先顺序
从左至右递减,在 CAMS 应用中, 这两个参数采用上述所示的系统缺省值

e.g,
# This file is actually generated by netca. But if customers choose to
# install "Software Only", this file wont exist and without the native
# authentication, they will not be able to connect to the database on NT.
SQLNET.AUTHENTICATION_SERVICES = (NTS)
6) tnsnames.ora
PDHPTLT10G,PDHPTLT10G_YDCRH08,PDHPTLT10G_YDCRH08.WORLD =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 172.18.133.154)(PORT = 15037))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = pdhptlt10g)
    )
  )

394°/3941 人阅读/0 条评论 发表评论

登录 后发表评论