oracle使用者管理的備份和恢復

2021-06-26 13:45:16 字數 2317 閱讀 5040

做使用者備份之前,檢查確定資料檔案

1select name from v$datafile; 2

select t.name "tablespace", f.name "datafile"

from v$tablespace t, v$datafile f

where t.ts# = f.ts#

order by t.name;

3select member from v$logfile;

4select name from v$controlfile;

select t.name as "tb_name", d.file# as "df#", d.name as "df_name", b.status

from v$datafile d, v$tablespace t, v$backup b

where d.ts#=t.ts#

and b.file#=d.file#

and b.status='active';

status要是not active那麼表明了檔案沒有在備份狀態,也就是沒有執行alter tablespace ... begin backup 或 alter database begin backup語句。
備份離線的表空間和資料檔案
1檢視表空間資訊
select tablespace_name, file_name

from sys.dba_data_files

where tablespace_name = 'users';

2離線表空間
alter tablespace users offline normal;

3使用作業系統命令備份資料檔案
alter tablespace users online;
5歸檔未歸檔的日誌檔案
alter system archive log current;
需要使用alter tablespace ..begin backup命令將表空間置於備份模式,在備份模式,資料庫拷貝所有改變資料塊到redo流中,在使用alter tablespace ...end backup或alter database end backup後,資料庫將資料檔案頭標記成當前資料庫的檢查點。
1檢查表空間資訊
select tablespace_name, file_name

from sys.dba_data_files

where tablespace_name = 'users';

2alter tablespace users begin backup;3拷貝資料檔案
4alter tablespace users end backup;5alter system archive log current;
要是想對資料庫所有的表空間進行備份,可以使用alter database begin backup;
在begin backup後資料庫沒有end backup的時候shutdown abort了,需要處理如下:
1mount資料庫
2alter database end backup;
3 alter database open;
使用者備份的控制檔案
1備份控制檔案到二進位制檔案中,二進位制檔案中包含比trace檔案更多的資訊,如歸檔日誌備份歷史,offline的表空間,備份集和映象等。
alter database backup controlfile to '...bak' reuse;
2備份控制檔案到trace檔案中
alter database backup controlfile to trace;
可以用來重建控制檔案,為了避免恢復正常offline或唯讀表空間,將他們排出trace檔案中,當再次開啟資料庫的時候,資料字典會標記這些檔案為missing狀態,你可以使用alter database rename file命令來重新命名回原來的名字。
驗證使用者備份
dbv file=tbs_52.f

使用作業系統命令查詢檔案

find $oracle_home -name "*.ora" -print

Elasticsearch的資料備份和恢復以及遷移

目錄 1.為什麼備份?2.資料備份 3.資料恢復 4.es備份資料遷移目標伺服器 5.指令碼備份恢復 常見的資料庫都會提供備份機制,以解決在資料庫無法使用的情況下通過備份來恢復資料減少損失。elasticsearch 雖然有良好的容災性,但以下原因,其依然需要備份機制 1 資料災備 在整個集群無法正...

Oracle和MySQL資料庫的備份與恢復

oracle 最簡單的備份與恢復的例子 匯出 exp scott tiger orcl file c wolfetest export scott data.dmp 匯入 imp scott tiger orcl file c wolfetest export scott data.dmp 注意 在...

mysql利用mysqldump備份和恢復

mysqldump使用語法 mysqldump u 使用者 h host p 密碼 dbname table 路徑 遠端備份單庫例子 mysqldump uroot pabc123456 h192.168.1.101 zabbix gzip mysql data back zabbix users....