rman备份mysql_rman备份与还原
備份方案與流程
目前有test1 , test2 ,CN_test是用戶建立的表
1.建立一個catalog表空間,和即將要備份和恢復的數據不能為一個表空間
SQL> create tablespace recover1 datafile
'/db/oracle/oradata/recover1' size 1024M;
2.建立一個rman2用戶
授權:
3.登錄創建目錄
備份的時候自動備份控制文件:
Configure controlfile autobackup on;
4.注冊目標數據庫
5.分配通道,設置備份路徑:
打開控制文件自動備份,并儲存到/control目錄下:
rman>configure controlfile
autobackup on;
rman>configure controlfile
autobakcup format for device type disk to '/control/%F';
6.開始備份:backup
database plus archivelog;
增量0級備份:backup
incremental level 0 database;
增量1級差異備份:backup
incremental level 1 database;
增量1級累計備份:backup
incremental level 1 cumulativedatabase;
常見的備份策略(差異備份):
星期
差異增量
累積增量
星期天
0級
0級
星期一
2級
2級
星期二
2級
2級
星期三
1級
1級
星期四
2級
2級
星期五
2級
2級
星期六
2級
2級
星期天
0級
0級
還原步驟
1.因為有可能需要按時間點做還原,所以需要設置oracle用戶的環境變量
NLS_DATE_FORMAT='mm/dd/yyyy
hh24:mi:ss';
export NLS_DATE_FORMAT
2.使用rman登錄
rman target=rman2/rman2@test
3.將數據庫變更為掛載狀態
startup mount;
強制更改:startup force mount;
4.以下為按照時間點不完全恢復
run{
set until time "to_date('2011/06/2814:00:30','yyyy/mm/dd hh24:mi:ss')";
restore
database;
recoverdatabase;
}基于時間點的不完全恢復
5.完成后重新掛載
alter database open
resetlogs;
其他:
1.按時間點還原時候出現:
until time or recovery window is before
resetlogs time錯誤
需要將原型重置到恢復時間節點之前的resetlogs
list incarnation of database "test";
reset database to incarnation數字;
恢復誤刪除數據:
1.做全備份,歸檔當前日志:
2.備份一個pfile:
3.備份當前數據庫
關閉數據庫
SQL> shut immediate
數據庫文件夾改名備份,并創建一個原庫名文件夾
$mkdir test
4.啟動數據庫到nomount
5.恢復controlfile
run
{
allocate
channel t1 type disk;
restore
controlfile from 'c-2053343983-20110630-01';
release
channel t1;
}
6.啟動數據庫mount,恢復歸檔日志:
SQL> startup mount;
RMAN> list backup of archivelog all;
找到最近2兩天的seq,進行恢復
run
{
allocate
channel t1 type disk;
set
archivelog destination to '/db/oracle/flash_recovery_area/TEST/archivelog';
restore archivelog sequence6thread 1;
release
channel t1;
}
7.恢復數據庫
run
{
allocate
channel t1 type disk;
set untilscn916578;
restore
database;
recoverdatabase;
release
channel t1;
}
alter database open
resetlogs;
scn用最后一個日志的next scn
exp按照用戶導出
exp
software/software? rows=y indexes=n
compress=n buffer=65536 feedback=100000 volsize=0 owner=software
file=/oraexp/exp_software_201107.dmp log=/oraexp/exp_software_201107.log
Imp按用戶導入
imp
software/software fromuser=software touser=software rows=y indexes=n commit=y
buffer=65536 feedback=100000 ignore=y volsize=0 file=exp_software_201107.dmp
總結
以上是生活随笔為你收集整理的rman备份mysql_rman备份与还原的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 微信小程序 授权登录功能实现
- 下一篇: 使用RMAN备份与恢复数据库(2)——参