【備份恢復】從備份恢復資料庫
準備工作
[root@edbjr2p1 ~]# su - oracle
[oracle@edbjr2p1 ~]$ export ORACLE_SID=PROD
[oracle@edbjr2p1 ~]$ cd /u01/arch
備份資料庫,備份指令碼如下
backup.cmd
run {
CONFIGURE RETENTION POLICY TO REDUNDANCY 3;
crosscheck backup;
crosscheck archivelog all;
delete force noprompt expired backup;
delete force noprompt expired archivelog all;
allocate channel c1 device type disk connect sys/oracle@PROD;
sql 'alter system archive log current';
backup as compressed backupset database format '/u01/arch/full_%d_%s_%p_%T' plus archivelog delete all input format '/u01/arch/arch_%d_%s_%p_%T';
backup current controlfile format '/u01/arch/ctl_%d_%s_%p_%T';
backup spfile format ‘/u01/arch/spfile_%d_%T.bak’;
release channel c1;
}
backup.sh
rman target / nocatalog cmdfile=/u01/backup.cmd log=/u01/backup-`date +%Y%m%d`.log
一、檢視備份
[oracle@edbjr2p1 arch]$ ls -lrt
total 69508
-rw-r----- 1 oracle oinstall 13312 Jan 9 11:19 arch_PROD_39_1_20150109
-rw-r----- 1 oracle oinstall 62971904 Jan 9 11:20 full_PROD_40_1_20150109
-rw-r----- 1 oracle oinstall 1114112 Jan 9 11:20 full_PROD_41_1_20150109
-rw-r----- 1 oracle oinstall 3072 Jan 9 11:20 arch_PROD_42_1_20150109
-rw-r----- 1 oracle oinstall 6881280 Jan 9 11:20 ctl_PROD_43_1_20150109
-rw-r----- 1 oracle oinstall 98304 Jan 9 11:20 spfile_PROD_44_1_20150109
[oracle@edbjr2p1 arch]$
[oracle@edbjr2p1 arch]$
[oracle@edbjr2p1 arch]$
[oracle@edbjr2p1 arch]$ rm -rf $ORACLE_HOME/dbs/*PROD.ora
[oracle@edbjr2p1 arch]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Fri Jan 9 11:21:02 2015
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options
SYS@PROD>shutdown abort
ORACLE instance shut down.
SYS@PROD>exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options
二、刪除資料庫,嘗試啟動。
[oracle@edbjr2p1 arch]$ rm -rf /u01/app/oracle/oradata/PROD/disk*/*
[oracle@edbjr2p1 arch]$ set -o vi
[oracle@edbjr2p1 arch]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Fri Jan 9 11:22:23 2015
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to an idle instance.
SYS@PROD>startup
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/10.2.0/db_1/dbs/initPROD.ora'
SYS@PROD>exit
Disconnected
三、還原引數檔案
[oracle@edbjr2p1 arch]$ rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on Fri Jan 9 11:22:31 2015
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database (not started)
RMAN> restore spfile from '/u01/arch/spfile_PROD_44_1_20150109';
Starting restore at 09-JAN-15
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 01/09/2015 11:22:46
RMAN-12010: automatic channel allocation initialization failed
RMAN-06403: could not obtain a fully authorized session
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux Error: 2: No such file or directory
RMAN> startup nomount;
startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/10.2.0/db_1/dbs/initPROD.ora'
starting Oracle instance without parameter file for retrival of spfile
Oracle instance started
Total System Global Area 159383552 bytes
Fixed Size 1218268 bytes
Variable Size 54528292 bytes
Database Buffers 100663296 bytes
Redo Buffers 2973696 bytes
RMAN> restore spfile from '/u01/arch/spfile_PROD_44_1_20150109';
Starting restore at 09-JAN-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=36 devtype=DISK
channel ORA_DISK_1: autobackup found: /u01/arch/spfile_PROD_44_1_20150109
channel ORA_DISK_1: SPFILE restore from autobackup complete
Finished restore at 09-JAN-15
RMAN> shutdown abort
Oracle instance shut down
RMAN> startup nomount;
connected to target database (not started)
Oracle instance started
Total System Global Area 524288000 bytes
Fixed Size 1220384 bytes
Variable Size 155189472 bytes
Database Buffers 364904448 bytes
Redo Buffers 2973696 bytes
RMAN> exit
Recovery Manager complete.
[oracle@edbjr2p1 arch]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Fri Jan 9 11:23:25 2015
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options
SYS@PROD>show parameter com
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
commit_point_strength integer 1
commit_write string
compatible string 10.2.0
max_commit_propagation_delay integer 0
nls_comp string
plsql_compiler_flags string INTERPRETED, NON_DEBUG
plsql_v2_compatibility boolean FALSE
SYS@PROD>exit
Disconnected from Oracle Database 10g Enterprise Edition Data Mining Scoring Engine options
[oracle@edbjr2p1 arch]$ ls -lrt
total 69508
-rw-r----- 1 oracle oinstall 13312 Jan 9 11:19 arch_PROD_39_1_20150109
-rw-r----- 1 oracle oinstall 62971904 Jan 9 11:20 full_PROD_40_1_20150109
-rw-r----- 1 oracle oinstall 1114112 Jan 9 11:20 full_PROD_41_1_20150109
-rw-r----- 1 oracle oinstall 3072 Jan 9 11:20 arch_PROD_42_1_20150109
-rw-r----- 1 oracle oinstall 6881280 Jan 9 11:20 ctl_PROD_43_1_20150109
-rw-r----- 1 oracle oinstall 98304 Jan 9 11:20 spfile_PROD_44_1_20150109
四、恢復控制檔案
[oracle@edbjr2p1 arch]$ rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on Fri Jan 9 11:23:41 2015
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: PROD (not mounted)
RMAN> restore controlfile from '/u01/arch/ctl_PROD_43_1_20150109';
Starting restore at 09-JAN-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=321 devtype=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
output filename=/u01/app/oracle/oradata/PROD/disk1/control01.ctl
output filename=/u01/app/oracle/oradata/PROD/disk2/control02.ctl
output filename=/u01/app/oracle/oradata/PROD/disk3/control03.ctl
Finished restore at 09-JAN-15
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
五、恢復資料庫
RMAN> restore database;
Starting restore at 09-JAN-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=320 devtype=DISK
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u01/app/oracle/oradata/PROD/disk1/system01.dbf
restoring datafile 00002 to /u01/app/oracle/oradata/PROD/disk1/undotbs01.dbf
restoring datafile 00003 to /u01/app/oracle/oradata/PROD/disk1/sysaux01.dbf
restoring datafile 00004 to /u01/app/oracle/oradata/PROD/disk1/USERS.dbf
restoring datafile 00005 to /u01/app/oracle/oradata/PROD/disk1/DSS.dbf
channel ORA_DISK_1: reading from backup piece /u01/arch/full_PROD_40_1_20150109
channel ORA_DISK_1: restored backup piece 1
piece handle=/u01/arch/full_PROD_40_1_20150109 tag=TAG20150109T112000
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
Finished restore at 09-JAN-15
RMAN> recover database;
Starting recover at 09-JAN-15
using channel ORA_DISK_1
starting media recovery
channel ORA_DISK_1: starting archive log restore to default destination
channel ORA_DISK_1: restoring archive log
archive log thread=1 sequence=36
channel ORA_DISK_1: reading from backup piece /u01/arch/arch_PROD_42_1_20150109
channel ORA_DISK_1: restored backup piece 1
piece handle=/u01/arch/arch_PROD_42_1_20150109 tag=TAG20150109T112017
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
archive log filename=/u01/arch/1_36_865882219.dbf thread=1 sequence=36
unable to find archive log
archive log thread=1 sequence=37
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 01/09/2015 11:25:24
RMAN-06054: media recovery requesting unknown log: thread 1 seq 37 lowscn 178388
RMAN> alter databaes open resetlogs;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "identifier": expecting one of: "clone, database"
RMAN-01008: the bad identifier was: databaes
RMAN-01007: at line 1 column 7 file: standard input
RMAN> alter database open resetlogs;
database opened
RMAN>
Recovery Manager complete.
至此資料庫恢復完成
[oracle@edbjr2p1 arch]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Fri Jan 9 11:27:01 2015
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options
SYS@PROD>show parameter com
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
commit_point_strength integer 1
commit_write string
compatible string 10.2.0
max_commit_propagation_delay integer 0
nls_comp string
plsql_compiler_flags string INTERPRETED, NON_DEBUG
plsql_v2_compatibility boolean FALSE
SYS@PROD>shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SYS@PROD>startup
ORACLE instance started.
Total System Global Area 524288000 bytes
Fixed Size 1220384 bytes
Variable Size 155189472 bytes
Database Buffers 364904448 bytes
Redo Buffers 2973696 bytes
Database mounted.
Database opened.
SYS@PROD>show parameter com
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
commit_point_strength integer 1
commit_write string
compatible string 10.2.0
max_commit_propagation_delay integer 0
nls_comp string
plsql_compiler_flags string INTERPRETED, NON_DEBUG
plsql_v2_compatibility boolean FALSE
SYS@PROD>alter system set compatible='10.2.0.1.0' scope=spfile;
System altered.
SYS@PROD>shutdown abort
ORACLE instance shut down.
SYS@PROD>startup
ORACLE instance started.
Total System Global Area 524288000 bytes
Fixed Size 1220384 bytes
Variable Size 155189472 bytes
Database Buffers 364904448 bytes
Redo Buffers 2973696 bytes
Database mounted.
Database opened.
SYS@PROD>show parameter com
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
commit_point_strength integer 1
commit_write string
compatible string 10.2.0.1.0
max_commit_propagation_delay integer 0
nls_comp string
plsql_compiler_flags string INTERPRETED, NON_DEBUG
plsql_v2_compatibility boolean FALSE
SYS@PROD>
簡單做了個備份恢復的實驗,記錄一下。
2015.1.9
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29319205/viewspace-1407979/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 備份與恢復:polardb資料庫備份與恢復資料庫
- 資料庫備份恢復資料庫
- RAC備份恢復之Voting備份與恢復
- Mysql資料庫備份及恢復MySql資料庫
- 達夢資料庫備份恢復資料庫
- postgresql備份與恢復資料庫SQL資料庫
- ORACLE DG從庫 Rman備份恢復Oracle
- 資料庫備份與恢復技術資料庫
- Mongo 資料庫備份和恢復命令Go資料庫
- pg_dump 備份,恢復資料庫資料庫
- PostgreSql資料庫的備份和恢復SQL資料庫
- MySQL備份與恢復——基於Xtrabackup物理備份恢復MySql
- Mysql資料備份與恢復MySql
- mydumper備份恢復
- Mysql備份恢復MySql
- 備份和恢復
- SqlServer資料庫恢復備份資料的方法SQLServer資料庫
- vivo 資料庫備份恢復系統演化資料庫
- 使用Mysqldump備份和恢復MySQL資料庫MySql資料庫
- MySQL-19.資料庫備份與恢復MySql資料庫
- PG-pg_dump備份/恢復資料庫資料庫
- 備份與恢復:Polardb資料庫資料基於時間點恢復資料庫
- RabbitMQ如何備份與恢復資料MQ
- gitlab的資料備份和恢復Gitlab
- 磁碟資料恢復及備份工具資料恢復
- 詳解叢集級備份恢復:物理細粒度備份恢復
- MySQL備份與恢復——基於MyDumper/MyLoader 邏輯備份恢復MySql
- Mysql備份與恢復(1)---物理備份MySql
- rman 增量備份恢復
- Jenkins備份與恢復Jenkins
- Postgresql 備份與恢復SQL
- MySQL 備份與恢復MySql
- KunlunDB備份和恢復
- RMAN備份恢復技巧
- redis 備份和恢復Redis
- Grafana 備份恢復教程Grafana
- 賦能雲HBase備份恢復 百T級別資料量備份恢復支援
- RMAN備份恢復典型案例——資料庫卡頓資料庫
- Linux下MySQL資料庫的備份與恢復LinuxMySql資料庫