ORACLE RAC資料庫配置Dataguard環境(2)
二、開始執行建立
為了貫徹優化地幹活這一中心思想,三思決定通過rman的duplicate命令執行standby資料庫的建立,在本節中你可以看到,只要一切配置OK,建立的操作簡單到只需執行一條命令,是的,只有一條~~~~
不過,操作前其它的配置環節,工作還是必不可少的~~
通過Primary db建立Standby db的spfile
要啟動Standby端的例項,需要相應的初始化引數檔案,這裡我們可以通過Primary spfile建立出Standby的pfile,操作方法不需要多說了吧,最後修改的standby端pfile內容如下(注意確保相關路徑的正確喲):
*.audit_file_dest=¨/data/ora10g/admin/jssstd/adump¨
*.background_dump_dest=¨/data/ora10g/admin/jssstd/bdump¨
*.compatible=¨10.2.0.1.0¨
*.control_files=¨/data1/jssstd/control01.ctl¨,¨/data1/jssstd/control02.ctl¨,¨/data1/jssstd/control03.ctl¨
*.core_dump_dest=¨/data/ora10g/admin/jssstd/cdump¨
*.db_block_size=8192
*.db_domain=¨¨
*.db_file_multiblock_read_count=16
*.db_name=¨jssdb¨
*.db_unique_name=¨jssstd¨
*.job_queue_processes=10
*.log_archive_dest_1=¨location=/data1/jssstd/arclog valid_for=(all_logfiles,all_roles) db_unique_name=jssstd¨
*.open_cursors=300
*.pga_aggregate_target=94371840
*.processes=150
*.remote_login_passwordfile=¨exclusive¨
*.sga_target=283115520
*.undo_management=¨AUTO¨
*.undo_tablespace=¨UNDOTBS1¨
*.user_dump_dest=¨/data/ora10g/admin/jssstd/udump¨
提示一點,此時尚未新增任何與dataguard相關的初始化引數,接下來就要對此進行處理,增加引數如下:
*.log_archive_config=¨dg_config=(jssdb,jssstd)¨
*.standby_file_management=¨AUTO¨
*.db_file_name_convert=¨+ASMDISK1/jssdb/datafile¨,¨/data1/jssstd¨,¨+ASMDISK1/jssdb/tempfile¨,¨/data1/jssstd¨
*.log_file_name_convert=¨+ASMDISK1/jssdb/onlinelog¨,¨/data1/jssstd¨
*.fal_server=jssdb
*.fal_client=jssstd由於asm儲存檔案時自動進行了分目錄處理,因此這裡在設定db_file_name_convert引數時,也要注意設定相應的轉換,否則可能導致檔案建立時出錯的,切記切記。
客戶端初始化引數檔案建立之後,就可以通過它建立Standby資料庫的spfile,並啟動例項了,如下:
SQL> create spfile from pfile=¨/data/ora10g/admin/jssstd/pfile/jssstd.ora¨;
File created.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 2083368 bytes
Variable Size 88081880 bytes
Database Buffers 188743680 bytes
Redo Buffers 6303744 bytes複製Primary端相關檔案到Standby端;
複製檔案,包括Primary端建立的最新備份、Standby控制檔案。最好是能在複製到Standby端伺服器時,保持與Primary端相同的目錄結構,這樣在恢復操作時會更簡單一些,否則的話,再執行恢復前,還需要先用catalog註冊這些備份,否則恢復時可能會提供找不到必要的備份。
建立Standby端金鑰檔案;
金鑰檔案的金鑰注意要保持與Primary端完全相同,或者直接複製Primary端的金鑰檔案過來,注意複製的話一定是要複製到standby端$ORACLE_HOME/dbs目錄下,並注意按照命名規則修改名稱!
建立Standby資料庫;
重頭戲來了,建立Standby資料庫!這裡三思不是通過備份恢復喲,而是決定通過rman的duplicate命令來實施建立,操作相當簡單!
我們在Primary端執行建立,連線到RMAN命令列模式,執行命令如下:
[oracle@jssdbn2 ~]$ rman target / auxiliary sys/123456@jssstd
Recovery Manager: Release 10.2.0.4.0 - Production on Thu Apr 15 13:59:51 2010
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: JSSDB (DBID=953576437)
connected to auxiliary database: JSSDB (not mounted)接下來只需要一條命令:
RMAN> duplicate target database for standby;
Starting Duplicate Db at 15-APR-10
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=156 devtype=DISK
allocated channel: ORA_AUX_DISK_2
channel ORA_AUX_DISK_2: sid=155 devtype=DISK
contents of Memory Script.
{
restore clone standby controlfile;
sql clone ¨alter database mount standby database¨;
}
executing Memory Script.
Starting restore at 15-APR-10
using channel ORA_AUX_DISK_1
using channel ORA_AUX_DISK_2
channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece /data/backup/0glb6gts_1_1
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/data/backup/0glb6gts_1_1 tag=TAG20100415T133555
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:05
output filename=/data1/jssstd/control01.ctl
output filename=/data1/jssstd/control02.ctl
output filename=/data1/jssstd/control03.ctl
Finished restore at 15-APR-10
sql statement: alter database mount standby database
released channel: ORA_AUX_DISK_1
released channel: ORA_AUX_DISK_2
contents of Memory Script.
{
set newname for tempfile 1 to
"/data1/jssstd/temp.265.703671701";
switch clone tempfile all;
set newname for datafile 1 to
"/data1/jssstd/system.260.703671683";
set newname for datafile 2 to
"/data1/jssstd/undotbs1.259.703671695";
set newname for datafile 3 to
"/data1/jssstd/sysaux.266.703671697";
set newname for datafile 4 to
"/data1/jssstd/undotbs2.258.703671705";
set newname for datafile 5 to
"/data1/jssstd/users.257.703671709";
set newname for datafile 6 to
"/data1/jssstd/jsstbs.269.703779631";
restore
check readonly
clone database
;
}
executing Memory Script.
executing command: SET NEWNAME
renamed temporary file 1 to /data1/jssstd/temp.265.703671701 in control file
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 15-APR-10
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=155 devtype=DISK
allocated channel: ORA_AUX_DISK_2
channel ORA_AUX_DISK_2: sid=156 devtype=DISK
channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /data1/jssstd/system.260.703671683
restoring datafile 00002 to /data1/jssstd/undotbs1.259.703671695
restoring datafile 00006 to /data1/jssstd/jsstbs.269.703779631
channel ORA_AUX_DISK_1: reading from backup piece /data/backup/0alb5tv2_1_1
channel ORA_AUX_DISK_2: starting datafile backupset restore
channel ORA_AUX_DISK_2: specifying datafile(s) to restore from backup set
restoring datafile 00003 to /data1/jssstd/sysaux.266.703671697
restoring datafile 00004 to /data1/jssstd/undotbs2.258.703671705
restoring datafile 00005 to /data1/jssstd/users.257.703671709
channel ORA_AUX_DISK_2: reading from backup piece /data/backup/0blb5tvj_1_1
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/data/backup/0alb5tv2_1_1 tag=TAG20100415T081218
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:05
channel ORA_AUX_DISK_2: restored backup piece 1
piece handle=/data/backup/0blb5tvj_1_1 tag=TAG20100415T081218
channel ORA_AUX_DISK_2: restore complete, elapsed time: 00:01:09
Finished restore at 15-APR-10
contents of Memory Script.
{
switch clone datafile all;
}
executing Memory Script.
datafile 1 switched to datafile copy
input datafile copy recid=7 stamp=716401106 filename=/data1/jssstd/system.260.703671683
datafile 2 switched to datafile copy
input datafile copy recid=8 stamp=716401106 filename=/data1/jssstd/undotbs1.259.703671695
datafile 3 switched to datafile copy
input datafile copy recid=9 stamp=716401106 filename=/data1/jssstd/sysaux.266.703671697
datafile 4 switched to datafile copy
input datafile copy recid=10 stamp=716401106 filename=/data1/jssstd/undotbs2.258.703671705
datafile 5 switched to datafile copy
input datafile copy recid=11 stamp=716401106 filename=/data1/jssstd/users.257.703671709
datafile 6 switched to datafile copy
input datafile copy recid=12 stamp=716401106 filename=/data1/jssstd/jsstbs.269.703779631
Finished Duplicate Db at 15-APR-10Standby 建立完成!注意,我說的是Standby建立完成,沒說Dataguard配置完成喲!接下來還有工作要做,首先要做的是檢查Standby資料庫的狀態,開個sqlplus連線到Standby資料庫,此時Standby應已處於mount模式:
[oracle@jssnode1 ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.4.0 - Production on Thu Apr 15 16:22:07 2010
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> set line 150 pages 1000
SQL> select database_role,protection_level,open_mode from v$database;
DATABASE_ROLE PROTECTION_LEVEL OPEN_MODE
---------------- -------------------- ----------
PHYSICAL STANDBY MAXIMUM PERFORMANCE MOUNTED
SQL> select name from v$datafile;
NAME
------------------------------------------------------------------------------------------------------------------------------------------------------
/data1/jssstd/system.260.703671683
/data1/jssstd/undotbs1.259.703671695
/data1/jssstd/sysaux.266.703671697
/data1/jssstd/undotbs2.258.703671705
/data1/jssstd/users.257.703671709
/data1/jssstd/jsstbs.269.703779631
6 rows selected.
SQL> select name from v$tempfile;
NAME
------------------------------------------------------------------------------------------------------------------------------------------------------
/data1/jssstd/temp.265.703671701
SQL> select member from v$logfile;
MEMBER
------------------------------------------------------------------------------------------------------------------------------------------------------
/data1/jssstd/group_1.263.703671679
/data1/jssstd/group_2.261.703671681
/data1/jssstd/group_3.256.703672257
/data1/jssstd/group_4.268.703672257可上述結果可以看出,檔案路徑也均已被轉換,其實這個結果從duplicate的日誌就可以被得知,執行的查詢更堅定的證實了這一點。對於正式環境,建議建立適當組數的standby redolog,以提高日誌的應用效率。Standby redolog的建立和管理方式在一步一步學Dataguard中有詳細描述,這裡不再舉例說明。
配置Primary資料庫,傳送歸檔到Standby端;
接下來要修改Primary資料庫,以傳送日誌到Standby端,具體操作如下,連線到RAC任意結點,然後執行下列語句:
SQL> alter system set log_archive_config=¨dg_config=(jssdb,jssstd)¨;
System altered.
SQL> alter system set log_archive_dest_2=¨service=jssstd lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=jssstd¨;
System altered.Primary 端切換一下日誌:
SQL> alter system switch logfile;
System altered.
SQL> select thread#,max(sequence#) from v$archived_log group by thread#;
THREAD# MAX(SEQUENCE#)
---------- --------------
1 295
2 127轉到Standby端執行查詢:
SQL> select thread#,max(sequence#) from v$archived_log group by thread#;
THREAD# MAX(SEQUENCE#)
---------- --------------
2 127
SQL> select process,status,client_process,thread#,sequence# from v$managed_standby;
PROCESS STATUS CLIENT_P THREAD# SEQUENCE#
--------- ------------ -------- ---------- ----------
ARCH CONNECTED ARCH 0 0
ARCH CONNECTED ARCH 0 0
RFS IDLE UNKNOWN 0 0
RFS IDLE LGWR 2 128嘗試啟動應用,然後再次執行查詢:
SQL> alter database recover managed standby database disconnect from session;
Database altered.
SQL> select process,status,client_process,thread#,sequence# from v$managed_standby;
PROCESS STATUS CLIENT_P THREAD# SEQUENCE#
--------- ------------ -------- ---------- ----------
ARCH CONNECTED ARCH 0 0
ARCH CONNECTED ARCH 0 0
RFS IDLE UNKNOWN 0 0
RFS IDLE LGWR 2 128
MRP0 WAIT_FOR_LOG N/A 1 291稍等片刻,standby即會開始尋找日誌,就缺少的日誌檔案向主庫請求獲取,並逐個應用了!
SQL> select process,status,client_process,thread#,sequence# from v$managed_standby;
PROCESS STATUS CLIENT_P THREAD# SEQUENCE#
--------- ------------ -------- ---------- ----------
ARCH CONNECTED ARCH 0 0
ARCH CONNECTED ARCH 0 0
RFS IDLE UNKNOWN 0 0
RFS IDLE LGWR 2 128
MRP0 APPLYING_LOG N/A 1 292
RFS IDLE LGWR 1 296
RFS IDLE UNKNOWN 0 0Ok ,至此RAC資料庫的Standby算是弄起來了,當然,這只是一個雛形,如果是生產環境,接下來需要考慮的因素還比較多,比如容災策略、備份策略、歸檔傳送策略等等。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/7607759/viewspace-661674/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- ORACLE RAC資料庫配置Dataguard環境(3)Oracle資料庫
- ORACLE RAC資料庫配置Dataguard環境(1)Oracle資料庫
- Oracle10g RAC環境下 DataGuard備庫搭建例項-2-eygleOracle
- RAC+Dataguard環境中JDBC Failover配置JDBCAI
- Oracle10g RAC環境下DataGuard備庫搭建例項Oracle
- Oracle10g RAC環境下DataGuard備庫搭建例項-eygleOracle
- RAC環境下dataguard的搭建
- 從單例項資料庫轉換到RAC環境——RAC的建立和配置單例資料庫
- Oracle10g RAC環境下 DataGuard備庫搭建例項-3-eygleOracle
- Oracle10g RAC環境下 DataGuard備庫搭建例項-1-eygleOracle
- RAC環境利用備份恢復RAC資料庫(五)資料庫
- RAC環境利用備份恢復RAC資料庫(四)資料庫
- RAC環境利用備份恢復RAC資料庫(三)資料庫
- RAC環境利用備份恢復RAC資料庫(二)資料庫
- RAC環境利用備份恢復RAC資料庫(一)資料庫
- Docker環境Oracle資料庫搭建DockerOracle資料庫
- 搭建rac+DataGuard的測試環境
- Oracle10g RAC環境下 DataGuard備庫搭建例項-4-自己補Oracle
- rman 可否克隆rac資料庫到另外一個rac環境的資料庫中?資料庫
- rac環境下standby資料庫的實現資料庫
- 【RAC】rac環境下的資料庫備份與還原資料庫
- RAC和Dataguard環境下主備庫切換演練模板
- ORACLE11GR2 RAC DATABASE+STANDLONE DATAGUARD配置摘要OracleDatabase
- Linux環境配置DBD::Oracle,幫助Perl連線Oracle資料庫LinuxOracle資料庫
- 成功恢復無備份RAC環境資料庫資料庫
- RAC環境只啟動單例項資料庫單例資料庫
- RAC環境的STANDBY資料庫備份報錯資料庫
- RAC環境中的資料庫部署技術——RAC部署和效能資料庫
- ORACLE資料庫dataguard配置,rman移機,dx鎖處Oracle資料庫
- Oracle11gR2 RAC環境歸檔模式的配置案例一則Oracle模式
- 配置 Oracle 10g RAC primary + RAC physical standby dataguardOracle 10g
- ORACLE資料庫Dataguard dg brokerOracle資料庫
- oracle rac + dataguardOracle
- python環境連結Oracle資料庫PythonOracle資料庫
- oracle rac 環境檢測Oracle
- RAC環境下單例項啟動Oracle資料庫重建控制檔案案例單例Oracle資料庫
- 【Dataguard】Oracle多租戶環境對Dataguard的影響Oracle
- oracle 11gR2 rac+asm 資料庫安裝配置步驟OracleASM資料庫