复制密码文件
cp orapwwip /u01/product/10.2.0/db_1/dbs/
备库通过pfile启动到nomount状态,根据pfile创建spfile
[oracle@DataGuard rman]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.5.0 - Production on Mon Jan 9 17:47:38 2017
Copyright (c) 1982, 2010, Oracle. All Rights Reserved.
Connected to an idle instance.
SQL> startup nomount pfile='/mnt/rman/initorcl.ora'
ORACLE instance started.
Total System Global Area 3238002688 bytes
Fixed Size 2099784 bytes
Variable Size 654312888 bytes
Database Buffers 2566914048 bytes
Redo Buffers 14675968 bytes
SQL> create spfile from pfile='/mnt/rman/initorcl.ora';
File created.
SQL>
将数据库启动至mount状态
SQL> alter database mount;
Database altered.
通过rman恢复数据库至备库
[oracle@DataGuard rman]$ rman target/
Recovery Manager: Release 10.2.0.5.0 - Production on Mon Jan 9 17:54:35 2017
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: WIP (DBID=277772385, not open)
RMAN> restore database;
主库修改对于standby的tns地址
将主库的archivelog拷贝至备库
scp *.dbf root@10.55.1.204:/oradata/archivelog/
备库开启监听
[iyunv@DataGuard archivelog]# su - oracle
[oracle@DataGuard ~]$ lsnrctl start
备库recover主库拷贝过来的archivelog
[oracle@DataGuard ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.5.0 - Production on Mon Jan 9 20:19:07 2017
Copyright (c) 1982, 2010, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> recover standby database using backup controlfile until cancel;
ORA-00279: change 13449706423844 generated at 01/09/2017 14:51:38 needed for
thread 1
ORA-00289: suggestion : /oradata/archivelog/1_24855_751423971.dbf
ORA-00280: change 13449706423844 for thread 1 is in sequence #24855
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
AUTO
ORA-00279: change 13449706423844 generated at 01/09/2017 10:39:34 needed for
thread 2
ORA-00289: suggestion : /oradata/archivelog/2_14209_751423971.dbf
ORA-00280: change 13449706423844 for thread 2 is in sequence #14209
ORA-00279: change 13449706423844 generated at 01/09/2017 13:45:09 needed for
thread 3
ORA-00289: suggestion : /oradata/archivelog/3_13732_751423971.dbf
ORA-00280: change 13449706423844 for thread 3 is in sequence #13732
ORA-00279: change 13449706456434 generated at 01/09/2017 15:00:13 needed for
thread 2
ORA-00289: suggestion : /oradata/archivelog/2_14210_751423971.dbf
ORA-00280: change 13449706456434 for thread 2 is in sequence #14210
ORA-00278: log file '/oradata/archivelog/2_14209_751423971.dbf' no longer
needed for this recovery
ORA-00279: change 13449708067563 generated at 01/09/2017 16:23:20 needed for
thread 3
ORA-00289: suggestion : /oradata/archivelog/3_13733_751423971.dbf
ORA-00280: change 13449708067563 for thread 3 is in sequence #13733
ORA-00278: log file '/oradata/archivelog/3_13732_751423971.dbf' no longer
needed for this recovery
ORA-00279: change 13449708406961 generated at 01/09/2017 16:57:01 needed for
thread 1
ORA-00289: suggestion : /oradata/archivelog/1_24856_751423971.dbf
ORA-00280: change 13449708406961 for thread 1 is in sequence #24856
ORA-00278: log file '/oradata/archivelog/1_24855_751423971.dbf' no longer
needed for this recovery
ORA-00279: change 13449709361975 generated at 01/09/2017 17:29:34 needed for
thread 1
ORA-00289: suggestion : /oradata/archivelog/1_24857_751423971.dbf
ORA-00280: change 13449709361975 for thread 1 is in sequence #24857
ORA-00278: log file '/oradata/archivelog/1_24856_751423971.dbf' no longer
needed for this recovery
ORA-00279: change 13449709362031 generated at 01/09/2017 17:29:37 needed for
thread 3
ORA-00289: suggestion : /oradata/archivelog/3_13734_751423971.dbf
ORA-00280: change 13449709362031 for thread 3 is in sequence #13734
ORA-00278: log file '/oradata/archivelog/3_13733_751423971.dbf' no longer
needed for this recovery
ORA-00279: change 13449709362034 generated at 01/09/2017 17:29:37 needed for
thread 2
ORA-00289: suggestion : /oradata/archivelog/2_14211_751423971.dbf
ORA-00280: change 13449709362034 for thread 2 is in sequence #14211
ORA-00278: log file '/oradata/archivelog/2_14210_751423971.dbf' no longer
needed for this recovery
ORA-00279: change 13449709411751 generated at 01/09/2017 17:30:51 needed for
thread 2
ORA-00289: suggestion : /oradata/archivelog/2_14212_751423971.dbf
ORA-00280: change 13449709411751 for thread 2 is in sequence #14212
ORA-00278: log file '/oradata/archivelog/2_14211_751423971.dbf' no longer
needed for this recovery
ORA-00279: change 13449709411858 generated at 01/09/2017 17:30:52 needed for
thread 3
ORA-00289: suggestion : /oradata/archivelog/3_13735_751423971.dbf
ORA-00280: change 13449709411858 for thread 3 is in sequence #13735
ORA-00278: log file '/oradata/archivelog/3_13734_751423971.dbf' no longer
needed for this recovery
ORA-00279: change 13449709411887 generated at 01/09/2017 17:30:52 needed for
thread 1
ORA-00289: suggestion : /oradata/archivelog/1_24858_751423971.dbf
ORA-00280: change 13449709411887 for thread 1 is in sequence #24858
ORA-00278: log file '/oradata/archivelog/1_24857_751423971.dbf' no longer
needed for this recovery
ORA-00279: change 13449709412924 generated at 01/09/2017 17:31:19 needed for
thread 1
ORA-00289: suggestion : /oradata/archivelog/1_24859_751423971.dbf
ORA-00280: change 13449709412924 for thread 1 is in sequence #24859
ORA-00278: log file '/oradata/archivelog/1_24858_751423971.dbf' no longer
needed for this recovery
ORA-00308: cannot open archived log '/oradata/archivelog/1_24859_751423971.dbf'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01152: file 1 was not restored from a sufficiently old backup
ORA-01110: data file 1: '/oradata/wip/system01.dbf'
同步日志
SQL> recover managed standby database disconnect from session;
Media recovery complete.
关闭数据库并进行备库开启
startup nomount;
alter database mount standby database;
alter database recover managed standby database disconnect from session; 开启MRP
7、查看应用是否正常
确认同步:备库执行 RFS远程文件接收进程 MRP0日志应用进程
SQL> select process,status from v$managed_standby;
SQL> /
PROCESS STATUS
--------- ------------
ARCH CONNECTED
ARCH CONNECTED
MRP0 APPLYING_LOG
RFS IDLE
RFS IDLE
RFS IDLE
6 rows selected.
SQL> /
PROCESS STATUS
--------- ------------
ARCH CONNECTED
ARCH CONNECTED
MRP0 WAIT_FOR_LOG
RFS IDLE
RFS IDLE
RFS IDLE
SQL> SELECT SEQUENCE#,APPLIED FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;
SEQUENCE# APP
---------- ---
13735 YES
13736 YES
13737 YES
13738 YES
13739 YES
13740 YES
13741 YES
14212 YES
14213 YES
14214 YES
14215 YES
SEQUENCE# APP
---------- ---
14216 YES
14217 YES
14218 NO
24859 YES
24860 YES
24861 YES
24862 NO
18 rows selected.
SQL> select message from v$dataguard_status;
MESSAGE
--------------------------------------------------------------------------------
ARC0: Archival started
ARC1: Archival started
ARC0: Becoming the 'no FAL' ARCH
ARC0: Becoming the 'no SRL' ARCH
ARC1: Becoming the heartbeat ARCH
Attempt to start background Managed Standby Recovery process
MRP0: Background Managed Standby Recovery process started
Managed Standby Recovery not using Real Time Apply
Clearing online redo logfile 1 /oradata/wip/redo01.log
Clearing online redo logfile 1 complete
Media Recovery Waiting for thread 1 sequence 24859
MESSAGE
--------------------------------------------------------------------------------
Redo Shipping Client Connected as PUBLIC
-- Connected User is Valid
RFS[1]: Assigned to RFS process 23716
RFS[1]: Identified database type as 'physical standby'
Redo Shipping Client Connected as PUBLIC
-- Connected User is Valid
RFS[2]: Assigned to RFS process 23718
RFS[2]: Identified database type as 'physical standby'
Redo Shipping Client Connected as PUBLIC
-- Connected User is Valid
RFS[3]: Assigned to RFS process 23720
MESSAGE
--------------------------------------------------------------------------------
RFS[3]: Identified database type as 'physical standby'
Media Recovery Log /oradata/archivelog/1_24859_751423971.dbf
Media Recovery Waiting for thread 2 sequence 14212
Fetching gap sequence in thread 2, gap sequence 14212-14212
Error 12545 received logging on to the standby
FAL[client, MRP0]: Error 12545 connecting to wip1 for fetching gap sequence
Error 12545 received logging on to the standby
FAL[client, MRP0]: Error 12545 connecting to wip1 for fetching gap sequence
Media Recovery Log /oradata/archivelog/2_14212_751423971.dbf
Media Recovery Waiting for thread 3 sequence 13735
Fetching gap sequence in thread 3, gap sequence 13735-13735
MESSAGE
--------------------------------------------------------------------------------
Error 12545 received logging on to the standby
FAL[client, MRP0]: Error 12545 connecting to wip1 for fetching gap sequence
Redo Shipping Client Connected as PUBLIC
-- Connected User is Valid
RFS[4]: Assigned to RFS process 23729
RFS[4]: Identified database type as 'physical standby'
Redo Shipping Client Connected as PUBLIC
-- Connected User is Valid
RFS[5]: Assigned to RFS process 23731
RFS[5]: Identified database type as 'physical standby'
Error 12545 received logging on to the standby
MESSAGE
--------------------------------------------------------------------------------
FAL[client, MRP0]: Error 12545 connecting to wip1 for fetching gap sequence
Redo Shipping Client Connected as PUBLIC
-- Connected User is Valid
RFS[6]: Assigned to RFS process 23734
RFS[6]: Identified database type as 'physical standby'
Media Recovery Log /oradata/archivelog/3_13735_751423971.dbf
Media Recovery Log /oradata/archivelog/2_14213_751423971.dbf
Media Recovery Log /oradata/archivelog/3_13736_751423971.dbf
Media Recovery Waiting for thread 1 sequence 24860
Media Recovery Log /oradata/archivelog/1_24860_751423971.dbf
Media Recovery Log /oradata/archivelog/2_14214_751423971.dbf
MESSAGE
--------------------------------------------------------------------------------
Media Recovery Log /oradata/archivelog/3_13737_751423971.dbf
Media Recovery Waiting for thread 2 sequence 14215
Media Recovery Log /oradata/archivelog/2_14215_751423971.dbf
Media Recovery Waiting for thread 3 sequence 13738
Media Recovery Log /oradata/archivelog/3_13738_751423971.dbf
Media Recovery Waiting for thread 1 sequence 24861
Media Recovery Log /oradata/archivelog/1_24861_751423971.dbf
Media Recovery Log /oradata/archivelog/2_14216_751423971.dbf
Media Recovery Log /oradata/archivelog/3_13739_751423971.dbf
Media Recovery Log /oradata/archivelog/3_13740_751423971.dbf
Media Recovery Waiting for thread 2 sequence 14217
MESSAGE
--------------------------------------------------------------------------------
Media Recovery Log /oradata/archivelog/2_14217_751423971.dbf
Media Recovery Waiting for thread 3 sequence 13741
Media Recovery Log /oradata/archivelog/3_13741_751423971.dbf
Media Recovery Waiting for thread 1 sequence 24862
Media Recovery Log /oradata/archivelog/1_24862_751423971.dbf
Media Recovery Waiting for thread 2 sequence 14218
Media Recovery Log /oradata/archivelog/2_14218_751423971.dbf
Media Recovery Waiting for thread 3 sequence 13742
74 rows selected.
SQL> select switchover_status from v$database;
SWITCHOVER_STATUS
--------------------
SESSIONS ACTIVE
8、开启备份,制定备份计划
对时脚本添加
[iyunv@DataGuard ~]# crontab -l
#time
15 8 * * * /usr/sbin/ntpdate 10.53.1.9 &>/dev/null
备份脚本
#dbbackup
20 0 * * * /OCS/script/removebackup.sh
15 4 * * * /OCS/script/rman.sql
16 8 * * * /OCS/script/removearchive.sh
[iyunv@DataGuard script]# cat removearchive.sh
/usr/bin/find /oradata/archivelog -name '*.dbf' -mtime +6 > /OCS/script/rmlog
for i in `/bin/cat /OCS/script/rmlog`
do
/bin/rm -f $i
done
[iyunv@DataGuard script]# cat removebackup.sh
#/bin/ls
#/bin/rm
/usr/bin/find /mnt/rman -name 'oradb1*' > /OCS/script/rmlog
for i in `/bin/cat /OCS/script/rmlog`
do
/bin/rm -rf $i
done
[iyunv@DataGuard script]# cat rman.sql
su - oracle <<EOF
export ORACLE_SID=wip
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
sqlplus /nolog @/OCS/script/switch1.sql
rman target / @/OCS/script/rman_full_backup.sql >>/mnt/rman/log/RmanBackup_`date +%y%m%d`.log
/bin/mv /mnt/rman/oradb /mnt/rman/oradb`date +%y%m%d`
/bin/mkdir -p /mnt/rman/oradb
sqlplus /nolog @/OCS/script/switch2.sql
exit
EOF
[iyunv@DataGuard script]# cat rman_full_backup.sql
run{
sql 'alter database backup controlfile to trace';
backup database tag 'FULL' filesperset 1 format '/mnt/rman/oradb/%d_Full_%T_%u_%p_%c';
crosscheck archivelog all;
delete noprompt expired archivelog all;
crosscheck backup;
delete noprompt expired backup;
backup archivelog all filesperset 5 format '/mnt/rman/oradb/%d_LOG_%T_%u_%p_%c';
delete archivelog until time 'sysdate-7';
#backup filesperset 20 format 'al_%s_%p_%t' archivelog all delete input;
copy current controlfile to '/mnt/rman/oradb/CON_BACKUP.CTL';
delete noprompt obsolete;
}
exit
[iyunv@DataGuard script]# cat switch1.sql
connect / as sysdba
alter database recover managed standby database cancel ;
alter database open read only ;
exit
[iyunv@DataGuard script]# cat switch2.sql
connect / as sysdba
alter database recover managed standby database disconnect from session ;
exit
安装CA软件的agent,进行磁带备份