RMAN different machines to restore the main steps and precautions

After diverted or old look back, I will have them, it was a joy to do

【备份】
--创建目录
[oracle@test20 backup]$ mkdir -p /home/oracle/backup
--备份脚本
[oracle@test20 backup]$ cat backup2.sh
#!/bin/bash
source /home/oracle/.bash_profile
$ORACLE_HOME/bin/rman target / log=/home/oracle/backup/backup_`date +%m%d`.log append <<EOF
CONFIGURE CONTROLFILE AUTOBACKUP ON;
run {
allocate channel ch1 device type disk;
allocate channel ch2 device type disk;
allocate channel ch3 device type disk;
allocate channel ch4 device type disk;
sql 'alter system archive log current';
#backup database format '/home/oracle/backup/data_%d_%T_%U.bak';
#compressed
backup as compressed backupset database format '/home/oracle/backup/data_%d_%T_%U.bak';
#backup archivelog all format '/home/oracle/backup/arch_%d_%T_%U.bak';
#compressed
backup as compressed backupset archivelog all format '/home/oracle/backup/arch_%d_%T_%U.bak';
#for standby
#backup current controlfile for standby format '/home/oracle/backup/ctl_%d_%T_%U.bak';
#for restore
backup current controlfile format '/home/oracle/backup/ctl_%d_%T_%U.bak';
release channel ch1;
release channel ch2;
release channel ch3;
release channel ch4;
}
EOF

- Authorization
[oracle @ test20 backup] $ chmod + x backup.sh

- Backup
[@ Test20 the Oracle Backup] $ ./backup.sh
- transmission

[Recovery]
- to create the directory. Oracle machine software has been installed, DB closed
mkdir -p / u01 / App / oracle / ADMIN / payme / {the adump, bdump, cdump, dpdump, udump, pfile}
mkdir -p / u01 / App / oracle / oradata / payme
mkdir -p / u01 / app / oracle / fast_recovery_area / payme

- the parameter file and the SID
echo 'db_name = payme'> $ ORACLE_HOME / DBS / initpayme.ora
More $ ORACLE_HOME / DBS / initpayme.ora
Export the ORACLE_SID = payme
RMAN target /
- original database dbid payme (DBID = 1239133617) from RMAN backup log check under the
set dbid 1239133617

- Start
SQL> startup nomount;

- Restore the control file
RMAN target /
RMAN> Restore controlfile from '/home/oracle/backup/ctl_payme_20191108_35ugc7rl_1_1.bak';
...
# will output a new control file
output file name = / u01 / app / oracle / oradata / datafile /TEST154/controlfile/o1_mf_grv284j3_.ctl
Output File name = / u01 / App / Oracle / oradata / FLASH_RECOVERY_AREA / TEST154 / controlfile / o1_mf_grv284k0_.ctl

- Start instance to mount state
alter database mount;

- Check the validity of the backup
crosscheck backup;

- registration data file backup and archive backup in a new control file. At the end to take / and no spaces, pay attention to file permissions
catalog start with '/ home / oracle / backup /';

- performing main library, generated rename SQL, replaced with corresponding data file path
COL the FOR AA A200
the SET 100 pageSize
the SET Line 200 is
the SELECT 'SET newname for datafile' || # || A.FILE 'to "' || a.name || ' ";' AA the AS
the FROM A V $ DATAFILE
the UNION ALL
the SELECT 'SET newname for the tempfile' || # || A.FILE 'to"' || || a.name ' ";' AA the AS
the FROM $ V TEMPFILE A;

--开始恢复
RMAN> run
{
allocate channel ch1 device type disk;
allocate channel ch2 device type disk;
allocate channel ch3 device type disk;
allocate channel ch4 device type disk;
set newname for datafile 1 to "/u01/app/oracle/oradata/payme/system01.dbf";
set newname for datafile 2 to "/u01/app/oracle/oradata/payme/sysaux01.dbf";
set newname for datafile 3 to "/u01/app/oracle/oradata/payme/undotbs01.dbf";
set newname for datafile 4 to "/u01/app/oracle/oradata/payme/tbs_1.dbf";
set newname for datafile 5 to "/u01/app/oracle/oradata/payme/users01.dbf";
set newname for datafile 6 to "/u01/app/oracle/oradata/payme/example01.dbf";
...
set newname for tempfile 1 to "/u01/app/oracle/oradata/payme/temp01.dbf";
set newname for tempfile 2 to "/u01/app/oracle/oradata/payme/temp_01.dbf";
set newname for tempfile 3 to "/u01/app/oracle/oradata/payme/TEMP21.dbf";
set newname for tempfile 4 to "/u01/app/oracle/oradata/payme/temp_pfpt.dbf";
release channel ch1;
release channel ch2;
release channel ch3;
release channel ch4;
restore database;
switch datafile all;
switch tempfile all;
recover database;
}

renamed tempfile 1 to /u01/app/oracle/oradata/payme/temp01.dbf in control file
renamed tempfile 2 to /u01/app/oracle/oradata/payme/temp_01.dbf in control file

Starting recover at 2019-11-08 16:17:31
using channel ORA_DISK_1

starting media recovery

channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=486
channel ORA_DISK_1: reading from backup piece /home/oracle/backup/arch_payme_20191108_34ugc7r6_1_1.bak
channel ORA_DISK_1: piece handle=/home/oracle/backup/arch_payme_20191108_34ugc7r6_1_1.bak tag=TAG20191108T160349
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=/u01/app/oracle/oradata/flash_recovery_area/arch_1021737825_1_486.arc thread=1 sequence=486
unable to find archived log
archived log thread=1 sequence=487
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 11/08/2019 16:17:33
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 487 and starting SCN of 69884756

Processing temp and redo log []
- If the instance to install a different path, or redo log and table space corresponding to the temporary file is not found on the target server
the SQL> COL A7 Status for
the SQL> COL type for A7;
the SQL> COL Member for A64;
SQL> the SELECT * from v $ logfile;

GROUP# STATUS TYPE MEMBER IS_RECOVE
---------- ------- ------- ---------------------------------------------------------------- ---------
1 ONLINE /u01/app/oracle/oradata/dbtest/actlog/redo01.log NO
2 ONLINE /u01/app/oracle/oradata/dbtest/actlog/redo02.log NO
3 ONLINE /u01/app/oracle/oradata/dbtest/actlog/redo03.log NO

show parameter standby_file_management;
--alter system set standby_file_management=MANUAL scope=both;

- new, old redo log directly clear path consistent can automatically generate a new redo log. Inconsistent with the first implementation of the ALTER
the ALTER the rename Database File '/u01/app/oracle/oradata/dbtest/actlog/redo01.log' to '/u01/app/oracle/oradata/flash_recovery_area/payme/onlinelog/redo01.log';
the ALTER database clear logfile group 1;

alter database rename file '/u01/app/oracle/oradata/dbtest/actlog/redo02.log' to '/u01/app/oracle/oradata/flash_recovery_area/payme/onlinelog/redo02.log';
alter database clear logfile group 2;

alter database rename file '/u01/app/oracle/oradata/dbtest/actlog/redo03.log' to '/u01/app/oracle/oradata/flash_recovery_area/payme/onlinelog/redo03.log';
alter database clear logfile group 3;

--resetlogs, observe alter the log to see if there are abnormal
SQL> alter database open resetlogs;

If the TEMP folder path is inconsistent, the first drop and then add, at this time we can open DB to
SQL> COL name for A80;
SQL> name from the SELECT v $ tempfile;

NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/payme/temp01.dbf
/u01/app/oracle/oradata/payme/temp_01.dbf

alter database tempfile '/u01/app/oracle/oradata/payme/temp01.dbf' drop;
alter database tempfile '/u01/app/oracle/oradata/payme/temp_01.dbf' drop;

/ *
--ORA-01109: the database needs to be added is not open in the open state
ALTER TABLESPACE TEMP the Add the tempfile '/u01/app/oracle/oradata/payme/temp01.dbf' size 100M AUTOEXTEND ON MAXSIZE Next 1OM 4G;
ALTER TABLESPACE TEMP the tempfile the Add '/u01/app/oracle/oradata/payme/temp_01.dbf' size 100M AUTOEXTEND ON MAXSIZE Next 1OM 4G;
* /

【创建spfile】
create spfile from pfile='$ORACLE_HOME/dbs/initpayme.ora';
create pfile from spfile;

[] Configuration environment variable
vi .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH
umask 022
export ORACLE_HOSTNAME=test154
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
#export ORACLE_SID=test154
export ORACLE_SID=payme
export PATH=.:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$ORACLE_HOME/jdk/bin:$PATH
export LC_ALL="en_US"
export LANG="zh_CN.UTF-8"
export NLS_LANG="SIMPLIFIED CHINESE_CHINA.AL32UTF8"
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"

alias sql="sqlplus '/as sysdba'"
set line 200
set pagesize 200
stty erase ^h
set _EDITOR=vi

alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'
alias dbs='cd /u01/app/oracle/product/11.2.0/dbhome_1/dbs/'
alias admin='cd /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/'
alias oralog='cd /u01/app/oracle/diag/rdbms/payme/payme/trace/'

Modify TNSNAME and LISTENER]

--TNSNAME
payme =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL= TCP)(HOST = 192.168.xx.154)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME =payme)
)
)

--LISTENER
LISTENER=
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST =192.168.xx.154)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY =EXTPROC1521))
)
)

SID_LIST_LISTENER=
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = payme)
(ORACLE_HOME =/u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME = payme)
)
)

ADR_BASE_LISTENER = /u01/app/oracle

Guess you like

Origin www.cnblogs.com/ritchy/p/11823011.html