在一节点上进行全备
确定备份路径,并赋予属组
mkdir /rmanbackup
chown oracle:oinsatll /rmanbackup
进入rman进行全备
rman target /
run
{
allocate channel d1 type disk;
backup incremental level 0 format '/rmanbackup/orcl_full_%U' database include current controlfile;
delete noprompt obsolete;
sql 'alter system archive log current';
backup format '/rmanbackup/orcl_arch_full_%U' archivelog all not backed up delete input;
crosscheck backup;
delete noprompt expired backup;
release channel d1;
}
将生成的备份传到单机环境
cd /rmanbackup
scp * oracle@192.168.100.199:/rmanbackup/ (单机上已备好此路径)
创建pfile文件并修改传送到单机环境对应目录下
SQL> create pfile='/rmanbackup/initorcl.ora' from spfile='/u02/app/oracle/product/11.2.0/db_home/dbs/spfileorcl1.ora.bak';
vi initorcl.ora
*.audit_file_dest='/u01/app/oracle/admin/orcl/adump'
*.audit_trail='NONE'
*.compatible='11.2.0.4.0'
*.control_files='/u01/app/oracle/oradata/orcl/control01.dbf'
*.db_block_size=8192
*.db_create_file_dest='/u01/app/oracle/oradata/'
*.db_create_online_log_dest_1='/u01/app/oracle/oradata/'
*.db_domain=''
*.db_files=2000
*.db_name='orcl'
*.deferred_segment_creation=FALSE
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
*.enable_ddl_logging=TRUE
*.event='28401 TRACE NAME CONTEXT FOREVER, LEVEL 1'
*.log_archive_dest_1='LOCATION=/arch'
*.log_archive_format='%t_%s_%r.dbf'
*.max_dump_file_size='25m'
*.open_cursors=300
*.pga_aggregate_target=288358400
*.processes=1500
*.remote_login_passwordfile='exclusive'
*.sec_case_sensitive_logon=FALSE
*.sessions=1655
*.sga_max_size=1100m
*.sga_target=1100m
scp initorcl.ora oracle@192.168.100.199://u01/app/oracle/product/11.2.0/dbhome_1/dbs/
单机环境上
用传过来的pfile生成spfile文件
SQL> create spfile from pfile;
SQL> startup nomount;
恢复控制文件
RMAN> restore controlfile from '/rmanbackup/orcl_full_19ra5tlf_1_1';
RMAN> alter database mount;
检查并标记控制文件中存在,但是实际已经不存在的备份文件。
RMAN>crosscheck backup;
清理控制文件中存在,但是实际已经不存在的备份文件。
RMAN>delete noprompt expired backup;
将备份注册到rman
RMAN>catalog start with '/rmanbackup/' ; ----注册整个目录
RMAN> catalog backuppiece '/rmanbackup/orcl_full_19ra5tlf_1_1';
RMAN> catalog backuppiece '/rmanbackup/orcl_full_18ra5tih_1_1';
RMAN> catalog backuppiece '/rmanbackup/orcl_arch_full_1ara5tnb_1_1';
现在我们确定的点到媒介恢复应该恢复数据库上运行。
RMAN> list backup of archivelog all;
修改数据文件 (直接生成执行命令方法):
select 'set newname for datafile '||chr(39)||name||chr(39)||' to '||chr(39)||replace(name,'+DATA/orcl/datafile/','/u01/app/oracle/oradata/orcl/')||chr(39)||';' from v$datafile;
根据备份信息,恢复数据文件及数据库
RMAN> RUN {
set until sequence 84 thread 1;
SET NEWNAME FOR DATAFILE 1 to '/u01/app/oracle/oradata/orcl/system.dbf';
SET NEWNAME FOR DATAFILE 2 to '/u01/app/oracle/oradata/orcl/sysaux.dbf';
SET NEWNAME FOR DATAFILE 3 to '/u01/app/oracle/oradata/orcl/undotbs1.dbf';
SET NEWNAME FOR DATAFILE 4 to '/u01/app/oracle/oradata/orcl/users.dbf';
SET NEWNAME FOR DATAFILE 5 to '/u01/app/oracle/oradata/orcl/undotbs2.dbf';
SET NEWNAME FOR DATAFILE 6 to '/u01/app/oracle/oradata/orcl/huyuwu.dbf';
SET NEWNAME FOR DATAFILE 7 to '/u01/app/oracle/oradata/orcl/syd.dbf';
SET NEWNAME FOR DATAFILE 8 to '/u01/app/oracle/oradata/orcl/syd2.dbf';
SET NEWNAME FOR DATAFILE 9 to '/u01/app/oracle/oradata/orcl/syd1.dbf';
SET NEWNAME FOR DATAFILE 10 to '/u01/app/oracle/oradata/orcl/syd3.dbf';
SET NEWNAME FOR DATAFILE 11 to '/u01/app/oracle/oradata/orcl/syd4.dbf';
RESTORE DATABASE;
SWITCH DATAFILE ALL;
recover database;
}
查看日志文件
SQL> select member from v$logfile;
修改日志文件:
SQL> select 'alter database rename file '||chr(39)||member||chr(39)||' to '||chr(39)||replace(member,'+DATA/orcl/onlinelog/','/u01/app/oracle/oradata/orcl/onlinelog/')||chr(39)||';' from v$logfile;
alter database rename file '+DATA/orcl/onlinelog/group_redo06a.log' to '/u01/app/oracle/oradata/orcl/redo6_1.log';
alter database rename file '+FRA/orcl/onlinelog/group_redo06b.log' to '/u01/app/oracle/oradata/orcl/redo6_2.log';
alter database rename file '+DATA/orcl/onlinelog/redo0001a.log' to '/u01/app/oracle/oradata/orcl/redo1_1.log';
alter database rename file '+FRA/orcl/onlinelog/redo0001b.log' to '/u01/app/oracle/oradata/orcl/redo1_2.log';
alter database rename file '+DATA/orcl/onlinelog/group_redo02a.log' to '/u01/app/oracle/oradata/orcl/redo2_1.log';
alter database rename file '+FRA/orcl/onlinelog/group_redo02b.log' to '/u01/app/oracle/oradata/orcl/redo2_2.log';
alter database rename file '+DATA/orcl/onlinelog/redo0003a.log' to '/u01/app/oracle/oradata/orcl/redo3_1.log';
alter database rename file '+FRA/orcl/onlinelog/redo0003b.log' to '/u01/app/oracle/oradata/orcl/redo3_2.log';
alter database rename file '+DATA/orcl/onlinelog/group_redo04a.log' to '/u01/app/oracle/oradata/orcl/redo4_1.log';
alter database rename file '+FRA/orcl/onlinelog/group_redo04b.log' to '/u01/app/oracle/oradata/orcl/redo4_2.log';
alter database rename file '+DATA/orcl/onlinelog/redo0005a.log' to '/u01/app/oracle/oradata/orcl/redo5_1.log';
alter database rename file '+FRA/orcl/onlinelog/redo0005b.log' to '/u01/app/oracle/oradata/orcl/redo5_2.log';
alter database rename file '+FRA/orcl/onlinelog/group_redo07a.log' to '/u01/app/oracle/oradata/orcl/redo7_1.log';
alter database rename file '+DATA/orcl/onlinelog/group_redo07b.log' to '/u01/app/oracle/oradata/orcl/redo7_2.log';
alter database rename file '+DATA/orcl/onlinelog/redo0008a.log' to '/u01/app/oracle/oradata/orcl/redo8_1.log';
alter database rename file '+FRA/orcl/onlinelog/redo0008b.log' to '/u01/app/oracle/oradata/orcl/redo8_2.log';
打开数据库
alter database open resetlogs;
查看redo log 信息,并删除无效日志组
查看redo log 信息,并删除无效日志组(节点2日志)
select THREAD#, STATUS, ENABLED from v$thread;
THREAD# STATUS ENABLED
---------- ------ --------
1 OPEN PUBLIC
2 CLOSED PUBLIC
select group# from v$log where THREAD#=2;
GROUP#
----------
3
4
6
8
SQL> alter database disable thread 2;
SQL> alter database drop logfile group 3;
SQL> alter database drop logfile group 4;
SQL> alter database drop logfile group 6;
SQL> alter database drop logfile group 8;
SQL> select THREAD#, STATUS, ENABLED from v$thread;
THREAD# STATUS ENABLED
---------- ------ --------
1 OPEN PUBLIC
查看undo表空间,并删除节点2(在此不使用)的undo表空间
SQL> sho parameter undo;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
undo_management string AUTO
undo_retention integer 900
undo_tablespace string UNDOTBS1
SQL> select tablespace_name from dba_tablespaces where contents='UNDO';
TABLESPACE_NAME
------------------------------
UNDOTBS1
UNDOTBS2
SQL> drop tablespace UNDOTBS2 including contents and datafiles;
SQL> select name from v$tempfile;
NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/ORCL/datafile/o1_mf_temp_cr602c5z_.tmp
SQL> select tablespace_name from dba_tablespaces where contents='TEMPORARY';
TABLESPACE_NAME
------------------------------
TEMP
SQL> create temporary tablespace TEMP1 tempfile '/u01/app/oracle/oradata/orcl/temp01.dbf' size 50M;
SQL> alter database default temporary tablespace TEMP1;
SQL> drop tablespace TEMP including contents and datafiles;
查看监听状态并配置,编辑tnsname.ora文件。(mos文档没有)
通过以下命令创建密码文件,注意密码文件的位置(mos文档没有)
[oracle@orc1 dbs]$ orapwd file=orapwracdb1 password=oracle entries=30
————————————————
原文链接:https://blog.csdn.net/songyundong1993/article/details/52920379