时间:2021-07-01 10:21:17 帮助过:10人阅读
[oracle@powerlong5 ~]$ rman target sys/syspl1758@PD1 auxiliary /
Recovery Manager: Release 11.2.0.1.0 - Production on Sat Feb 7 19:08:16 2015
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: POWERDES (DBID=3391761643)
connected to auxiliary database: POWERDES (not mounted)
RMAN> run {
allocate auxiliary channel c1 device type disk;
allocate auxiliary channel c2 device type disk;
duplicate target database for standby nofilenamecheck dorecover;
release channel c1;
release channel c2;
}
2> 3> 4> 5> 6> 7>
using target database control file instead of recovery catalog
allocated channel: c1
channel c1: SID=767 device type=DISK
allocated channel: c2
channel c2: SID=1150 device type=DISK
Starting Duplicate Db at 07-FEB-15
contents of Memory Script:
{
set until scn 10903678943;
restore clone standby controlfile;
}
executing Memory Script
executing command: SET until clause
Starting restore at 07-FEB-15
channel c1: starting datafile backup set restore
channel c1: restoring control file
channel c1: reading from backup piece /oracle/app/oracle/flash_recovery_area/PDUNQ/backupset/2015_02_07/o1_mf_ncsnf_TAG20150207T182252_bfct20tb_.bkp
channel c1: piece handle=/oracle/app/oracle/flash_recovery_area/PDUNQ/backupset/2015_02_07/o1_mf_ncsnf_TAG20150207T182252_bfct20tb_.bkp tag=TAG20150207T182252
channel c1: restored backup piece 1
channel c1: restore complete, elapsed time: 00:00:01
output file name=/oracle/data_ora/powerdes/control01.ctl
output file name=/oracle/app/oracle/flash_recovery_area/powerdes/control02.ctl
Finished restore at 07-FEB-15
contents of Memory Script:
{
sql clone \‘alter database mount standby database\‘;
}
executing Memory Script
sql statement: alter database mount standby database
contents of Memory Script:
{
set until scn 10903678943;
set newname for datafile 1 to
\"/home/oradata/pwerdes/system01.dbf\";
set newname for datafile 2 to
\"/home/oradata/pwerdes/sysaux01.dbf\";
set newname for datafile 3 to
\"/home/oradata/pwerdes/undotbs01.dbf\";
set newname for datafile 4 to
\"/home/oradata/pwerdes/users01.dbf\";
set newname for datafile 6 to
\"/home/oradata/pwerdes/plas01.dbf\";
set newname for datafile 7 to
\"/home/oradata/pwerdes/pl01.dbf\";
set newname for datafile 8 to
\"/home/oradata/pwerdes/help01.dbf\";
set newname for datafile 9 to
\"/home/oradata/pwerdes/adobelc01.dbf\";
set newname for datafile 10 to
\"/home/oradata/pwerdes/sms01.dbf\";
restore
clone database
;
}
executing Memory Script
executing command: SET until clause
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 07-FEB-15
channel c1: starting datafile backup set restore
channel c1: specifying datafile(s) to restore from backup set
channel c1: restoring datafile 00001 to /home/oradata/pwerdes/system01.dbf
channel c1: restoring datafile 00002 to /home/oradata/pwerdes/sysaux01.dbf
channel c1: restoring datafile 00003 to /home/oradata/pwerdes/undotbs01.dbf
channel c1: restoring datafile 00004 to /home/oradata/pwerdes/users01.dbf
channel c1: restoring datafile 00006 to /home/oradata/pwerdes/plas01.dbf
channel c1: restoring datafile 00007 to /home/oradata/pwerdes/pl01.dbf
channel c1: restoring datafile 00008 to /home/oradata/pwerdes/help01.dbf
channel c1: restoring datafile 00009 to /home/oradata/pwerdes/adobelc01.dbf
channel c1: restoring datafile 00010 to /home/oradata/pwerdes/sms01.dbf
channel c1: reading from backup piece /oracle/app/oracle/flash_recovery_area/PDUNQ/backupset/2015_02_07/o1_mf_nnndf_TAG20150207T182252_bfcsvxoz_.bkp
channel c1: piece handle=/oracle/app/oracle/flash_recovery_area/PDUNQ/backupset/2015_02_07/o1_mf_nnndf_TAG20150207T182252_bfcsvxoz_.bkp tag=TAG20150207T182252
channel c1: restored backup piece 1
channel c1: restore complete, elapsed time: 00:04:05
Finished restore at 07-FEB-15
contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script
datafile 1 switched to datafile copy
input datafile copy RECID=3 STAMP=871067691 file name=/home/oradata/pwerdes/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=4 STAMP=871067691 file name=/home/oradata/pwerdes/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=5 STAMP=871067691 file name=/home/oradata/pwerdes/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=6 STAMP=871067691 file name=/home/oradata/pwerdes/users01.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=7 STAMP=871067691 file name=/home/oradata/pwerdes/plas01.dbf
datafile 7 switched to datafile copy
input datafile copy RECID=8 STAMP=871067691 file name=/home/oradata/pwerdes/pl01.dbf
datafile 8 switched to datafile copy
input datafile copy RECID=9 STAMP=871067691 file name=/home/oradata/pwerdes/help01.dbf
datafile 9 switched to datafile copy
input datafile copy RECID=10 STAMP=871067692 file name=/home/oradata/pwerdes/adobelc01.dbf
datafile 10 switched to datafile copy
input datafile copy RECID=11 STAMP=871067692 file name=/home/oradata/pwerdes/sms01.dbf
contents of Memory Script:
{
set until scn 10903678943;
recover
standby
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 07-FEB-15
starting media recovery
archived log for thread 1 with sequence 302 is already on disk as file /oracle/app/oracle/flash_recovery_area/archivelog/1_302_870804216.dbf
archived log file name=/oracle/app/oracle/flash_recovery_area/archivelog/1_302_870804216.dbf thread=1 sequence=302
media recovery complete, elapsed time: 00:00:00
Finished recover at 07-FEB-15
Finished Duplicate Db at 07-FEB-15
released channel: c1
released channel: c2
RMAN> exit
3.7 standby上修改参数文件
先关闭oracle
shutdown immediate
然后开始修改参数文件
cd $ORACLE_HOME/dbs
vim initpowerdes.ora
# 主要是修改db_unique_name
*.db_unique_name=‘pdunq_dg‘
*.diagnostic_dest=‘/oracle/app/oracle‘
*.dispatchers=‘(PROTOCOL=TCP) (SERVICE=powerdesXDB)‘
*.fal_client=‘PD1‘
*.fal_server=‘PD2‘
*.global_names=FALSE
*.job_queue_processes=1000
*.log_archive_config=‘DG_CONFIG=(pdunq,pddgunq)‘
重新创建参数文件
create spfile from pfile;
3.8 启动数据库
startup nomount;
alter database mount standby database;
alter database add standby logfile;
alter database add standby logfile;
alter database add standby logfile;
alter database recover managed standby database using current logfile disconnect from session;
4,检查看到归档没有过来
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination ?/dbs/arch
Oldest online log sequence 0
Next log sequence to archive 0
Current log sequence 0
SQL>
看到归档信息为0,说明primary上的redo日志没有传到standby上来。
4.1,查看alert日志
[oracle@powerlong5 trace]$ tail -f /oracle/app/oracle/diag/rdbms/pdunq_dg/powerdes/trace/alert_powerdes.log
MRP0 started with pid=41, OS id=21243
MRP0: Background Managed Standby Recovery process started (powerdes)
started logmerger process
Sat Feb 07 20:12:18 2015
Managed Standby Recovery not using Real Time Apply
Parallel Media Recovery started with 4 slaves
Waiting for all non-current ORLs to be archived...
All non-current ORLs have been archived.
Media Recovery Waiting for thread 1 sequence 303
Completed: alter database recover managed standby database disconnect from session
查看日志传输情况
select sequence#,first_time,next_time from v$archived_log;
SELECT sequence#,to_char(first_time,‘yyyy-mm-dd hh24:mi:ss‘) first_time,to_char(next_time,‘yyyy-mm-dd hh24:mi:ss‘) next_time from v$archived_log;
primary :
问题分析解决:
primary主库上的alert日志有错:
Error 12154 received logging on to the standby
Errors in file /oracle/app/oracle/diag/rdbms/pdunq/powerdes/trace/powerdes_arc2_22609.trc:
ORA-12154: TNS:could not resolve the connect identifier specified
PING[ARC2]: Heartbeat failed to connect to standby ‘pdunq_dg‘. Error is 12154.
错误很清晰了,主库无法检测到从库存在
tns 12154 错误,主库无法 tnsping pdunq_dg
tnsping standby库报错
[oracle@powerlong4 admin]$ tnsping pdunq_dg
TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 08-FEB-2015 21:42:26
Copyright (c) 1997, 2009, Oracle. All rights reserved.
Used parameter files:
TNS-03505: Failed to resolve name
[oracle@powerlong4 admin]$
参数文件里面
*.log_archive_dest_2=‘SERVICE=pdunq_dg lgwr sync affirm VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=pdunq_dg‘
SERVICE=pdunq_dg 要和tnsnames.ora里面的保持一致。
4.2,去tnsnames.ora里面修改配置
去把tnsnames.ora里面的改成pdunq_dg即可。
重启lsnrctl,然后查看从库归档日志,有日志了,如下所示:
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 350
Next log sequence to archive 0
Current log sequence 351
SQL>
备库切换到open状态:
退出redo应用状态
SQL> alter database recover managed standby database cancel;
Database altered.
PS:停止standby的redo应用 ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;注意,此时只是暂时redo 应用,并不是停止Standby 数据库,standby 仍会保持接收只不过不会再应用接收到的归档,直到你再次启动redo 应用为止。类似mysql里面的stop slave功能;
打开standby上的oracle库
SQL> alter database open;
Database altered.
再应用redo日志
SQL> alter database recover managed standby database using current logfile disconnect ;
Database altered.
SQL>
去primary、standby库上面执行检查
SQL> select sequence#,applied from v$archived_log;
查看最新的scn:
SQL> select max(sequence#) from v$archived_log;
primary和standby都保持一致,OK,dataguard搭建完成。
本文出自 “青天飞云” 博客,谢绝转载!
ORACLE 11G 搭建dataguard详细步骤(所有操作总结)
标签:oracle 容灾