Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

RMAN Duplicate database from Active database with ASM

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

I. Environment

Main library: install grid software and create disk groups; install database software and create databases

Standby library: just install grid software and create asm disk group, and install database software at the same time.

Hostnam

Database version

Dbname

ORACLE_SID

Ip address

System version

Server1 (Master)

Oracle11204

Jason

Jason

192.168.1.250

Rhel6.6_x86_64

Server2 (standby)

Jason

192.168.1.252

Second, the main library configuration 1. Open archiving

SQL > archive log list

Database log mode Archive Mode

Automatic archival Enabled

Archive destination + DATA

Oldest online log sequence 24

Next log sequence to archive 26

Current log sequence 26

two。 Configure snooping and tnsname

Grid users create listeners as follows:

[grid@server1 ~] $cd / u01/app/11.2.0/grid/network/admin/

[grid@server1 admin] $cat listener.ora

# listener.ora Network Configuration File:/u01/app/11.2.0/grid/network/admin/listener.ora

# Generated by Oracle configuration tools.

LISTENER =

(DESCRIPTION_LIST =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = IPC) (KEY = EXTPROC1521))

(ADDRESS = (PROTOCOL = TCP) (HOST = server1) (PORT = 1521))

)

)

ADR_BASE_LISTENER = / u01/app/grid

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON # line added by Agent

The configuration of tnsname.ora under oracle users is as follows

[oracle@server1 ~] $cd / u01/app/oracle/product/11.2.0/dbhome_1/network/admin/

[oracle@server1 admin] $cat tnsnames.ora

# tnsnames.ora Network Configuration File:/u01/app/11.2.0/grid/network/admin/tnsnames.ora

# Generated by Oracle configuration tools.

JASONPRI =

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.1.250) (PORT = 1521))

)

(CONNECT_DATA =

(SERVICE_NAME = JASON)

)

)

JASONSTD =

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.1.252) (PORT = 1521))

)

(CONNECT_DATA =

(SERVICE_NAME = JASON)

)

)

[oracle@server1 admin] $lsnrctl status

LSNRCTL for Linux: Version 11.2.0.4.0-Production on 12-AUG-201622:43:25

Copyright (c) 1991, 2013, Oracle. All rights reserved.

Connecting to (ADDRESS= (PROTOCOL=tcp) (HOST=) (PORT=1521))

STATUS of the LISTENER

-

Alias LISTENER

Version TNSLSNRfor Linux: Version 11.2.0.4.0-Production

Start Date 12-AUG-2016 17:56:24

Uptime 0 days 4 hr. 47 min. 0 sec

Trace Level off

Security ON:Local OS Authentication

SNMP OFF

Listener Parameter File / u01/app/11.2.0/grid/network/admin/listener.ora

Listener Log File / u01/app/grid/diag/tnslsnr/server1/listener/alert/log.xml

Listening Endpoints Summary...

(DESCRIPTION= (ADDRESS= (PROTOCOL=ipc) (KEY=EXTPROC1521)

(DESCRIPTION= (ADDRESS= (PROTOCOL=tcp) (HOST=server1) (PORT=1521))

Services Summary...

Service "+ ASM" has 1 instance (s).

Instance "+ ASM", status READY, has 1 handler (s) for this service...

Service "JASON" has 1 instance (s).

Instance "JASON", status READY, has 1 handler (s) for this service...

Service "JASONXDB" has 1 instance (s).

Instance "JASON", status READY, has 1 handler (s) for this service...

The command completed successfully

[oracle@server1 admin] $

3. Generate pfile files and synchronize the corresponding files to the standby library

Generate a pfile file in the main database.

SQL > create pfile='/home/oracle/pfile.ora' from spfile

File created.

Synchronize password authentication files to the standby machine.

[oracle@jason1 dbs] $pwd

/ u01/app/oracle/product/11.2.0/dbhome_1/dbs

[oracle@jason1 dbs] $scp initJASON.ora orapwJASON 192.168.1.252:/u01/app/oracle/product/11.2.0/dbhome_1/dbs/

The authenticity of host '192.168.1.100 (192.168.1.100)' can't beestablished.

RSA key fingerprint is 25:ca:65:90:d3:30:fa:68:ed:11:64:b2:0e:b0:39:a7.

Are you sure you want to continue connecting (yes/no)? Yes

Warning: Permanently added '192.168.1.100' (RSA) to the list of knownhosts.

Oracle@192.168.1.252's password:

InitJASON.ora 10015 1.4KB/s 00:00

OrapwJASON 100% 1536 1.5KB/s 00:00

[oracle@jason1 dbs]

Third, prepare the library configuration 4. Create a corresponding directory

Create a related directory on the standby library

[oracle@server2 oracle] $mkdir-p / u01/app/oracle/admin/JASON/adump

5. Prepare the library parameter file configuration

Modify the initial parameter file on the repository. The parameters are as follows.

JASON.__db_cache_size=67108864

JASON.__java_pool_size=4194304

JASON.__large_pool_size=8388608

JASON.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment

JASON.__pga_aggregate_target=209715200

JASON.__sga_target=201326592

JASON.__shared_io_pool_size=0

JASON.__shared_pool_size=113246208

JASON.__streams_pool_size=0

* .audit_file_dest='/u01/app/oracle/admin/JASON/adump'

* .audit_trail='db'

* .compatible='11.2.0.4.0'

* .control_files='+DATA'

* .db_block_size=8192

* .db_create_file_dest='+DATA'

* .db_domain=''

* .db_name='JASON'

* .diagnostic_dest='/u01/app/oracle'

* .dispatchers=' (PROTOCOL=TCP) (SERVICE=JASONXDB)'

* .log_archive_dest_1='LOCATION=+DATA'

* .log_archive_dest_state_1='ENABLE'

* .log_archive_format='%t_%s_%r.dbf'

* .memory_target=411041792

* .open_cursors=300

* .processes=150

* .remote_login_passwordfile='EXCLUSIVE'

* .undo_tablespace='UNDOTBS1'

6. Configure snooping

Grid users create listeners, and slave listeners must be configured for static snooping. As follows:

[grid@server2 admin] $cat listener.ora

# listener.ora Network Configuration File:/u01/app/11.2.0/grid/network/admin/listener.ora

# Generated by Oracle configuration tools.

SID_LIST_LISTENER =

(SID_LIST =

(SID_DESC =

(GLOBAL_DBNAME = JASON2)

(ORACLE_HOME = / u01/app/oracle/product/11.2.0/dbhome_1)

(SID_NAME = JASON)

)

)

LISTENER =

(DESCRIPTION_LIST =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = IPC) (KEY = EXTPROC1521))

)

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP) (HOST = server2) (PORT = 1521))

)

)

ADR_BASE_LISTENER = / u01/app/grid

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER = ON

The configuration of tnsname.ora under oracle users is as follows

[oracle@server1 ~] $cd/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/

[oracle@server1 admin] $cat tnsnames.ora

# tnsnames.ora Network Configuration File:/u01/app/11.2.0/grid/network/admin/tnsnames.ora

# Generated by Oracle configuration tools.

JASONPRI =

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.1.250) (PORT = 1521))

)

(CONNECT_DATA =

(SERVICE_NAME = JASON)

)

)

JASONSTD =

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.1.252) (PORT = 1521))

)

(CONNECT_DATA =

(SERVICE_NAME = JASON)

)

)

7. Create a standby library

Start the slave database to the nomount state, and then connect to the master library on the slave for duplicate operation.

[oracle@server2 ~] $rman target sys/system@JASONPRI auxiliarysys/system@JASONSTD

Recovery Manager: Release 11.2.0.4.0-Production on Mon Aug 22 03VO 0015 34 2016

Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.

Connected to target database: JASON (DBID=2143845850)

Connected to auxiliary database: JASON (not mounted)

RMAN > duplicate target database to JASON from active databasenofilenamecheck

Starting Duplicate Db at 22-AUG-16

Using target database control file instead of recovery catalog

Allocated channel: ORA_AUX_DISK_1

Channel ORA_AUX_DISK_1: SID=24 device type=DISK

Contents of Memory Script:

{

Sql clone "create spfilefrom 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 409194496 bytes

Fixed Size 2253744 bytes

Variable Size 318770256 bytes

Database Buffers 83886080 bytes

Redo Buffers 4284416 bytes

Contents of Memory Script:

{

Sql clone "alter systemset control_files =

'' + DATA/jason/controlfile/current.256.920517337'' comment=

'' Set by RMAN'' scope=spfile''

Sql clone "alter systemset db_name =

'' JASON'' comment=

'' Modified by RMAN duplicate''scope=spfile''

Sql clone "alter systemset db_unique_name =

'' JASON'' comment=

'' Modified by RMAN duplicate''scope=spfile''

Shutdown clone immediate

Startup clone force nomount

Backup as copy currentcontrolfile auxiliary format'+ DATA/jason/controlfile/current.257.920517339'

Sql clone "alter systemset control_files =

'' + DATA/jason/controlfile/current.257.920517339'' comment=

'' Set by RMAN''scope=spfile''

Shutdown clone immediate

Startup clone nomount

Alter clone database mount

}

Executing Memory Script

Sql statement: alter system set control_files =''+ DATA/jason/controlfile/current.256.920517337'' comment=''Set byRMAN'' scope=spfile

Sql statement: alter system set db_name =''JASON'' comment=''Modified by RMAN duplicate'' scope=spfile

Sql statement: alter system set db_unique_name =''JASON''comment=' 'Modified by RMAN duplicate'' scope=spfile

Oracle instance shut down

Oracle instance started

Total System Global Area 409194496 bytes

Fixed Size 2253744 bytes

Variable Size 318770256 bytes

Database Buffers 83886080 bytes

Redo Buffers 4284416 bytes

Starting backup at 22-AUG-16

Allocated channel: ORA_DISK_1

Channel ORA_DISK_1: SID=31 device type=DISK

Channel ORA_DISK_1: starting datafile copy

Copying current control file

Output filename=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_JASON.ftag=TAG20160822T031556 RECID=2 STAMP=920517390

Channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:08

Finished backup at 22-AUG-16

Sql statement: alter system set control_files =''+ DATA/jason/controlfile/current.257.920517339'' comment=''Set byRMAN'' scope=spfile

Oracle instance shut down

Connected to auxiliary database (not started)

Oracle instance started

Total System Global Area 409194496 bytes

Fixed Size 2253744 bytes

Variable Size 318770256 bytes

Database Buffers 83886080 bytes

Redo Buffers 4284416 bytes

Database mounted

Contents of Memory Script:

{

Set newname for clonedatafile 1 to new

Set newname for clonedatafile 2 to new

Set newname for clonedatafile 3 to new

Set newname for clonedatafile 4 to new

Backup as copy reuse

Datafile 1 auxiliary format new

Datafile 2 auxiliary format new

Datafile 3 auxiliary format new

Datafile 4 auxiliary format new

Sql 'alter system archive logcurrent'

}

Executing Memory Script

Executing command: SET NEWNAME

Executing command: SET NEWNAME

Executing command: SET NEWNAME

Executing command: SET NEWNAME

Starting backup at 22-AUG-16

Using channel ORA_DISK_1

Channel ORA_DISK_1: starting datafile copy

Input datafile file number=00001name=+DATA/jason/datafile/system.256.919631481

Output file name=+DATA/jason/datafile/system.258.920517425tag=TAG20160822T031700

Channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:56

Channel ORA_DISK_1: starting datafile copy

Input datafile file number=00002name=+DATA/jason/datafile/sysaux.257.919631481

Output file name=+DATA/jason/datafile/sysaux.259.920517485tag=TAG20160822T031700

Channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:46

Channel ORA_DISK_1: starting datafile copy

Input datafile file number=00003 name=+DATA/jason/datafile/undotbs1.258.919631481

Output file name=+DATA/jason/datafile/undotbs1.260.920517533tag=TAG20160822T031700

Channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:08

Channel ORA_DISK_1: starting datafile copy

Input datafile file number=00004 name=+DATA/jason/datafile/users.259.919631483

Output file name=+DATA/jason/datafile/users.261.920517537tag=TAG20160822T031700

Channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01

Finished backup at 22-AUG-16

Sql statement: alter system archive log current

Contents of Memory Script:

{

Backup as copy reuse

Archivelog like "+ DATA/jason/archivelog/2016_08_22/thread_1_seq_29.294.920517565" auxiliary format

"+ DATA"

Catalog clone start with "+ DATA"

Switch clone datafile all

}

Executing Memory Script

Starting backup at 22-AUG-16

Using channel ORA_DISK_1

Channel ORA_DISK_1: starting archived log copy

Input archived log thread=1 sequence=29 RECID=41 STAMP=920517576

Output file name=+DATA/jason/archivelog/2016_08_22/thread_1_seq_29.262.920517585RECID=0 STAMP=0

Channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01

Finished backup at 22-AUG-16

Searching for all files that match the pattern + DATA

List of Files Unknown to the Database

= =

File Name:+data/JASON/ARCHIVELOG/2016_08_22/thread_1_seq_29.262.920517585

File Name: + data/JASON/DATAFILE/SYSTEM.258.920517425

File Name: + data/JASON/DATAFILE/SYSAUX.259.920517485

File Name: + data/JASON/DATAFILE/UNDOTBS1.260.920517533

File Name: + data/JASON/DATAFILE/USERS.261.920517537

File Name: + data/JASON/CONTROLFILE/Current.256.920517337

File Name: + data/ASM/ASMPARAMETERFILE/REGISTRY.253.919634957

Cataloging files...

Cataloging done

List of Cataloged Files

=

File Name:+data/JASON/ARCHIVELOG/2016_08_22/thread_1_seq_29.262.920517585

File Name: + data/JASON/DATAFILE/SYSTEM.258.920517425

File Name: + data/JASON/DATAFILE/SYSAUX.259.920517485

File Name: + data/JASON/DATAFILE/UNDOTBS1.260.920517533

File Name: + data/JASON/DATAFILE/USERS.261.920517537

List of Files Which Where Not Cataloged

= =

File Name: + data/JASON/CONTROLFILE/Current.256.920517337

RMAN-07517: Reason: The file headeris corrupted

File Name: + data/ASM/ASMPARAMETERFILE/REGISTRY.253.919634957

RMAN-07518: Reason: Foreigndatabase file DBID: 0 Database Name:

Datafile 1 switched to datafile copy

Input datafile copy RECID=6 STAMP=920517585 file name=+DATA/jason/datafile/system.258.920517425

Datafile 2 switched to datafile copy

Input datafile copy RECID=7 STAMP=920517585 filename=+DATA/jason/datafile/sysaux.259.920517485

Datafile 3 switched to datafile copy

Input datafile copy RECID=8 STAMP=920517585 file name=+DATA/jason/datafile/undotbs1.260.920517533

Datafile 4 switched to datafile copy

Input datafile copy RECID=9 STAMP=920517585 filename=+DATA/jason/datafile/users.261.920517537

Contents of Memory Script:

{

Set until scn 1100818

Recover

Clone database

Delete archivelog

}

Executing Memory Script

Executing command: SET until clause

Starting recover at 22-AUG-16

Allocated channel: ORA_AUX_DISK_1

Channel ORA_AUX_DISK_1: SID=23 device type=DISK

Starting media recovery

Archived log for thread 1 with sequence 29 is already on disk as file+DATA/jason/archivelog/2016_08_22/thread_1_seq_29.262.920517585

Archived log filename=+DATA/jason/archivelog/2016_08_22/thread_1_seq_29.262.920517585 thread=1sequence=29

Media recovery complete, elapsed time: 00:00:03

Finished recover at 22-AUG-16

Oracle instance started

Total System Global Area 409194496 bytes

Fixed Size 2253744 bytes

Variable Size 318770256 bytes

Database Buffers 83886080 bytes

Redo Buffers 4284416 bytes

Contents of Memory Script:

{

Sql clone "alter systemset db_name =

'' JASON'' comment=

'' Reset to original value byRMAN'' scope=spfile''

Sql clone "alter systemreset db_unique_name scope=spfile"

Shutdown clone immediate

Startup clone nomount

}

Executing Memory Script

Sql statement: alter system set db_name =''JASON'' 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 409194496 bytes

Fixed Size 2253744 bytes

Variable Size 318770256 bytes

Database Buffers 83886080 bytes

Redo Buffers 4284416 bytes

Sql statement: CREATE CONTROLFILE REUSE SET DATABASE "JASON" RESETLOGS ARCHIVELOG

MAXLOGFILES 16

MAXLOGMEMBERS 3

MAXDATAFILES 100

MAXINSTANCES 8

MAXLOGHISTORY 292

LOGFILE

GROUP 1 SIZE 50 M

GROUP 2 SIZE 50 M

GROUP 3 SIZE 50 M

DATAFILE

'+ DATA/jason/datafile/system.258.920517425'

CHARACTER SET ZHS16GBK

Contents of Memory Script:

{

Set newname for clonetempfile 1 to new

Switch clone tempfile all

Catalog clone datafilecopy "+ DATA/jason/datafile/sysaux.259.920517485"

"+ DATA/jason/datafile/undotbs1.260.920517533"

"+ DATA/jason/datafile/users.261.920517537"

Switch clone datafile all

}

Executing Memory Script

Executing command: SET NEWNAME

Renamed tempfile 1 to + DATA in control file

Cataloged datafile copy

Datafile copy file name=+DATA/jason/datafile/sysaux.259.920517485RECID=1 STAMP=920517623

Cataloged datafile copy

Datafile copy file name=+DATA/jason/datafile/undotbs1.260.920517533RECID=2 STAMP=920517623

Cataloged datafile copy

Datafile copy file name=+DATA/jason/datafile/users.261.920517537 RECID=3STAMP=920517623

Datafile 2 switched to datafile copy

Input datafile copy RECID=1 STAMP=920517623 filename=+DATA/jason/datafile/sysaux.259.920517485

Datafile 3 switched to datafile copy

Input datafile copy RECID=2 STAMP=920517623 filename=+DATA/jason/datafile/undotbs1.260.920517533

Datafile 4 switched to datafile copy

Input datafile copy RECID=3 STAMP=920517623 filename=+DATA/jason/datafile/users.261.920517537

Reenabling controlfile options for auxiliary database

Executing: alter database force logging

Contents of Memory Script:

{

Alter clone database openresetlogs

}

Executing Memory Script

Database opened

Finished Duplicate Db at 22-AUG-16

RMAN >

Note: after creating the standby database, the database is in OPEN state.

8. Create a spfile file

After the slave library is created, you need to create a spfile file.

Modify the control_files parameter of the pfile file, specify the control file of the backup library, and view the asm disk group to obtain the control file name and location. As follows:

Control_files='+DATA/jason/controlfile/current.257.920517339'

Create spfile.

SQL > create SPFILE='+DATA/JASON/spfileJASON.ora' frompfile='/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initJASON.ora'

File created.

SQL >

Create a pfile file to point to

[oracle@server2dbs] $cat initJASON.ora

SPFILE='+DATA/JASON/spfileJASON.ora'

[oracle@server2dbs] $

After the spfile file is created successfully, the standby database restart will start the database using the spfile file.

SQL > showparameter spfile

NAME TYPE VALUE

-

Spfile string + DATA/jason/spfilejason.ora

SQL >

4. Register for CRS

Register for CRS

Slave database is not registered into CRS, and slave restart only starts with ASM instance and crs, while CRS cannot start database. So register the repository to CRS.

Execute as oracle user

[oracle@server2 dbs] $srvctl add database-d JASON-o/u01/app/oracle/product/11.2.0/dbhome_1-p + DATA/JASON/spfileJASON.ora-I jason-n jason

[oracle@server2 dbs] $srvctl modify database-d JASON-a 'data'

[oracle@server2 dbs] $srvctl config database-d jason-a

Database unique name: JASON

Database name: jason

Oracle home: / u01/app/oracle/product/11.2.0/dbhome_1

Oracle user: oracle

Spfile: + DATA/JASON/spfileJASON.ora

Domain:

Start options: open

Stop options: immediate

Database role:

Management policy: AUTOMATIC

Database instance: jason

Disk Groups: DATA

Services:

Database is enabled

[oracle@server2 dbs] $

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.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report