Oracle Dataguard(主库为双节点集群)配置详解(5):将主库复制到备库并启动同步

Oracle Dataguard(主库为双节点集群)配置详解(5):将主库复制到备库并启动同步

目录

  • Oracle Dataguard(主库为双节点集群)配置详解(5):将主库复制到备库并启动同步
    • 一、使用 rman 连接主库和备库,并设置好主备关系
    • 二、执行复制命令
    • 三、启动备库
        • 1、查看备库的状态
        • 2、正常启动备库
        • 3、开启实时同步
        • 4、查看备库状态
        • 5、查看备库进程
        • 6、查看主库状态
        • 7、查看主库进程
    • 四、实时同步验证

一、使用 rman 连接主库和备库,并设置好主备关系

target——主库:auxiliary——备库。

在主库的节点1执行如下命令:

[oracle@rac01 ~]$ rman target sys/oracle@hisdb1 auxiliary sys/oracle@hisdbdgRecovery Manager: Release 11.2.0.4.0 - Production on Sat Jan 11 11:45:08 2025Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.connected to target database: HISDB (DBID=2102569523)
connected to auxiliary database: HISDB (not mounted)

二、执行复制命令

该命令可以直接恢复数据文件、standby日志文件和控制文件。

RMAN> DUPLICATE TARGET DATABASE FOR STANDBY FROM ACTIVE DATABASE;  Starting Duplicate Db at 11-JAN-25
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=20 device type=DISKcontents of Memory Script:
{backup as copy reusetargetfile  '/u01/app/oracle/product/11.2.0/db_1/dbs/orapwhis1' auxiliary format '/usr/local/oracle/product/11.2.0/db_1/dbs/orapwhisdg'   ;
}
executing Memory ScriptStarting backup at 11-JAN-25
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1 instance=his1 device type=DISK
Finished backup at 11-JAN-25contents of Memory Script:
{backup as copy current controlfile for standby auxiliary format  '/usr/local/oradata/hisdbdg/control01.ctl';restore clone controlfile to  '/usr/local/oracle/fast_recovery_area/hisdbdg/control02.ctl' from '/usr/local/oradata/hisdbdg/control01.ctl';
}
executing Memory ScriptStarting backup at 11-JAN-25
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
copying standby control file
output file name=/u01/app/oracle/product/11.2.0/db_1/dbs/snapcf_his1.f tag=TAG20250111T124752 RECID=3 STAMP=1190119677
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
Finished backup at 11-JAN-25Starting restore at 11-JAN-25
using channel ORA_AUX_DISK_1channel ORA_AUX_DISK_1: copied control file copy
Finished restore at 11-JAN-25contents of Memory Script:
{sql clone 'alter database mount standby database';
}
executing Memory Scriptsql statement: alter database mount standby databasecontents of Memory Script:
{set newname for tempfile  1 to "/usr/local/oradata/hisdbdg/temp.263.1189953499";switch clone tempfile all;set newname for datafile  1 to "/usr/local/oradata/hisdbdg/system.256.1189953387";set newname for datafile  2 to "/usr/local/oradata/hisdbdg/sysaux.257.1189953387";set newname for datafile  3 to "/usr/local/oradata/hisdbdg/undotbs1.258.1189953387";set newname for datafile  4 to "/usr/local/oradata/hisdbdg/users.259.1189953387";set newname for datafile  5 to "/usr/local/oradata/hisdbdg/undotbs2.264.1189953701";backup as copy reusedatafile  1 auxiliary format "/usr/local/oradata/hisdbdg/system.256.1189953387"   datafile 2 auxiliary format "/usr/local/oradata/hisdbdg/sysaux.257.1189953387"   datafile 3 auxiliary format "/usr/local/oradata/hisdbdg/undotbs1.258.1189953387"   datafile 4 auxiliary format "/usr/local/oradata/hisdbdg/users.259.1189953387"   datafile 5 auxiliary format "/usr/local/oradata/hisdbdg/undotbs2.264.1189953701"   ;sql 'alter system archive log current';
}
executing Memory Scriptexecuting command: SET NEWNAMErenamed tempfile 1 to /usr/local/oradata/hisdbdg/temp.263.1189953499 in control fileexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEStarting backup at 11-JAN-25
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=+DATA/hisdb/datafile/system.256.1189953387
output file name=/usr/local/oradata/hisdbdg/system.256.1189953387 tag=TAG20250111T124809
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:35
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=+DATA/hisdb/datafile/sysaux.257.1189953387
output file name=/usr/local/oradata/hisdbdg/sysaux.257.1189953387 tag=TAG20250111T124809
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:05
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=+DATA/hisdb/datafile/undotbs1.258.1189953387
output file name=/usr/local/oradata/hisdbdg/undotbs1.258.1189953387 tag=TAG20250111T124809
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005 name=+DATA/hisdb/datafile/undotbs2.264.1189953701
output file name=/usr/local/oradata/hisdbdg/undotbs2.264.1189953701 tag=TAG20250111T124809
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=+DATA/hisdb/datafile/users.259.1189953387
output file name=/usr/local/oradata/hisdbdg/users.259.1189953387 tag=TAG20250111T124809
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 11-JAN-25sql statement: alter system archive log currentcontents of Memory Script:
{switch clone datafile all;
}
executing Memory Scriptdatafile 1 switched to datafile copy
input datafile copy RECID=3 STAMP=1190119881 file name=/usr/local/oradata/hisdbdg/system.256.1189953387
datafile 2 switched to datafile copy
input datafile copy RECID=4 STAMP=1190119881 file name=/usr/local/oradata/hisdbdg/sysaux.257.1189953387
datafile 3 switched to datafile copy
input datafile copy RECID=5 STAMP=1190119881 file name=/usr/local/oradata/hisdbdg/undotbs1.258.1189953387
datafile 4 switched to datafile copy
input datafile copy RECID=6 STAMP=1190119881 file name=/usr/local/oradata/hisdbdg/users.259.1189953387
datafile 5 switched to datafile copy
input datafile copy RECID=7 STAMP=1190119881 file name=/usr/local/oradata/hisdbdg/undotbs2.264.1189953701
Finished Duplicate Db at 11-JAN-25

三、启动备库

1、查看备库的状态

执行完同步后,数据库状态会从 nomount --> mount

SQL> select open_mode from v$database;OPEN_MODE
--------------------
MOUNTED
2、正常启动备库
SQL> alter database open;Database altered.
3、开启实时同步
SQL> alter database recover managed standby database using current logfile disconnect from session;Database altered.
4、查看备库状态
SQL> select open_mode,log_mode,open_mode ,database_role from v$database;OPEN_MODE	     LOG_MODE	  OPEN_MODE	       DATABASE_ROLE
-------------------- ------------ -------------------- ----------------
READ ONLY WITH APPLY ARCHIVELOG   READ ONLY WITH APPLY PHYSICAL STANDBY
5、查看备库进程
SQL> select process, status, thread#,sequence#, block#, blocks from v$managed_standby;PROCESS   STATUS	  THREAD#  SEQUENCE#	 BLOCK#     BLOCKS
--------- ------------ ---------- ---------- ---------- ----------
ARCH	  CONNECTED		0	   0	      0 	 0
ARCH	  CONNECTED		0	   0	      0 	 0
ARCH	  CLOSING		2	  20	  10240       1912
ARCH	  CLOSING		1	  24	  32768        265
RFS	  IDLE			0	   0	      0 	 0
RFS	  IDLE			0	   0	      0 	 0
RFS	  WRITING		2	  21	    144 	 1
RFS	  WRITING		1	  25	    103 	 1
RFS	  IDLE			0	   0	      0 	 0
RFS	  IDLE			0	   0	      0 	 0
MRP0	  APPLYING_LOG		2	  20	   2418      1215111 rows selected.
6、查看主库状态
SQL> select open_mode,log_mode,open_mode ,database_role from v$database;OPEN_MODE	     LOG_MODE	  OPEN_MODE	       DATABASE_ROLE
-------------------- ------------ -------------------- ----------------
READ WRITE	     ARCHIVELOG   READ WRITE	       PRIMARY
7、查看主库进程
SQL> select process, status, thread#,sequence#, block#, blocks from v$managed_standby;PROCESS   STATUS	  THREAD#  SEQUENCE#	 BLOCK#     BLOCKS
--------- ------------ ---------- ---------- ---------- ----------
ARCH	  CLOSING		1	  24	  32768        265
ARCH	  CLOSING		1	  23	  47104       1418
ARCH	  CONNECTED		0	   0	      0 	 0
ARCH	  CLOSING		1	  24	  32769        264
LNS	  WRITING		1	  25	    151 	 1

四、实时同步验证

1、在主库创建 t1 表插入以下数据

SQL> 
create table t1(id int primary key,name varchar2(20));
insert into t1 values(1,'mark');
insert into t1 values(2,'jack');
commit;Table created.SQL> 
1 row created.SQL> 
1 row created.SQL> 
Commit complete.

2、在备库查询 t1 表中的数据

SQL> select * from t1;ID NAME
---------- --------------------1 mark2 jack

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/pingmian/66933.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

树的模拟实现

一.链式前向星 所谓链式前向星,就是用链表的方式实现树。其中的链表是用数组模拟实现的链表。 首先我们需要创建一个足够大的数组h,作为所有结点的哨兵位。创建两个足够大的数组e和ne,一个作为数据域,一个作为指针域。创建一个变…

【C++入门】详解(中)

目录 💕1.函数的重载 💕2.引用的定义 💕3.引用的一些常见问题 💕4.引用——权限的放大/缩小/平移 💕5. 不存在的空引用 💕6.引用作为函数参数的速度之快(代码体现) &#x1f4…

springboot整合mysql

1.首先在pom.xml中添加依赖&#xff1a; <!-- MySQL Driver --><dependency><groupId>com.mysql</groupId><artifactId>mysql-connector-j</artifactId><scope>runtime</scope></dependency><!-- Druid连接池 -->…

Windows C++开发环境:VSCode + cmake + ninja + msvc (cl.exe) + msys2/bash shell

这套环境的作用/优点 VSCode&#xff1a;代替Visual Studio, 启动迅速&#xff0c;内存占用小cmake: 与linux一致的构建系统ninja msvc: 用ninja作为cmake的generator, 配合msvc生成工具完成C工程的编译和链接 msvc作为编译工具&#xff0c;而不是msys2或mingw64的gcc&#x…

《Opencv》图像的旋转

一、使用numpy库实现 np.rot90(img,-1) 后面的参数为-1时事顺时针旋转&#xff0c;为1时是逆时针旋转。 import cv2 import numpy as np img cv2.imread(./images/kele.png) """方法一""" # 顺时针90度 rot_1 np.rot90(img,-1) # 逆时针90度…

CES 2025|全面拥抱端侧AI,美格智能在CES发布系列创新成果

要点&#xff1a; ▶ 在AI机器人领域&#xff0c;以高算力AI模组助力发布“通天晓”人形机器人和2款全新微小型AI机器人 ▶ 在AI硬件领域&#xff0c;发布消费级AI智能体产品——AIMO&#xff0c;引领个人专属的大模型时代 ▶ 在5G通信领域&#xff0c;发布全新5GWiFi-7 CPE…

Python自学 - 类进阶(生成器)

<< 返回目录 1 Python自学 - 类进阶(生成器) 生成器是一种特殊的迭代器&#xff0c;它允许在迭代过程中暂停和恢复函数的执行。生成器的特点&#xff1a; 使用yield返回值&#xff0c;而不是return 函数执行到yield时会进入暂停状态并保存状态。 再次执行函数时&#…

Spring Boot 支持哪些日志框架

Spring Boot 支持多种日志框架&#xff0c;主要包括以下几种&#xff1a; SLF4J (Simple Logging Facade for Java) Logback&#xff08;默认&#xff09;Log4j 2Java Util Logging (JUL) 其中&#xff0c;Spring Boot 默认使用 SLF4J 和 Logback 作为日志框架。如果你需要使…

SpringBoot的@Scheduled和@Schedules有什么区别

Scheduled 的详细解析 参数详解 cron: 使用Cron表达式来指定复杂的调度模式。Cron表达式的格式如下&#xff1a; 秒&#xff08;0-59&#xff09;分钟&#xff08;0-59&#xff09;小时&#xff08;0-23&#xff09;日&#xff08;1-31&#xff09;月&#xff08;1-12 或 JAN-…

js基础---书写位置

js基础—书写位置 内部 直接写在html文件里面&#xff0c;用script标签包住 规范 &#xff1a;script 标签写在上面 代码演示 <!DOCTYPE html> <html lang"en"> <head><meta charset"UTF-8"><meta name"viewport"…

SpringBoot操作spark处理hdfs文件

SpringBoot操作spark处理hdfs文件 1、导入依赖 <!-- spark依赖--><dependency><groupId>org.apache.spark</groupId><artifactId>spark-core_2.12</artifactId><version>3.2.2</version></dependency><depend…

Jaeger UI使用、采集应用API排除特定路径

Jaeger使用 注&#xff1a; Jaeger服务端版本为&#xff1a;jaegertracing/all-in-one-1.6.0 OpenTracing版本为&#xff1a;0.33.0&#xff0c;最后一个版本&#xff0c;停留在May 06, 2019。最好升级到OpenTelemetry。 Jaeger客户端版本为&#xff1a;jaeger-client-1.3.2。…

PySide6-UI界面设计

导论&#xff1a; PySide6和PyQt都是Python对Qt框架的绑定&#xff0c;允许开发者使用Qt创建平台的GUI应用程序。如果你正在开发商业项目&#xff0c;或者需要使用最新的QT6特性&#xff0c;PySide6是一个更好的选择。如果你更倾向于一个成熟的社区和丰富的资源&#xff0c;Py…

使用 Multer 上传图片到阿里云 OSS

文件上传到哪里更好&#xff1f; 上传到服务器本地 上传到服务器本地&#xff0c;这种方法在现今商业项目中&#xff0c;几乎已经见不到了。因为服务器带宽&#xff0c;磁盘 IO 都是非常有限的。将文件上传和读取放在自己服务器上&#xff0c;并不是明智的选择。 上传到云储存…

电机控制的数字化升级:基于DSP和FPGA的仿真与实现

数字信号处理器&#xff08;DSP&#xff0c;Digital Signal Processor&#xff09;在工业自动化领域的应用日益广泛。DSP是一种专门用于将模拟信号转换成数字信号并进行处理的技术&#xff0c;能够实现信号的数字滤波、重构、调制和解调等多项功能&#xff0c;确保信号处理的精…

微服务的CAP定理与数据一致性抉择

分布式系统中的CAP定理&#xff0c;包括一致性&#xff08;Consistency&#xff09;、可用性&#xff08;Availability&#xff09;和分区容错性&#xff08;Partition Tolerance&#xff09;三个核心要素。 微服务是分布式系统的一种表现形式&#xff0c;以及用户对于系统是分…

leetcode_2816. 翻倍以链表形式表示的数字

2816. 翻倍以链表形式表示的数字 - 力扣&#xff08;LeetCode&#xff09; 搜先看到这个题目 链表的节点那么多 已经远超longlong能够表示的范围 那么暴力解题 肯定是不可以的了 我们可以想到 乘法运算中 就是从低位到高位进行计算 刚开始 我想先反转链表 然后在计算 然后在进…

Element Plus 之 el-table相同行合并(通用函数),相同列合并(自行判断需合并的字段以及相应的列下标)

展示 代码 <el-table :data"tableData" border style"width: 100%" :span-method"objectSpanMethod"><el-table-column prop"date" label"Date" width"180" align"center" /><el-table…

QT中引入OpenCV库总结(qmake方式和cmake方式)

文章目录 前言opencv环境配置一、opencv库获取的两种方式二、qmake和cmake配置2.1、 qmake2.2、cmake2.2.1、引入opencv示例 三、qt与opencv对应关系四、问题 前言 我的软件环境&#xff0c;写在前面 Windows10QT5.12.12VS2017OpenCV4.5.4 opencv环境配置 一、opencv库获取…

[石榴翻译] 维吾尔语音识别 + TTS语音合成

API网址 丝路AI平台 获取 Access token 接口地址&#xff1a;https://open.xjguoyu.cn/api/auth/oauth/token&#xff0c;请求方式&#xff1a;GET&#xff0c;POST Access token是调用服务API的凭证&#xff0c;调用服务API之前需要获取 token。每次成功获取 token 以后只有…