yq:192.168.56.102
yq01:192.168.56.109
主库监听
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(ORACLE_HOME =/oracle/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME = ORCL)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST =192.168.56.102)(PORT = 1521))
)
)
tnsnames.ora文件
ORCL_PRI =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.102)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ORCL_PRI)
)
)
ORCL_STY =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.109)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ORCL_STY)
)
)
主库参数修改
startup mount;
alter database archivelog;
alter database force logging;
alter database open;
alter system set log_archive_config = 'DG_CONFIG=(orcl_pri,orcl_sty)' scope=spfile;
alter system set log_archive_dest_1 = 'LOCATION=/oracle/app/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=orcl_pri' scope=spfile;
alter system set log_archive_dest_2 = 'SERVICE=orcl_sty LGWR SYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=orcl_sty' scope=spfile;
alter system set log_archive_dest_state_1 = ENABLE;
alter system set log_archive_dest_state_2 = ENABLE;
alter system set fal_server=orcl_sty scope=spfile;
alter system set fal_client=orcl_pri scope=spfile;
alter system set standby_file_management=AUTO scope=spfile;
在primary端pfile参数文件和密码文件,并且拷贝到standby段相应路径
SQL> create pfile='/oracle/backup/pfile0523.ora' from spfile;
scp orapworcl oracle@192.168.56.109:/oracle/backup
scp pfile0523.ora oracle@192.168.56.109:/oracle/backup
backup as compressed backupset full database include current controlfile for standby format '/oracle/backup/db_%T_%s_%p.bak' plus archivelog format '/oracle/backup/archfull_%T_%s_%p.bak';
备库监听设置
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(ORACLE_HOME =/oracle/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME = ORCL)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST =192.168.56.109)(PORT = 1521))
)
)
重启监听正常即可
启动备库到nomount状态
SQL> startup nomount pfile='/oracle/backup/pfile0523.ora';
ORA-09925: Unable to create audit trail file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 9925
设置告警日志文件路径
pfile文件中有记录
*.audit_file_dest='/oracle/app/oracle/admin/orcl/adump'
mkdir -p /oracle/app/oracle/admin/orcl/adump
先关闭再启动
SQL> shutdown immediate
ORA-01507: database not mounted
ORACLE instance shut down.
SQL> startup nomount pfile='/oracle/backup/pfile0523.ora';
ORACLE instance started.
Total System Global Area 784998400 bytes
Fixed Size 2232472 bytes
Variable Size 465571688 bytes
Database Buffers 314572800 bytes
Redo Buffers 2621440 bytes
SQL>
创建spfile二进制文件
SQL> create spfile from pfile='/oracle/backup/pfile0523.ora';
File created.
重启数据库,以spfile文件启动
SQL> shutdown immediate
ORA-01507: database not mounted
ORACLE instance shut down.
SQL>
SQL>
SQL> startup nomount
ORACLE instance started.
Total System Global Area 784998400 bytes
Fixed Size 2232472 bytes
Variable Size 465571688 bytes
Database Buffers 314572800 bytes
Redo Buffers 2621440 bytes
SQL> show parameter spfile
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string /oracle/app/oracle/product/11.
2.0/dbhome_1/dbs/spfileorcl.or
a
alter system set db_unique_name=orcl_sty scope=spfile;
alter system set log_archive_config='DG_CONFIG=(orcl_pri,orcl_sty)' scope=spfile;
alter system set log_archive_dest_1 = 'LOCATION=/oracle/app/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=orcl_sty' scope=spfile;
alter system set log_archive_dest_2 = 'SERVICE=orcl_pri LGWR SYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=orcl_pri' scope=spfile;
alter system set fal_server=orcl_pri scope=spfile;
alter system set fal_client=orcl_sty scope=spfile;
主库进行DUPLICATE
[oracle@yq admin]$ rman target sys/oracle@orcl_pri auxiliary sys/oracle@orcl_sty nocatalog
Recovery Manager: Release 11.2.0.3.0 - Production on Mon May 22 03:36:03 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL (DBID=1472386011)
using target database control file instead of recovery catalog
connected to auxiliary database: ORCL (not mounted)
RMAN>
RMAN>
RMAN> duplicate target database for standby from active database nofilenamecheck;
Starting Duplicate Db at 22-MAY-17
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=18 device type=DISK
contents of Memory Script:
{
backup as copy reuse
targetfile '/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/orapworcl' auxiliary format
'/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/orapworcl' ;
}
executing Memory Script
Starting backup at 22-MAY-17
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=39 device type=DISK
Finished backup at 22-MAY-17
contents of Memory Script:
{
backup as copy current controlfile for standby auxiliary format '/oracle/app/oracle/orcl/control01.ctl';
restore clone controlfile to '/oracle/app/oracle/fast_recovery_area/orcl/control02.ctl' from
'/oracle/app/oracle/orcl/control01.ctl';
}
executing Memory Script
Starting backup at 22-MAY-17
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
copying standby control file
output file name=/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_orcl.f tag=TAG20170522T033617 RECID=2 STAMP=944624179
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
Finished backup at 22-MAY-17
Starting restore at 22-MAY-17
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: copied control file copy
Finished restore at 22-MAY-17
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 newname for tempfile 1 to
"/oracle/app/oracle/orcl/temp01.dbf";
switch clone tempfile all;
set newname for datafile 1 to
"/oracle/app/oracle/orcl/system01.dbf";
set newname for datafile 2 to
"/oracle/app/oracle/orcl/sysaux01.dbf";
set newname for datafile 3 to
"/oracle/app/oracle/orcl/undotbs01.dbf";
set newname for datafile 4 to
"/oracle/app/oracle/orcl/users01.dbf";
backup as copy reuse
datafile 1 auxiliary format
"/oracle/app/oracle/orcl/system01.dbf" datafile
2 auxiliary format
"/oracle/app/oracle/orcl/sysaux01.dbf" datafile
3 auxiliary format
"/oracle/app/oracle/orcl/undotbs01.dbf" datafile
4 auxiliary format
"/oracle/app/oracle/orcl/users01.dbf" ;
sql 'alter system archive log current';
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to /oracle/app/oracle/orcl/temp01.dbf in control file
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting backup at 22-MAY-17
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=/oracle/app/oracle/orcl/system01.dbf
output file name=/oracle/app/oracle/orcl/system01.dbf tag=TAG20170522T033635
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:36
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=/oracle/app/oracle/orcl/undotbs01.dbf
output file name=/oracle/app/oracle/orcl/undotbs01.dbf tag=TAG20170522T033635
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:26
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=/oracle/app/oracle/orcl/sysaux01.dbf
output file name=/oracle/app/oracle/orcl/sysaux01.dbf tag=TAG20170522T033635
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:07
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/oracle/app/oracle/orcl/users01.dbf
output file name=/oracle/app/oracle/orcl/users01.dbf tag=TAG20170522T033635
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 22-MAY-17
sql statement: alter system archive log current
contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script
datafile 1 switched to datafile copy
input datafile copy RECID=2 STAMP=944625285 file name=/oracle/app/oracle/orcl/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=3 STAMP=944625285 file name=/oracle/app/oracle/orcl/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=4 STAMP=944625285 file name=/oracle/app/oracle/orcl/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=5 STAMP=944625285 file name=/oracle/app/oracle/orcl/users01.dbf
Finished Duplicate Db at 22-MAY-17
主备库同时增加standby日志组
alter database add standby logfile
group 4 ('/oracle/app/oracle/orcl/styredo04.log') size 50m,
group 5 ('/oracle/app/oracle/orcl/styredo05.log') size 50m,
group 6 ('/oracle/app/oracle/orcl/styredo06.log') size 50m,
group 7 ('/oracle/app/oracle/orcl/styredo07.log') size 50m;
查询standby日志组
SELECT GROUP#,THREAD#,SEQUENCE#,ARCHIVED,STATUS FROM V$STANDBY_LOG;
备库开启实时应用
recover managed standby database using current logfile disconnect from session;
查询备库应用日志状态
select process,client_process,sequence#,status from v$managed_standby;
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/31467250/viewspace-2140662/
,如需转载,请注明出处,否则将追究法律责任。