ORACLE有DATA GUARD(ADG)、EXPDP/IMPDP、RMAN、存储这四种迁移方式。
因为原数据库有28TB数据量,业务不接受停机时间过长,无法使用EXPDP/IMPDP、RMAN、存储方式完成数据库迁移,所以本次迁移使用ADG方式迁移数据库。
迁移过程
主库环境
操作系统:Red Hat 7.8
Oracle和grid版本 :19.11.0.0.210420
数据库架构:RAC
存储:ASM
备库环境
操作系统:Red Hat 7.9
Oracle和grid版本:19.11.0.0.210420
数据库架构:单机
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination +ARCH
Oldest online log sequence 207743
Next log sequence to archive 207746
Current log sequence 207746
主库已经启归档模式,如果未启用需要先启用归档模式。
SQL> select force_logging from v$database;
FORCE_LOGGING
---------------------------------------
YES
主库已开启强制日志,如果没有启用则需要开启,开启后需要做一次数据库全备,在用NBU恢复时也需要用最新的全备进行恢复。
alter system set log_archive_config=DG_CONFIG=(orcl,orcladg) scope=both;
alter system set log_archive_dest_1=LOCATION=+ARCH valid_for=(all_logfiles,all_roles) db_unique_name=orcl scope=both;
alter system set log_archive_dest_2=SERVICE=orcladg lgwr sync valid_for=(online_logfile,primary_role) db_unique_name=orcladg scope=both;
alter system set log_archive_dest_state_2=defer scope=both;
alter system set fal_client=orcl scope=both;
alter system set fal_server=orcladg scope=both;
alter system set standby_file_management=auto scope=both;
SQL> select THREAD#,BYTES/1024/1024 from v$log;
THREAD# BYTES/1024/1024
---------- ---------------
1 1024
1 1024
2 1024
2 1024
查询日志组数量和路径:
col MEMBER for a80;
col TYPE for a10;
set lin240 pages999;
select * from v$logfile;
GROUP# STATUS TYPE MEMBER IS_ CON_ID
------ ------ ------ ----------------------------------------- --- -------
1 ONLINE +DATA/ORCL/ONLINELOG/group_1.258.1061077801 NO 0
2 ONLINE +DATA/ORCL/ONLINELOG/group_2.259.1061077801 NO 0
3 ONLINE +DATA/ORCL/ONLINELOG/group_3.270.1061083275 NO 0
4 ONLINE +DATA/ORCL/ONLINELOG/group_4.271.1061083275 NO 0
alter database add standby logfile thread 1 group 5 +DATA size 1024m;
alter database add standby logfile thread 1 group 6 +DATA size 1024m;
alter database add standby logfile thread 1 group 7 +DATA size 1024m;
alter database add standby logfile thread 2 group 8 +DATA size 1024m;
alter database add standby logfile thread 2 group 9 +DATA size 1024m;
alter database add standby logfile thread 2 group 10 +DATA size 1024m;
create pfile=/tmp/init.ora from spfile;
scp /tmp/init.ora 备库IP:/oracle/app/oracle/product/19.0.0/db/dbs/initorcl.ora
*.audit_file_dest=/oracle/app/oracle/admin/orcl/adump
*.audit_trail=NONE
*.cluster_database=FALSE
*.compatible=19.0.0
*.control_files=+data/ORCL/CONTROLFILE/xxxx
*.db_block_size=8192
*.db_cache_size=60129542144
*.db_create_file_dest=+DATA
*.db_domain=
*.db_files=2000
*.db_name=orcl
*.db_unique_name=orcldg
*.diagnostic_dest=/oracle/app/oracle
*.dispatchers=(PROTOCOL=TCP) (SERVICE=orclXDB)
*.event=28401 trace name context forever,level 1
*.java_jit_enabled=TRUE
*.fal_client=orcldg
*.fal_server=orcl
*.log_archive_config=DG_CONFIG=(orcldg,orcl)
*.log_archive_dest_1=LOCATION=+arch
*.log_archive_dest_3=SERVICE=orcl lgwr sync valid_for=(online_logfile,primary_role) db_unique_name=orcl
*.log_archive_dest_state_2=ENABLE
*.open_cursors=1000
*.parallel_max_servers=128
*.parallel_min_servers=32
*.parallel_servers_target=128
*.pga_aggregate_target=27068989440
*.processes=3000
*.remote_login_passwordfile=exclusive
*.service_names=orcl
*.session_cached_cursors=200
*.sessions=3305
*.sga_target=100G
*.standby_file_management=auto
*.undo_retention=3600
*.undo_tablespace=UNDOTBS1
cd /oracle/app/oracle/product/19.0.0/dbhome_1/dbs
scp orapworcl1 备库IP:/oracle/app/oracle/product/19.0.0/db/dbs/orapworcl
scp orapworcl1 节点2IP:/oracle/app/oracle/product/19.0.0/db/dbs/orapworcl2
SQL> alter database create standby controlfile as /tmp/standby.ctl;
scp /tmp/standby.ctl 备库IP:/tmp/standby.ctl;
rman target /
startup pfile=/oracle/app/oracle/product/19.0.0/db/dbs/initorcl.ora nomount;
RMAN> restore standby controlfile to +DATA FROM /tmp/standby.ctl;
mkdir -p /oracle/app/oracle/admin/orcl/adump
ORCLDG =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 备库IP)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 节点1IP)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 节点2IP)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
ORCLDG =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 备库IP)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
lsnrctl start
主备库添加白名后reload监听:
reload
Tnsping测试:
tnsping ORCL
tnsping ORCLDG
vi nbu_rman.sh
#!/bin/bash
source /home/oracle/.bash_profile
rman target / < run{
ALLOCATE CHANNEL c0 TYPE SBT_TAPE SEND NB_ORA_SERV=NBUmaster,NB_ORA_CLIENT=xxxx,NB_ORA_DISK_MEDIA_SERVER=xxxx;
ALLOCATE CHANNEL c1 TYPE SBT_TAPE SEND NB_ORA_SERV=NBUmaster,NB_ORA_CLIENT=xxxx,NB_ORA_DISK_MEDIA_SERVER=xxxx;
ALLOCATE CHANNEL c2 TYPE SBT_TAPE SEND NB_ORA_SERV=NBUmaster,NB_ORA_CLIENT=xxxx,NB_ORA_DISK_MEDIA_SERVER=xxxx;
ALLOCATE CHANNEL c3 TYPE SBT_TAPE SEND NB_ORA_SERV=NBUmaster,NB_ORA_CLIENT=xxxx,NB_ORA_DISK_MEDIA_SERVER=xxxx;
ALLOCATE CHANNEL c4 TYPE SBT_TAPE SEND NB_ORA_SERV=NBUmaster,NB_ORA_CLIENT=xxxx,NB_ORA_DISK_MEDIA_SERVER=xxxx;
ALLOCATE CHANNEL c5 TYPE SBT_TAPE SEND NB_ORA_SERV=NBUmaster,NB_ORA_CLIENT=xxxx,NB_ORA_DISK_MEDIA_SERVER=xxxx;
restore database;
recover database;
RELEASE CHANNEL c0;
RELEASE CHANNEL c1;
RELEASE CHANNEL c2;
RELEASE CHANNEL c3;
RELEASE CHANNEL c4;
RELEASE CHANNEL c5;
}
EOF
SQL> alter system set log_archive_dest_state_2=enable scope=both;
alter database recover managed standby database using current logfile disconnect from session;
PR00 (PID:112926): FAL: Failed to request gap sequence
PR00 (PID:112926): GAP - thread 1 sequence 211212-211250
PR00 (PID:112926): DBID 1915883988 branch 1085828161
PR00 (PID:112926): FAL: All defined FAL servers have been attempted
PR00 (PID:112926): -------------------------------------------------------------------------
PR00 (PID:112926): Check that the CONTROL_FILE_RECORD_KEEP_TIME initialization
PR00 (PID:112926): parameter is defined to a value thats sufficiently large
PR00 (PID:112926): enough to maintain adequate log switch information to resolve
PR00 (PID:112926): archived redo log gaps.
PR00 (PID:112926): -------------------------------------------------------------------------
如果存现主库和NBU缺失部分归档文件无法完成在备库应用,可以选择主库最新的全备文件重新进行恢复。
RMAN> configure CHANNEL device type SBT_TAPE PARMS ENV=
(NB_ORA_SERV=NBUmaster,NB_ORA_CLIENT=xxxx,NB_ORA_DISK_MEDIA_SERVER=xxxx);
RMAN> list backup of archivelog all;
RMAN> catalog device type SBT_TAPE backuppiece arch_xxxx1;
RMAN> catalog device type SBT_TAPE backuppiece arch_xxxx2;
RMAN> CONFIGURE CHANNEL DEVICE TYPE SBT_TAPE CLEAR;
run {
ALLOCATE CHANNEL c0 TYPE SBT_TAPE SEND NB_ORA_SERV=NBUmaster,NB_ORA_CLIENT=xxxx,NB_ORA_DISK_MEDIA_SERVER=xxxx;
ALLOCATE CHANNEL c1 TYPE SBT_TAPE SEND NB_ORA_SERV=NBUmaster,NB_ORA_CLIENT=xxxx,NB_ORA_DISK_MEDIA_SERVER=xxxx;
restore archivelog sequence between xxxx1 and xxxx8;
RELEASE CHANNEL c0;
RELEASE CHANNEL c1;
}
run{
ALLOCATE CHANNEL c1 TYPE SBT_TAPE SEND NB_ORA_SERV=NBUmaster,NB_ORA_CLIENT=xxxx,NB_ORA_DISK_MEDIA_SERVER=xxxx;
restore archivelog sequence between xxxx2 and xxxx6 thread 2;
RELEASE CHANNEL c1;
}
alter database recover managed standby database cancel;
alter database open;
alter database recover managed standby database using current logfile disconnect from session;
SQL> select OPEN_MODE from v$database;
OPEN_MODE
--------------------
READ ONLY WITH APPLY
以上状态说明ORACLE ADG搭建成功。
alter database recover managed standby database cancel;
shutdown immediate;
startup mount;
alter database flashback on;
alter database open;
alter system set log_archive_dest_state_2=defer;
select open_mode from v$database;
OPEN_MODE
--------------------
READ ONLY
alter database activate standby database;
文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。
转载请注明本文地址:https://www.ucloud.cn/yun/129385.html
ElasticSearch索引跨集群迁移 img{ display:block; margin:0 auto !important; width:100%; } body{ width:75%; ...
摘要:题记三国时赤壁鏖战,孔明说,天有不测风云,欲破曹公,宜用火攻,万事俱备,只欠东风。现在公共云混战,我想说,无灾备不上云,保护数据,未雨绸缪,带了雨伞,还需雨衣。题记:三国时赤壁鏖战,孔明说,天有不测风云,欲破曹公,宜用火攻,万事俱备,只欠东风。现在公共云混战,我想说,无灾备不上云,保护数据,未雨绸缪,带了雨伞,还需雨衣。未雨绸缪,到底是带雨伞还是雨衣呢?时代在变,人的追求也在变。随着公共云对...
摘要:经过与阿里云工程师的沟通决定使用阿里云的迁云工具来完成这次迁移。出现之后,打开阿里云控制台,你会发现多了三个快照和一个镜像然后用这个镜像直接购买实例就可以了。 摘要: ERP物理机迁移至阿里云实践 机房选型 随着公司的不断发展,业务量逐渐增大,对信息化的要求也越来越高,随之对信息部的要求也越来越多,为此公司决定对现有的信息系统进行升级改造. ERP物理机迁移至阿里云实践 一、机房选...
摘要:灾难恢复服务和物联网云存储等技术越来越受到关注。下面,根据流行度,列举了年阅读量较高的一大云存储技巧。在灾难发生后保护,并确保重要数据可用并不是一件小事,但是使用云存储平台可使提供商做更多的工作。自2016年起,我们已经分析了十大重要存储平台,从实施混合云到制定数据迁移策略。对于云存储来说,渡过了一个漫长而奇怪的一年。曾经认为的存储时尚刚刚出现在各地,同时云迁移策略比以往更加广泛了。对于一些...
摘要:基于云迁移的三个阶段细分为八个主要步骤,评估阶段主要包括项目启动现状梳理以及应用系统关联关系分析三个步骤,设计阶段包括云架构优化设计和云迁移方案设计,实施阶段包括目标架构迁移演练及实施和试运行三个步骤。 在云计算市场规模不断扩大的大背景下,云迁移的需求越来越大且面临挑战。云迁移不是一个迁移软件工具,而是一种服务。前IBM资深架构师姜亚杰从云迁移的三个阶段、四个维度到八个步骤的方法,简述...
阅读 1249·2023-01-11 13:20
阅读 1557·2023-01-11 13:20
阅读 1011·2023-01-11 13:20
阅读 1680·2023-01-11 13:20
阅读 3971·2023-01-11 13:20
阅读 2519·2023-01-11 13:20
阅读 1310·2023-01-11 13:20
阅读 3486·2023-01-11 13:20