oracle_sid, instance_name 和service_name 的區別

昨天用dbca -silent -responsefile hhu.rsp 創建了一個數據庫,其中hhu.rsp裏面有這麼2個參數設置
[quote]
#--------------------------------------------------------
# Name : GDBNAME
# Datatype : String
# Description : [color=red]Global database name of the database[/color]
# Valid values : <db_name>.<db_domain> - when database domain isn't NULL
# <db_name> - when database domain is NULL
# Default value : None
# Mandatory : Yes
#---------------------------------------------------------------------

GDBNAME = "hhu.us.oracle.com"

#---------------------------------------------------------------------
# Name : SID
# Datatype : String
# Description : [color=red]System identifier (SID) of the database[/color]
# Valid values : Check Oracle10g Administrator's Guide
# Default value : <db_name> specified in GDBNAME
# Mandatory : No
#---------------------------------------------------------------------

SID = "hhu"
[/quote]
1、db_name 對應一個數據庫(oracle database)的唯一表示,這種對於單個數據庫是足夠的,但是隨着多個數據庫構成的分佈式數據庫的普及,這中命名方法給數據庫的管理造成一定的負擔,因爲各個數據庫的名字可能一樣,造成管理上的混亂。爲了解決這種情況,引入了Db_domain參數,這樣在數據庫的標識是由Db_name和Db_domain兩個參數共同決定的,避免了因爲數據庫重名而造成管理上的混亂。

2、db_domain 定義一個數據庫所在的域,該域的命名同互聯網的“域”沒有任何關係,只是數據庫管理員爲了更好的管理分佈式數據庫而設計的。

3、GLOBAL_DBNAME對一個數據庫的唯一標識,oracle建議用此種方法命令數據庫。該值是在創建數據庫是決定的,缺省值爲Db_name. Db_domain。在以後對參數文件中Db_name與Db_domain參數的任何修改不影響Global_name的值,如果要修改Global_name,只能用ALTER DATABASE RENAME GLOBAL_NAME TO <db_name.db_domain>命令進行修改,然後修改相應參數。
下面是官方文檔的解釋,當database service處理一個客戶端的請求,監聽將嘗試該參數值與客戶端鏈接標示符中的service_name 是否一至。
[quote]Use the parameter GLOBAL_DBNAME to identify the database service.
While processing a client connection request, the listener tries to match the value of this parameter with the value of the SERVICE_NAME parameter in the client connect descriptor. If the client connect descriptor uses the SID parameter, then the listener does not attempt to map the values. This parameter is primarily intended for configurations with Oracle8 release 8.0 or Oracle7 databases (where dynamic service registration is not supported for dedicated servers). This parameter may also be required for use with Oracle9i and Oracle8 database services by some configurations and management tools.

The value for this parameter is typically obtained from the combination of the DB_NAME and DB_DOMAIN parameters (DB_NAME.DB_DOMAIN) in the initialization parameter file, but the value can also contain any valid name used by clients to identify the service.[/quote]
4、Instance_name 數據庫實例名。用於和操作系統之間的聯繫,用於對外部連接時使用。在操作系統中要取得與數據庫之間的交互,必須使用數據庫實例名。例如,要和某一個數據庫server連接,就必須知道其數據庫實例名,只知道數據庫名是沒有用的,與數據庫名不同,在數據安裝或創建數據庫之後,
db_name與instance_name的聯繫:數據庫名和實例名是一對一的關係,但如果在oracle並行服務器架構(即oracle實時應用集羣)中,數據庫名和實例名是一對多的關係(一個數據庫對應多個實例,同一時間內用戶只一個實例相聯繫,當某一實例出現故障,其它實例自動服務,以保證數據庫安全運行) 。
instance_name參數是ORACLE數據庫的參數,此參數可以在參數文件中查詢到,而ORACLE_SID參數則是操作系統環境變量,用於和操作系統的交互,在數據庫安裝好後,oracle_sid被用於定義數據庫參數文件的名稱。如 :$ORACLE_BASE/admin/DB_NAME/pfile/init$ORACLE_SID.ora。

5、service_name
該參數是oracle8i新引進的。在8i以前,我們用SID來表示標識數據庫的一個實例,但是在Oracle的並行環境中,一個數據庫對應多個實例,這樣就需要多個網絡服務名,設置繁瑣。爲了方便並行環境中的設置,引進了Service_name參數,該參數對應一個數據庫,而不是一個實例,而且該參數有許多其它的好處。該參數的缺省值爲Db_name. Db_domain,即等於Global_name。一個數據庫可以對應多個Service_name,以便實現更靈活的配置。該參數與SID沒有直接關係,即不必Service name 必須與SID一樣。

[quote]SQL> show parameter instance_name

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
instance_name string hhu
SQL> show parameter service

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
service_names string hhu.us.oracle.com
SQL> show parameter db_domain

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_domain string us.oracle.com

Linux下
[oracle@dagu response]$ env | grep ORACLE
ORACLE_SID=orc
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
[/quote]
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章