oracle的那些名字,那些事

  对于初学者,oracle的很多名字令人迷茫。我也是哈。数据库名-全局名-服务名-实例名-别名之间的关系,剪不断,理还乱,理解了,别有一番滋味在心头。

  SQL> show parameter name


  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不是全局数据库名哦。


  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.


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


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';
ORACLE instance started.

Total System Global Area  419430400 bytes
Fixed Size                  1219760 bytes
Variable Size             121635664 bytes
Database Buffers          293601280 bytes
Redo Buffers                2973696 bytes
SQL> select instance_name from v$instance;

INSTANCE_NAME
------------------------------------------------
think
SQL> !ps -ef|grep ora_
oracle    1937     1  0 15:01 ?        00:00:00 ora_pmon_think
oracle    1939     1  0 15:01 ?        00:00:00 ora_psp0_think
oracle    1941     1  0 15:01 ?        00:00:00 ora_mman_think
oracle    1943     1  0 15:01 ?        00:00:00 ora_dbw0_think
oracle    1945     1  0 15:01 ?        00:00:00 ora_lgwr_think
oracle    1947     1  0 15:01 ?        00:00:00 ora_ckpt_think
oracle    1949     1  0 15:01 ?        00:00:00 ora_smon_think
oracle    1951     1  0 15:01 ?        00:00:00 ora_reco_think
oracle    1953     1  0 15:01 ?        00:00:00 ora_cjq0_think
oracle    1955     1  0 15:01 ?        00:00:00 ora_mmon_think
oracle    1957     1  0 15:01 ?        00:00:00 ora_mmnl_think
oracle    1959     1  0 15:01 ?        00:00:00 ora_d000_think
oracle    1961     1  0 15:01 ?        00:00:00 ora_s000_think
oracle    2055  1911  0 15:06 pts/3    00:00:00 /bin/bash -c ps -ef|grep ora_
oracle    2057  2055  0 15:06 pts/3    00:00:00 grep ora_



  NO.4
  global_name:如果是分布式数据库,db_name会出现重名。global_name是对db_name的扩展。管理上采用和service_name一样的方式。即:加个db.domain。在db link时,必须关心一下global_name.这个缺省下,是作为网络服务名对外提供服务的。但大部分我们是不用的。
  SQL> show parameter global_names


NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
global_names                         boolean     FALSE
  GLOBAL_NAMES参数并不是用来控制GLOBAL_NAME的,而是用来限制DBLINK的使用.GLOBAL_NAMES参数的作用,简单得说来就是:当GLOBAL_NAMES参数设置为TRUE时,使用DBLINK的名称必须与被连接库的GLOBAL_NAME一致。
  SQL> select * from global_name;

GLOBAL_NAME
------------------------------------------------------------------------------------------------------------------------------------------------------
ORCL.ORACLE.COM

  全局数据库名可以从视图global_name里面获取。


  NO.5
  db_unique_name
  是数据库的别名,小名。在initorcl.ora中修改。配置DG时需要关心他。
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值