数据库

oracle管理(十二)db恢复

2017-11-23  本文已影响1人  王滕辉

备份文件路径
/home/bak/BACKUPSET
挂载硬盘
cp文件

开始恢复数据

准备工作
su ora112
cd $ORACLE_HOME/dbs

image.png

echo $ORACLE_BASE
echo $ORACLE_HOME
echo $ORACLE_SID
echo $NLS_LANG


image.png

shutdown immediate

无条件关闭
 shutdown abort
执行完成后关闭
shutdown immediate
image.png

删除文件
rm initorcl.ora initorcl.ora.bak
ls
rm spfileorcl.ora spfileorcl.ora.bak
ls

建议使用 mv 重命名 rm 删除没法 找到了
cd $ORACLE_HOME/dbs
mv initorcl.ora initorcl.ora.bak
mv spfileorcl.ora spfileorcl.ora.bak

image.png

开始恢复
vim $ORACLE_HOME/dbs/initorcl15.ora

compatible='11.2.0.4.0'
db_name=orcl15
db_recovery_file_dest=/home/bak
db_recovery_file_dest_size=10000000g
memory_target=10g


image.png image.png

vim /home/ora112/.bash_profile


image.png

使生效
. /home/ora112/.bash_profile


image.png
sqlplus
startup nomount
image.png

修改组
chown ora112:oinstall -R /home/bak


image.png
查看 15 的导出日志 vim log_level0_170105.log
image.png
cd $ORACLE_HOME/bin
rman target /
image.png
rman

restore spfile to pfile "/app/oracle/product/11.2.0.1/dbs/initorcl15.ora" from "/home/bak/ORCL15/autobackup/2017_01_05/o1_mf_s_932434581_d6tdnp6z_.bkp";

image.png

su ora112
vim /app/oracle/product/11.2.0.1/dbs/initorcl15.ora
删掉之前添加的


image.png

sqlplus
create spfile from pfile;
shutdown abort
startup nomount


image.png

ora112
mkdir -p /app/oracle/oradata/orcl15
chown -R ora112:oinstall /app/oracle/oradata/orcl15


image.png

mkdir -p /app/oracle/admin/orcl15/adump
chown -R ora112:oinstall /app/oracle/admin/orcl15/adump

sqlplus
startup nomount;


image.png

rman
exit
rman target /
restore controlfile from "/home/bak/ORCL15/autobackup/2017_01_05/o1_mf_s_932434581_d6tdnp6z_.bkp";


image.png

sqlplus
alter database mount;


image.png

恢复文件位置验证
set linesize 100
set pagesize 9999
select FILE#,name from v$datafile;

image.png

set linesize 100
set pagesize 9999
select * from v$logfile;

image.png

rman
catalog start with '/home/bak';


image.png

监测
crosscheck backup;


image.png

sqlplus
--估算文件恢复之后占用的大小:
select sum(blocks)*8/1024/1024 from v$backup_datafile;


image.png

set linesize 500
set pagesize 9999
col a for a400
select replace('set newname for datafile '||FILE#||' to '''||name||''';','+DATA','/home/oradata') a from v$datafile;

image.png

vim test.rman
run {
set newname for datafile 1 to '/app/oracle/oradata/orcl15/system01.dbf';
set newname for datafile 2 to '/app/oracle/oradata/orcl15/sysaux01.dbf';
set newname for datafile 3 to '/app/oracle/oradata/orcl15/undotbs01.dbf';
set newname for datafile 4 to '/app/oracle/oradata/orcl15/users01.dbf';
set newname for datafile 5 to '/app/oracle/oradata/orcl15/zhcx_data001.dbf';
set newname for datafile 6 to '/app/oracle/oradata/orcl15/zhcx_index001.dbf';
restore database;
switch datafile all;
}


image.png

rman target /
@/test.rman


image.png

recover database;


image.png

alter database open resetlogs;


image.png
上一篇下一篇

猜你喜欢

热点阅读