linux下定时使用rman总结
来源:互联网 发布:怎么得到知乎live礼券 编辑:程序博客网 时间:2024/05/16 11:18
1.oracle备份和恢复体系
冷备份
热备份
2.rman备份
oracle结构体系
nocatalog 模式
catalog模式
create tablespace tbs_rman datafile '/u02/oradata/digoal/tbs_rman01.dbf' size 300m;
create user rmanuser identified by rman default tablespace tbs_rman temporary
tablespace temp;
grant recovery_catalog_owner to rmanuser;
conn rmanuser/rman
select * from session_privs; 查看权限。
conn / as sysdba
alter user rmanuser quota unlimited on tbs_rman;
连接rman
rman catalog rmanuser/rman
创建恢复目录
create catalog tablespace tbs_rman;
注册,同步数据库,控制文件
register database;
report schema;
全库备份
run{
allocate channel d1 device type disk;
backup as compressed backupset
format='/home/oracle/rmanbak/full_%d_%U'
tag='fullbak'
channel=d1
database plus archivelog delete input;
}
crosscheck copy
备模式
增量备份模式
0级备份
run{
allocate channel d1 device type disk;
backup as compressed backupset
incremental level=0
format ='/home/oracle/rmanbak/inc0_%d_%U'
tag='inc0'
channel=d1
database plus archivelog delete input;
release channel d1;
}
1级备份
run{
allocate channel d1 device type disk;
backup as compressed backupset
incremental level=1
format='/home/oracle/rmanbak/inc1_%d_%U'
tag='inc1'
channel=d1
database;
release channel d1;
}
run{
allocate channel d1 device type disk;
backup as compressed backupset
format='/home/oracle/rmanbak/arch_%d_%U'
tag='arch'
channel=d1
archivelog all;
release channel d1;
}
}
linux下的定时备份策略
实施步骤
mkdir
编写通用脚本
connect.rcv
connect catalog rmanuser/rman@ora10g
connect target sys/admin@ora10g
Global_del global_arch global_ctl
replace global script global_del{
allocate channel d1 device type disk;
delete obsolete recovery window of 15 days;
release channel d1;
}
replace global script global_arch comment "backup current archive log as well delete input "{
allocate channel d1 device type disk;
sql "alter database archive log current";
set limit channel d1 readrate=10240;
set limit channel d1 kbytes=4096000;
format '/home/oracle/rmanbak/arch_%d_%U'
tag='bkarch'
channel=d1
archivelog all delete input;
release channel d1;
}
replace global script global_bkctl{
allocate channel d1 device type disk;
backup as compressed backupset
format '/home/oracle/rmanbak/backupctl.ctl'
tag='bkctl'
channel=d1
current contorlfile reuse;
release channel d1;
}
replace global script golbal_inc0 comment "backup database as incremental level 0"{
execute global script global_del;
allocate channel d1 device type disk;
set limit channel d1 readrate=10240;
set limit channel d1 kbytes=4096000;
backup as compressed backupset
incremental level=0
format '/home/oracle/rmanbak/inc0_%d_%U'
tag='inc0'
channel=d1
database;
release channel d1;
execute global script global_arch;
execute global script global_bkctl;
}
replace global script golbal_inc1 comment "backup database as incremental level 1"{
execute global script global_del;
allocate channel d1 device type disk;
set limit channel d1 readrate=10240;
set limit channel d1 kbytes=4096000;
backup as compressed backupset
incremental level=1
format '/home/oracle/rmanbak/inc0_%d_%U'
tag='inc1'
channel=d1
database;
release channel d1;
execute global script global_arch;
execute global script global_bkctl;
}
replace global script golbal_inc2 comment "backup database as incremental level 2"{
execute global script global_del;
allocate channel d1 device type disk;
set limit channel d1 readrate=10240;
set limit channel d1 kbytes=4096000;
backup as compressed backupset
incremental level=2
format '/home/oracle/rmanbak/inc0_%d_%U'
tag='inc2'
channel=d1
database;
release channel d1;
execute global script global_arch;
execute global script global_bkctl;
}
vi inrc0.rvc
@@/home/oracle/rmabak/script/connect.rcv
run{
execute global script global_inc0;
}
exit
vi inrc1.rvc
@@/home/oracle/rmabak/script/connect.rcv
run{
execute global script global_inc1;
}
exit
vi inrc2.rvc
@@/home/oracle/rmabak/script/connect.rcv
run{
execute global script global_inc2;
}
exit
vi inc0.sh
nohup $ORACLE_HOME/bin/rman cmdfile=/home/oracle/rmanbak/script/inc0.rcv log=/home/oracle/rmanbak/script/inc0.log append &
vi inc1.sh
nohup $ORACLE_HOME/bin/rman cmdfile=/home/oracle/rmanbak/script/inc1.rcv log=/home/oracle/rmanbak/script/inc1.log append &
vi inc2.sh
nohup $ORACLE_HOME/bin/rman cmdfile=/home/oracle/rmanbak/script/inc2.rcv log=/home/oracle/rmanbak/script/inc2.log append &
linux下的定时脚本
crontab -e
#min hour date mon day command
0 1 * * 0 /home/oracle/rmanbak/script/inc0.sh
0 1 * * 1 /home/oracle/rmanbak/script/inc2.sh
0 1 * * 2 /home/oracle/rmanbak/script/inc2.sh
0 1 * * 3 /home/oracle/rmanbak/script/inc2.sh
0 1 * * 4 /home/oracle/rmanbak/script/inc1.sh
0 1 * * 5 /home/oracle/rmanbak/script/inc2.sh
0 1 * * 6 /home/oracle/rmanbak/script/inc2.sh
cmdfile&rman catalog script
shell script
crontab -e
chown u+x *.sh
3.rman恢复
物理灾难
datafile controlfile redo log
non-system tbs
alter datafile offline
或者alter tablespace offline
run{
allocate channel d1 device type disk;
sql "alter database datafile 5 offline";
restore datafile 5;
recover datafile 5;
sql "alter database datafile 5 online";
}
unbo表空间还原
alter database checkpoint;
run{
allocate channel d1 device type disk;
restore datafile 2;
recover datafile 2;
}
recover datafile 2;
select status from v$datafile;
系统表空间还原
将数据库至于mount状态
run{
allocate channel d1 device type disk;
restore datafile 1;
recover datafile 1;
sql "alter database open";
}
控制文件还原
startup nomount force
restore controlfile from 备份的控制文件名;
alter database open resetlogs;
online redolog还原
run{
allocate channel d1 device type disk;
resotre contorlfile;
recover database;
}
archivelog还原
restore archivelog time between "to_date('2009-06-24 08:00:00','yyyy-mm-dd hh24:mi:ss')" and "to_date('2009-06-24 13:00','yyyy-mm-dd hh24:mi:ss')" preview;
用trace文件生成控制文件脚本
alter database backup controlfile to trace;
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "ORA10G" NORESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/u02/oradata/ora10g/redo01.log' SIZE 50M,
GROUP 2 '/u02/oradata/ora10g/redo02.log' SIZE 50M,
GROUP 3 '/u02/oradata/ora10g/redo03.log' SIZE 50M
-- STANDBY LOGFILE
DATAFILE
'/u02/oradata/ora10g/system01.dbf',
'/u02/oradata/ora10g/undotbs01.dbf',
'/u02/oradata/ora10g/sysaux01.dbf',
'/u02/oradata/ora10g/users01.dbf',
'/u02/oradata/digoal/tbs_rman01.dbf',
'/u02/oradata/ora10g/DATA01.dbf'
CHARACTER SET ZHS16GBK
;
//将catalog的注册信息转换成nocatalog模式
MAN> run
2> {
3> catalog start with '/home/oracle/rmanbak';
4> }
- linux下定时使用rman总结
- linux下dataguard使用rman备份
- linux下cron定时任务的总结
- windows下oracle采用rman定时备份
- Linux Crontab 定时任务使用总结
- LINUX下使用crontab进行RMAN备份实验
- Linux下使用RMAN迁移文件系统数据库到ASM
- Linux平台下使用rman进行oracle数据库迁移
- Linux下ORACLE使用RMAN备份指定数据库
- linux下设置定时任务-cron使用
- linux下使用contab定时备份数据库
- linux下定时任务crontab的使用
- Linux下使用crontab定时备份日志
- linux下使用crontab新建定时任务
- LINUX 下rman 自动备份
- linux下rman备份笔记
- linux下定时任务
- linux下定时任务
- 二、CXF 入门示例
- mvc 第三步,全局观
- KMP 算法 自己的一些理解
- Spring Controller应用举例
- 关于ORACLE COMMIT操作的详解—转
- linux下定时使用rman总结
- asp.net页面事件执行顺序
- 性能测试-理发店模型
- sybase的trunc log on chkpt 选项
- Android下获取开机时间
- WPF Summary:Window外观
- STM8固件库+IAR 之--环境
- 高性能NOSQL数据库redis结合谷歌开源tcmalloc库的安装笔记
- 适配器模式