--=============================================================
-- ORACLE_SID 、 DB_NAME 、 INSTANCE_NAME 、 DB_DOMIAN 、 GLOBAL_NAME
--=============================================================
?
??? ORACLE_SID 、 DB_NAME 、 INSTANCE_NAME 、 DB_DOMIAN 、 GLOBAL_NAMES 是 Oracle 中幾個重要的參數,而且也比較容易混淆,下面給出這些參數的具體描述。
???
一、 SID 、 ORACLE_SID :
??? SID 的全稱為 site identifier , Oracle_SID 則為 Oracle site identifier .
??? 下面引用 Tom ( Thomas Kyte ) 的一段話來解釋 Oracle_SID
???
??????? If you’re unfamiliar with the term SID or ORACLE_SID, a full definition is called for. The SID is a site identifier. It and ORACLE_HOME (where the Oracle software is installed) are hashed together in UNIX to create a unique key name for attaching an SGA. If your ORACLE_SID or ORACLE_HOME is not set correctly, you’ll get the ORACLE NOT AVAILABLE error, since you can’t attach to a shared memory segment that is identified by ??? this unique key. On Windows, shared memory isn’t used in the same fashion as UNIX, but the SID is still ? important. You can have more than one database on the same ORACLE_HOME, so you need a way to uniquely identify each one, along with their configuration files.
???????
??? 即:在 Unix 系統中, SID 和 ORACLE_HOME 在一起哈希后得到一個唯一的值作為 SGA 的 key 。
??????? 當 oracle 實例啟動時,在操作系統上的 fork 進程則根據 Oracle_SID 來創建相關后臺進程。
??????? Oracle 11g 支持 Oracle_SID 的長度為 12 位, db_name 的長度為 8 位
???????
??? 作用:
??????? 用于區別同一臺主機上不同的 Oracle 實例
??????? 決定實例所啟動后臺進程的名稱。 ( 實例由 SGA 和后臺進程組成 )
??????? 決定了參數文件的名稱。如 spfile < ORACLE_SID >. ora , init < ORACLE_SID >. ora
??????? 決定后臺進程產生的相關跟蹤文件、日志文件等。
如 alert_ < ORACLE_SID>.log,<ORACLE_SID > _arc1_ < spid >. trc ,< SID > _ora_ < SPID >. trc
??????? 同一主機上不同的 $ORACLE_HOME ,可以創建相同的 ORACLE_SID
??????? 由此可以得出
??? ??????? ORACLE_HOME 相同時,可以使用不同的 ORACLE_SID
??????? ??? ORACLE_HOME 不同時,可以使用相同的 ORACLE_SID ?????
?
??????? [oracle@robinson ~]$ export ORACLE_SID = orcl ?? -- 設定 ORACLE_SID 為 orcl
??????? [oracle@robinson ~]$ sqlplus / as sysdba;
?
??????? SQL * Plus : Release 10.2.0.1.0 - Production on Wed Sep 1 09 : 46 : 36 2010
?
??????? Copyright ( c ) 1982 , 2005 , Oracle . ? All rights reserved .
?
??????? Connected to an idle instance .
?
??????? SQL > startup nomount ;
??????? ORACLE instance started .
?
??????? Total System Global Area ? 469762048 bytes
??????? Fixed Size ????????????????? 1220048 bytes
??????? Variable Size ???????????? 117441072 bytes
??????? Database Buffers ????????? 348127232 bytes
??????? Redo Buffers ??????????????? 2973696 bytes
???????
??????? SQL > ho ps - ef | grep oracle ?? --ORACLE_SID 參與了后臺進程命名
??????? oracle ??? 3272 ???? 1 ? 0 09 : 46 ? ??????? 00 : 00 : 00 ora_pmon_orcl
??????? oracle ??? 3274 ???? 1 ? 0 09 : 46 ? ??????? 00 : 00 : 00 ora_psp0_orcl
??????? oracle ??? 3276 ???? 1 ? 1 09 : 46 ? ??????? 00 : 00 : 00 ora_mman_orcl
??????? oracle ??? 3278 ???? 1 ? 0 09 : 46 ? ??????? 00 : 00 : 00 ora_dbw0_orcl
??????? oracle ??? 3280 ???? 1 ? 0 09 : 46 ? ??????? 00 : 00 : 00 ora_lgwr_orcl
??????? oracle ??? 3282 ???? 1 ? 0 09 : 46 ? ??????? 00 : 00 : 00 ora_ckpt_orcl
??????? oracle ??? 3284 ???? 1 ? 0 09 : 46 ? ??????? 00 : 00 : 00 ora_smon_orcl
??????? ---------............ 部分結果省略 .............. --------------
?
二、 INSTANCE_NAME
??? 用于標識數據庫實例的名稱,缺省值通常為 ORACLE_SID
??? 用于和操作系統之間聯系,根據實例名產生的響應的實例來取得與數據庫的交互
??? 初始化參數中 INSTANCE_NAME 與 ORACLE_SID 可以不同
??? 不同的實例可以擁有相同的 INSTANCE_NAME ,只要 ORACLE_SID 不同,則與 ORACLE_HOME 哈希可以得到不同的值
??? INSTANCE_NAME 可以用于向監聽器動態注冊
?
??? [oracle@robinson ~]$ cp $ORACLE_HOME / dbs / initorcl . ora $ORACLE_HOME / dbs / initscott . ora
??? [oracle@robinson ~]$ export ORACLE_SID = scott ?????????? -- 設定 ORACLE_SID 為 scott
??? [oracle@robinson ~]$ env | grep ORA
??? ORACLE_SID = scott
??? ORACLE_BASE =/ u01 / app / oracle
??? ORACLE_HOME =/ u01 / app / oracle / 10g
??? [oracle@robinson ~]$ sqlplus / as sysdba ?
?
??? SQL * Plus : Release 10.2.0.1.0 - Production on Wed Sep 1 10 : 04 : 59 2010
?
??? Copyright ( c ) 1982 , 2005 , Oracle . ? All rights reserved .
?
??? Connected to an idle instance .
?
??? SQL> startup nomount; ???????????????????????????????? -- 啟動實例 scott
??? ORACLE instance started.
?
??? Total System Global Area ? 469762048 bytes
??? Fixed Size ????????????????? 1220048 bytes
??? Variable Size ???????????? 134218288 bytes
??? Database Buffers ????????? 331350016 bytes
??? Redo Buffers ??????????????? 2973696 bytes
???
??? SQL > show parameter instance_name ; ?????????????????
?
??? NAME ???????????????????????????????? TYPE ??????? VALUE
??? ------------------------------------ ----------- ------------------------------
??? instance_name ??????????????????????? string ????? scott
?
??? SQL > ho ps - ef | grep scott ???? -- 可以看到后臺以 scott 命名的進程
??? oracle ??? 3489 ???? 1 ? 0 10 : 05 ? ??????? 00 : 00 : 00 ora_pmon_scott
??? oracle ??? 3491 ???? 1 ? 0 10 : 05 ? ??????? 00 : 00 : 00 ora_psp0_scott
??? oracle ??? 3493 ???? 1 ? 0 10 : 05 ? ??????? 00 : 00 : 00 ora_mman_scott
??? oracle ??? 3495 ???? 1 ? 0 10 : 05 ? ??????? 00 : 00 : 00 ora_dbw0_scott
??? oracle ??? 3497 ???? 1 ? 0 10 : 05 ? ??????? 00 : 00 : 00 ora_lgwr_scott
??? oracle ??? 3499 ???? 1 ? 0 10 : 05 ? ??????? 00 : 00 : 00 ora_ckpt_scott
??? ---------............ 部分結果省略 .............. --------------
?
??? SQL > ho ps - ef | grep ora -- 此時可以看到后臺啟動了 orcl 和 scott 兩個實例
??? oracle ??? 3445 ???? 1 ? 0 10 : 01 ? ??????? 00 : 00 : 00 ora_pmon_orcl
??? oracle ??? 3447 ???? 1 ? 0 10 : 01 ? ??????? 00 : 00 : 00 ora_psp0_orcl
??? oracle ??? 3449 ???? 1 ? 0 10 : 01 ? ??????? 00 : 00 : 00 ora_mman_orcl
??? oracle ??? 3451 ???? 1 ? 0 10 : 01 ? ??????? 00 : 00 : 00 ora_dbw0_orcl
??? oracle ??? 3453 ???? 1 ? 0 10 : 01 ? ??????? 00 : 00 : 00 ora_lgwr_orcl
??? oracle ??? 3455 ???? 1 ? 0 10 : 01 ? ??????? 00 : 00 : 00 ora_ckpt_orcl
??? oracle ??? 3457 ???? 1 ? 0 10 : 01 ? ??????? 00 : 00 : 00 ora_smon_orcl
??? oracle ??? 3497 ???? 1 ? 0 10 : 05 ? ??????? 00 : 00 : 00 ora_lgwr_scott
??? oracle ??? 3499 ???? 1 ? 0 10 : 05 ? ??????? 00 : 00 : 00 ora_ckpt_scott
??? oracle ??? 3501 ???? 1 ? 0 10 : 05 ? ??????? 00 : 00 : 00 ora_smon_scott
??? oracle ??? 3503 ???? 1 ? 0 10 : 05 ? ??????? 00 : 00 : 00 ora_reco_scott
??? oracle ??? 3505 ???? 1 ? 0 10 : 05 ? ??????? 00 : 00 : 00 ora_cjq0_scott
??? oracle ??? 3507 ???? 1 ? 0 10 : 05 ? ??????? 00 : 00 : 00 ora_mmon_scott
??? ---------............ 部分結果省略 .............. --------------
?
??? SQL > select * from dual ;
?
??? ADDR ?????????? INDX ??? INST_ID D
??? -------- ---------- ---------- -
??? 0C4B2FD4 ????????? 0 ????????? 1 X
?
??? -- 用于向監聽器動態注冊
??? SQL > ho lsnrctl status
?
??? LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 01-SEP-2010 12:30:13
??? -------------------------- 部分省略 ---------------------------------------
??? Listener Parameter File ?? /u01/app/oracle/10g/network/admin/listener.ora
??? Listener Log File ???????? /u01/app/oracle/10g/network/log/listener.log
??? Listening Endpoints Summary ...
??? ? ( DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
??? ? ( DESCRIPTION =( ADDRESS =( PROTOCOL = tcp )( HOST = robinson . com )( PORT = 1521 )))
??? Services Summary ...
??? Service "PLSExtProc" has 1 instance ( s ). -- 服務名 PLSExtProc 及實例名 PLSExtProc
??? ? Instance "PLSExtProc" , status UNKNOWN , has 1 handler(s) for this service...
??? Service "orcl" has 1 instance ( s ).
??? ? Instance "orcl" , status READY , has 1 handler ( s) for this service...
??? Service "orclXDB" has 1 instance ( s ). ? -- 服務名 orcl_XDB ,實例名為 orcl
??? ? Instance "orcl" , status READY , has 1 handler(s) for this service...
??? Service "orcl_XPT" has 1 instance ( s ). -- 服務名 orcl_XPT ,實例名為 orcl
??? ? Instance "orcl" , status READY , has 1 handler ( s ) for this service...
??? The command completed successfully
?
三、 DB_NAME
??? 數據庫的唯一標識,是一個不超過 8 個字符的文本串
在創建數據庫時定義,被記錄在數據文件、控制文件和日志文件當中。
??? 用于實例與數據庫的掛接,通常缺省的情況下, INSTANCE_NAME 與 DB_NAME 設置為相同。
??? 在 RAC 環境中,多實例對應于一個數據庫,故 INSTANCE_NAME 與 DB_NAME 不同。
??? 對于早期的數據庫,單單用 DB_NAME 參數足以表示一個數據庫,隨著多個數據庫構成分布式數據庫,因為數據庫名字可能一樣,為避免此類命名方式造成了管理上的混亂,引入 DB_DOMAIN 參數,即數據庫名字由 DB_NAME 和 DB_DOMAIN 兩個參數共同決定的,兩個參數中間用 . 連接,類似于互聯網上機器名的管理。兩者的組合即被稱為 GLOBAL_NAME 。關于 DB_DOMAIN 和 GLOBAL_NAME 請參照后續描述。
?
??? 實例與數據庫的關系
??????? 一個實例可以 mount 并打開任何數據庫,但同一時間一個實例僅僅只能打開一個數據庫
??????? 一個數據庫可以被一個或多個實例 mount 并打開,比如在 RAC 環境中,一個數據可以被多個實例打開
??????? 在非 RAC 環境中使用不同的實例名來打開同一個數據庫將收到錯誤提示,如下:
?
??? [oracle@robinson ~]$ export ORACLE_SID = scott ? -- 設置實例名為 scott 并啟動該實例
??? [oracle@robinson ~]$ sqlplus / as sysdba
?
??? SQL * Plus : Release 10.2.0.1.0 - Production on Wed Sep 1 12 : 41 : 49 2010
?
??? Copyright ( c ) 1982 , 2005 , Oracle . ? All rights reserved .
?
??? Connected to an idle instance.
?
??? SQL > startup
??? ORACLE instance started .
?
??? Total System Global Area ? 469762048 bytes
??? Fixed Size ????????????????? 1220048 bytes
??? Variable Size ???????????? 134218288 bytes
??? Database Buffers ????????? 331350016 bytes
??? Redo Buffers ??? ???????????? 2973696 bytes
??? ORA - 01102 : cannot mount database in EXCLUSIVE mode -- 收到錯誤信息,不能夠 mount 該數據庫
?
??? SQL > select instance_name , status from v$instance ;
?
??? INSTANCE_NAME ??? STATUS
??? ---------------- ------------
??? scott ??????????? STARTED
?
??? SQL > ho ps - ef | grep oracle ? -- 查看后臺啟動了兩個實例一個為 orcl, 一個為 scott
?
??? oracle ??? 4800 ???? 1 ? 0 12 : 19 ? ????? ?? 00 : 00 : 00 ora_pmon_orcl
??? oracle ??? 4805 ???? 1 ? 0 12 : 19 ? ??????? 00 : 00 : 00 ora_psp0_orcl
??? oracle ??? 4807 ???? 1 ? 0 12 : 19 ? ??????? 00 : 00 : 00 ora_mman_orcl
??? oracle ??? 4809 ???? 1 ? 0 12 : 19 ? ??????? 00 : 00 : 00 ora_dbw0_orcl
??? oracle ??? 4811 ???? 1 ? 0 12 : 19 ? ??????? 00 : 00 : 00 ora_lgwr_orcl
??? oracle ??? 4813 ???? 1 ? 0 12 : 19 ? ??????? 00 : 00 : 00 ora_ckpt_orcl
??? oracle ??? 4961 ???? 1 ? 0 12 : 41 ? ??????? 00 : 00 : 00 ora_pmon_scott
??? oracle ??? 4963 ???? 1 ? 0 12 : 41 ? ??????? 00 : 00 : 00 ora_psp0_scott
??? oracle ??? 4965 ???? 1 ? 0 12 : 41 ? ??????? 00 : 00 : 00 ora_mman_scott
??? oracle ??? 4967 ???? 1 ? 0 12 : 41 ? ??????? 00 : 00 : 00 ora_dbw0_scott
??? ---------............ 部分結果省略 .............. --------------
???
??? SQL > ho grep name $ORACLE_HOME / dbs / initscott . ora ? --initscott.ora 由 initorcl.ora 復制而來,故有相同的數據庫名稱
??? *. db_name = 'orcl' ???????
?
??? -- 而此時 DB_NAME='orcl' 已被實例 orcl 啟動,故收到了 ORA-01102: cannot mount database in EXCLUSIVE mode
??? -- 關閉 orcl 實例后,并啟動 scott 實例,使之加載 orcl 數據庫
???
??? SQL > ho env | grep ORA
??? ORACLE_SID = scott
??? ORACLE_BASE =/ u01 / app / oracle
??? ORACLE_HOME =/ u01 / app / oracle / 10g
?
??? SQL > startup
??? ORACLE instance started .
?
??? Total System Global Area ? 469762048 bytes
??? Fixed Size ????????????????? 1220048 bytes
??? Variable Size ???????????? 134218288 bytes
??? Database Buffers ????????? 331350016 bytes
??? Redo Buffers ??????????????? 2973696 bytes
??? Database mounted.
??? Database opened . ???? -- 正常啟動,即一個數據可以被任意實例 mount 并打開
?
??? SQL > select instance_name , status , database_status from v$instance ;
?
??? INSTANCE_NAME ??? STATUS ?????? DATABASE_STATUS
??? ---------------- ------------ -----------------
??? scott ??????????? OPEN ???????? ACTIVE
?
??? SQL > select name , open_mode from v$database ;
?
??? NAME ????? OPEN_MODE
??? --------- ----------
??? ORCL ????? READ WRITE
?
??? 總結:
??????? 一個實例可以 mount 并打開任何數據庫,但任一時刻僅僅只能打開一個數據庫
??????? 一個數據庫可以被一個或多個實例 mount 并打開,比如在 RAC 環境中,一個數據可以被多個實例打開
??????????? 如數據庫 orcl 首先被 orcl 實例打開。但不能被 scott 實例打開
??????????? 當關閉 orcl 實例后,數據庫 orcl 能夠被 scott 實例 mount 并打開
?
四、 DB_DOMAIN
??? 通常用于分布式數據庫系統中標識一個數據庫的邏輯位置。為數據定義一個域,該參數作為 Global_names 的一部分,即在不同的域中可以使用相同的數據庫名稱,該參數缺省情況下位空,在 RAC 環境中需要為每一個實例指定該值,且多實例具有相同的值
??? SQL > show parameter db_domain
?
??? NAME ???????????????????????????????? TYPE ??????? VALUE
??? ------------------------------------ ----------- ------------------------------
??? db_domain ??????????????????????????? string
???
五、 GLOBAL_NAME
一個是 GLOBAL_NAME ,一個是 GLOBAL_NAMES 參數, GLOBAL_NAME 是全局數據庫名, GLOBAL_NAMES 參數設定是否啟用全局數據庫名。
??? GLOBAL_NAME 的形式為 :DB_NAME.DB_DOMAIN
??? 修改 global_name ,只能用 ALTER DATABASE RENAME GLOBAL_NAME TO < db_name . db_domain > 命令進行修改,然后修改相應參數。
???
??? SQL > select * from global_name ; ?? -- 查看數據庫的 global_name
?
??? GLOBAL_NAME
??? --------------------------------------------------------------------------------
??? ORCL . REGRESS . RDBMS . DEV . US . ORACLE . COM
?
??? SQL > alter database rename global_name to orcl . robinson . com ; -- 修改數據庫的 global_name
?
??? Database altered .
?
??? SQL > select * from global_name ;
?
??? GLOBAL_NAME
??? --------------------------------------------------------------------------------
??? ORCL . ROBINSON . COM
???
??? GLOBAL_NAMES 參數通常對于分布式處理, Oracle 建議將該值設為 TRUE ,用于確保通連接到網絡環境使用一致性的命名方式。
??? 一般情況下假定全局數據庫的名稱為 orcl . robinosn . com ,當 GLOBAL_NAMES 設置為 true 時,數據庫執行調用時會核查鏈接的名字是否和遠程
??? 全局數據庫名稱一致,否則如果為 false ,可以任意定義數據庫鏈接的名字。
??? 假定遠程數據庫名稱為 orcl . robinosn . com ,參數 global_names 設為 true , 則必須使用下面的方式來調用
??????? select * from scott . emp@orcl . robinson . com
??? 如果 global_names 設為 false , 則可以使用定義的任意名字來調用
??????? select * from scott . emp@orclalias
???????
??? SQL > show parameter global_names ?? -- 查看 global_names 參數的設置情況
?
??? NAME ???????????????????????????????? TYPE ??????? VALUE
??? ------------------------------------ ----------- ------------------------------
??? global_names ???????????????????????? boolean ???? FALSE ?
???
??? 關于 GLOBAL_NAMES 更多參考: Oracle Database Administrator’s Guide ( Distributed Database Concepts )
?
???
六、 GLOBAL_DBNAME
??? 事實上, GLOBAL_DBNAME 并不是一個初始化參數文件中的參數,而是在配置偵聽器中用于標識數據庫服務
??? 下面是來自 Oracle 的官方描述
??? Identifies 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 databases(where dynamic service registration is not supported for dedicated servers). This parameter may also be required for use with Oracle8i and higher database services by some configurations.
??????? 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.
???????
??? 也稱為全局數據庫名稱,是對一個數據庫( Oracle database )的唯一標識, oracle 建議用此種方法命令數據庫。
??? 該值是在創建數據庫是決定,缺省值為 DB_NAME.DB_DOMAIN 。
??? 在以后對參數文件中 DB_NAME 與 DB_DOMAIN 參數的任何修改不影響 GLOBAL_NAME 的值
???
七、更多 ???
?
?
?
?
?
? Oracle 聯機重做日志文件(ONLINE LOG FILE)
?
?
?
?
?
?
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
