單例項資料庫工具轉化多例項資料庫
需要說明一下,這篇文章不是介紹將一個單例項的資料庫環境升級為RAC環境,而是介紹如何將一個RAC環境下的單例項資料庫,轉變為多例項資料庫。
這篇介紹利用Oracle的工具進行轉化。
單例項資料庫手工轉化多例項資料庫:http://yangtingkun.itpub.net/post/468/483713
Oracle的CLUSTER軟體已經在兩個節點上建立成功,Oracle的ASM例項已經啟動。事實上,RAC環境的資料庫已經建立起來。
不過在這個RAC環境中,其中一個節點上建立了一個單例項的資料庫,資料檔案已經儲存在ASM中,因此下面要做的只是將這個資料庫變為多例項訪問的RAC資料庫。
bash-3.00$ cd $ORACLE_HOME/../crs/bin
bash-3.00$ crs_stat -t
名稱 型別 目標 狀態 主機
------------------------------------------------------------
ora.rac11g.db application OFFLINE OFFLINE
ora....g1.inst application ONLINE OFFLINE
ora....g2.inst application ONLINE OFFLINE
ora.ractest.db application OFFLINE OFFLINE
ora....t1.inst application OFFLINE OFFLINE
ora....t2.inst application OFFLINE OFFLINE
ora....SM1.asm application ONLINE ONLINE ser1
ora....R1.lsnr application ONLINE ONLINE ser1
ora.ser1.gsd application ONLINE ONLINE ser1
ora.ser1.ons application ONLINE ONLINE ser1
ora.ser1.vip application ONLINE ONLINE ser1
ora....SM2.asm application ONLINE ONLINE ser2
ora....R2.lsnr application ONLINE ONLINE ser2
ora.ser2.gsd application ONLINE ONLINE ser2
ora.ser2.ons application ONLINE ONLINE ser2
ora.ser2.vip application ONLINE ONLINE ser2
登陸資料庫進行檢查:
bash-3.00$ export ORACLE_SID=test
bash-3.00$ sqlplus "/ as sysdba"
SQL*Plus: Release 11.1.0.6.0 - Production on 星期三 4月 8 17:35:11 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.
連線到:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
SQL> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
PL/SQL Release 11.1.0.6.0 - Production
CORE 11.1.0.6.0 Production
TNS for Solaris: Version 11.1.0.6.0 - Production
NLSRTL Version 11.1.0.6.0 - Production
SQL> col parameter format a40
SQL> col value format a30
SQL> select * from v$option
2 where parameter = 'Real Application Clusters';
PARAMETER VALUE
---------------------------------------- ------------------------------
Real Application Clusters TRUE
SQL> show parameter cluster
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
cluster_database boolean FALSE
cluster_database_instances integer 1
cluster_interconnects string
SQL> select inst_id, instance_number, instance_name
2 from gv$instance;
INST_ID INSTANCE_NUMBER INSTANCE_NAME
---------- --------------- ----------------
1 1 test
建立一個PFILE,一會使用DBUA的時候需要用到。
SQL> create pfile='/export/home/oracle/inittest.ora' from spfile;
檔案已建立。
根據上面的檢查可以發現,資料庫已經安裝RAC選項,但是當前資料庫是單例項資料庫。下面透過DBUA和DBCA配合的方式將當前的資料庫變為RAC環境:
首先執行DBUA,修改單例項的配置為RAC環境配置。選擇需要修改的資料庫test,單擊確定。彈出對話方塊,內容如下:
The database “test” does not have the cluster configuration and also not listed in the registry of remote cluster nodes. Do you want the Database Upgrade Assistant to upgrade it as a single instance database?
Click Yes to upgrade it as a single instance database. Click No to upgrade it as a cluster database.
點選NO,然後輸入本地例項名稱:test。DBUA會報錯,認為是一個不可重複執行的錯誤。登陸資料庫,發現Oracle其實已經修改可部分初始化引數,比如CLUSTER_DATABASE已經設定為TRUE。不過利用DBUA將單例項變為RAC還是存在bug。
手工編輯剛才的初始化引數,新增下列內容:
cluster_database=true
cluster_database_instances=1
test1.instance_number=1
test1.thread=1
test1.local_listener='(ADDRESS=(PROTOCOL=TCP)(HOST=172.0.2.62)(PORT=1521))'
利用這個pfile啟動資料庫:
bash-3.00$ export ORACLE_SID=test1
bash-3.00$ sqlplus "/ as sysdba"
SQL*Plus: Release 11.1.0.6.0 - Production on 星期一 4月 13 14:56:14 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.
已連線到空閒例程。
SQL> startup pfile=/export/home/oracle/inittest.ora
ORACLE 例程已經啟動。
Total System Global Area 776896512 bytes
Fixed Size 2098776 bytes
Variable Size 199940520 bytes
Database Buffers 570425344 bytes
Redo Buffers 4431872 bytes
資料庫裝載完畢。
資料庫已經開啟。
SQL> show parameter cluster_database
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
cluster_database boolean TRUE
cluster_database_instances integer 1
SQL> create spfile = '+DATA/test/spfiletest.ora' from pfile;
檔案已建立。
利用這個pfile建立spfile檔案。
編輯2個節點上的listener.ora新增test1和test2的配置:
(SID_DESC =
(SID_NAME = test1)
(ORACLE_HOME = /data/oracle/product/11.1/database)
)
然後重啟監聽。
還需要將database和instance的資訊新增到srvctl中:
$ srvctl add database -d test -o /data/oracle/product/11.1/database -p +DATA/test/spfiletest.ora -n test
$ srvctl add instance -d test -i test1 -n ser1
如果監聽沒有啟動,或者srvctl沒有配置資料庫和例項資訊,在dbca中是看不到test資料庫資訊的。
利用orapwd建立密碼檔案:
bash-3.00$ orapwd file=orapwtest1 password=test
下面使用dbca來新增例項,注意dbca必須在新增例項的節點執行。
選擇Oracle Real Application Clusters Database,選擇Instance Management,選擇Add an Instance。
選擇test資料庫,並確認test資料庫狀態為active。輸入sys使用者以及sys使用者密碼。
需要注意,如果test資料庫不存在,說明Oracle沒有認為TEST資料庫是RAC環境資料庫,需要將test使用者新增到srvctl命令中。
如果test資料庫狀態不是active,那麼可能是listener的配置問題,也可能是資料庫的當前狀態沒有反應到srvctl中。正確的配置監聽,利用srvctl重新啟動監聽、asm及資料庫例項,就可以保證資料庫的狀態正確了。
隨後DBCA顯示當前執行的例項,點選確定後,選擇要新增的新節點,以及對應的例項名稱。這裡選擇ser2節點,並輸入test2作為例項名。
由於使用了OMF,因此在儲存設定的位置不用進行修改。如果需要,可以修改UNDOTBS2資料檔案的大小。
最後確認後點選FINISH,就可以進行節點的新增了。
在10g的DBCA中,如果是ASM + OMF方式,存在bug,導致DBCA無法完成表空間和日誌檔案的新增,在11g中,這個問題已經被解決。
安裝完成後,這個資料庫已經變為RAC環境。
bash-3.00$ export ORACLE_SID=test2
bash-3.00$ sqlplus "/ as sysdba"
SQL*Plus: Release 11.1.0.6.0 - Production on 星期二 4月 14 14:22:37 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.
連線到:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
SQL> select name from v$database;
NAME
---------
TEST
SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------
test2
SQL> select instance_number, instance_name from gv$instance;
INSTANCE_NUMBER INSTANCE_NAME
--------------- ----------------
2 test2
1 test1
由於是DBCA工具建立的資料庫,因此TNSNAMES.ORA中會自動配置資料庫的服務名,test2例項的資訊也會自動的新增到srvctl工具中。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/4227/viewspace-592454/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 多例項資料庫一個用PSU(轉載)資料庫
- MySQL資料庫入門多例項配置MySql資料庫
- 多例項資料庫一個用PSU資料庫
- 資料庫正規化與例項資料庫
- 達夢資料庫單例項轉實時同步叢集資料庫單例
- oracle資料庫建立資料庫例項-九五小龐Oracle資料庫
- 19C 單例項資料庫安裝單例資料庫
- mongodb關閉資料庫例項MongoDB資料庫
- oracle資料庫與oracle例項Oracle資料庫
- Oracle 11G資料庫單例項安裝Oracle資料庫單例
- ajax讀取資料庫資料程式碼例項資料庫
- oracle 11g 單例項資料庫的安裝Oracle單例資料庫
- 3.1.5.4 啟動例項並mount 資料庫資料庫
- 3.1.5.1 關於啟動資料庫例項資料庫
- 如何將Azure SQL 資料庫還原到本地資料庫例項中SQL資料庫
- 將RAC備份集恢復為單例項資料庫單例資料庫
- Javaweb的例項--訂單管理系統--設計資料庫JavaWeb資料庫
- 【資料庫資料恢復】ASM例項不能掛載的Oracle資料庫資料恢復案例資料庫資料恢復ASMOracle
- MySQL多例項使用mysqld_multi stop 無法關閉資料庫MySql資料庫
- 資料庫例項效能調優利器:Performance Insights資料庫ORM
- 國產資料庫達夢資料庫(DM7)例項初始化引數淺析資料庫
- 【ASK_ORACLE】Relink ASM單例項資料庫詳細步驟OracleASM單例資料庫
- 資料庫設計三大正規化應用例項剖析資料庫
- 關於PHP往mysql資料庫中批次插入資料例項教程PHPMySql資料庫
- JDBC連線MySQL資料庫的方法和例項JDBCMySql資料庫
- 達夢資料庫例項的狀態和模式資料庫模式
- canal同步mysql,監聽單例項,多例項配置MySql單例
- Oracle 資料庫巡檢指令碼 單例項 RAC 輸出HTML格式Oracle資料庫指令碼單例HTML
- 設計模式使用例項(5)——建造者模式例項之資料庫連線管理設計模式資料庫
- 一條SQL完成跨資料庫例項Join查詢SQL資料庫
- MySQL 資料庫-索引注意事項MySql資料庫索引
- ORACLE 資料庫11.2.0.4 單例項伺服器IO等待高問題分析Oracle資料庫單例伺服器
- 資料庫轉換工具,不同資料庫之前任意轉換資料庫
- 【資料庫資料恢復】Oracle ASM例項無法掛載的資料恢復案例資料庫資料恢復OracleASM
- MSSQL·最佳實踐·例項級別資料庫上雲RDSSQLServerSQL資料庫Server
- 探討PostgreSQL例項中資料庫之間的關係SQL資料庫
- 【學習】體系結構-001-例項與資料庫資料庫
- oracle11g單例項透過命令列dbca靜默建立資料庫Oracle單例命令列資料庫
- 資料庫PostrageSQL-預置選項資料庫SQL