首页 > 数据库 > Oracle > 从控制文件自动备份还原参数文件
----从控制文件自动备份还原服务器参数文件:
---前提:查看快速恢复区的参数:
sys@PROD>show parameter recovery
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest string /u01/app/oracle/fast_recovery_
area
db_recovery_file_dest_size big integer 4182M
recovery_parallelism integer 0
sys@PROD>
---修改快速恢复区的路径:
sys@PROD>alter system set db_recovery_file_dest='/u01/app/FRA';
System altered.
sys@PROD>show parameter recovery
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest string /u01/app/FRA
db_recovery_file_dest_size big integer 4182M
recovery_parallelism integer 0
sys@PROD>
---备份系统表空间:#因为上面是刚刚修改了快速恢复区,这里需要为了生成一个控制文件与参数文件的自动备份文件#
RMAN> backup tablespace system;
Starting backup at 07-NOV-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=17 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/PROD/system01.dbf
channel ORA_DISK_1: starting piece 1 at 07-NOV-16
channel ORA_DISK_1: finished piece 1 at 07-NOV-16
piece handle=/u01/app/backup/db_0frkarjn_1_1.rmn tag=TAG20161107T143223 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:50
Finished backup at 07-NOV-16
Starting Control File and SPFILE Autobackup at 07-NOV-16
piece handle=/u01/app/FRA/PROD/autobackup/2016_11_07/o1_mf_s_927297253_d20836cs_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 07-NOV-16
#完成备份。
---删除spfile参数文件:
[oracle@enmo ~]$ cd $ORACLE_HOME/dbs
[oracle@enmo dbs]$ ls
hc_PROD.dat init.ora lkPROD orapwPROD snapcf_PROD.f spfilePROD.ora
[oracle@enmo dbs]$ rm spfilePROD.ora
[oracle@enmo dbs]$ ls
hc_PROD.dat init.ora lkPROD orapwPROD PROD.ora.bck snapcf_PROD.f
[oracle@enmo dbs]$ ls spfile*
ls: spfile*: No such file or directory
---强行关库:
sys@PROD>shutdown abort;
ORACLE instance shut down.
sys@PROD>
---恢复参数文件:
[oracle@enmo ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Mon Nov 7 14:40:42 2016
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database (not started)
RMAN>
RMAN> startup force nomount;
startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initPROD.ora'
starting Oracle instance without parameter file for retrieval of spfile
Oracle instance started
Total System Global Area 1068937216 bytes
Fixed Size 2260088 bytes
Variable Size 281019272 bytes
Database Buffers 780140544 bytes
Redo Buffers 5517312 bytes
RMAN>
RMAN> run {
2> restore spfile from autobackup
3> recovery area ='/u01/app/FRA' #指定快速恢复区的路径#
4> DB_NAME='PROD'; #指定库名#
5> }
Starting restore at 07-NOV-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK
recovery area destination: /u01/app/FRA
database name (or database unique name) used for search: PROD
channel ORA_DISK_1: AUTOBACKUP /u01/app/FRA/PROD/autobackup/2016_11_07/o1_mf_s_927297253_d20836cs_.bkp found in the recovery area
AUTOBACKUP search with format "%F" not attempted because DBID was not set
channel ORA_DISK_1: restoring spfile from AUTOBACKUP /u01/app/FRA/PROD/autobackup/2016_11_07/o1_mf_s_927297253_d20836cs_.bkp
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 07-NOV-16
RMAN>
#恢复完成。
--系统查看生成的参数文件:
[oracle@enmo dbs]$ ll
total 9560
-rw-rw---- 1 oracle oinstall 1544 Nov 7 14:42 hc_PROD.dat
-rw-r--r-- 1 oracle oinstall 2851 May 15 2009 init.ora
-rw-r----- 1 oracle oinstall 24 Oct 30 21:30 lkPROD
-rw-r----- 1 oracle oinstall 1536 Oct 30 21:36 orapwPROD
-rw-r----- 1 oracle oinstall 2560 Nov 7 14:38 PROD.ora.bck
-rw-r----- 1 oracle oinstall 9748480 Nov 7 14:34 snapcf_PROD.f
-rw-r----- 1 oracle oinstall 2560 Nov 7 14:44 spfilePROD.ora
[oracle@enmo dbs]$
#已经生产新的spfile参数文件。
--校验:
sys@PROD>select status from v$instance;
select status from v$instance
*
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 14307
Session ID: 1 Serial number: 5
sys@PROD>shutdown abort;
ORACLE instance shut down.
sys@PROD>
---重新启动数据库:
sys@PROD>startup
ORACLE instance started.
Total System Global Area 835104768 bytes
Fixed Size 2257840 bytes
Variable Size 507513936 bytes
Database Buffers 322961408 bytes
Redo Buffers 2371584 bytes
Database mounted.
Database opened.
sys@PROD>
sys@PROD>select status from v$instance;
STATUS
------------
OPEN
#参数文件恢复成功。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/31392094/viewspace-2127980/ ,如需转载,请注明出处,否则将追究法律责任。