RAC到单机搭建DataGuard

  1. 云栖社区>
  2. 博客>
  3. 正文

RAC到单机搭建DataGuard

持续高温 2019-06-19 15:43:42 浏览388
展开阅读全文

一、环境信息

1、服务器:Cetnos 7.2
2、数据库版本:11.2.0.4
3、RAC -> 单机

二、环境准备

     目标是搭建RAC到单机的Activity DataGuard,首先RAC环境是准备完善的,接下来需要搭建一个单机环境。

1、安装数据库软件

     安装过程这里不在叙述。

2、通过RAC RMAN备份还原DB

①在RAC用RMAN做全备

②将备拷贝到单机服务器进行还原,还原过程可参考:https://yq.aliyun.com/articles/704904?spm=a2c4e.11153959.0.0.2210147cw6pHFU

③在还原过程中需要注意的几点:

  a、还原参数文件时注意去掉集群参数
  b、还原控制文件要转化为standby:
    restore standby controlfile from '/software/bak/control_7eu36n34_1_1.bak';

④还原数据之后,将数据库启动到mount状态

三、搭建DataGuard

1、修改主备参数

①修改主库参数

官网参数介绍:
https://docs.oracle.com/cd/E11882_01/server.112/e41134/create_ps.htm#SBYDB4721
https://docs.oracle.com/cd/E11882_01/server.112/e41134/log_arch_dest_param.htm#SBYDB01100
a、startup mount;
  create pfile='/software/pfile20190617.ora' from spfile;
  alter database archivelog;
b、alter database force logging;
  select log_mode,force_logging from v$database;
c、alter system set db_unique_name=xxx scope=spfile sid='*';
d、alter system set log_archive_config='DG_CONFIG=(xxx,xxxDG)' scope=spfile sid='*';
e、alter system set log_archive_dest_1='location=+BACKUPDG valid_for=(all_logfiles,all_roles) db_unique_name=xxx mandatory' scope=spfile sid='*';
f、alter system set log_archive_dest_2='service=xxxDG LGWR SYNC AFFIRM valid_for=(online_logfiles,primary_role)  db_unique_name=xxxDG' scope=spfile sid='*';
g、LOG_ARCHIVE_DEST_STATE_1=ENABLE,LOG_ARCHIVE_DEST_STATE_2=ENABLE(默认是enable)
h、alter system set fal_server=xxxDG scope=spfile sid='*';
i、alter system set db_file_name_convert='/s01/oracle/app/oracle/oradata/hisdgdb','+DATA/xxx/datafile' scope=spfile sid='*';
  alter system set log_file_name_convert='/s01/oracle/app/oracle/oradata/hisdgdb','+DATA/xxx/onlinelog','/s01/oracle/app/oracle/oradata/hisdgdb','+BACKUPDG/xxx/onlinelog/' scope=spfile sid='*';
j、alter system set standby_file_management=AUTO scope=spfile sid='*';
k、修改完后重启数据库:
srvctl status database -d db_name
srvctl stop database -d db_name
srvctl st database -d db_name

②修改备库参数

a、startup nomount;
  alter database archivelog;
b、alter database force logging;
  select log_mode,force_logging from v$database;
c、alter system set db_unique_name=xxxDG scope=spfile;
d、alter system set log_archive_config='DG_CONFIG=(xxx,xxxDG)';
e、alter system set log_archive_dest_1='location=/s01/oracle/app/oracle/oradata/arch valid_for=(all_logfiles,all_roles) db_unique_name=xxxDG mandatory' scope=spfile;
f、alter system set log_archive_dest_2='service=xxx LGWR SYNC AFFIRM valid_for=(online_logfiles,primary_role) db_unique_name=xxx' scope=spfile;
g、LOG_ARCHIVE_DEST_STATE_1=ENABLE,LOG_ARCHIVE_DEST_STATE_2=ENABLE(默认是enable)
h、alter system set fal_server=xxx;
i、alter system set db_file_name_convert='+DATA/xxx/datafile','/s01/oracle/app/oracle/oradata/hisdgdb' scope=spfile;
  alter system set log_file_name_convert='+DATA/xxx/onlinelog','/s01/oracle/app/oracle/oradata/hisdgdb','+BACKUPDG/xxx/onlinelog/','/s01/oracle/app/oracle/oradata/hisdgdb' scope=spfile;
j、alter system set standby_file_management=AUTO;
k、修改完之后数据库重启:
shutdown immediate;
startup mount;

2、创建STANDBY日志

  创建STANDBY的数量比当前redo日志数量多一组。

①主库创建(切换为备库时生效)

alter database add standby logfile thread 1 '+DATA/zlhis/onlinelog/std_redo01.log' size 50m;
alter database add standby logfile thread 1 '+DATA/zlhis/onlinelog/std_redo02.log' size 50m;
alter database add standby logfile thread 1 '+DATA/zlhis/onlinelog/std_redo05.log' size 50m;

alter database add standby logfile thread 2 '+DATA/zlhis/onlinelog/std_redo03.log' size 50m;
alter database add standby logfile thread 2 '+DATA/zlhis/onlinelog/std_redo04.log' size 50m;
alter database add standby logfile thread 1 '+DATA/zlhis/onlinelog/std_redo06.log' size 50m;

②备库创建

  备库虽然是单机,也需要创建thread 2的standby log,用于接收主库thread 2传过来的redo log。

alter database add standby logfile thread 1 '/s01/oracle/app/oracle/oradata/hisdgdb/std_redo01.log' size 50m;
alter database add standby logfile thread 1 '/s01/oracle/app/oracle/oradata/hisdgdb/std_redo02.log' size 50m;
alter database add standby logfile thread 1 '/s01/oracle/app/oracle/oradata/hisdgdb/std_redo05.log' size 50m;

alter database add standby logfile thread 2 '/s01/oracle/app/oracle/oradata/hisdgdb/std_redo03.log' size 50m;
alter database add standby logfile thread 2 '/s01/oracle/app/oracle/oradata/hisdgdb/std_redo04.log' size 50m;
alter database add standby logfile thread 2 '/s01/oracle/app/oracle/oradata/hisdgdb/std_redo06.log' size 50m;

3、配置监听

  修改主备库的tnsnames.ora文件,使主备库之间能够远程连接。在修改RAC时需要注意在2个节点上都做修改

4、开启复制

recover managed standby database using current logfile disconnect from session;  --非实时应用
recover managed standby database disconnect from session;  --非实时应用
alter database recover managed standby database cancel;

5、检查复制状态

select name,open_mode,database_role,protection_mode,protection_level,switchover_status from v$database;
select PROCESS,PID,STATUS,THREAD#,SEQUENCE# from  v$managed_standby;
select GROUP#,THREAD#,SEQUENCE#,USED,ARCHIVED,STATUS from v$standby_log;
select name from v$archived_log;

_1
_2
_3
_4
_5

6、开启备库到open状态

待备库追上主库redo日志时,将备库启动到open状态:
alter database recover managed standby database cancel;
alter database open;
recover managed standby database using current logfile disconnect from session;

网友评论

登录后评论
0/500
评论
持续高温
+ 关注