某保 Oracle 数据库备份恢复测试

本文涉及的产品
日志服务 SLS,月写入数据量 50GB 1个月
简介: 一、备份原库,将备份的文件拷贝到单实例的相同目录backup as compressed backupset database plus archivelog format '/u01/app/oracle/backup_db/full_%d_%s_%p_%u.
一、备份原库,将备份的文件拷贝到单实例的相同目录
backup as compressed backupset database plus archivelog format '/u01/app/oracle/backup_db/full_%d_%s_%p_%u.%T';
run{
    allocate channel d1 type disk maxpiecesize=20G;
allocate channel d2 type disk maxpiecesize=20G;
allocate channel d3 type disk maxpiecesize=20G;
allocate channel d4 type disk maxpiecesize=20G;
backup database format '/u01/app/dump/qmcb_bak/db_%U_%T' include current controlfile;
sql 'alter system archive log current';
backup archivelog like '/u01/app/archive_log/%' format  '/u01/app/dump/qmcb_bak/arch_%U_%T';
backup spfile format '/u01/app/dump/qmcb_bak/spfile_%U_%T';
release channel d1;
release channel d2;
release channel d3;
release channel d4;
}
select sid,spid,client_info from v$process p,v$session s where p.addr=s.paddr and client_info like '%rman%';
-- delete input 从 log_archive_Dest_n 位置删除日志
-- delete input 备份后只删除用于备份的归档日志文件的那个复制的输入对象
scp * oracle@192.168.93.222:/u01/app/oracle/backup_db/

二、修改单实例的参数文件
create pfile='/u01/app/oracle/backup_db/initorcl.ora' from spfile;
vi initorcl.ora
*.audit_file_dest='/u01/app/oracle/admin/orcl/adump'
*.audit_trail='NONE'
*.compatible='11.2.0.4.0'
*.control_files='/u01/app/oracle/oradata/orcl/control01.dbf','/u01/app/oracle/oradata/orcl/control02.dbf'
*.db_block_size=8192
*.db_domain=''
*.db_name='orcl'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
*.job_queue_processes=1000
*.log_archive_dest_1='location=/u01/app/archive_log'
*.log_archive_format='%t_%s_%r.dbf'
*.max_dump_file_size='200m'
*.open_cursors=300
*.pga_aggregate_target=2147483648
*.processes=1000
*.remote_login_passwordfile='EXCLUSIVE'
*.resource_limit=TRUE
*.sessions=1250
*.sga_target=3221225472
*.timed_statistics=TRUE
*.undo_tablespace='UNDOTBS2'
scp initorcl.ora oracle@192.168.100.199:/u01/app/oracle/product/11.2.0/dbhome_1/dbs/ 
用传过来的pfile生成spfile文件
SQL> create spfile from pfile='/u01/app/oracle/backup_db/initorcl1.ora';
SQL> startup nomount;

三、恢复控制文件
rman target /
restore controlfile from '/u01/app/dump/qmcb_bak/control_c-1365404862-20191226-00.BKU';
alter database mount;
检查并标记控制文件中存在但是实际已经不存在的备份文件。
RMAN>crosscheck backup;
清理控制文件中存在但是实际已经不存在的备份文件。
RMAN>delete noprompt expired backup;
将备份注册到rman,如果备份及路径一致则不需要注册。
RMAN> catalog backuppiece '/u01/app/dump/qmcb_bak/ORCL_125_1_3tt920g8.20180727';
RMAN> catalog backuppiece '/u01/app/dump/qmcb_bak/ORCL_127_1_3vt920i4.20180727';
RMAN> catalog backuppiece '/u01/app/dump/qmcb_bak/db_ORCL_129_1_41t9224q.20180727';
RMAN> catalog backuppiece '/u01/app/dump/qmcb_bak/44t923ek_1_1';
RMAN> catalog backuppiece '/u01/app/dump/qmcb_bak/c-1510034848-20180727-03';

catalog backuppiece '/u01/app/dump/qmcb_bak/arch_q4ukcv45_1_1_20191226';

四、还原数据文件,需要指定scn号,可以list backup查看,需要写到你能恢复到的那个时间点,SCN 为最新的SCN号。
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/u01/ssd/oradata/orcl/system01.dbf
/u01/ssd/oradata/orcl/sysaux01.dbf
/u01/ssd/oradata/orcl/zabbix01.dbf
/u01/ssd/oradata/orcl/users01.dbf
/u01/ssd/oradata/orcl/data01.dbf
/u01/ssd/oradata/orcl/data02.dbf
/u01/photo/oradata/UNDOTBS2.dbf
/u01/ssd/oradata/orcl/RKXX_PHOTO01.dbf
/u01/ssd/oradata/orcl/users11.dbf
/u01/ssd/oradata/orcl/users12.dbf
/u01/ssd/oradata/orcl/users02.dbf
/u01/ssd/oradata/orcl/users03.dbf
/u01/ssd/oradata/orcl/users13.dbf
/u01/ssd/oradata/orcl/users14.dbf
/u01/ssd/oradata/orcl/users15.dbf
/u01/ssd/oradata/orcl/users04.dbf
/u01/ssd/oradata/orcl/users05.dbf
/u01/ssd/oradata/orcl/users16.dbf
/u01/ssd/oradata/orcl/users17.dbf
/u01/ssd/oradata/orcl/users18.dbf
/u01/photo/oradata/data03.dbf
/u01/photo/oradata/data04.dbf
/u01/photo/oradata/data05.dbf
/u01/photo/oradata/data06.dbf
/u01/photo/oradata/data07.dbf
/u01/photo/oradata/data08.dbf
/u01/ssd/oradata/orcl/users06.dbf
/u01/ssd/oradata/orcl/users07dbf
/u01/ssd/oradata/orcl/users08dbf
/u01/ssd/oradata/orcl/users09.dbf
/u01/ssd/oradata/orcl/users10.dbf

RMAN> list backup of archivelog all;
根据备份信息,恢复数据文件及数据库并同步控制文件信息
RUN { 
    allocate channel d1 type disk;
allocate channel d2 type disk;
allocate channel d3 type disk;
allocate channel d4 type disk;
set until scn 16708288579293;
SET NEWNAME FOR DATAFILE '/u01/ssd/oradata/orcl/system01.dbf' to '/u01/app/oracle/oradata/orcl/system01.dbf';
SET NEWNAME FOR DATAFILE '/u01/ssd/oradata/orcl/sysaux01.dbf' to '/u01/app/oracle/oradata/orcl/sysaux01.dbf';
SET NEWNAME FOR DATAFILE '/u01/ssd/oradata/orcl/zabbix01.dbf' to '/u01/app/oracle/oradata/orcl/zabbix01.dbf';
SET NEWNAME FOR DATAFILE '/u01/ssd/oradata/orcl/users01.dbf' to '/u01/app/oracle/oradata/orcl/users01.dbf';
SET NEWNAME FOR DATAFILE '/u01/ssd/oradata/orcl/data01.dbf' to '/u01/app/oracle/oradata/orcl/data01.dbf';
SET NEWNAME FOR DATAFILE '/u01/ssd/oradata/orcl/data02.dbf' to '/u01/app/oracle/oradata/orcl/data02.dbf';
SET NEWNAME FOR DATAFILE '/u01/photo/oradata/UNDOTBS2.dbf' to '/u01/app/oracle/oradata/orcl/UNDOTBS2.dbf';
SET NEWNAME FOR DATAFILE '/u01/ssd/oradata/orcl/RKXX_PHOTO01.dbf' to '/u01/app/oracle/oradata/orcl/RKXX_PHOTO01.dbf';
SET NEWNAME FOR DATAFILE '/u01/ssd/oradata/orcl/users11.dbf' to '/u01/app/oracle/oradata/orcl/users11.dbf';
SET NEWNAME FOR DATAFILE '/u01/ssd/oradata/orcl/users12.dbf' to '/u01/app/oracle/oradata/orcl/users12.dbf';
SET NEWNAME FOR DATAFILE '/u01/ssd/oradata/orcl/users02.dbf' to '/u01/app/oracle/oradata/orcl/users02.dbf';
SET NEWNAME FOR DATAFILE '/u01/ssd/oradata/orcl/users03.dbf' to '/u01/app/oracle/oradata/orcl/users03.dbf';
SET NEWNAME FOR DATAFILE '/u01/ssd/oradata/orcl/users13.dbf' to '/u01/app/oracle/oradata/orcl/users13.dbf';
SET NEWNAME FOR DATAFILE '/u01/ssd/oradata/orcl/users14.dbf' to '/u01/app/oracle/oradata/orcl/users14.dbf';
SET NEWNAME FOR DATAFILE '/u01/ssd/oradata/orcl/users15.dbf' to '/u01/app/oracle/oradata/orcl/users15.dbf';
SET NEWNAME FOR DATAFILE '/u01/ssd/oradata/orcl/users04.dbf' to '/u01/app/oracle/oradata/orcl/users04.dbf';
SET NEWNAME FOR DATAFILE '/u01/ssd/oradata/orcl/users05.dbf' to '/u01/app/oracle/oradata/orcl/users05.dbf';
SET NEWNAME FOR DATAFILE '/u01/ssd/oradata/orcl/users16.dbf' to '/u01/app/oracle/oradata/orcl/users16.dbf';
SET NEWNAME FOR DATAFILE '/u01/ssd/oradata/orcl/users17.dbf' to '/u01/app/oracle/oradata/orcl/users17.dbf';
SET NEWNAME FOR DATAFILE '/u01/ssd/oradata/orcl/users18.dbf' to '/u01/app/oracle/oradata/orcl/users18.dbf';
SET NEWNAME FOR DATAFILE '/u01/photo/oradata/data03.dbf' to '/u01/app/oracle/oradata/orcl/data03.dbf';
SET NEWNAME FOR DATAFILE '/u01/photo/oradata/data04.dbf' to '/u01/app/oracle/oradata/orcl/data04.dbf';
SET NEWNAME FOR DATAFILE '/u01/photo/oradata/data05.dbf' to '/u01/app/oracle/oradata/orcl/data05.dbf';
SET NEWNAME FOR DATAFILE '/u01/photo/oradata/data06.dbf' to '/u01/app/oracle/oradata/orcl/data06.dbf';
SET NEWNAME FOR DATAFILE '/u01/photo/oradata/data07.dbf' to '/u01/app/oracle/oradata/orcl/data07.dbf';
SET NEWNAME FOR DATAFILE '/u01/photo/oradata/data08.dbf' to '/u01/app/oracle/oradata/orcl/data08.dbf';
SET NEWNAME FOR DATAFILE '/u01/ssd/oradata/orcl/users06.dbf' to '/u01/app/oracle/oradata/orcl/users06.dbf';
SET NEWNAME FOR DATAFILE '/u01/ssd/oradata/orcl/users07dbf' to '/u01/app/oracle/oradata/orcl/users07.dbf';
SET NEWNAME FOR DATAFILE '/u01/ssd/oradata/orcl/users08dbf' to '/u01/app/oracle/oradata/orcl/users08.dbf';
SET NEWNAME FOR DATAFILE '/u01/ssd/oradata/orcl/users09.dbf' to '/u01/app/oracle/oradata/orcl/users09.dbf';
SET NEWNAME FOR DATAFILE '/u01/ssd/oradata/orcl/users10.dbf' to '/u01/app/oracle/oradata/orcl/users10.dbf'; 
RESTORE DATABASE; 
SWITCH DATAFILE ALL;
recover database;
release channel d1;
release channel d2;
release channel d3;
release channel d4;
}
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 110875 and starting SCN of 16708288579684
recover database until scn 16708288579684;

五、查看日志文件修改日志文件的路径
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/u01/ssd/oradata/orcl/redo03.log
/u01/ssd/oradata/orcl/redo02.log
/u01/ssd/oradata/orcl/redo01.log

alter database rename file '/u01/ssd/oradata/orcl/redo03.log' to '/u01/app/oracle/oradata/orcl/redo03.log';
alter database rename file '/u01/ssd/oradata/orcl/redo02.log' to '/u01/app/oracle/oradata/orcl/redo02.log';
alter database rename file '/u01/ssd/oradata/orcl/redo01.log' to '/u01/app/oracle/oradata/orcl/redo01.log';

六、打开数据库,完成续操作
alter database open resetlogs;
查看redo log 信息,并删除无效日志组
select THREAD#, STATUS, ENABLED from v$thread;
   THREAD# STATUS             ENABLED
---------- ------------------ ------------------------
         1 OPEN               PUBLIC
         2 CLOSED             PUBLIC
select group# from v$log where THREAD#=2;    
    GROUP#
----------
         4
         5
         6
SQL> alter database disable thread 2;
SQL> alter database drop logfile group 4;
SQL> alter database drop logfile group 5;
SQL> alter database drop logfile group 6;

SQL> select THREAD#, STATUS, ENABLED from v$thread;
   THREAD# STATUS ENABLED
---------- ------ --------
         1 OPEN   PUBLIC
 
查看undo表空间,并删除节点2(在此不使用)的undo表空间
SQL> show parameter undo;
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
undo_management                      string      AUTO
undo_retention                       integer     900
undo_tablespace                      string      UNDOTBS1

SQL> select tablespace_name from dba_tablespaces where contents='UNDO';
TABLESPACE_NAME
------------------------------
UNDOTBS1
UNDOTBS2
SQL> drop tablespace UNDOTBS2 including contents and datafiles;

SQL> select name from v$tempfile;
NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/ORCL/datafile/o1_mf_temp_cr602c5z_.tmp

SQL> select tablespace_name from dba_tablespaces where contents='TEMPORARY';
TABLESPACE_NAME
------------------------------
TEMP
SQL> create temporary tablespace TEMP1 tempfile '/u01/app/oracle/oradata/orcl/temp01.dbf' size 10G autoextend on maxsize unlimited;
SQL> alter database default temporary tablespace TEMP1;
SQL> drop tablespace TEMP including contents and datafiles;

查看监听状态并配置,编辑tnsname.ora文件。

创建密码文件,注意密码文件的位置
$ orapwd file=orapworcl password=oracle123456 entries=5 force=y

目录
相关文章
|
14天前
|
存储 Oracle 关系型数据库
数据库数据恢复—ORACLE常见故障的数据恢复方案
Oracle数据库常见故障表现: 1、ORACLE数据库无法启动或无法正常工作。 2、ORACLE ASM存储破坏。 3、ORACLE数据文件丢失。 4、ORACLE数据文件部分损坏。 5、ORACLE DUMP文件损坏。
57 11
|
27天前
|
Oracle 关系型数据库 数据库
Oracle数据恢复—Oracle数据库文件有坏快损坏的数据恢复案例
一台Oracle数据库打开报错,报错信息: “system01.dbf需要更多的恢复来保持一致性,数据库无法打开”。管理员联系我们数据恢复中心寻求帮助,并提供了Oracle_Home目录的所有文件。用户方要求恢复zxfg用户下的数据。 由于数据库没有备份,无法通过备份去恢复数据库。
|
1月前
|
存储 Oracle 关系型数据库
oracle数据恢复—Oracle数据库文件大小变为0kb的数据恢复案例
存储掉盘超过上限,lun无法识别。管理员重组存储的位图信息并导出lun,发现linux操作系统上部署的oracle数据库中有上百个数据文件的大小变为0kb。数据库的大小缩水了80%以上。 取出&并分析oracle数据库的控制文件。重组存储位图信息,重新导出控制文件中记录的数据文件,发现这些文件的大小依然为0kb。
|
20天前
|
存储 Oracle 关系型数据库
服务器数据恢复—华为S5300存储Oracle数据库恢复案例
服务器存储数据恢复环境: 华为S5300存储中有12块FC硬盘,其中11块硬盘作为数据盘组建了一组RAID5阵列,剩下的1块硬盘作为热备盘使用。基于RAID的LUN分配给linux操作系统使用,存放的数据主要是Oracle数据库。 服务器存储故障: RAID5阵列中1块硬盘出现故障离线,热备盘自动激活开始同步数据,在同步数据的过程中又一块硬盘离线,RAID5阵列瘫痪,上层LUN无法使用。
|
1月前
|
SQL Oracle 关系型数据库
Oracle数据库优化方法
【10月更文挑战第25天】Oracle数据库优化方法
50 7
|
1月前
|
Oracle 关系型数据库 数据库
oracle数据库技巧
【10月更文挑战第25天】oracle数据库技巧
31 6
|
1月前
|
存储 Oracle 关系型数据库
Oracle数据库优化策略
【10月更文挑战第25天】Oracle数据库优化策略
29 5
|
SQL Oracle 关系型数据库
Oracle 10g提权测试
一直想摸索一下orcl提权的方式,今天测试了一下10g,可以成功提权。   C:\wmpub>sqlplus scott/tiger@orcl SQL*Plus: Release 10.2.0.1.
1224 0
|
2月前
|
存储 Oracle 关系型数据库
Oracle数据库的应用场景有哪些?
【10月更文挑战第15天】Oracle数据库的应用场景有哪些?
194 64
|
2月前
|
存储 Oracle 关系型数据库
数据库数据恢复—Oracle ASM磁盘组故障数据恢复案例
Oracle数据库数据恢复环境&故障: Oracle ASM磁盘组由4块磁盘组成。Oracle ASM磁盘组掉线 ,ASM实例不能mount。 Oracle数据库故障分析&恢复方案: 数据库数据恢复工程师对组成ASM磁盘组的磁盘进行分析。对ASM元数据进行分析发现ASM存储元数据损坏,导致磁盘组无法挂载。

热门文章

最新文章

推荐镜像

更多