本篇文章给大家分享的是有关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进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。