Oracle搭建rac到單庫的adg

邪丶壞人發表於2022-03-18

ip
db_name
db_uniquename
SID
servername
主庫節點1
10.10.33.115
uencordb
uencordb
uencordb1
uencordb
主庫節點2
10.10.33.115
uencordb
uencordb
uencordb2
uencordb
北京備庫
10.10.61.52
uencordb
bjcordb
uencordb
bjcordb
上海主庫rac的資料目錄全放在ASM下面
北京備庫的資料目錄存放在/data/uencordb/下面
主庫:
1、把密碼檔案拷貝過去
2、建立備庫控制檔案,拷貝到備庫
alter database create standby controlfile as '/home/oracle/stdctl.ctl';
3、把redo改成合適的大小和組數
4、建立standby redo log  --主庫建立這個是為了轉換為備庫,不轉備庫的話沒必要建
alter system set standby_file_management='manual';
alter database add standby logfile thread 1 group 41 ('+DATA/uencordb/onlinelog/standby41.log') size 1g;
alter database add standby logfile thread 1 group 42 ('+DATA/uencordb/onlinelog/standby42.log') size 1g;
alter database add standby logfile thread 1 group 43 ('+DATA/uencordb/onlinelog/standby43.log') size 1g;
alter database add standby logfile thread 1 group 44 ('+DATA/uencordb/onlinelog/standby44.log') size 1g;
alter database add standby logfile thread 1 group 45 ('+DATA/uencordb/onlinelog/standby45.log') size 1g;
alter database add standby logfile thread 1 group 46 ('+DATA/uencordb/onlinelog/standby46.log') size 1g;
alter database add standby logfile thread 1 group 47 ('+DATA/uencordb/onlinelog/standby47.log') size 1g;
alter database add standby logfile thread 2 group 51 ('+DATA/uencordb/onlinelog/standby51.log') size 1g;
alter database add standby logfile thread 2 group 52 ('+DATA/uencordb/onlinelog/standby52.log') size 1g;
alter database add standby logfile thread 2 group 53 ('+DATA/uencordb/onlinelog/standby53.log') size 1g;
alter database add standby logfile thread 2 group 54 ('+DATA/uencordb/onlinelog/standby54.log') size 1g;
alter database add standby logfile thread 2 group 55 ('+DATA/uencordb/onlinelog/standby55.log') size 1g;
alter database add standby logfile thread 2 group 56 ('+DATA/uencordb/onlinelog/standby56.log') size 1g;
alter database add standby logfile thread 2 group 57 ('+DATA/uencordb/onlinelog/standby57.log') size 1g;
alter system set standby_file_management='auto';
5、修改主庫資料庫引數
ALTER SYSTEM SET LOG_ARCHIVE_CONFIG='DG_CONFIG=(uencordb,bjcordb)' scope=both  sid='*';
ALTER SYSTEM SET LOG_ARCHIVE_DEST_1='LOCATION=+ARCH  VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=uencordb' scope=both  sid='*';
ALTER SYSTEM SET LOG_ARCHIVE_DEST_3='SERVICE=bjcordb LGWR ASYNC AFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=bjcordb' scope=both  sid='*';
ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_1=ENABLE scope=both  sid='*';
ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=ENABLE scope=both  sid='*';
ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_3=ENABLE scope=both  sid='*';
ALTER SYSTEM SET FAL_CLIENT = 'uencordb' scope=both  sid='*';
ALTER SYSTEM SET FAL_SERVER ='bjcordb' scope=both  sid='*';
ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT =AUTO scope=both  sid='*';
如果rac主庫要被切換為備庫的話,就配置下面的引數,需要重啟資料庫
SQL> alter system set db_file_name_convert ='/data/uencordb/','+DATA/uencordb/datafile/','/data/uencordb/','+DATA/uencordb/tempfile/' scope=spfile sid='*';
SQL> alter system set log_file_name_convert='/data/uencordb/','+DATA/uencordb/onlinelog/' scope=spfile sid='*';



6、配置北京備庫引數


*.audit_file_dest='/u01/app/oracle/admin/uencordb/adump'
*.audit_trail='db'
*.compatible='11.2.0.4.0'
*.control_files='/data/uencordb/control01.ctl','/data/uencordb/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='uencordb'
*.db_unique_name='bjcordb'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=uencordbXDB)'
*.fal_client='bjcordb'
*.fal_server='uencordb'
*.log_archive_config='dg_config=(uencordb,bjcordb)'
*.log_archive_dest_1='LOCATION=/data/arch/coradg VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=bjcordb'
*.log_archive_dest_2='SERVICE=uencordb LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=uencordb'
*.db_file_name_convert='+DATA/uencordb/datafile/','/data/uencordb/','+DATA/uencordb/tempfile/','/data/uencordb/'
*.log_file_name_convert='+DATA/uencordb/onlinelog/','/data/uencordb/'
*.standby_file_management='auto'
*.log_archive_format='%t_%s_%r.dbf'
*.open_cursors=300
*.pga_aggregate_target=16135487488
*.processes=5000
*.remote_login_passwordfile='EXCLUSIVE'
*.sessions=5505
*.sga_max_size=85899345920
*.sga_target=48407511040
*.undo_tablespace='UNDOTBS1'


7、配置靜態監聽:

主庫配置靜態監聽是為了配置dgbroker
主庫節點1
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(GLOBAL_DBNAME = uencordb_DGMGRL)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
(SID_NAME = uencordb1)
)
)
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(GLOBAL_DBNAME = uencordb_DGMGRL)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
(SID_NAME = uencordb2)
)
)
北京備庫
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(GLOBAL_DBNAME = uencordb_DGMGRL)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/ dbhome_1)
(SID_NAME = uencordb)
)
)


8、配置好監聽後,主備互相驗證:

sqlplus sys/xxx@uencordb as sysdba
然後進去rman還原控制檔案:
restore controlfile from '/home/oracle/stdctl.ctl';
然後重新進來做dumplicate
[oracle@adg admin]$ rman target sys/xxx@uencordb auxiliary sys/xxx@bjcordb


RMAN> duplicate target database for standby from active database;
恢復好後,進去sql模式(當前是mount),開啟程式追下歸檔
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;
等日誌追平後,再開到readonly
select thread#,sequence#, applied from v$archived_log order by 3 desc,2;
select THREAD#,max(SEQUENCE#) from v$archived_log group by THREAD#;
select process,status from v$managed_standby;
SQL>  alter database recover managed standby database cancel;
SQL> ALTER DATABASE OPEN READ ONLY;
結束


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31098809/viewspace-2872490/,如需轉載,請註明出處,否則將追究法律責任。

相關文章