一、前期准备
按照DG部署步骤修改DG参数、添加standby redo log、配置静态监听、配置tnsnames文件、备端修改参数文件、创建所需目录等配置好部署环境,这里不再赘述,跟正常部署DG无区别。
环境配置好后,进行后面的操作。
二、使用RMAN备份复制主端数据库
2.1.主端备份数据库
RMAN> run {
allocate channel c1 type disk;
allocate channel c2 type disk;
backup incremental level 0 format '/home/oracle/orcl_full_%U' database;
backup format '/home/oracle/orcl_full_stanctl_%U' current controlfile for standby;
release channel c1;
release channel c2;
}
2.2.备端启动至nomount
SQL> create spfile from pfile='/home/oracle/pfile.ora';
SQL> startup nomount
2.3.恢复控制文件
RMAN> restore standby controlfile from '/home/oracle/orcl_full_stanctl_061vp2sb_1_1';
RMAN> alter database mount;
2.4.恢复数据文件
RMAN> catalog backuppiece '/home/oracle/orcl_full_021vp2qu_1_1';
RMAN> catalog backuppiece '/home/oracle/orcl_full_031vp2qu_1_1';
RMAN> catalog backuppiece '/home/oracle/orcl_full_041vp2s7_1_1';
RMAN> catalog backuppiece '/home/oracle/orcl_full_051vp2s9_1_1';
RMAN> run {
allocate channel d1 type disk;
allocate channel d2 type disk;
restore database;
recover database;
release channel d1;
release channel d2;
}
三、只能mount同步,无法只读打开
3.1.备库开启同步
SQL> alter database recover managed standby database using current logfile disconnect from session;
3.2.验证是否同步
## 备库查询MRP0恢复进程应用块数
SQL> SELECT PROCESS,STATUS,THREAD#,SEQUENCE#,BLOCK#,BLOCKS,DELAY_MINS FROM V$MANAGED_STANDBY;
PROCESS STATUS THREAD# SEQUENCE# BLOCK# BLOCKS DELAY_MINS
------- ------------ --------- --------- ------ ------ ----------
DGRD ALLOCATED 0 0 0 0 0
ARCH CLOSING 1 34 1 342 0
DGRD ALLOCATED 0 0 0 0 0
ARCH CONNECTED 0 0 0 0 0
ARCH CONNECTED 0 0 0 0 0
ARCH CONNECTED 0 0 0 0 0
RFS IDLE 1 0 0 0 0
RFS IDLE 0 0 0 0 0
RFS IDLE 1 35 23 1 0
MRP0 APPLYING_LOG 1 35 23 102400 0
10 rows selected.
SQL> /
PROCESS STATUS THREAD# SEQUENCE# BLOCK# BLOCKS DELAY_MINS
------- ----------- ------- --------- ------ ------ ----------
DGRD ALLOCATED 0 0 0 0 0
ARCH CLOSING 1 34 1 342 0
DGRD ALLOCATED 0 0 0 0 0
ARCH CONNECTED 0 0 0 0 0
ARCH CONNECTED 0 0 0 0 0
ARCH CONNECTED 0 0 0 0 0
RFS IDLE 1 0 0 0 0
RFS IDLE 0 0 0 0 0
RFS IDLE 1 35 27 1 0
MRP0 APPLYING_LOG 1 35 27 102400 0
10 rows selected.
SQL> /
PROCESS STATUS THREAD# SEQUENCE# BLOCK# BLOCKS DELAY_MINS
------- ---------- ------- --------- ------ ------ ----------
DGRD ALLOCATED 0 0 0 0 0
ARCH CLOSING 1 34 1 342 0
DGRD ALLOCATED 0 0 0 0 0
ARCH CONNECTED 0 0 0 0 0
ARCH CONNECTED 0 0 0 0 0
ARCH CONNECTED 0 0 0 0 0
RFS IDLE 1 0 0 0 0
RFS IDLE 0 0 0 0 0
RFS IDLE 1 35 28 1 0
MRP0 APPLYING_LOG 1 35 28 102400 0
10 rows selected.
## 主库查询归档日志序列号
SQL> select max(sequence#),thread# from v$archived_log where RESETLOGS_CHANGE# = (SELECT RESETLOGS_CHANGE# FROM V$DATABASE_INCARNATION WHERE STATUS = 'CURRENT') GROUP BY THREAD#;
MAX(SEQUENCE#) THREAD#
-------------- -------
34 1
## 备端查询归档日志序列号
SQL> select max(sequence#),thread# from v$archived_log where applied='YES' and RESETLOGS_CHANGE# = (SELECT RESETLOGS_CHANGE# FROM V$DATABASE_INCARNATION WHERE STATUS = 'CURRENT') GROUP BY THREAD#;
MAX(SEQUENCE#) THREAD#
-------------- -------
33 1
## 检查alert日志是否正常
2023-06-27T16:44:48.145275+08:00
MRP0 (PID:24798): Media Recovery Waiting for T-1.S-36
2023-06-27T16:44:48.243077+08:00
rfs (PID:24785): Selected LNO:4 for T-1.S-36 dbid 1668400254 branch 1140619521
2023-06-27T16:44:48.243519+08:00
ARC1 (PID:24769): Archived Log entry 5 added for T-1.S-35 ID 0x6371a37e LAD:1
2023-06-27T16:44:49.181453+08:00
Recovery of Online Redo Log: Thread 1 Group 4 Seq 36 Reading mem 0
Mem# 0: /oradata/orcldg/standby_redo04.log
## 备库应用是否存在延迟
SQL> select name,value from v$dataguard_stats;
NAME VALUE
--------------------- ------------
transport lag +00 00:00:00
apply lag +00 00:00:00
apply finish time
estimated startup time 5
四、主库创建测试表,备库升级后验证数据是否同步
SQL> create user test identified by admin;
User created.
SQL> grant create session,resource to test;
Grant succeeded.
SQL> conn test/admin
Connected.
SQL> create table t1 (id number);
Table created.
SQL> insert into t1 values(1);
1 row created.
SQL> commit;
Commit complete.
SQL> select * from t1;
ID
------
1
五、备库进行故障转移
由于跨版本无法进行正常的主备切换,故采用故障转移的方式,将备库改为主库,进行升级操作。文章来源:https://www.toymoban.com/news/detail-727267.html
## 备库
SQL> alter database recover managed standby database finish;
SQL> alter database commit to switchover to primary;
## 升级模式打开数据库
SQL> shutdown immediate
SQL> startup upgrade
六、开始升级
## 切换后的新主库执行升级脚本
cd $ORACLE_HOME/bin
./dbupgrade
或
$ORACLE_HOME/perl/bin/perl catctl.pl catupgrd.sql
七、升级后打开数据库,验证同步数据
## 启动数据库
SQL> startup
SQL> conn test/admin
Connected.
SQL> select * from t1;
ID
-----
1
升级后,数据正常,所以此方式可以作为升级迁移数据的一种方式。
八、部署过程中遇到的问题
8.1.不能使用rman duplicate方式复制主端数据库
因为主备端RMAN版本不一致造成此方式无法使用,报错现象如下:文章来源地址https://www.toymoban.com/news/detail-727267.html
[oracle@dg-19 ~]$ rman target sys/admin@orcl auxiliary sys/admin@orcldg nocatalog
Recovery Manager: Release 19.0.0.0.0 - Production on Tue Jun 27 15:59:11 2023
Version 19.13.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00554: initialization of internal recovery manager package failed
RMAN-06429: TARGET database is not compatible with this version of RMAN
RMAN-06618: RMAN client and database version mismatch; indicated database version is 11.2.0.4
8.2.升级后用户无法登录的问题
## 错误现象:
SQL> conn test/admin
ERROR:ORA-01017: invalid username/password; logon denied
## 原因
Oracle 19c SEC_CASE_SENSITIVE_LOGON参数对用户登录的影响:
(1)设置为FALSE,关闭密码大小写限制,会造成用户无法登录。
(2)设置为TRUE,开启密码大小写限制,用户登录正常。
## 解决方法
(1)alter system set sec_case_sensitive_logon=true;
(2)如Oracle 19c 需要开启关闭密码大小写限制。需要在sqlnet.ora 文件添加参数:
SQLNET.ALLOWED_LOGON_VERSION_SERVER=8。
然后重新设置用户密码:
SQL> alter user test identified by admin;
SQL> conn test/admin
Connected.
SQL> conn test/ADMIN
Connected.
也可登录成功。
到了这里,关于Oracle Dataguard跨版本数据迁移(11.2.0.4~19.13.0.0)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!