In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Under Oracle 10g, we can use the RMAN duplicate command to create a replication library with different DBID. When it comes to Oracle 11gR2, RMAN's duplicate can be implemented in two ways:
1. Active database duplication
2. Backup-based duplication
Active database duplication through the network, directly copy target the library to the auxiliary library, and then create a replication library. This approach eliminates the need to back up the database with RMAN and then send the backup files to the auxiliary side.
The function of this function is very great. Especially for T-level libraries. Because it is very expensive to back up such a library and then send the backup set to the standby library, it is very expensive to duplicate. First, the backup takes time, second, it takes up backup space, and third, when it is transmitted through the network, it also needs to occupy bandwidth and time. So Active database duplicate solves the above problems very well. It is very useful for the migration of large libraries.
If it is from RAC duplicate to single instance, the operation is the same. If it is from single instance duplicate to RAC. Then duplicate to a single instance first. Then convert the single instance to RAC.
For examples of Rman duplicate under Oracle 10g, please see:
RMAN off-machine replication database
Http://blog.csdn.net/tianlesoftware/archive/2010/07/20/5749932.aspx
Let's take a look at the steps of Active Database Duplicate under 11gR2:
1. Create the Initialization Parameter of the Auxiliary library:
If you use spfile, you only need to set one DB_NAME parameter in the pfile file, and the other parameters will be set yourself in the duplicate command.
If you use pfile, you need to set the following parameters:
DB_NAME
CONTROL_FILES
DB_BLOCK_SIZE
DB_FILE_NAME_CONVERT
LOG_FILE_NAME_CONVERT
DB_RECOVERY_FILE_DEST
two。 Create a Password File file in the Auxiliary library
It is not necessary for Backup-based duplication,Password File, but it is necessary for Active Database Duplication,Password File. Because Active Database Duplication uses the same SYSDBA password to connect directly to the auxiliary library. Therefore, it is important to ensure that the SYSDBA password of the target library is as important as the SYSDBA password of the Auxiliary library.
Of course, we can also add the PASSWORD FILE option (which is also the default) to the duplicate command, so that RMAN will also copy the password file from the target library when copy, and if Password file already exists on the auxiliary library, this operation will overwrite that file.
Such as:
RMAN > DUPLICATE TARGET DATABASE TO Dave
2 > FROM ACTIVE DATABASE
3 > NOFILENAMECHECK
4 > PASSWORD FILE
5 > SPFILE
3. If it is a windows platform, you also need to create a Database service:
% set ORACLE_SID=DAVE
% set ORACLE_HOME=E:/oracle/product/11.1.0/db_1
% oradim-NEW-SID DAVE
4. Configure oracle net, modify listener.ora and the tnsnames.ora files:
Both the Target library and Auxiliary need to be modified. This can also be configured using the netca and netmgr commands.
Listener.ora
[oracle@qs-dmm-rh2 admin] $cat listener.ora
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = localhost6.localdomain6) (PORT = 1521))
)
)
ADR_BASE_LISTENER = / u01/app/oracle
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orcl)
(ORACLE_HOME = / u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME = orcl)
)
)
Tnsname.ora
[oracle@qs-dmm-rh2 admin] $cat tnsnames.ora
ORCL_ST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.2.43) (PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
ORCL_PD =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.2.42) (PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
5. Start Auxiliary to the nomout state using the pfile file created in the first step. Then Active Database duplicate is performed.
Let's look at a complete example of replication:
Target DB:
IP: 192.168.2.42
SID:orcl
Auxiliary:
IP:192.168.2.43
SID:orcl
The directory I copied here is the same. If different, you need to add db_file_name_convert and log_file_name_convert to the pfile.
1. Create a pfile parameter file in Auxiliary:
[oracle@qs-dmm-rh3 dbs] $pwd
/ u01/app/oracle/product/11.2.0/dbhome_1/dbs
[oracle@qs-dmm-rh3 dbs] $cat initorcl.ora
DB_NAME=orcl
There is only one parameter: DB_NAME
two。 Create a password file on the Auxiliary library
[oracle@qs-dmm-rh3 admin] $orapwd file=?/dbs/orapworcl password=oracle
3. Create the relevant directory structure in the Auxiliary library:
[oracle@qs-dmm-rh3 trace] $mkdir-p / u01/app/oracle/oradata/orcl
Otherwise, the following error will be reported in duplicate:
ORA-19505: failed to identify file "/ u01/app/oracle/oradata/orcl/users01.dbf"
ORA-27040: file create error, unable to create file
4. Start Auxiliary to nomout status:
[oracle@qs-dmm-rh3 admin] $sqlplus / nolog
SQL*Plus: Release 11.2.0.1.0 Production on Tue Mar 8 00:28:48 2011
Copyright (c) 1982, 2009, Oracle. All rights reserved.
SQL > conn / as sysdba
Connected to an idle instance.
SQL > startup nomount pfile=?/dbs/initorcl.ora
ORACLE instance started.
Total System Global Area 146472960 bytes
Fixed Size 1335080 bytes
Variable Size 92274904 bytes
Database Buffers 50331648 bytes
Redo Buffers 2531328 bytes
SQL >
5. Configure Oracle Net (Listener.ora and tnsnames.ora) on both Target and Auxiliary:
[oracle@qs-dmm-rh2 admin] $cat listener.ora
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = localhost6.localdomain6) (PORT = 1521))
)
)
ADR_BASE_LISTENER = / u01/app/oracle
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orcl)
(ORACLE_HOME = / u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME = orcl)
)
)
[oracle@qs-dmm-rh2 admin] $cat tnsnames.ora
ORCL_ST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.2.43) (PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
ORCL_PD =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.2.42) (PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
6. Start RMAN duplicate from active database:
Note: if the directory structure of target and Auxiliary libraries is the same, remember to add the nofilenamecheck parameter, otherwise the following error will be reported:
RMAN-05001: auxiliary file name / u01/app/oracle/oradata/orcl/users01.dbf conflicts with a file used by the target database
If the directory is different, add the following two parameters to the pfile to convert:
Db_file_name_convert
Log_file_name_convert.
[oracle@qs-dmm-rh3 dbs] $rman target sys/oracle@orcl_pd auxiliary sys/oracle@orcl_st
Recovery Manager: Release 11.2.0.1.0-Production on Tue Mar 8 01:01:42 2011
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Connected to target database: ORCL (DBID=1272955137)
Connected to auxiliary database: ORCL (not mounted)
RMAN > duplicate target database to orcl from active database nofilenamecheck
Starting Duplicate Db at 08-MAR-11
Using target database control file instead of recovery catalog
Allocated channel: ORA_AUX_DISK_1
Channel ORA_AUX_DISK_1: SID=20 device type=DISK
Contents of Memory Script:
{
Sql clone "create spfile from memory"
}
Executing Memory Script
Sql statement: create spfile from memory
Contents of Memory Script:
{
Shutdown clone immediate
Startup clone nomount
}
Executing Memory Script
Oracle instance shut down
Connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 146472960 bytes
Fixed Size 1335080 bytes
Variable Size 92274904 bytes
Database Buffers 50331648 bytes
Redo Buffers 2531328 bytes
Contents of Memory Script:
{
Sql clone "alter system set db_name =
'' ORCL'' comment=
'' Modified by RMAN duplicate'' scope=spfile''
Sql clone "alter system set db_unique_name =
'' ORCL'' comment=
'' Modified by RMAN duplicate'' scope=spfile''
Shutdown clone immediate
Startup clone force nomount
Backup as copy current controlfile auxiliary format'/ u01qapplash oracle.productUniverse 11.2.0According to dbsAccord cntrlorcl.dbf'
Alter clone database mount
}
Executing Memory Script
Sql statement: alter system set db_name =''ORCL'' comment=' 'Modified by RMAN duplicate'' scope=spfile
Sql statement: alter system set db_unique_name =''ORCL'' comment=' 'Modified by RMAN duplicate'' scope=spfile
Oracle instance shut down
Oracle instance started
Total System Global Area 146472960 bytes
Fixed Size 1335080 bytes
Variable Size 92274904 bytes
Database Buffers 50331648 bytes
Redo Buffers 2531328 bytes
Starting backup at 08-MAR-11
Allocated channel: ORA_DISK_1
Channel ORA_DISK_1: SID=43 device type=DISK
Channel ORA_DISK_1: starting datafile copy
Copying current control file
Output file name=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_orcl.f tag=TAG20110308T010214 RECID=3 STAMP=745203735
Channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 08-MAR-11
Database mounted
Contents of Memory Script:
{
Set newname for datafile 1 to
"/ u01/app/oracle/oradata/orcl/system01.dbf"
Set newname for datafile 2 to
"/ u01/app/oracle/oradata/orcl/sysaux01.dbf"
Set newname for datafile 3 to
"/ u01/app/oracle/oradata/orcl/undotbs01.dbf"
Set newname for datafile 4 to
"/ u01/app/oracle/oradata/orcl/users01.dbf"
Backup as copy reuse
Datafile 1 auxiliary format
"/ u01/app/oracle/oradata/orcl/system01.dbf" datafile
2 auxiliary format
"/ u01/app/oracle/oradata/orcl/sysaux01.dbf" datafile
3 auxiliary format
"/ u01/app/oracle/oradata/orcl/undotbs01.dbf" datafile
4 auxiliary format
"/ u01/app/oracle/oradata/orcl/users01.dbf"
Sql 'alter system archive log current'
}
Executing Memory Script
Executing command: SET NEWNAME
Executing command: SET NEWNAME
Executing command: SET NEWNAME
Executing command: SET NEWNAME
Starting backup at 08-MAR-11
Using channel ORA_DISK_1
Channel ORA_DISK_1: starting datafile copy
-- start the copy data file here, which is slow.
Input datafile file number=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
Output file name=/u01/app/oracle/oradata/orcl/system01.dbf tag=TAG20110308T010221
Channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:45
Channel ORA_DISK_1: starting datafile copy
Input datafile file number=00002 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
Output file name=/u01/app/oracle/oradata/orcl/sysaux01.dbf tag=TAG20110308T010221
Channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:35
Channel ORA_DISK_1: starting datafile copy
Input datafile file number=00003 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
Output file name=/u01/app/oracle/oradata/orcl/undotbs01.dbf tag=TAG20110308T010221
Channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
Channel ORA_DISK_1: starting datafile copy
Input datafile file number=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf
Output file name=/u01/app/oracle/oradata/orcl/users01.dbf tag=TAG20110308T010221
Channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 08-MAR-11
Sql statement: alter system archive log current
Contents of Memory Script:
{
Backup as copy reuse
Archivelog like "/ u01/app/oracle/flash_recovery_area/ORCL/archivelog/2011_03_08/o1_mf_1_7_6qb3zyoo_.arc" auxiliary format
"/ u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch2_7_745174404.dbf"
Catalog clone archivelog "/ u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch2_7_745174404.dbf"
Switch clone datafile all
}
Executing Memory Script
Starting backup at 08-MAR-11
Using channel ORA_DISK_1
Channel ORA_DISK_1: starting archived log copy
Input archived log thread=1 sequence=7 RECID=3 STAMP=745203841
Output file name=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch2_7_745174404.dbf RECID=0 STAMP=0
Channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:07
Finished backup at 08-MAR-11
Cataloged archived log
Archived log file name=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch2_7_745174404.dbf RECID=3 STAMP=745203848
Datafile 1 switched to datafile copy
Input datafile copy RECID=3 STAMP=745203849 file name=/u01/app/oracle/oradata/orcl/system01.dbf
Datafile 2 switched to datafile copy
Input datafile copy RECID=4 STAMP=745203849 file name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
Datafile 3 switched to datafile copy
Input datafile copy RECID=5 STAMP=745203849 file name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
Datafile 4 switched to datafile copy
Input datafile copy RECID=6 STAMP=745203849 file name=/u01/app/oracle/oradata/orcl/users01.dbf
Contents of Memory Script:
{
Set until scn 844147
Recover
Clone database
Delete archivelog
}
Executing Memory Script
Executing command: SET until clause
Starting recover at 08-MAR-11
Allocated channel: ORA_AUX_DISK_1
Channel ORA_AUX_DISK_1: SID=18 device type=DISK
Starting media recovery
Archived log for thread 1 with sequence 7 is already on disk as file / u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch2_7_745174404.dbf
Archived log file name=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch2_7_745174404.dbf thread=1 sequence=7
Media recovery complete, elapsed time: 00:00:01
Finished recover at 08-MAR-11
Contents of Memory Script:
{
Shutdown clone immediate
Startup clone nomount
Sql clone "alter system set db_name =
'' ORCL'' comment=
'' Reset to original value by RMAN'' scope=spfile''
Sql clone "alter system reset db_unique_name scope=spfile"
Shutdown clone immediate
Startup clone nomount
}
Executing Memory Script
Database dismounted
Oracle instance shut down
Connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 146472960 bytes
Fixed Size 1335080 bytes
Variable Size 92274904 bytes
Database Buffers 50331648 bytes
Redo Buffers 2531328 bytes
Sql statement: alter system set db_name =''ORCL'' comment=' 'Reset to original value by RMAN'' scope=spfile
Sql statement: alter system reset db_unique_name scope=spfile
Oracle instance shut down
Connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 146472960 bytes
Fixed Size 1335080 bytes
Variable Size 92274904 bytes
Database Buffers 50331648 bytes
Redo Buffers 2531328 bytes
Sql statement: CREATE CONTROLFILE REUSE SET DATABASE "ORCL" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ('/ u01amp SIZE SIZE 50 M REUSE
GROUP 2 ('/ u01amp SIZE SIZE 50 M REUSE
GROUP 3 ('/ u01 shock SIZE SIZE 50 M REUSE)
DATAFILE
'/ u01 apprenticeship oracleplains oradata'orclplets system01.dbf'
CHARACTER SET ZHS16GBK
Contents of Memory Script:
{
Set newname for tempfile 1 to
"/ u01/app/oracle/oradata/orcl/temp01.dbf"
Switch clone tempfile all
Catalog clone datafilecopy "/ u01/app/oracle/oradata/orcl/sysaux01.dbf"
"/ u01/app/oracle/oradata/orcl/undotbs01.dbf"
"/ u01/app/oracle/oradata/orcl/users01.dbf"
Switch clone datafile all
}
Executing Memory Script
Executing command: SET NEWNAME
Renamed tempfile 1 to / u01/app/oracle/oradata/orcl/temp01.dbf in control file
Cataloged datafile copy
Datafile copy file name=/u01/app/oracle/oradata/orcl/sysaux01.dbf RECID=1 STAMP=745203867
Cataloged datafile copy
Datafile copy file name=/u01/app/oracle/oradata/orcl/undotbs01.dbf RECID=2 STAMP=745203867
Cataloged datafile copy
Datafile copy file name=/u01/app/oracle/oradata/orcl/users01.dbf RECID=3 STAMP=745203867
Datafile 2 switched to datafile copy
Input datafile copy RECID=1 STAMP=745203867 file name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
Datafile 3 switched to datafile copy
Input datafile copy RECID=2 STAMP=745203867 file name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
Datafile 4 switched to datafile copy
Input datafile copy RECID=3 STAMP=745203867 file name=/u01/app/oracle/oradata/orcl/users01.dbf
Contents of Memory Script:
{
Alter clone database open resetlogs
}
Executing Memory Script
Database opened
Finished Duplicate Db at 08-MAR-11
RMAN >
The copy is over. Query:
Target Library:
SQL > select name,dbid from v$database
NAME DBID
--
ORCL 1272955137
Auxiliary Library:
SQL > select name,dbid from v$database
NAME DBID
--
ORCL 1272984602
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.