您好,登錄后才能下訂單哦!
本篇文章給大家分享的是有關rac環境的dg配置duplicate方式是怎么樣的,小編覺得挺實用的,因此分享給大家學習,希望大家閱讀完這篇文章后可以有所收獲,話不多說,跟著小編一起來看看吧。
創建物理備庫
1、
修改tnsnames.ora
RAC環境中可以使用vip傳送
主庫
pridb =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.101)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = PROD)
)
)
stdb =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.11)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = STPROD)---靜態監聽的全局名
)
)
備庫
pridb =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac1)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = PROD)
)
)
stdb =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = test)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = STPROD)
)
)
2、主庫修改參數
在主節點上修改spfile
alter system set log_archive_config='dg_config=(PROD,STPROD)' scope=spfile sid='*';
alter system set fal_server='STDB' scope=spfile sid='*';--TSN
alter system set fal_client='PRIDB' scope=spfile sid='*';--TNS
alter system set standby_file_management=auto scope=spfile sid='*';
alter system set log_archive_dest_1='location=use_db_recovery_file_dest valid_for=(ALL_LOGFILES,ALL_ROLES) db_unique_name=PROD mandatory verify' scope=both sid='*';
alter system set log_archive_dest_2='SERVICE=STDB LGWR async valid_for=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=STPROD' scope=both sid='*';
alter system set log_archive_dest_state_2='ENABLE' scope=both sid='*';
alter system set log_archive_dest_state_1='ENABLE' scope=both sid='*';
alter system set db_file_name_convert='/u01/app/oracle/oradata/STPROD/','+DATA/prod/datafile/','/u01/app/oracle/oradata/STPROD/','+DATA/prod/tempfile/' scope=spfile;---先對方后自己
alter system set log_file_name_convert='/u01/app/oracle/oradata/STPROD/' scope=spfile;
開啟強制日
alter database force logging;
創建參數文件
create pfile='/home/oracle/initSDPROD' from spfile;
alter system set log_archive_dest_2='SERVICE=PRIDB LGWR async valid_for=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=PROD' scope=both sid='*';
備庫也需要參數轉化所有的密碼文件必須一致
tempfile也需要
alter system set db_file_name_convert='+DATA/prod/datafile/','/u01/app/oracle/oradata/STPROD/','+DATA/prod/tempfile/','/u01/app/oracle/oradata/STPROD/' scope=spfile;---先對方后自己
alter system set log_file_name_convert='+DATA/prod/datafile/','/u01/app/oracle/oradata/STPROD/'' scope=spfile;
3、創建adump目錄和備份集存放目錄和數據文件存放目錄
mkdir -p /u01/app/oracle/admin/STPROD/adump
mkdir -p /u01/app/oracle/fast_recovery_area
創建備庫控制文件
ALTER DATABASE CREATE STANDBY CONTROLFILE AS '/u01/app/oracle/11.2.0/dbs/control.ctl'
啟動到
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = STPROD)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME = STPROD)---必須和密碼文件的sid相同
)
)
把密碼文件傳送到備庫,參數文件傳到備庫并修改
啟動到mount狀態下
rman target sys/oracle@PRIDB auxiliary sys/oracle@STDB
duplicate target database for standby from active database dorecover nofilenamecheck;
duplicate target database for standby from active database dorecover nofilenamecheck;
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;--需要創建standy log
alter database recover managed standby database disconnect from session;
alter database recover managed standby database cancel;
查看主備狀態
select name,PROTECTION_MODE,DATABASE_ROLE ,SWITCHOVER_STATUS from v$database;
select NAME,OPEN_MODE,PROTECTION_MODE,DATABASE_ROLE,SWITCHOVER_STATUS from v$database;
--查看進程,看有沒有LNS進程,如果沒有
select process,client_process,sequence#,status from v$managed_standby;
select dest_name,status,target,archiver,error,process from v$archive_dest;
select name,value,datum_time from v$dataguard_stats;
必須有多線程的日志-密碼文件必須一致
單實例standby:
alter database add standby logfile thread 1 group 11('/u01/app/oracle/oradata/STPROD/standby_redo05.log') size 50m;
alter database add standby logfile thread 1 group 12('/u01/app/oracle/oradata/STPROD/standby_redo06.log') size 50m;
alter database add standby logfile thread 1 group 13('/u01/app/oracle/oradata/STPROD/standby_redo07.log') size 50m;
alter database add standby logfile thread 2 group 14('/u01/app/oracle/oradata/STPROD/standby_redo08.log') size 50m;
alter database add standby logfile thread 2 group 15('/u01/app/oracle/oradata/STPROD/standby_redo09.log') size 50m;
alter database add standby logfile thread 2 group 16('/u01/app/oracle/oradata/STPROD/standby_redo10.log') size 50m;
alter database drop standby logfile group 8('/u01/app/oracle/oradata/STPROD/standby_redo08.log') size 50m;
primary rac下:
alter database add standby logfile thread 1 group 5 size 50M,group 6 size 50M ,group 7 size 50M ;
alter database add standby logfile thread 2 group 8 size 50M,group 9 size 50M ,group 10 size 50M ;
THREAD#
SELECT GROUP#,THREAD#,BYTES/1024/1024 M FROM V$STANDBY_LOG;
SELECT GROUP#,THREAD#,STATUS,BYTES/1024/1024 M FROM V$LOG;
DATA Guard在最大保護和最高可用性模式下,Standby數據庫必須配置 Standby Redo Log
備庫創建并配置 Standby Redo Log 是為了能夠接收到主庫傳過來的日志,用作恢復.
主庫創建并配置 Standby Redo Log 是為了在主備切換之后,能夠接收到原備庫(切換之后的主庫)傳過來的日志
注意:為了主備切換后能正常,主備庫都必須創建standby redo log
創建原則:建議Standby Redologs日志組數量基于Primary數據庫的線程數來確定(這里的線程數可以理解為RAC環境中的節點數)。
有一個推薦的公式可供參考:(每線程的日志組數+1)×最大線程數。
nx+1
使用這個公式可以降低Primary數據庫實例LGWR進程鎖住的可能性。
創建原則和單實例一樣,大小相等,但是日志組數量要比primary數據庫多一組,比如在我的環境中,有2個節點,每個節點有4組redo,那么現在要創建的standby redo log組數為:(4+1)*2=10個
Standby Redologs的操作方式與Online Redologs幾乎一模一樣,只不過在創建或刪除時需要多指定一個Standby關鍵字
備庫配置監聽
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = STPROD)---數據庫服務名
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME = STPTOD)--數據庫sid名字
)
)
需要修改的參數是:
audit_file_dest
control_files
db_file_name_convert
db_unique_name
fal_client
fal_server
log_archive_config
log_archive_dest_1
log_archive_dest_2
log_archive_dest_3
log_file_name_convert
需要修改
ALTER TABLESPACE TEMP ADD TEMPFILE '/u01/app/oracle/oradata/STPROD/temp01.dbf' size 10M autoextend off;
alter database tempfile '+DATA' drop;
常見錯誤
Errors in file /u01/app/oracle/diag/rdbms/stprod/STPROD/trace/STPROD_dbw0_2593.trc:
ORA-01186: file 201 failed verification tests
ORA-01157: cannot identify/lock data file 201 - see DBWR trace file
ORA-01110: data file 201: '+DATA'
File 201 not verified due to error ORA-01157
重建后刪除
DROP TABLESPACE TEMP INCLUDING CONTENTS AND DATAFILES CASCADE CONSTRAINTS;
alter tablespace TEMP add TEMPFILE '+DATA' size 32G AUTOEXTEND OFF;
CREATE TEMPORARY TABLESPACE TEMP1 TEMPFILE '+DATA' SIZE 10M AUTOEXTEND OFF;
ALTER DATABASE DEFAULT TEMPORARY TABLESPACE temp1;
alter tablespace TEMP1 add TEMPFILE '/u01/app/oracle/oradata/STPROD/temp01.dbf' size 10M AUTOEXTEND OFF;
select NAME,OPEN_MODE,PROTECTION_MODE,DATABASE_ROLE,SWITCHOVER_STATUS from v$database;
select dest_name,status,target,archiver,error,process from v$archive_dest;
select process,client_process,sequence#,status from v$managed_standby;
select * from v$archive_gap;
select name,value,datum_time from v$dataguard_stats;
正常主備切換
查看主庫狀態
select NAME,OPEN_MODE,PROTECTION_MODE,DATABASE_ROLE,SWITCHOVER_STATUS from v$database;
主庫切為備庫
alter database commit to switchover to standby;
查看備庫狀態
select NAME,OPEN_MODE,PROTECTION_MODE,DATABASE_ROLE,SWITCHOVER_STATUS from v$database;
NAME OPEN_MODE PROTECTION_MODE DATABASE_ROLE
--------- -------------------- -------------------- ----------------
SWITCHOVER_STATUS
--------------------
PROD READ ONLY WITH APPLY MAXIMUM PERFORMANCE PHYSICAL STANDBY
TO PRIMAR
備庫切主庫
alter database commit to switchover to primary;
新備庫啟動到mount狀態應用日志
startup nomount;
應用日志
alter database recover managed standby database using current logfile disconnect from session;
alter database recover managed standby database cancel;
alter database open;
查看新主庫狀態
NAME OPEN_MODE PROTECTION_MODE DATABASE_ROLE
--------- -------------------- -------------------- ----------------
SWITCHOVER_STATUS
--------------------
PROD READ WRITE MAXIMUM PERFORMANCE PRIMARY
SESSIONS ACTIVE
以上就是rac環境的dg配置duplicate方式是怎么樣的,小編相信有部分知識點可能是我們日常工作會見到或用到的。希望你能通過這篇文章學到更多知識。更多詳情敬請關注億速云行業資訊頻道。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。