oracle数据库文件从文件系统备份到裸设备
上一篇 / 下一篇 2013-10-07 20:15:02 / 个人分类:数据库
chkconfig --level 235B raw on
设置数据库位归档模式:
Sqlplus sys/sys as sysdba------以sysdba身份登录oracle数据库
archive log list------查看数据库与归档相关的信息。
Shutdown immediate---------关闭数据库
Startup mount----------以加载方式启动数据库。
Alter database archivelog(noarchivelog)------------设置数据库为归档模式(非归档模式)
Alter database open------打开数据库
archive log list -------再验证数据库与归档相关的信息。
做数据库的全备份
设置归档路径:
alter system set log_archive_dest='/home/oracle/archive' scope=spfile;
检查和清空
run {
allocate channel 'dev0' type type disk;
crosscheck archivelog all;
crosscheck backup;
delete archivelog all;
delete backup;
release channel 'dev0';
}
备份:
run{
allocate channel 'dev0' type disk;
allocate channel 'dev1' type disk;
allocate channel 'dev2' type disk;
backup database format '/opt/orainst.bak/C3DB%s:%t:%p.dbf';
backup archivelog all delete input format '/opt/orainst.bak/C3DB%s:%t:%p.arclog';
backup current controlfile format '/opt/orainst.bak/C3DB_confile%s:%t:%p.ctl';
backup spfile format '/opt/orainst.bak/C3DB%s:%t:%p.spfile';
release channel 'dev0';
release channel 'dev1';
release channel 'dev2';
}
如何设置自动备份控制文件:
rman target /
configure controlfile autobackup on;
查看备份集:
list backup of controlfile;
list backup of spfile;
1.将A机pfile复制B机的设备中。
并更改权限。
/oracle/app/product/11g/db/dbs/initvcdb.ora
2.恢复A机祼设备SPFILE到B机中对应的祼设备。restore spfile to '/dev/vgora/lvspfile' from '/oracle/app/product/11g/db/dbs/spfilevcdb.ora'; --nomount
create pfile='/home/oracle/nowpfile.ora' from spfile;
create spfile='/oracle/app/product/11g/db/dbs/spfile_raw' from pfile='/home/oracle/nowpfile.ora'; --数据库unavailable状态
cd /dev/raw && chown oracle:oinstall `ls | grep -v rawctl`
restore spfile to '/dev/raw/raw1' from '/home/oracle/backup/C3DB%s:%t:%p.spfile';
将initvcdb.ora拷贝至相应目录,重启oracle.
3.恢复备份集里的控制文件,
restore controlfile from '/home/oracle/backup/C3DB_confile53:778848833:1.ctl'; --nomount--
restore controlfile to '/dev/raw/raw13' from '/home/oracle/backup/C3DB_confile53:778848833:1.ctl';
restore controlfile to '/dev/raw/raw14' from '/home/oracle/backup/C3DB_confile53:778848833:1.ctl';
restore controlfile to '/dev/raw/raw15' from '/home/oracle/backup/C3DB_confile53:778848833:1.ctl'; -----不要
alter system set control_files='/dev/raw/raw13','/dev/raw/raw14','/dev/raw/raw15' scope=spfile;
restore controlfile from '/home/oracle/backup/C3DB_confile53:778848833:1.ctl';
startup mount
alter database backup controlfile to '/dev/raw/raw13'; -----不要
alter database backup controlfile to '/dev/raw/raw14';
alter database backup controlfile to '/dev/raw/raw15';
alter database backup controlfile to '/oracle/app/oradata/vcdb/vcdb/control01.ctl';
alter database backup controlfile to '/oracle/app/oradata/vcdb/vcdb/control02.ctl';
alter database backup controlfile to '/oracle/app/oradata/vcdb/vcdb/control03.ctl'; -----不要
查找所有的数据文件。
select name from v$datafile;
alter database mount;
run{
allocate channel 'dev0' type disk;
set newname for datafile '/oracle/app/oradata/vcdb/vcdb/system01.dbf' to '/dev/raw/raw2';
set newname for datafile '/oracle/app/oradata/vcdb/vcdb/sysaux01.dbf' to '/dev/raw/raw3';
set newname for datafile '/oracle/app/oradata/vcdb/vcdb/undotbs01.dbf' to '/dev/raw/raw4';
set newname for datafile '/oracle/app/oradata/vcdb/vcdb/users01.dbf' to '/dev/raw/raw6';
set newname for datafile '/home/oracle/c3db/c3modelidx.dbf' to '/dev/raw/raw1501';
set newname for datafile '/home/oracle/c3db/c3smidx.dbf' to '/dev/raw/raw1502';
set newname for datafile '/home/oracle/c3db/c3pmidx.dbf' to '/dev/raw/raw1503';
set newname for datafile '/home/oracle/c3db/c3pmidx.dbf' to '/dev/raw/raw1504';
set newname for datafile '/home/oracle/c3db/c3fmidx.dbf' to '/dev/raw/raw1505';
set newname for datafile '/home/oracle/c3db/c3sysidx.dbf' to '/dev/raw/raw1506';
set newname for datafile '/home/oracle/c3db/c3defaultidx.dbf' to '/dev/raw/raw1507';
set newname for datafile '/home/oracle/c3db/c3icsidx.dbf' to '/dev/raw/raw1508';
set newname for datafile '/home/oracle/c3db/c3iccruleidx.dbf' to '/dev/raw/raw1509';
set newname for datafile '/home/oracle/c3db/c3iccrulehistoryidx.dbf' to '/dev/raw/raw1510';
set newname for datafile '/home/oracle/c3db/c3ieeidx.dbf' to '/dev/raw/raw1511';
set newname for datafile '/home/oracle/c3db/c3logserviceidx.dbf' to '/dev/raw/raw1512';
set newname for datafile '/home/oracle/c3db/c3logserviceidx.dbf' to '/dev/raw/raw1513';
set newname for datafile '/home/oracle/c3db/c3modeldata.dbf' to '/dev/raw/raw1701';
set newname for datafile '/home/oracle/c3db/c3smdata.dbf' to '/dev/raw/raw1702';
set newname for datafile '/home/oracle/c3db/c3pmdata.dbf' to '/dev/raw/raw1703';
set newname for datafile '/home/oracle/c3db/c3pmdata.dbf' to '/dev/raw/raw1704';
set newname for datafile '/home/oracle/c3db/c3pmdata.dbf' to '/dev/raw/raw1705';
set newname for datafile '/home/oracle/c3db/c3pmdata.dbf' to '/dev/raw/raw1706';
set newname for datafile '/home/oracle/c3db/c3pmdata.dbf' to '/dev/raw/raw1707';
set newname for datafile '/home/oracle/c3db/c3pmdata.dbf' to '/dev/raw/raw1708';
set newname for datafile '/home/oracle/c3db/c3pmdata.dbf' to '/dev/raw/raw1709';
set newname for datafile '/home/oracle/c3db/c3fmdata.dbf' to '/dev/raw/raw1710';
set newname for datafile '/home/oracle/c3db/c3sysdata.dbf' to '/dev/raw/raw1711';
set newname for datafile '/home/oracle/c3db/c3defaultdata.dbf' to '/dev/raw/raw1712';
set newname for datafile '/home/oracle/c3db/c3icsdata.dbf' to '/dev/raw/raw1713';
set newname for datafile '/home/oracle/c3db/c3iccruledata.dbf' to '/dev/raw/raw1714';
set newname for datafile '/home/oracle/c3db/c3iccrulehistorydata.dbf' to '/dev/raw/raw1715';
set newname for datafile '/home/oracle/c3db/c3iccrulehistorydata.dbf' to '/dev/raw/raw1716';
set newname for datafile '/home/oracle/c3db/c3ieedata.dbf' to '/dev/raw/raw1717';
set newname for datafile '/home/oracle/c3db/c3logservicedata.dbf' to '/dev/raw/raw1718';
set newname for datafile '/home/oracle/c3db/c3logservicedata.dbf' to '/dev/raw/raw1719';
set newname for datafile '/home/oracle/c3db/c3logservicedata.dbf' to '/dev/raw/raw1720';
set newname for datafile '/home/oracle/c3db/c3logservicedata.dbf' to '/dev/raw/raw1721';
set newname for datafile '/home/oracle/c3db/c3logservicedata.dbf' to '/dev/raw/raw1722';
set newname for datafile '/home/oracle/c3db/c3logservicedata.dbf' to '/dev/raw/raw1723';
set newname for datafile '/home/oracle/c3db/c3logservicedata.dbf' to '/dev/raw/raw1724';
set newname for datafile '/home/oracle/c3db/c3logservicedata.dbf' to '/dev/raw/raw1725';
set newname for datafile '/home/oracle/c3db/c3logservicedata.dbf' to '/dev/raw/raw1726';
set newname for datafile '/home/oracle/c3db/c3logservicedata.dbf' to '/dev/raw/raw1727';
set newname for datafile '/home/oracle/c3db/c3logservicedata.dbf' to '/dev/raw/raw1728';
set newname for datafile '/home/oracle/c3db/vcenter.dbf' to '/dev/raw/raw2001';
restore database;
switch datafile all;
release channel 'dev0';}
修改临时表空间。
alter database tempfile '/oracle/app/oradata/vcdb/vcdb/temp01.dbf' offline; ---mount 或启动
create temporary tablespace temp1 tempfile '/dev/raw/raw5' size 20M;
alter database tempfile '/dev/raw/raw5' resize 8000M;
alter database tempfile '/dev/raw/raw5' autoextend off;
alter database default temporary tablespace temp1;
drop tablespace temp;
alter database tempfile '/dev/raw/raw5' online;
select tablespace_name,file_name,bytes/1024/1024 "file_size(M)",autoextensible from dba_temp_files;
恢复数据库
recover database;
alter database open;
如果报如下错误:
RMAN> recover database;
Starting recover at 26-MAR-12
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=869 device type=DISK
starting media recovery
unable to find archived log
archived log thread=1 sequence=491
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 03/26/2012 17:54:29
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 491 and starting SCN of 14984976
则执行:alter database open resetlogs
select name from v$datafile;
增加表空间到多个裸设备。执行sql语句tablespace_modify.sql
ALTER tablespace c3pmidx add DATAFILE '/dev/raw/raw1503' SIZE 3000M;
ALTER tablespace c3logserviceidx add DATAFILE '/dev/raw/raw1512' SIZE 3000M;
ALTER tablespace c3pmdata add DATAFILE '/dev/raw/raw1703' SIZE 3000M;
ALTER tablespace c3pmdata add DATAFILE '/dev/raw/raw1704' SIZE 3000M;
ALTER tablespace c3pmdata add DATAFILE '/dev/raw/raw1705' SIZE 3000M;
ALTER tablespace c3pmdata add DATAFILE '/dev/raw/raw1706' SIZE 3000M;
ALTER tablespace c3pmdata add DATAFILE '/dev/raw/raw1707' SIZE 3000M;
ALTER tablespace c3pmdata add DATAFILE '/dev/raw/raw1708' SIZE 3000M;
ALTER tablespace c3iccrulehistorydata add DATAFILE '/dev/raw/raw1715' SIZE 3000M;
ALTER tablespace c3logservicedata add DATAFILE '/dev/raw/raw1718' SIZE 3000M;
ALTER tablespace c3logservicedata add DATAFILE '/dev/raw/raw1719' SIZE 3000M;
ALTER tablespace c3logservicedata add DATAFILE '/dev/raw/raw1720' SIZE 3000M;
ALTER tablespace c3logservicedata add DATAFILE '/dev/raw/raw1721' SIZE 3000M;
ALTER tablespace c3logservicedata add DATAFILE '/dev/raw/raw1722' SIZE 3000M;
ALTER tablespace c3logservicedata add DATAFILE '/dev/raw/raw1723' SIZE 3000M;
ALTER tablespace c3logservicedata add DATAFILE '/dev/raw/raw1724' SIZE 3000M;
ALTER tablespace c3logservicedata add DATAFILE '/dev/raw/raw1725' SIZE 3000M;
ALTER tablespace c3logservicedata add DATAFILE '/dev/raw/raw1726' SIZE 3000M;
ALTER tablespace c3logservicedata add DATAFILE '/dev/raw/raw1727' SIZE 3000M;
查看临时表空间
select tablespace_name,file_name,bytes/1024/1024 "file_size(M)",autoextensible from dba_temp_files;
查看数据库表空间。
select tablespace_name,file_name,bytes/1024/1024,autoextensible from dba_data_files order by file_name;
恢复某一个datafile的操作方法。
rman>restore datafile 1
批量恢复数据文件:
restore datafile 5,6,7,8,9,10,16,17,19;
restore datafile 18,20,21,22,23,24,26;
restore datafile 11,12,13,14,15,25,27;
重新创建控制文件:
create controlfile reuse database dave noresetlogs archivelog
LOGFILE
GROUP 1 '/u01/app/oracle/oradata/dave/redo01.log',
GROUP 2 '/u01/app/oracle/oradata/dave/redo02.log',
GROUP 3 '/u01/app/oracle/oradata/dave/redo03.log'
DATAFILE
'/u01/app/oracle/oradata/dave/sysaux01.dbf',
'/u01/app/oracle/oradata/dave/system01.dbf',
'/u01/app/oracle/oradata/dave/undotbs01.dbf',
'/u01/app/oracle/oradata/dave/users01.dbf'
CHARACTER SET ZHS16GBK;
=========================================================================
create controlfile reuse database orainst noresetlogs archivelog
LOGFILE
GROUP 1 '/dev/vgora/lvredo1',
GROUP 2 '/dev/vgora/lvredo2',
GROUP 3 '/dev/vgora/lvredo3'
GROUP 4 '/dev/vgora/lvredo4'
GROUP 5 '/dev/vgora/lvredo5'
GROUP 6 '/dev/vgora/lvredo6'
DATAFILE
'/dev/raw/raw3',
'/dev/raw/raw2',
'/dev/raw/raw4',
'/dev/raw/raw6'
CHARACTER SET ZHS16GBK;
TAG:
我的栏目
标题搜索
日历
|
|||||||||
日 | 一 | 二 | 三 | 四 | 五 | 六 | |||
1 | 2 | 3 | 4 | 5 | 6 | ||||
7 | 8 | 9 | 10 | 11 | 12 | 13 | |||
14 | 15 | 16 | 17 | 18 | 19 | 20 | |||
21 | 22 | 23 | 24 | 25 | 26 | 27 | |||
28 | 29 | 30 |
我的存档
数据统计
- 访问量: 124435
- 日志数: 67
- 建立时间: 2010-12-07
- 更新时间: 2019-08-28