RAC到单机搭建DataGuard

简介: 一、环境信息1、服务器:Cetnos 7.22、数据库版本:11.2.0.43、RAC -> 单机二、环境准备     目标是搭建RAC到单机的Activity DataGuard,首先RAC环境是准备完善的,接下来需要搭建一个单机环境。

一、环境信息

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;
相关文章
|
数据库 数据安全/隐私保护
使用rman把单机的备份集恢复到RAC的方法
环境准备 在ASM磁盘组里面创建相应的目录
222 0
|
数据库
rac 转换单机
rac 转换单机
153 0
|
数据库
rac 转单机
rac 转单机
121 0
|
数据库
|
Oracle 关系型数据库 数据库
把oracle rac 转化为单机数据库
1. Stop database and CRS on both node $ srvctl stop database -d mydb # crsctl stop crs 2.
4215 0
|
Oracle 关系型数据库 测试技术
zt: 在linux上单机模拟Oracle 10g RAC集群(OCFS+ASM)
http://www.itpub.net/579479.html 本想做个安装记录,把遇到的错误和解决办法写下来,以备以后操作时参考,但在写的过程中阴错阳差地对付着把系统装上了,所以就当个安装说明吧,不过其中还有个错误(在下面有记录),感觉应该对使用有影响,所以以后还要想办法修正。
1425 0
|
4月前
|
运维 Oracle 前端开发
Oracle 11g RAC集群日常运维命令总结
Oracle 11g RAC集群日常运维命令总结
112 2
|
4月前
|
Oracle 关系型数据库
分布式锁设计问题之Oracle RAC保证多个节点写入内存Page的一致性如何解决
分布式锁设计问题之Oracle RAC保证多个节点写入内存Page的一致性如何解决