搭建RAC到單例項DG
一. 環境介紹
Primary Database RAC環境 11R2
IP:192.168.202.35 TESTRAC1
IP:192.168.202.29 TESTRAC2
Stanby single instance環境
10.5.60.33 standby 只安裝了oracle 11R2軟體
由於DG是以DB_UNIQUE_NAME作為區分資料庫標識的,因此主從庫的該引數一定要不同以做區分。但是資料庫名db_name必須一致以
便主從切換時方便
Standby庫只需要安裝資料庫軟體,不必建立資料庫
主從庫的資料庫軟體大版本必須一致,且必須是企業版資料庫
二.配置安裝
1.RAC主庫準備工作
1.1)RAC主庫必須是歸檔模式
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 158
Next log sequence to archive 159
Current log sequence 159
2.2)RAC主庫必須設定為ForceLogging模式
SQL> alter database force logging;
2.3)RAC主庫執行RMAN全備
RMAN> run{
2> allocate channel c1 type disk;
3> allocate channel c2 type disk;
4> backup database format '/backup/full_%U.bak';
5> backup archivelog all format '/backup/arc_%U.bak';
6> release channel c1;
7> release channel c2;
8> }
2.4)RAC主庫執行建立物理備庫控制檔案
alter database create standby controlfile as '/backup/st.ctl';
2.5)RAC主庫建立物理備庫初始化引數檔案
SQL> create pfile='/backup/test.ora' from spfile;
File created.
修改主庫引數檔案
[oracle@gitiraca backup]$ vi test.ora
加入
*.service_names=TESTRAC
*.log_archive_config='dg_config=(TESTRAC,RACDG)'
*.log_archive_dest_3='location=standby valid_for=(online_logfiles,primary_role) db_unique_name=RACDG'
*.db_file_name_convert='/u01/app/standbydata','+DATA/TESTRAC/DATAFILE','/u01/app/tempdata','+DATA/TESTRAC/TEMPFILE
'
*.log_file_name_convert='/u01/app/redo','+DATA/TESTRAC/ONLINELOG/'
*.standby_file_management='auto'
*.fal_server='standby'
log_archive_dest_3引數錯誤會導致主庫關閉夠無法OPEN
alter檔案會警告
WARNING: No local destinations have been defined for archival of the Standby Redo Log
關閉RAC
Srvctl stop database –d TESTRAC
建立spfile檔案
SQL> create spfile='+DATA/TESTRAC/spfileTESTRAC.ora' from pfile='/backup/test.ora';
File created.
2.物理備庫準備工作
2.1)修改.bash_profile檔案(使用者目錄下)
## For Oracle ##
export EDITOR=vi
export ORACLE_SID=standby
export ORACLE_BASE=/u01/app/oracle
export ORACLE_UNQNAME=RACDG
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export PATH=$ORACLE_HOME/bin:$ORA_CRS_HOME/bin:$PATH
umask 022
#export NLS_LANG='AMERICAN_AMERICA.UTF8'
export NLS_LANG=AMERICAN_AMERICA.ZHS16CGB231280
#export NLS_LANG=AMERICAN_AMERICA.ZHT16BIG5
#export NLS_LANG="traditional chinese_taiwan.ZHT16BIG5"
#export LC_CTYPE=en_US.UTF-8
export LANG=en_US
#alias sqlplus="uniread sqlplus"
#alias adrci="uniread adrci"
2.2)將備份檔案傳遞到備庫
scp backup/*.bak oracle@10.5.160.33:/backup/
scp /ora01/oracle/product/11.2.0/db_1/dbs/orapwTESTRAC1 oracle@10.5.160.33:/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwstandby
[oracle@gitiraca backup]$
scp test.ora oracle:10.5.160.33:/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initstandby.ora
2.3)修改備庫引數檔案
standby.__db_cache_size=2583691264standby.__java_pool_size=16777216
standby.__large_pool_size=16777216
standby.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
standby.__pga_aggregate_target=1275068416
standby.__sga_target=3372220416
standby.__shared_io_pool_size=0
standby.__shared_pool_size=721420288
standby.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/standby/adump'
*.core_dump_dest='/u01/app/oracle/admin/standy/cdump'
*.user_dump_dest='/u01/app/oracle/admin/standy/udump'
*.background_dump_dest='/u01/app/oracle/admin/standy/bdump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/u01/backup/standy.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_file_name_convert='+DATA/TESTRAC/DATAFILE','/u01/app/standbydata','+DATA/TESTRAC/TEMPFILE','/u01/app/tempdata
'
*.db_unique_name='RACDG'
*.db_name='TESTRAC'
*.db_recovery_file_dest='+DATABK'
*.db_recovery_file_dest_size=6005194752
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=standbyXDB)'
*.fal_server='TESTRAC1','TESTRAC2'
*.fal_client='standby'
*.standby_archive_dest='/u01/app/arch'
*.log_archive_dest_1='location=/u01/app/arch'
*.log_archive_dest_2='service=TESTRAC1 valid_for=(online_logfiles,primary_role) db_unique_name=TESTRAC'
*.log_archive_config='dg_config=(TESTRAC,RACDG)'
*.log_archive_format='%t_%s_%r.dbf'
*.log_file_name_convert='+DATA/TESTRAC/ONLINELOG/','/u01/app/redo'
*.open_cursors=300
*.pga_aggregate_target=1263534080
*.processes=150
*.remote_login_passwordfile='exclusive'
*.sessions=170
*.sga_target=3371171840
*.standby_file_management='auto'
*.service_names='standby'
thread=1
undo_tablespace='UNDOTBS1'
注意*.db_file_name_convert和*.log_file_name_convert,因為RAC和standby的資料檔案物理結構目錄不一樣,在備庫上就要把
RAC的資料檔案地址'+DATA/TESTRAC/DATAFILE'轉變成備庫上資料檔案地址
2.4)配置RAC主庫,物理備庫的tnsnames.ora檔案
TESTRAC =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST =192.168.202.35)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST =192.168.202.29)(PORT = 1521))
(LOAD_BLANCE = yes)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = TESTRAC)
(FAILOVER_MODE=
(TYPE = session)
(METHOD = basic)
(RETRIES = 180)
(DELAY = 5)
)
)
TESTRAC1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.202.35)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = TESTRAC)
(INSTANCE_NAME=TESTRAC1)
)
)
TESTRAC2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.202.29)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = TESTRAC)
(INSTANCE_NAME=TESTRAC2)
)
)
standby =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.5.160.33)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = standby)
)
)
2.5)修改備庫listener.ora
standby =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST =SH-HQ-USACLONE)(PORT = 1521))
)
)
SID_LIST_standby =
(SID_LIST =
(SID_DESC =
(SID_NAME = standby)
(ORACLE_HOME =/u01/app/oracle/product/11.2.0/dbhome_1)
)
)
ADR_BASE_LISTENER =/u01/app/oracle
3.建立物理備庫
3.1)物理備庫啟動到nomount狀態:
startup pfile='/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initstandby.ora' nomount;
3.2)RMAN恢復備庫控制檔案
[oracle@SH-HQ-USACLONE admin]$ rman target/
RMAN> restore standby controlfile from '/backup/standby.ctl';
Starting restore at 19-MAR-15
using channel ORA_DISK_1
channel ORA_DISK_1: copied control file copy
output file name=/u01/backup/standy.ctl
Finished restore at 19-MAR-15
3.3)MOUNT物理備庫
SQL> alter database mount;
Database altered.
主庫alter報錯
PING[ARC2]: Heartbeat failed to connect to standby 'standby'. Error is 16047.
PING[ARC2]: Heartbeat failed to connect to standby 'standby'. Error is 16047.
解決方法:
原因的備庫的unique_name 和主庫裡的
*.log_archive_dest_3='location=standby valid_for=(all_logfiles,all_roles) db_unique_name=RACDG' 引數裡的RACDG不一
致導致
修改備庫引數*.db_unique_name='RACDG'(上面備庫引數已經修改)
3.4)restore 備庫
檢查備份集
RMAN> crosscheck backupset
恢復備庫
RMAN> restore database;
3.5)備庫建立standbylogfile
SQL> alter database add standby logfile thread 1 group 5('/u01/app/redo/st_1_5.rdo') size 50M;
Database altered.
SQL> alter database add standby logfile thread 1 group 6('/u01/app/redo/st_1_6.rdo') size 50M;
Database altered.
SQL> alter database add standby logfile thread 1 group 7('/u01/app/redo/st_1_7.rdo') size 50M;
Database altered.
SQL> alter database add standby logfile thread 2 group 8('/u01/app/redo/st_2_8.rdo') size 50M;
Database altered.
SQL> alter database add standby logfile thread 2 group 9('/u01/app/redo/st_2_9.rdo') size 50M;
Database altered.
SQL> alter database add standby logfile thread 2 group 10('/u01/app/redo/st_2_10.rdo') size 50M;
Database altered.
RAC每個redo thread都需要建立對應的standby redo log。建立原則:檔案大小相等,日誌組數數量要多一組
RAC主庫查詢日常傳送情況
SQL> select dest_name,status,error from v$archive_dest;
3.6)開始同步
啟動MRP
SQL> recover managed standby database disconnect from session;
Media recovery complete.
3.7)備庫READONLY方式開啟
SQL> alter database recover managed standby database cancel;
Database altered.
SQL> alter database open read only;
Database altered.
SQL> alter database recover managed standby database using current logfile disconnect from session;
Database altered.
rac主庫執行查詢
select dbid,name,current_scn,protection_mode,database_role,force_logging,open_mode,switchover_status from v$database;
備庫查詢
select dbid,name,current_scn,protection_mode,database_role,force_logging,open_mode,switchover_status from v$database;
成功!!!!
4.修改模式
由上面可以看到配置預設的是最大效能模式 Maximun Performance
現在修改成最大可用性Maximun Availability
1. 關閉資料庫重啟到mount狀態,如果是RAC環境需要關閉所有例項,然後啟動一個例項到mount狀態即可
[oracle@gitiraca ~]$ srvctl stop database -d TESTRAC
SQL> startup mount;
SQL> alter database set standby database to maximize availability;
Database altered.
SQL>alter database open
SQL> select protection_mode,protection_level from v$database;
PROTECTION_MODE
------------------------------------------------------------
PROTECTION_LEVEL
------------------------------------------------------------
MAXIMUM AVAILABILITY
RESYNCHRONIZATION
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29989552/viewspace-1471755/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- duplicate搭建DG最大效能(rac-單例項)單例
- OGG搭建(rac到-->單例項)單例
- RAC+DG(asm單例項)ASM單例
- RAC+單例項DG的切換單例
- DG RAC - 單點搭建
- rac恢復到單例項單例
- RAC asm恢復到單例項ASM單例
- 一步一步搭建11gR2 rac+dg之配置單例項的DG(八)單例
- 11g 兩個節點RAC 搭建單例項DG詳細步驟以及注意事項單例
- CentOS 7.3 ECS上搭建RAC 18c+單例項DG+EMCC+DG的FSFO快速故障轉移配置CentOS單例
- rac到單例項的rman恢復單例
- rac asm 恢復到 單例項 1ASM單例
- rac asm 恢復到 單例項 2ASM單例
- RMAN異機恢復:RAC到單例項單例
- RAC恢復到單例項節點上單例
- 恢復rac db(raw)到單例項下單例
- 單例項備份集恢復到RAC單例
- 11g兩個節點RAC搭建單例項DG過程問題以及解決方法單例
- ORACLE 11G 建立 DATAGUARD(雙節點RAC-->單例項DG)Oracle單例
- RAC從帶庫到單例項的恢復單例
- 恢復RAC資料庫到單例項(ASM)資料庫單例ASM
- RAC起單例項make單例
- oracle單例項轉RACOracle單例
- 【DG】在Linux平臺上搭建單例項的dataguard--duplicateLinux單例
- Oracle RAC+DG搭建Oracle
- Oracle 11g RAC到單例項OGG同步Oracle單例
- 10g rac asm 恢復到 單例項(二)ASM單例
- 10g rac asm 恢復到 單例項(一)ASM單例
- 9204RAC到單例項的SWITCHOVER切換單例
- RAC 例項 遷移到 單例項 -- 使用RMAN Duplicate單例
- rhel6.4-11.2.0.3-RAC搭建單節點DG
- RAC資料庫恢復到單例項資料庫資料庫單例
- 單例項恢復至RAC單例
- 使用RMAN將RAC+ASM複製到單例項+ASM上ASM單例
- 單例項opatch出現RAC資訊單例
- 從單例項資料庫轉換到RAC環境——RAC的建立和配置單例資料庫
- 11G RAC+DG搭建
- 單例項DG切換中的虛擬IP單例