oracle的那些名字,那些事(一)

2014-11-24 11:46:42 · 作者: · 浏览: 0

oracle的那些名字,那些事
对于初学者,oracle的很多名字令人迷茫。我也是哈。 数据库名-全局名-服务名-实例名-别名之间的关系,剪不断,理还乱,理解了,别有一番滋味在心头。
SQL> show parameter name
www.2cto.com
NAME TYPE VALUE
------------------------------------ ---------------------------------
db_name string orcl
db_unique_name string orcl
global_names boolean FALSE
instance_name string orcl
service_names string orcl.oracle.com
缺省下,这些名字都是一样的。下面我们来学习一下这几个name。注意,这里的global_names不是全局数据库名哦。
www.2cto.com
NO.1
Service_name:为实例所连接的数据库定义一个或多个服务名。可以通过定义多个服务名将不同的用户区分开来,如销售用户可以在客服端定义sales服务名来访问连接,新闻用户可以通过news服务名来进行连接,这样,用户可以不必关心数据库是哪一个,他们只要知道服务名便可。这个参数的缺省格式是:**.db_domain。因此,监听配置时,在客服端的TNSNAMES.ORA文件配置中,service_name和sid是可以互相替换的,但oracle建议,用service_name而不是sid。在客户端配置完tnsname后,记得tnsping service_name测试一下。若能tnsping通的话,就可以conn user/pwd@service_name.
NO.2
db_name:是数据库的身份证号。是启动到nomount的最小参数。在数据库安装或创建完成之后,参数DB_NAME被写入参数文件之中。在创建数据库时就应考虑好数据库名,
并且在创建完数据库之后,数据库名不宜修改,即使要修改也会很麻烦。因为,数据库名还被写入控制文件中,控制文件是以二进制型式存储的,用户无法修改控制文件的内
容。假设用户修改了参数文件中的数据库名,即修改DB_NAME的值。但是在 Oracle启动时,由于参数文件中的DB_NAME与控制文件中的数据库名不一致,导致数据库启动失败,将返回ORA-01103错误。
NO.3
instance_name:实例名是可以随便修改的。下面来测试一下:
当实例名为orcl时:
[oracle@localhost ~]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Mon Jul 16 14:49:47 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> conn / as sysdba
Connected to an idle instance.
SQL> startup nomount
ORACLE instance started.
www.2cto.com
Total System Global Area 419430400 bytes
Fixed Size 1219760 bytes
Variable Size 125829968 bytes
Database Buffers 289406976 bytes
Redo Buffers 2973696 bytes
SQL> create pfile from spfile;
File created.
SQL> !ls $ORACLE_HOME/dbs
hc_orcl.dat init.ora lkORCL spfileorcl.ora
initdw.ora initorcl.ora orapworcl
www.2cto.com
SQL> !ps -ef|grep ora_
oracle 1695 1 0 14:50 00:00:00 ora_pmon_orcl
oracle 1697 1 0 14:50 00:00:00 ora_psp0_orcl
oracle 1699 1 0 14:50 00:00:00 ora_mman_orcl
oracle 1701 1 0 14:50 00:00:00 ora_dbw0_orcl
oracle 1703 1 0 14:50 00:00:00 ora_lgwr_orcl
oracle 1705 1 0 14:50 00:00:00 ora_ckpt_orcl
oracle 1707 1 0 14:50 00:00:00 ora_smon_orcl
oracle 1709 1 0 14:50 00:00:00 ora_reco_orcl
oracle 1711 1 0 14:50 00:00:00 ora_cjq0_orcl
oracle 1713 1 0 14:50 00:00:00 ora_mmon_orcl
oracle 1715 1 0 14:50 00:00:00 ora_mmnl_orcl
oracle 1717 1 0 14:50 00:00:00 ora_d000_orcl
oracle 1719 1 0 14:50 00:00:00 ora_s000_orcl
oracle 1739 1687 0 14:51 pts/2 00:00:00 /bin/bash -c ps -ef|grep ora_
当实例名为think时:
[oracle@localhost ~]$ export ORACLE_SID=think
[oracle@localhost ~]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Mon Jul 16 15:00:16 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> conn / as sysdba
Connected to an idle instance.
SQL> startup nomount
pfile='/u01/app/oracle/product/10.2.0/db_1/dbs/initorcl.ora';
O