Oracle RMAN异机迁移数据库从文件系统至ASM

Oracle RMAN异机迁移数据库从文件系统至ASM

准备环境

源库(文件系统) 目标库(ASM)
IP地址 172.30.21.191 172.30.21.98
主机名称 hfzcdb91 hfwmsdb98
数据库名 hfzcdb hfwmsdb
实例名 hfzcdb hfwmsdb

from:

source ip:172.30.21.191 19c hfzcdb filesystem 【172.30.21.191】

to:

target ip:172.30.21.98 19c asm

备份 【21.191】

备份参数文件

create pfile='/home/oracle/hfzcdb.pfile' from spfile;

备份数据库

vi hfzcdb_rman_full.sh

chmod u+x hfzcdb_rman_full.sh

./hfzcdb_rman_full.sh

sql 复制代码
rman target / msglog '/backup/hfzcdb_rman_full_backup.log' << EOF 
run { 
allocate channel d1 type disk; 
allocate channel d2 type disk; 
setlimit channel d1 kbytes 204800000 maxopenfiles 32 rate 204800000;
setlimit channel d2 kbytes 204800000 maxopenfiles 32 rate 204800000;
backup 
incremental level 0 
skip inaccessible 
tag itpux_level0 
filesperset 8
format '/backup/hfzcdb_full_%s_%p_%t' 
(database); 
release channel d1; 
release channel d2; 
 allocate channel d3 type disk; 
backup format '/backup/hfzcdb_ctl_%s_%p_%t' current controlfile; 
release channel d3; 
 allocate channel d4 type disk; 
copy current controlfile to '/backup/control_hfzcdb.ctl'; 
release channel d4; 
} 
exit 
EOF

传输备份到新主机

oracle@hfzcdb91:/home/oracle\]$nohup ./hfzcdb_rman_full.sh \& --执行sh文件,后台输出 scp /backup/\* 172.30.21.98:/backup/ scp orapwhfzcdb 172.30.21.98:$PWD scp hfzcdb.pfile 172.30.21.98:/backup/ ### 新主机准备目录 su - oracle \[oracle@hfwmsdb98:/backup\]$mkdir -p $ORACLE_HOME/admin/hfzcdb/adump \[oracle@hfwmsdb98:/backup\]$vi hfzcdb1.pfile ```sql *.audit_file_dest='/oracle/app/oracle/admin/hfzcdb/adump' *.audit_trail='NONE' *.compatible='19.0.0' *.control_files='+dgsystem/hfzcdb/control01.ctl','+dgsystem/hfzcdb/control02.ctl' *.db_block_size=16384 *.db_files=16384 *.db_name='hfzcdb' *.db_recovery_file_dest_size=107374182400 *.db_recovery_file_dest='+dgrecovery' *.diagnostic_dest='/oracle/app/oracle' *.dispatchers='(PROTOCOL=TCP) (SERVICE=hfzcdbXDB)' *.enable_ddl_logging=TRUE *.nls_language='AMERICAN' *.nls_territory='AMERICA' *.open_cursors=300 *.pga_aggregate_target=500m *.processes=3000 *.remote_login_passwordfile='EXCLUSIVE' *.sga_target=2340m *.undo_tablespace='UNDOTBS1' ``` #### 创建参数文件 \[oracle@hfwmsdb98:/backup\]$export ORACLE_SID=hfzcdb \[oracle@hfwmsdb98:/backup\]$sqlplus / as sysdba SQL\>create spfile from pfile='/backup/hfzcdb1.pfile'; #### 恢复控制文件 SQL\> show parameter control \[oracle@hfwmsdb98:/backup\]$rman target / RMAN\> restore controlfile from '/backup/hfzcdb_ctl_4_1_1093888570'; RMAN\>alter database mount; RMAN\>report schema; 【查看备份控制文件里面的控制信息】 ### 迁移恢复 ```sql run{ set newname for datafile 1 to '+dgsystem'; set newname for datafile 2 to '+dgsystem'; set newname for datafile 3 to '+dgsystem'; set newname for datafile 4 to '+dgsystem'; set newname for datafile 5 to '+dgsystem'; set newname for datafile 6 to '+dgsystem'; set newname for tempfile 1 to '+dgsystem'; restore database; switch datafile all; -- 【用新的文件名更新到控制文件里面,等价alter database rename file ......】 recover database; } ``` --报错:RMAN-06054:media recovery reauqesting unknown archived log for thread 1 with sequence 18 and starting SCN of 830613. SQL\> select \* from v$log; \[oracle@hfwmsdb98:/oradata/hfzcdb\]$scp redo3.log 172.30.21.98:/backup/ \[oracle@hfwmsdb98:/backup\]$export ORACLE_SID=hfzcdb \[oracle@hfwmsdb98:/backup\]$sqlplus / as sysdba SQL\>recover database until cancel; SQL\>recover database using backup controlfile until cancel; /backup/redo03.log 查看重做日志文件,路径是否正确: SQL\> select \* from v$logfile; SQL\> alter database rename file '/oradata/hfzcdb/redo01.log' to '+dgsystem'; SQL\> alter database rename file '/oradata/hfzcdb/redo02.log' to '+dgsystem'; SQL\> alter database rename file '/oradata/hfzcdb/redo03.log' to '+dgsystem'; SQL\> alter database open resetlogs; 数据库正常启动 ### 启动数据库 #### 调整日志路径 SQL\> select \* from v$logfile; 【启动数据库,发现自动放在dgrecover目录,调整到dgsystem】 SQL\> select \* from v$log; SQL\> alter database drop logfile group 2; SQL\> alter database add logfile group 2 ('+dgsystem') size 100M; SQL\> alter database drop logfile group 3; SQL\> alter database add logfile group 3 ('+dgsystem') size 100M; SQL\> alter system switch logfile; SQL\> alter system checkpoint; SQL\> alter database drop logfile group 1; SQL\> alter database add logfile group 1 ('+dgsystem') size 100M; SQL\> select \* from v$logfile; ```sql GROUP# STATUS TYPE MEMBER IS_REC CON_ID -------------------------------------------------- ------ ---------- 1 ONLINE +DGSYSTEM/HFZCDB/ONLINELOG/group_1.278.1133335247 NO 0 3 ONLINE +DGSYSTEM/HFZCDB/ONLINELOG/group_3.277.1133335113 NO 0 2 ONLINE +DGSYSTEM/HFZCDB/ONLINELOG/group_2.276.1133335063 NO 0 ``` #### 查看数据文件路径 SQL\> select file_name from dba_data_files; #### 查看控制文件路径 SQL\> select \* from v$controlfile; #### 查看闪回目录路径 SQL\> show parameter create; SQL\> show parameter recover; #### 调整pfile文件路径 SQL\> show parameter spfile; SQL\> create pfile from spfile; SQL\> create spfile ='+dgsystem' from pfile='inithfzcdb.ora'; SQL\> shutdown immediate \[oracle@hfwmsdb98:/oracle/app/oracle/product/19c/db_1/dbs\]$rm inithfzcdb.ora SQL\> startup nomount SQL\> show parameter spfile; 【读不到asm参数】 ASMCMD\> cd PARAMETERFILE/ ASMCMD\> ls spfile.275.1133299307 \[oracle@hfwmsdb98:/oracle/app/oracle/product/19c/db_1/dbs\]$vi inithfzcdb.ora \[oracle@hfwmsdb98:/oracle/app/oracle/product/19c/db_1/dbs\]$cat inithfzcdb.ora ```sql SPFILE='+DGSYSTEM/HFZCDB/PARAMETERFILE/spfile.275.1133299307' ``` SQL\> shutdown immediate 【spfile 如果是单机的话 放在本地也是可以的】 SQL\> startup SQL\> show parameter spfile; #### 查看归档日志路径 SQL\> archive log list #### 调整临时文件路径 SQL\> select file_name from dba_temp_files; SQL\>alter tablespace temp add tempfile '+dgsystem' size 100m; SQL\>alter tablespace temp drop tempfile '/oradata/hfzcdb/temp01.dbf'; SQL\> select file_name from dba_temp_files; SQL\> shutdown immediate SQL\> startup #### 复制tnsnames文件到本库 tnsnames.ora 文件需要拷贝到迁移主机,并测试下外部连接。 \[oracle@hfwmsdb98:/backup\]$ps -ef \|grep smon ```sql oracle 6422 15394 0 07:42 pts/1 00:00:00 grep --color=auto smon grid 8508 1 0 Apr04 ? 00:00:02 asm_smon_+ASM oracle 26264 1 0 Apr04 ? 00:00:02 ora_smon_hfzcdb ``` #### 查看集群参数 \[grid@hfwmsdb98:/home/grid\]$crsctl status res -t hfzcdb.db 在里面crs没有 --相关参数 \[oracle@hfwmsdb98:/home/oracle\]$srvctl add database -db hfzcdb -oraclehome /oracle/app/oracle/product/19c/db_1 \[oracle@hfwmsdb98:/home/oracle\]$srvctl modify database -db hfzcdb -spfile '+DGSYSTEM/HFZCDB/PARAMETERFILE/spfile.275.1133299307' #### 检查: \[oracle@hfwmsdb98:/home/oracle\]$srvctl config database -db hfzcdb \[oracle@hfwmsdb98:/home/oracle\]$srvctl stop database -db hfzcd 【报错没有识别到数据,到数据库里面停止】 \[oracle@hfwmsdb98:/home/oracle\]$srvctl start database -db hfzcd \[root@hfwmsdb98 \~\]# su - grid Last login: Wed Apr 5 07:51:35 CST 2023 on pts/1 \[grid@hfwmsdb98:/home/grid\]$crsctl status res -t ```sql -------------------------------------------------------------------------------- Name Target State Server State details -------------------------------------------------------------------------------- Local Resources -------------------------------------------------------------------------------- ora.DGDATA01.dg ONLINE ONLINE hfwmsdb98 STABLE ora.DGDATA02.dg ONLINE ONLINE hfwmsdb98 STABLE ora.DGGRID.dg ONLINE ONLINE hfwmsdb98 STABLE ora.DGRECOVERY.dg ONLINE ONLINE hfwmsdb98 STABLE ora.DGSYSTEM.dg ONLINE ONLINE hfwmsdb98 STABLE ora.LISTENER.lsnr ONLINE ONLINE hfwmsdb98 STABLE ora.asm ONLINE ONLINE hfwmsdb98 Started,STABLE ora.ons OFFLINE OFFLINE hfwmsdb98 STABLE -------------------------------------------------------------------------------- Cluster Resources -------------------------------------------------------------------------------- ora.cssd 1 ONLINE ONLINE hfwmsdb98 STABLE ora.diskmon 1 OFFLINE OFFLINE STABLE ora.evmd 1 ONLINE ONLINE hfwmsdb98 STABLE ora.hfwmsdb.db 1 OFFLINE OFFLINE STABLE ora.hfzcdb.db 1 ONLINE ONLINE hfwmsdb98 Open,HOME=/oracle/ap p/oracle/product/19c /db_1,STABLE -------------------------------------------------------------------------------- ``` ### 外部连接测试 通过外部连接进行数据库测试。

相关推荐
Мартин.2 分钟前
[CISSP] [5] 保护资产安全
数据库·安全·oracle
熠速3 分钟前
ITTIA DB Platform——实时嵌入式数据管理软件产品家族
数据库·嵌入式实时数据库
热爱编程的小曾35 分钟前
sqli-labs靶场 less 8
前端·数据库·less
THRUSTER1111144 分钟前
MySQL-- 函数(单行函数):数值函数, 字符串函数
数据库·mysql·函数·navicat·单行函数
橙序研工坊1 小时前
MySQL的进阶语法7(索引-B+Tree 、Hash、聚集索引 、二级索引(回表查询)、索引的使用及设计原则
数据库·sql·mysql
Bruce-li__1 小时前
深入理解Python asyncio:从入门到实战,掌握异步编程精髓
网络·数据库·python
小光学长1 小时前
基于vue框架的智能服务旅游管理系统54kd3(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面。
数据库
Bonnie_12151 小时前
07-MySQL-事务的隔离级别以及底层原理
数据库·mysql
ETLCloud数据集成社区2 小时前
ETLCloud是如何通过Oracle实现CDC的?
数据库·oracle·etl·实时数据同步
KATA~2 小时前
解决MyBatis-Plus枚举映射错误:No enum constant问题
java·数据库·mybatis