您好,登錄后才能下訂單哦!
利用rman duplicate同一主機(jī)上創(chuàng)建standby database.
OEL7.2
Oracle database 12.1.0.2.0
DB_NAME=S12102
|
primary |
standby |
parameter |
LOG_ARCHIVE_CONFIG='DG_CONFIG=(S12102,S12102D)' LOG_ARCHIVE_DEST_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=S12102' LOG_ARCHIVE_DEST_2='SERVICE=S12102D ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=S12102D' FAL_SERVER=S12102D FAL_CLIENT=S12102 STANDBY_FILE_MANAGEMENT=AUTO |
control_files='/u01/app/product/oradata/S12102D/control01.ctl','/u01/app/product/fast_recovery_area/S12102D/control02.ctl' DB_UNIQUE_NAME='S12102D' LOG_ARCHIVE_CONFIG='DG_CONFIG=(S12102D,S12102)' LOG_ARCHIVE_DEST_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=S12102D' LOG_ARCHIVE_DEST_2='SERVICE=S12102 ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=S12102' FAL_SERVER='S12102' FAL_CLIENT='S12102D' DB_FILE_NAME_CONVERT='/u01/app/product/oradata/S12102','/u01/app/product/oradata/S12102D' LOG_FILE_NAME_CONVERT='/u01/app/product/oradata/S12102','/u01/app/product/oradata/S12102D' STANDBY_FILE_MANAGEMENT='AUTO' |
Datafile dire |
/u01/app/product/oradata/S12102 |
/u01/app/product/oradata/S12102D |
shutdown immediate;
startup mount;
alter database archivelog;
alter database open;
create pfile from spfile;
ALTER DATABASE FORCE LOGGING;
ALTER DATABASE ADD STANDBY LOGFILE ('/u01/app/product/oradata/S12102/sredo01.log') SIZE 50M;
ALTER DATABASE ADD STANDBY LOGFILE ('/u01/app/product/oradata/S12102/sredo02.log') SIZE 50M;
ALTER DATABASE ADD STANDBY LOGFILE ('/u01/app/product/oradata/S12102/sredo03.log') SIZE 50M;
ALTER DATABASE ADD STANDBY LOGFILE ('/u01/app/product/oradata/S12102/sredo04.log') SIZE 50M;
--standby redo是在備庫(kù)上work的,主庫(kù)也可以添加,方便日后switchover改maxprotected模式時(shí)使用。添加在主庫(kù),在創(chuàng)建DataGuard時(shí),備庫(kù)自然也就有了,比較省事。-- The standby redo log must have at least one more redo log group than the redo log at the redo source database, for each redo thread at the redo source database. At the redo source database, query the V$LOG view to determine how many redo log groups are in the redo log at the redo source database and query the V$THREAD view to determine how many redo threads exist at the redo source database.
alter system set LOG_ARCHIVE_CONFIG='DG_CONFIG=(S12102,S12102D)';
alter system set LOG_ARCHIVE_DEST_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=S12102';
alter system set LOG_ARCHIVE_DEST_2='SERVICE=S12102D ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=S12102D' ;
alter system set FAL_SERVER=S12102D;
alter system set FAL_CLIENT=S12102;
alter system set STANDBY_FILE_MANAGEMENT=AUTO;
--此兩項(xiàng)需要重啟數(shù)據(jù)庫(kù)生效
alter system set DB_FILE_NAME_CONVERT='/u01/app/product/oradata/S12102D/','/u01/app/product/oradata/S12102' scope=spfile;
alter system set LOG_FILE_NAME_CONVERT='/u01/app/product/oradata/S12102D/','/u01/app/product/oradata/S12102' scope=spfile;
cd $ORACLE_HOME/dbs
cp initS12102.ora initS12102D.ora
cp orapwS12102 orapwS12102D
chmod 775 $TNS_ADMIN
編輯standby db參數(shù)文件,創(chuàng)建standby database目錄,配置standby系統(tǒng)環(huán)境變量略
[grid@localhost 12.1.0.2.0:(+ASM) network ] $ cat listener.ora
# listener.ora Network Configuration File: /u01/app/product/admin/network/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = S12102)
(ORACLE_HOME = /u01/app/product/database/12.1.0.2.0)
(SID_NAME = S12102)
)
(SID_DESC =
(GLOBAL_DBNAME = S12102D)
(ORACLE_HOME = /u01/app/product/database/12.1.0.2.0)
(SID_NAME = S12102D)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
ADR_BASE_LISTENER = /u01/app/product
[grid@localhost 12.1.0.2.0:(+ASM) network ] $ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/product/admin/network/tnsnames.ora
# Generated by Oracle configuration tools.
S12102D =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = S12102D)
)
)
S12102 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = S12102)
)
)
--備庫(kù)啟到nomount狀態(tài)略
rman target sys/oracle@S12102 auxiliary sys/oracle@S12102D
startup clone nomount;
run{
duplicate target database for standby from active database nofilenamecheck
SPFILE
set control_files='/u01/app/product/oradata/S12102D/control01.ctl','/u01/app/product/fast_recovery_area/S12102D/control02.ctl'
set DB_UNIQUE_NAME='S12102D'
set LOG_ARCHIVE_CONFIG='DG_CONFIG=(S12102D,S12102)'
set LOG_ARCHIVE_DEST_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=S12102D'
set LOG_ARCHIVE_DEST_2='SERVICE=S12102 ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=S12102'
set FAL_SERVER='S12102'
set FAL_CLIENT='S12102D'
set DB_FILE_NAME_CONVERT='/u01/app/product/oradata/S12102','/u01/app/product/oradata/S12102D'
set LOG_FILE_NAME_CONVERT='/u01/app/product/oradata/S12102','/u01/app/product/oradata/S12102D'
set STANDBY_FILE_MANAGEMENT='AUTO';
}
下面是duplicate過(guò)程詳細(xì)輸出
[oracle@localhost 12.1.0.2.0:(S12102) bin ] $ rman target sys/oracle@S12102 auxiliary sys/oracle@S12102D
Recovery Manager: Release 12.1.0.2.0 - Production on Fri Jun 1 17:35:24 2018
Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved.
connected to target database: S12102 (DBID=2197238228)
connected to auxiliary database (not started)
RMAN> startup clone nomount;
Oracle instance started
Total System Global Area 3070230528 bytes
Fixed Size 2929112 bytes
Variable Size 754978344 bytes
Database Buffers 2298478592 bytes
Redo Buffers 13844480 bytes
RMAN> run{
duplicate target database for standby from active database nofilenamecheck
SPFILE
set control_files='/u01/app/product/oradata/S12102D/control01.ctl','/u01/app/product/fast_recovery_area/S12102D/control02.ctl'
set DB_UNIQUE_NAME='S12102D'
set LOG_ARCHI2> 3> 4> 5> 6> VE_CONFIG='DG_CONFIG=(S12102D,S12102)'
set LOG_ARCHIVE_DEST_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=S12102D'
set LOG_ARCHIVE_DEST_2='SERVICE=S12102 ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NA7> 8> ME=S12102'
set FAL_SERVER='S12102'
set FAL_CLIENT='S12102D'
set DB_FILE_NAME_CONVERT='/u01/app/product/oradata/S12102','/u01/app/product/oradata/S12102D'
set LOG_FILE_NAME_CONVERT='/u01/app/product/oradata/S12102','/u01/app/product/oradata/S12102D'
set STA9> 10> 11> 12> 13> NDBY_FILE_MANAGEMENT='AUTO';
}
14>
Starting Duplicate Db at 01-JUN-2018 17:36:46
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=240 device type=DISK
contents of Memory Script:
{
backup as copy reuse
targetfile '/u01/app/product/database/12.1.0.2.0/dbs/orapwS12102' auxiliary format
'/u01/app/product/database/12.1.0.2.0/dbs/orapwS12102D' ;
restore clone from service 'S12102' spfile to
'/u01/app/product/database/12.1.0.2.0/dbs/spfileS12102D.ora';
sql clone "alter system set spfile= ''/u01/app/product/database/12.1.0.2.0/dbs/spfileS12102D.ora''";
}
executing Memory Script
Starting backup at 01-JUN-2018 17:36:47
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=37 device type=DISK
Finished backup at 01-JUN-2018 17:36:49
Starting restore at 01-JUN-2018 17:36:49
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service S12102
channel ORA_AUX_DISK_1: restoring SPFILE
output file name=/u01/app/product/database/12.1.0.2.0/dbs/spfileS12102D.ora
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 01-JUN-2018 17:36:50
sql statement: alter system set spfile= ''/u01/app/product/database/12.1.0.2.0/dbs/spfileS12102D.ora''
contents of Memory Script:
{
sql clone "alter system set control_files =
''/u01/app/product/oradata/S12102D/control01.ctl'', ''/u01/app/product/fast_recovery_area/S12102D/control02.ctl'' comment=
'''' scope=spfile";
sql clone "alter system set db_unique_name =
''S12102D'' comment=
'''' scope=spfile";
sql clone "alter system set LOG_ARCHIVE_CONFIG =
''DG_CONFIG=(S12102D,S12102)'' comment=
'''' scope=spfile";
sql clone "alter system set LOG_ARCHIVE_DEST_1 =
''LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=S12102D'' comment=
'''' scope=spfile";
sql clone "alter system set LOG_ARCHIVE_DEST_2 =
''SERVICE=S12102 ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=S12102'' comment=
'''' scope=spfile";
sql clone "alter system set FAL_SERVER =
''S12102'' comment=
'''' scope=spfile";
sql clone "alter system set FAL_CLIENT =
''S12102D'' comment=
'''' scope=spfile";
sql clone "alter system set db_file_name_convert =
''/u01/app/product/oradata/S12102'', ''/u01/app/product/oradata/S12102D'' comment=
'''' scope=spfile";
sql clone "alter system set LOG_FILE_NAME_CONVERT =
''/u01/app/product/oradata/S12102'', ''/u01/app/product/oradata/S12102D'' comment=
'''' scope=spfile";
sql clone "alter system set STANDBY_FILE_MANAGEMENT =
''AUTO'' comment=
'''' scope=spfile";
shutdown clone immediate;
startup clone nomount;
}
executing Memory Script
sql statement: alter system set control_files = ''/u01/app/product/oradata/S12102D/control01.ctl'', ''/u01/app/product/fast_recovery_area/S12102D/control02.ctl'' comment= '''' scope=spfile
sql statement: alter system set db_unique_name = ''S12102D'' comment= '''' scope=spfile
sql statement: alter system set LOG_ARCHIVE_CONFIG = ''DG_CONFIG=(S12102D,S12102)'' comment= '''' scope=spfile
sql statement: alter system set LOG_ARCHIVE_DEST_1 = ''LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=S12102D'' comment= '''' scope=spfile
sql statement: alter system set LOG_ARCHIVE_DEST_2 = ''SERVICE=S12102 ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=S12102'' comment= '''' scope=spfile
sql statement: alter system set FAL_SERVER = ''S12102'' comment= '''' scope=spfile
sql statement: alter system set FAL_CLIENT = ''S12102D'' comment= '''' scope=spfile
sql statement: alter system set db_file_name_convert = ''/u01/app/product/oradata/S12102'', ''/u01/app/product/oradata/S12102D'' comment= '''' scope=spfile
sql statement: alter system set LOG_FILE_NAME_CONVERT = ''/u01/app/product/oradata/S12102'', ''/u01/app/product/oradata/S12102D'' comment= '''' scope=spfile
sql statement: alter system set STANDBY_FILE_MANAGEMENT = ''AUTO'' comment= '''' scope=spfile
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 3070230528 bytes
Fixed Size 2929112 bytes
Variable Size 754978344 bytes
Database Buffers 2298478592 bytes
Redo Buffers 13844480 bytes
contents of Memory Script:
{
restore clone from service 'S12102' standby controlfile;
}
executing Memory Script
Starting restore at 01-JUN-2018 17:37:39
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=12 device type=DISK
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service S12102
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:04
output file name=/u01/app/product/oradata/S12102D/control01.ctl
output file name=/u01/app/product/fast_recovery_area/S12102D/control02.ctl
Finished restore at 01-JUN-2018 17:37:44
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
"/u01/app/product/oradata/S12102D/temp01.dbf";
switch clone tempfile all;
set newname for datafile 1 to
"/u01/app/product/oradata/S12102D/system01.dbf";
set newname for datafile 3 to
"/u01/app/product/oradata/S12102D/sysaux01.dbf";
set newname for datafile 4 to
"/u01/app/product/oradata/S12102D/undotbs01.dbf";
set newname for datafile 5 to
"/u01/app/product/oradata/S12102D/example01.dbf";
set newname for datafile 6 to
"/u01/app/product/oradata/S12102D/users01.dbf";
restore
from service 'S12102' clone database
;
sql 'alter system archive log current';
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to /u01/app/product/oradata/S12102D/temp01.dbf in control file
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 01-JUN-2018 17:37:50
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service S12102
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to /u01/app/product/oradata/S12102D/system01.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:36
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service S12102
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00003 to /u01/app/product/oradata/S12102D/sysaux01.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:35
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service S12102
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00004 to /u01/app/product/oradata/S12102D/undotbs01.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:16
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service S12102
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00005 to /u01/app/product/oradata/S12102D/example01.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:06
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service S12102
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00006 to /u01/app/product/oradata/S12102D/users01.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02
Finished restore at 01-JUN-2018 17:40:25
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=1 STAMP=977679627 file name=/u01/app/product/oradata/S12102D/system01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=977679627 file name=/u01/app/product/oradata/S12102D/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=977679627 file name=/u01/app/product/oradata/S12102D/undotbs01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=4 STAMP=977679627 file name=/u01/app/product/oradata/S12102D/example01.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=5 STAMP=977679627 file name=/u01/app/product/oradata/S12102D/users01.dbf
Finished Duplicate Db at 01-JUN-2018 17:40:46
RMAN>
當(dāng)監(jiān)聽(tīng)由gird用戶啟動(dòng)時(shí),注意$TNS_ADMIN目錄權(quán)限應(yīng)為775。
https://docs.oracle.com/database/121/SBYDB/rcmbackp.htm#SBYDB4987
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。