共計 4726 個字符,預計需要花費 12 分鐘才能閱讀完成。
丸趣 TV 小編給大家分享一下如何利用 Oracle Data Guard 完成跨平臺的數據庫遷移案例,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
客戶原本是一套單機版的 Oracle 11.2.0.3.0 Database for Windows 的數據庫系統,客戶的需求是將單機版的 Oracle Database 遷移到 3 節點的 Oracle RAC Database 中,并且平臺變成 Linux,但數據庫版本不變化。客戶希望盡可能短的停機時間。
通常對于不跨版本的 Oracle Database 遷移常使用 DG(Data Guard),配置好 DG 之后做一次 switchover 即可完成數據庫的快速遷移,后續再進行修改 IP 地址等工作。
雖然這個案例需要跨平臺,但從 11g 開始 Oracle Database 支持有限制的跨平臺配置 DG,下面是配置異構平臺 DG 的兼容性列表(物理 Standby):
從上面的兼容性列表可以看出,Microsoft Windows (x86_64)(12) 和 Linux x86_64(13) 能夠兼容構建異構平臺的 DG,但需要注意的是 Oracle Database 需要是 11g,并且需要應用 Patch 13104881,該 Patch 只存在于 Linux 平臺,并且只在 Windows(主庫)向 Linux(備庫)同步時,需要在 Linux 平臺應用此補丁(反向不會遇到相應的 bug),更多內容請參考 Patch 13104881 說明。
有關在異構平臺搭建 ADG 的詳細內容請參考文章:《在物理 Data Guard 中對異構主備系統的支持 (Doc ID 1602437.1)》
確認現有的平臺和新平臺之間能夠搭建 DG 之后,那么剩下的問題就是如何將單機 Database 轉換成 RAC Database,這步實際需要在將 Linux 平臺的備庫轉換成主庫之后進行的,下面描述的是整個遷移大致的步驟:
1. 在新環境下安裝 Oracle Grid Infrastructure 集群件。
2. 在新環境下安裝 Oracle RAC Database 軟件。
3. 創建 ASM 磁盤組,配置好監聽程序。
4. 在 RAC 的第一個節點創建 Windows 到 Linux 的 ADG(使用第一個節點的 VIP 地址,配置成實時同步模式),并直接將控制文件、數據文件、日志文件等存放到共享的 ASM 磁盤組。
由于是配置 Windows 到 Linux 的 DG,肯定涉及到 DB_FILE_NAME_CONVERT 和 LOG_FILE_NAME_CONVERT 參數的設置,這兩個參數需要重啟數據庫實例才能生效,需要注意的是,從主庫到備庫的 duplicate 操作,對目錄的轉換實際是由備庫中的這兩個參數設置來控制的,所以在前期配置階段可以不為主庫設置這兩個參數,這就意味著即使在跨平臺的環境中主庫也可以在不重啟的情況下完成 DG 的配置(除了這兩個參數外的其他大部分 DG 參數都不需要重啟便可生效)。
LOG_FILE_NAME_CONVERT 參數的值一定要包含所有在線 Redo 日志,standby Redo 日志的目錄的轉換。DB_FILE_NAME_CONVERT 參數的值一定要包含所有數據文件和臨時文件目錄的轉換。例如:
LOG_FILE_NAME_CONVERT= +DATA01/dbm/onlinelog/ , +DATA_DM01/dbm/onlinelog/ , +FRA01/dbm/onlinelog/ , +DBFS_DG/dbm/onlinelog/
DB_FILE_NAME_CONVERT= +DATA01/dbm/datafile/ , +DATA_DM01/dbm/datafile/,+DATA01/dbm/tempfile/ , +DATA_DM01/dbm/tempfile/
LOG_FILE_NAME_CONVERT 和 DB_FILE_NAME_CONVERT 兩個參數的值的最后都要加上 / 斜杠。
對 DB_FILE_NAME_CONVERT 的參數設置除了考慮到數據文件外,還需要考慮到臨時文件的位置,特別是 ASM 的時候,OMF 管理設置數據文件為 datafile 目錄,臨時文件為 tempfile,不能只指定磁盤組的名字,一定要指定到具體的絕對路徑。
另外還需要注意著兩個參數值的配置,假設有 A 庫(主庫)和 B 庫(備庫),在 A 庫配置的這兩個參數的值應該 = B 庫位置 , A 庫位置,在 B 庫配置的這兩個參數的值應該 = A 庫位置 , B 庫位置,切不可搞反了。
如果 DG 配置完成后,日志傳輸服務沒有正常工作,可以考慮執行 alter system set log_archive_dest_state_2=defer;alter system set log_archive_dest_state_2=enable; 的方式禁用再啟用遠程目錄傳輸。
再做單機版主庫到備庫的的 DG 的時候,最好將 ORACLE_SID 環境變量,instance_name 和 db_unique_name 配置為相同的值,之后再進行調整。
5. 將備庫轉換為主庫(可以做 Switchover 操作,也可以在確保主備庫實時同步的前提下直接關閉主庫,將備庫激活成為可讀可寫的數據庫)。
6. 執行下面的步驟將單機版的數據庫轉換為 RAC 數據庫:
4)
Take a backup of original single-instance pfile to e.g.
/tmp/initorcl.ora and Add the following entry in pfile, e.g. for a two
node RAC cluster
*.cluster_database = TRUE
*.cluster_database_instances = 2
*.undo_management=AUTO
.undo_tablespace=undotbs (undo tablespace which already exists)
.instance_name=
.instance_number=1
.thread=1
.local_listener=_
.instance_name=
.instance_number=2
.local_listener=_
.thread=2
.undo_tablespace=UNDOTBS2
.cluster_database = TRUE
.cluster_database_instances = 2
is equal to 1 . is equal to 2 , e.g. ORCL1, ORCL2.
5) change the location of control file in parameter file
local drive to shared cluster file system location
ie control_files= /control01.ctl
to ie control_files= /control01.ctl
6) create spfile from pfile(spfile should be stored in shared device)
export ORACLE_SID=ORCL1
sqlplus / as sysdba
create spfile= /spfileORCL.ora from pfile= /tmp/initORCL.ora
exit
7) Create the $ORACLE_HOME/dbs/init.ora e.g. initORCL1.ora file that contains the following entry
spfile= spfile_path_name
spfile_path_name is the complete path name of the SPFILE.
example :-
spfile= /cfs/spfile/spfileORCL1.ora
8) create new password file for ORCL1 instance.
orapwd file=orapwORCL1 password=oracle
9) start the database in mount stage
10) Rename the datafile,redo logs to new shared device
alter database rename file to new shared= location= path =
11) Add second instance redo logs (or more when multiple instances will be started)
alter database
add logfile thread 2
group 3 (shared location= redo2_01_100.dbf)= size= 100m,= group 4 (shared location= redo2_02_100.dbf)= size= 100m;=
alter database enable public thread 2;
12) create the second (or more) instance undo tablespace from existing instance
Path and file name will different for your environment
CREATE UNDO TABLESPACE UNDOTBS2 DATAFILE
/dev/RAC/undotbs_02_210.dbf SIZE 200M ;
13)
Open your database (i.e. alter database open;) and run
$ORACLE_HOME/rdbms/admin/catclust.sql to create cluster database
specific views within the existing instance
2. On the second node and other nodes
14) Set ORACLE_SID and ORACLE_HOME environment variables on the second node
15) Create the $ORACLE_HOME/dbs/init.ora e.g. initORCL2.ora file for the second node the same way as with point 7.
16) create new password file for second instance ORCL2 instance as in point 8
orapwd file=orapwORCL2 password=oracle
17) Start the second Instance
3. on one of the nodes
18) After configuring the listener,you have to add the database in cluster as below
srvctl add database -d -o -p
srvctl add instance -d -i -n
srvctl add instance -d -i -n
19) in case ASM is used, add the rdbms instance / asm dependency, e.g.
srvctl modify instance -d -i -s +ASM1
整個單機到 RAC 的轉換過程時間并不長,提前測試和準備好初始化參數文件、執行腳本將進一步縮短這部分時間。
完成單機到 RAC 的轉換后,后續完成調整 DG 參數,調整 IP 地址等工作即完成了數據庫的跨平臺遷移和從單機到 RAC 的轉換工作。
以上是“如何利用 Oracle Data Guard 完成跨平臺的數據庫遷移案例”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注丸趣 TV 行業資訊頻道!