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

Deploy Physical Dataguard and two-node Oracle RAC environment

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

For more information about oracle rac deployment, please visit here at http://worms.blog.51cto.com/969144/1416975

System Information:

Primary end

RAC Primary

RACDG1 (host)

RACDG2 (host)

Remarks

Public IP

172.20.10. eleven

172.20.10. twelve

Virtual IP

10.0.0.11

10.0.0.12

Instance

Racdg1

Racdg2

DB name

RACDG

DATA file

+ DATA2/racdg/datafile

Control file

+ DATA2/racdg/controlfile

+ DATA1/racdg/controlfile/

Redo Log file

+ DATA2/racdg/onlinelog/

Db_recovery_file_dest

Db_unique_name

Racdg

Service_names

Racdg

Oracle_Version

11.2.0.1.0

Standby end

Single instance standby

Hostnam

Remarks

IP

172.20.10.100

Oracle_version

11.2.0.1.0

Instance

Racdg

DB name

RACDG

DB_unique_name

Racdg_standy

Service_names

Racdg_standy

DATA file

/ u01/oracle/racdg_standy/datafile/

Control file

/ u01/app/oracle/controlfile1/

/ u01/app/oracle/controlfile2/

Redo Log file

/ u01/oracle/racdg_standy/onlinelog3/

/ u01/oracle/racdg_standy/onlinelog/

Structure diagram

Standby library type description

1. The characteristics of PhysicalStandby Databases:

Disaster recovery and high availability

Data protection

Reduction in primary database workload

Performance

2. The characteristics of LogicalStandby Databases:

Protection against additional kinds of failure

Effcient use of resource

Workload distribution

Optimized of reporting add decision supportrequirements

Minimizing downtime on software upgrade

3 、 Snapshot StandbyDatabases

A snapshot standby database is a type of updatable standby databasethat provides full data protection for a primary database. A snapshot standbydatabase receives and archives, but does not apply, redo data from its primarydatabase. Redo data received from the primary database is applied when asnapshot standby database is converted back into a physical standby database,after discarding all local updates to the snapshot standby database

A snapshot standby database typically diverges from its primarydatabase over time because redo data from the primarydatabase is not appliedas it is received. Local updates to the snapshot standby database will causeadditional divergence. The data in the primary database is fully protectedhowever, because a snapshot standby can be converted back into a physicalstandby database at any time, and the redo data received from the primary willthen be applied

This passage shows that snapshot standby DB completely protects the data of the main database, and snapshot standby DB is usually a relief for the testing and development of production libraries that cannot do business. The passage is as follows:

Benefits of a SnapshotStandby Database

A snapshot standby database isa fullyupdatable standby database that provides disaster recovery and data protectionbenefits that are similar to those of a physical standby database. Snapshotstandby databases are best used in scenarios where the benefit of having atemporary, updatable snapshot of the primary database justifies the increasedtime to recover from primary database failures.

The benefits of using a snapshot standbydatabase include the following:

It provides an exact replica of aproduction database for development and testing purposes, while maintainingdata protection at all times.

It can be easily refreshed to containcurrent production data by converting to a physical standby andresynchronizing.

The ability to create a snapshot standby,test, resynchronize with production, and then again create a snapshot standbyand test, is a cycle that can be repeated as often as desired. The same processcan be used to easily create and regularly update a snapshot standby forreporting purposes where read/write access to data is required.

The above can explain the real-time protection of the production library. Transfer the main library of development and testing to the standby library. Prepare the library and will accept the redlog of the main library but not apply. After the test is completed, switch the snapshot standby DB back to physical standby DB to restore the previous state.

The configuration here is of the physical standby database type

Prepare to configure the environment:

Configure tnsname.ora, add the following to the tnsname.ora file, and copy the tnsname.ora file to all nodes and standby DB.

Rac_dg1 =

(DESCRIPTION =

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

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = racdg)

(INSTANCE_NAME = racdg1)

)

)

Rac_dg2 =

(DESCRIPTION =

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

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = racdg)

(INSTANCE_NAME = racdg2)

)

)

Racdg_standy =

(DESCRIPTION =

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

(CONNECT_DATA =

(SERVER = DEDICATED)

(SID = racdg)

)

)

Configure physical standby DB snooping: listener.ora

SID_LIST_LISTENER =

(SID_LIST =

(SID_DESC =

(GLOBAL_DBNAME = PLSExtProc)

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

(SID_NAME = PLSExtProc)

)

)

LISTENER =

(DESCRIPTION_LIST =

(DESCRIPTION =

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

)

)

ADR_BASE_LISTENER = / u01/app/oracle

Preparingthe Primary Database for Standby Database Creation

EnableForced Logging (Place the primary database in FORCE LOGGING mode.)

Configure redotransport authentication

Configurethe Primary Database to Receive Redo Data

Set PrimaryDatabase Initialization Parameters

EnableArchiving

Creatinga Physical Standby Database

Create a Backup Copy of the Primary Database Datafiles

Create a Control File for the Standby Database

Copy Files from the Primary System to the Standby System

Prepare an Initialization Parameter File for the Standby Database

Start the Physical Standby Database

Verify the Physical Standby Database Is Performing Properly

Primarydatabase configuration:

1. Enable Force logging

SQL > ALTER DATABASE FORCE LOGGING

Executing this statement database is at least in the mounted or open state, and it may take a lot of time to complete, because enable forced logging waits for all unlogged write IbinO to finish.

View select force_logging from v$database

2 、 Configure RedoTransport Authentication

Data Guard usesOracle Net sessions to transport redo data and control messages between themembers of a Data Guard configuration. These redo transport sessions areauthenticated using either the Secure Sockets Layer (SSL) protocol or a remotelogin password file. Password file is used here.

Create a pwdfile on rac node 1

Orapwdfile=/u01/app/oracle/product/11.2.0/db_1/dbs/orapwracdg1 password=FANfan1234entries=10 force=y

Copy the orapwracdg1 to node 2 and the standby DB node and name it.

Scp$ORACLE_HOME/dbs/orapwracdg1 oracle@racdg2:$ORACLE_HOME/dbs/orapwracdg2

Scp$ORACLE_HOME/dbs/orapwracdg1 oracle@racdg2:$ORACLE_HOME/dbs/orapwracdg

3 、 Configure thePrimary Database to Receive Redo Data

Here, when you do switchoverto standby db in the main primary library, configure it again.

4 、 Set Primary DatabaseInitialization Parameters

Primary DB initialization parameter:

SQL > show parameter pfile

NAME TYPE VALUE

-

Spfile string + DATA1/racdg/spfileracdg.ora

SQL >

Createpfile='/home/oracle/primary_pfile.pfile' fromspfile='+DATA1/racdg/spfileracdg.ora'

Edit parameters:

Racdg2.__db_cache_size=276824064

Racdg1.__db_cache_size=276824064

Racdg2.__java_pool_size=4194304

Racdg1.__java_pool_size=4194304

Racdg2.__large_pool_size=4194304

Racdg1.__large_pool_size=4194304

Racdg2.__pga_aggregate_target=339738624

Racdg1.__pga_aggregate_target=339738624

Racdg2.__sga_target=503316480

Racdg1.__sga_target=503316480

Racdg2.__shared_io_pool_size=0

Racdg1.__shared_io_pool_size=0

Racdg2.__shared_pool_size=209715200

Racdg1.__shared_pool_size=209715200

Racdg2.__streams_pool_size=0

Racdg1.__streams_pool_size=0

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

* .audit_trail='db'

* .cluster_database=true

* .compatible='11.2.0.0.0'

* .control_files='+DATA2/racdg/controlfile/current.260.875118793','+DATA1/racdg/controlfile/current.256.875118799'

* .db_block_size=8192

* .db_create_file_dest='+DATA2'

* .db_domain=''

* .db_name='racdg'

* .db_recovery_file_dest='+DATA1'

* .db_recovery_file_dest_size=4070572032

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

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

Racdg1.instance_number=1

Racdg2.instance_number=2

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

* .memory_target=839909376

* .open_cursors=300

* .processes=150

* .remote_listener='scan.localdomain:1521'

* .remote_login_passwordfile='exclusive'

Racdg2.thread=2

Racdg1.thread=1

Racdg2.undo_tablespace='UNDOTBS2'

Racdg1.undo_tablespace='UNDOTBS1'

Add parameters:

* .db_unique_name=racdg

* .service_names=racdg

* .log_archive_config='dg_config= (racdg,racdg_standy)'

* .log_archive_dest_1=

'location=use_db_recovery_file_dest

Valid_for= (all_logfiles,all_roles)

Db_unique_name=racdg'

* .log_archive_dest_2=

'service=racdg_standy async

Valid_for= (online_logfiles,primary_role)

Db_unique_name=racdg_standy'

* .log_archive_dest_state_1=enable

* .log_archive_dest_state_2=enable

* .log_archive_max_processes=30

* .fal_server=racdg_standy

Racdg1.fal_client=racdg1

Racdg2.fal_client=racdg2

* .db_file_name_convert=

'/ u01Universe oracleUniplicationracdgActionstandyUniplicationdatafileAccording to the DATA2Universe racdgUniverse datafileUniverse'

'/ u01Universe oracleplicatracdgstop standytempfileUniplicateDATA2andracdgUnitempfileUniplicityDATA2Universe'

* .log_file_name_convert=

'/ u01Universe oracleplicaclypracdgActionstandyOnlinelogOnlinelogUniverse'

'/ u01Universe oracleplicatracdgstop standyplicasonlinelog3plicedDATA2andracdgUnixonlinelogly.'

* .standby_file_management=auto

Note:

Here you need to pay attention to the configuration of fal_server and fal_client and the parameter settings of db_unique_name.

Create a primary DB spfile:

Shut down the cluster

[grid@racdg1] $srvctl stop database-d racdg

[oracle@racdg1 ~] $sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production onTue Mar 17 18:18:09 2015

Copyright (c) 1982, 2009, Oracle. All rights reserved.

Connected to an idle instance.

SQL > createspfile='+DATA1/racdg/spfileracdg.ora' from pfile='/home/oracle/config.pfile'

File created.

Start the cluster:

[grid@racdg1 ~] $srvctl start database-dracdg

Log in to two nodes after startup to view the parameters:

Query the parameters in the Racdg1 node:

SQL > show parameter fal

NAME TYPE VALUE

-

Fal_client string racdg1

Fal_server string racdg_standy

SQL > show parameter archive

NAME TYPE VALUE

-

Archive_lag_target integer 0

Log_archive_config string dg_config= (racdg,racdg_standy)

Log_archive_dest string

Log_archive_dest_1 string location=use_db_recovery_file_

Dest

Valid_for= (all_logfiles,all_

Roles)

Db_unique_name=racdg

Log_archive_dest_10 string

Log_archive_dest_11 string

Log_archive_dest_12 string

NAME TYPE VALUE

-

Log_archive_dest_13 string

Log_archive_dest_14 string

Log_archive_dest_15 string

Log_archive_dest_16 string

Log_archive_dest_17 string

Log_archive_dest_18 string

Log_archive_dest_19 string

Log_archive_dest_2 string service=racdg_standy async

Valid_for= (online_logfiles,p

Rimary_role)

Db_unique_name=racdg_standy

SQL > show parameter db_file_name_convert

NAME TYPE VALUE

-

Db_file_name_convert string / u01/app/oracle/racdg_standy/d

Atafile, + DATA1/racdg/datafile

/, / u01/app/oracle/racdg_stand

Y/tempfile, + DATA1/racdg/tempf

Ile/

SQL >

SQL >

SQL > show parameterlog_file_name_convert

NAME TYPE VALUE

-

Log_file_name_convert string / u01/app/oracle/racdg_standy/o

Nlinelog, + DATA1/racdg/onlinel

Og/, / u01/app/oracle/racdg_sta

Ndy/onlinelog3, + DATA3/racdg/o

Nlinelog/

SQL > show parameter control

NAME TYPE VALUE

-

Control_file_record_keep_time integer 7

Control_files string + DATA1/racdg/controlfile/curre

Nt.296.874604041, + DATA3/racdg

/ controlfile/current.426.87460

4051

Control_management_pack_access string DIAGNOSTIC+TUNING

SQL >

View the parameters in the racdg2 node:

SQL > show parameter fal

NAME TYPE VALUE

-

Fal_client string racdg2

Fal_server string racdg_standy

SQL > show parameter archive

NAME TYPE VALUE

-

Archive_lag_target integer 0

Log_archive_config string dg_config= (racdg,racdg_standy)

Log_archive_dest string

Log_archive_dest_1 string location=use_db_recovery_file_

Dest

Valid_for= (all_logfiles,all_

Roles)

Db_unique_name=racdg

Log_archive_dest_10 string

Log_archive_dest_11 string

Log_archive_dest_12 string

NAME TYPE VALUE

-

Log_archive_dest_13 string

Log_archive_dest_14 string

Log_archive_dest_15 string

Log_archive_dest_16 string

Log_archive_dest_17 string

Log_archive_dest_18 string

Log_archive_dest_19 string

Log_archive_dest_2 string service=racdg_standy async

Valid_for= (online_logfiles,p

Rimary_role)

Db_unique_name=racdg_standy

SQL > show parameter control

NAME TYPE VALUE

-

Control_file_record_keep_time integer 7

Control_files string + DATA1/racdg/controlfile/curre

Nt.296.874604041,+DATA3/racdg

/ controlfile/current.426.87460

4051

Control_management_pack_access string DIAGNOSTIC+TUNING

SQL > show parameterlog_file_name_convert

NAME TYPE VALUE

-

Log_file_name_convert string / u01/app/oracle/racdg_standy/o

Nlinelog, + DATA1/racdg/onlinel

Og/, / u01/app/oracle/racdg_sta

Ndy/onlinelog3, + DATA3/racdg/o

Nlinelog/

SQL > show parameter db_file_name_convert

NAME TYPE VALUE

-

Db_file_name_convert string / u01/app/oracle/racdg_standy/d

Atafile, + DATA1/racdg/datafile

/, / u01/app/oracle/racdg_stand

Y/tempfile, + DATA1/racdg/tempf

Ile/

SQL >

5. Enable RAC archiving

Slightly

PhysicalStandby Database configuration

1. Create a primary DB backup

Rman backup primary DB

[oracle@racdg1db_backup] $rman target /

Recovery Manager:Release 11.2.0.1.0-Production on Tue Mar 17 18:58:43 2015

Copyright (c) 1982, Oracle and/or its affiliates. Allrights reserved.

Connected to targetdatabase: RACDG (DBID=1109864007)

RMAN > backup database format'/home/oracle/db_backup/racdbfull_%T_%t_%u_%s_%p'

Starting backup at17-MAR-15

Using targetdatabase control file instead of recovery catalog

Allocated channel:ORA_DISK_1

Channel ORA_DISK_1:SID=32 instance=racdg1 device type=DISK

Channel ORA_DISK_1:starting full datafile backup set

Channel ORA_DISK_1:specifying datafile (s) in backup set

Input datafile filenumber=00001 name=+DATA1/racdg/datafile/system.292.874603637

Input datafile filenumber=00002 name=+DATA1/racdg/datafile/sysaux.293.874603643

Input datafile filenumber=00003 name=+DATA1/racdg/datafile/undotbs1.294.874603645

Input datafile filenumber=00005 name=+DATA1/racdg/datafile/undotbs2.300.874604699

Input datafile filenumber=00004 name=+DATA1/racdg/datafile/users.295.874603647

Channel ORA_DISK_1:starting piece 1 at 17-MAR-15

Channel ORA_DISK_1:finished piece 1 at 17-MAR-15

Piecehandle=/home/oracle/db_backup/racdbfull_20150317_874609135_01q22uff_1_1tag=TAG20150317T185854 comment=NONE

Channel ORA_DISK_1:backup set complete, elapsed time: 00:02:45

Channel ORA_DISK_1:starting full datafile backup set

Channel ORA_DISK_1:specifying datafile (s) in backup set

Including currentcontrol file in backup set

Including currentSPFILE in backup set

Channel ORA_DISK_1:starting piece 1 at 17-MAR-15

Channel ORA_DISK_1:finished piece 1 at 17-MAR-15

Piece handle=/home/oracle/db_backup/racdbfull_20150317_874609302_02q22ukm_2_1tag=TAG20150317T185854 comment=NONE

Channel ORA_DISK_1:backup set complete, elapsed time: 00:00:16

Finished backup at17-MAR-15

RMAN >

2. Create a controlfile for standby db

SQL > ALTER DATABASE CREATE STANDBYCONTROLFILE AS'/ home/oracle/db_backup/racdg.ctl'

Database altered.

SQL > alter system switch logfile

System altered.

SQL >

3. Copy primaryDB backup files to standbyDB

[oracle@racdg1db_backup] $ll

Total 1074652

-rw-r--r-- 1 oracleasmadmin 2330 Mar 16 11:00backcuppfile.pfile

-rw-r- 1 oracleasmadmin 1062264832 Mar 17 19:01 racdbfull_20150317_874609135_01q22uff_1_1

-rw-r- 1 oracleasmadmin 18579456 Mar 17 19:02racdbfull_20150317_874609302_02q22ukm_2_1

-rw-r- 1 oracleasmadmin 18497536 Mar 17 19:06racdg.ctl

-rw-r--r-- 1 oracleoinstall 1575 Mar 6 19:51 standby_db.pfile

[oracle@racdg1db_backup] $scp racd* oracle@172.20.10.100:/home/oracle/db_backup/

Oracle@172.20.10.100'spassword:

Racdbfull_20150317_874609135_01q22uff_1_1 24% 203

4. Create standby initialization parameter

Preparatory work

Creation of related directories:

Log_file=/u01/oracle/racdg_standy/onlinelog

Db_file=/u01/oracle/racdg_standy/datafile

Archive_log=/u01/oracle/racdg_standy/arch

Set file directory permissions:

[root@localhost ~] # chown-Roracle:oinstall / u01/oracle/racdg_standy

[root@localhost ~] # chown 775/u01/oracle/racdg_standy

[root@localhost ~] # ls-ls/u01/oracle/racdg_standy/

Total 16

4 drwxr-xr-x 2 oracle oinstall 4096 Feb 1500:54 arch

4 drwxr-xr-x 2 oracle oinstall 4096 Feb 1500:54 datafile

4 drwxr-xr-x 2 oracle oinstall 4096 Feb 1500:54 onlinelog

4 drwxr-xr-x 2 oracle oinstall 4096 Feb 1500:54 tempfile

Copy primary DB parameter for modification

Remove the content from the primary parameter as follows:

* .cluster_database=TRUE

Racdg1.instance_number=1

Racdg2.instance_number=2

* .remote_listener='scan.localdomain:1521'

* .db_create_file_dest='+DATA1'

* .cluster_database=true

* .memory_target=842006528

* .db_recovery_file_dest='+DATA3'

* .db_recovery_file_dest_size=4070572032

Add modification parameters:

* .pga_aggregate_target=339738624

* .sga_target=503316480

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

* .core_dump_dest='/u01/app/oracle/admin/racdg_standy/cdump'

* .audit_trail='db'

* .compatible='11.2.0.0.0'

* .control_files='/u01/app/oracle/controlfile1/control1.ctl'

'/ u01OnOnOnApplash oracleandcontrolfile2control control2.ctl`

* .db_block_size=8192

* .db_domain=''

* .db_name='racdg'

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

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

* .open_cursors=300

* .processes=150

* .remote_login_passwordfile='exclusive'

* .thread=1

* .undo_tablespace='UNDOTBS1'

* .db_unique_name='racdg_standy'

* .service_names='racdg_standy'

* .log_archive_config='dg_config= (racdg_standy,racdg)'

* .log_archive_dest_1='location=/u01/oracle/racdg_standy/arch/

Valid_for= (all_logfiles,all_roles)

Db_unique_name=racdg_standy'

* .log_archive_dest_2='service=rac_dg1 async

Valid_for= (online_logfiles,primary_role)

Db_unique_name=racdg'

* .log_archive_dest_state_1='enable'

* .log_archive_dest_state_2='enable'

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

* .log_file_name_convert='+DATA1/racdg/onlinelog/','/u01/oracle/racdg_standy/onlinelog/'

'+ DATA2/racdg/onlinelog/','/u01/oracle/racdg_standy/onlinelog3/'

* .db_file_name_convert='+DATA2/racdg/datafile/','/u01/oracle/racdg_standy/datafile/'

'+ DATA2/racdg/tempfile/','/u01/oracle/racdg_standy/tempfile/'

* .log_archive_max_processes=30

* .standby_file_management='auto'

* .fal_client='racdg_standy'

* .fal_server='rac_dg1','rac_dg2'

Startup nomount

Note: 1. The rac_dg1 node configured here receives redo log.

2. Verify the directory in the parameter file

5 、 Create a serverparameter file for the standby database

Startup nomount

SQL > startup pfile='/home/oracle/db_backup/standby_0317.pfile' nomount

ORACLE instance started.

Total System Global Area 217157632 bytes

Fixed Size 2211928 bytes

Variable Size 159387560 bytes

Database Buffers 50331648 bytes

Redo Buffers 5226496 bytes

Create spfile

SQL > create spfile='/u01/app/oracle/product/11.2.0/db_1/dbs/spfileracdg.ora'from pfile='/home/oracle/db_backup/standby_0317.pfile'

File created.

SQL >

Check whether the relevant parameters are in effect

SQL > show parameter fal

NAME TYPE VALUE

-

Fal_client string racdg_standy

Fal_server string rac_dg1, rac_dg2

SQL > show parameter archive

NAME TYPE VALUE

-

Archive_lag_target integer 0

Log_archive_config string dg_config= (racdg_standy,racdg)

Log_archive_dest string

Log_archive_dest_1 string location=/u01/app/oracle/racdg

_ standy/arch/

Valid_for= (all_logfiles,all_

Roles)

Db_unique_name=racdg_standy

Log_archive_dest_10 string

Log_archive_dest_11 string

Log_archive_dest_12 string

NAME TYPE VALUE

-

Log_archive_dest_13 string

Log_archive_dest_14 string

Log_archive_dest_15 string

Log_archive_dest_16 string

Log_archive_dest_17 string

Log_archive_dest_18 string

Log_archive_dest_19 string

Log_archive_dest_2 string service=rac_dg1 async

Valid_for= (online_logfiles,pri

Mary_role)

Db_unique_name=racdg

6 、 Start the PhysicalStandby Database

Use rman to restore primary DB backups to the standby DB library

Execute the rman here:

[oracle@standydb~] $rman target sys/FANfan1234@rac_dg1 auxiliary /

Recovery Manager:Release 11.2.0.1.0-Production on Tue Mar 17 20:22:42 2015

Copyright (c) 1982, Oracle and/or its affiliates. Allrights reserved.

Connected to targetdatabase: RACDG (DBID=1109864007)

Connected toauxiliary database: RACDG (not mounted)

RMAN >

RMAN > duplicatetarget database for standby

Starting DuplicateDb at 17-MAR-15

Using targetdatabase control file instead of recovery catalog

Allocated channel:ORA_AUX_DISK_1

ChannelORA_AUX_DISK_1: SID=18 device type=DISK

Contents of MemoryScript:

{

Restore clone standby controlfile

}

Executing MemoryScript

Starting restore at17-MAR-15

Using channelORA_AUX_DISK_1

ChannelORA_AUX_DISK_1: restoring control file

ChannelORA_AUX_DISK_1: copied control file copy

Input filename=/home/oracle/db_backup/racdg.ctl

Output filename=/u01/app/oracle/controlfile1/control1.ctl

Output filename=/u01/app/oracle/controlfile2/control2.ctl

Finished restore at17-MAR-15

Contents of MemoryScript:

{

Sql clone 'alter database mount standbydatabase'

}

Executing MemoryScript

Sql statement:alter database mount standby database

Contents of MemoryScript:

{

Set newname for tempfile 1 to

"/ u01/app/oracle/racdg_standy/tempfile/temp.299.874604163"

Switch clone tempfile all

Set newname for datafile 1 to

"/ u01/app/oracle/racdg_standy/datafile/system.292.874603637"

Set newname for datafile 2 to

"/ u01/app/oracle/racdg_standy/datafile/sysaux.293.874603643"

Set newname for datafile 3 to

"/ u01/app/oracle/racdg_standy/datafile/undotbs1.294.874603645"

Set newname for datafile 4 to

"/ u01/app/oracle/racdg_standy/datafile/users.295.874603647"

Set newname for datafile 5 to

"/ u01/app/oracle/racdg_standy/datafile/undotbs2.300.874604699"

Restore

Clone database

}

Executing MemoryScript

Executing command:SET NEWNAME

Renamed tempfile 1to / u01/app/oracle/racdg_standy/tempfile/temp.299.874604163 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 at17-MAR-15

Using channelORA_AUX_DISK_1

ChannelORA_AUX_DISK_1: starting datafile backup set restore

ChannelORA_AUX_DISK_1: specifying datafile (s) to restore from backup set

ChannelORA_AUX_DISK_1: restoring datafile 00001 to/u01/app/oracle/racdg_standy/datafile/system.292.874603637

ChannelORA_AUX_DISK_1: restoring datafile 00002 to/u01/app/oracle/racdg_standy/datafile/sysaux.293.874603643

ChannelORA_AUX_DISK_1: restoring datafile 00003 to/u01/app/oracle/racdg_standy/datafile/undotbs1.294.874603645

Channel ORA_AUX_DISK_1:restoring datafile 00004 to/u01/app/oracle/racdg_standy/datafile/users.295.874603647

ChannelORA_AUX_DISK_1: restoring datafile 00005 to/u01/app/oracle/racdg_standy/datafile/undotbs2.300.874604699

ChannelORA_AUX_DISK_1: reading from backup piece/home/oracle/db_backup/racdbfull_20150317_874609135_01q22uff_1_1

ChannelORA_AUX_DISK_1: piecehandle=/home/oracle/db_backup/racdbfull_20150317_874609135_01q22uff_1_1tag=TAG20150317T185854

ChannelORA_AUX_DISK_1: restored backup piece 1

Channel ORA_AUX_DISK_1:restore complete, elapsed time: 00:04:25

Finished restore at17-MAR-15

Contents of MemoryScript:

{

Switch clone datafile all

}

Executing MemoryScript

Datafile 1 switchedto datafile copy

Input datafile copyRECID=1 STAMP=874614650 filename=/u01/app/oracle/racdg_standy/datafile/system.292.874603637

Datafile 2 switchedto datafile copy

Input datafile copyRECID=2 STAMP=874614651 filename=/u01/app/oracle/racdg_standy/datafile/sysaux.293.874603643

Datafile 3 switchedto datafile copy

Input datafile copyRECID=3 STAMP=874614651 filename=/u01/app/oracle/racdg_standy/datafile/undotbs1.294.874603645

Datafile 4 switchedto datafile copy

Input datafile copyRECID=4 STAMP=874614651 filename=/u01/app/oracle/racdg_standy/datafile/users.295.874603647

Datafile 5 switchedto datafile copy

Input datafile copyRECID=5 STAMP=874614651 filename=/u01/app/oracle/racdg_standy/datafile/undotbs2.300.874604699

Finished DuplicateDb at 17-MAR-15

RMAN >

View the status of the standby DB instance:

SQL > select instance_name,status from v$instance

INSTANCE_NAME STATUS

--

Racdg MOUNTED

SQL >

SQL > SELECT SWITCHOVER_STATUS FROMV$DATABASE

SWITCHOVER_STATUS

-

RECOVERY NEEDED

View log

SQL > select member from v$logfile

MEMBER

/ u01/app/oracle/racdg_standy/onlinelog/group_2.298.874604079

/ u01/app/oracle/racdg_standy/onlinelog3/group_2.428.874604089

/ u01/app/oracle/racdg_standy/onlinelog/group_1.297.874604065

/ u01/app/oracle/racdg_standy/onlinelog3/group_1.427.874604073

/ u01/app/oracle/racdg_standy/onlinelog/group_3.301.874604969

/ u01/app/oracle/racdg_standy/onlinelog3/group_3.429.874604987

/ u01/app/oracle/racdg_standy/onlinelog/group_4.302.874604999

/ u01/app/oracle/racdg_standy/onlinelog3/group_4.431.874605055

8 rows selected.

SQL > select * from v$controlfile

STATUS NAME IS_ BLOCK_SIZE FILE_SIZE_BLKS

/ u01/app/oracle/controlfile1/control1.ctl NO 16384 1128

/ u01/app/oracle/controlfile2/control2.ctl NO 16384 1128

SQL >

SQL > select name from v$datafile

NAME

/ u01/app/oracle/racdg_standy/datafile/system.292.874603637

/ u01/app/oracle/racdg_standy/datafile/sysaux.293.874603643

/ u01/app/oracle/racdg_standy/datafile/undotbs1.294.874603645

/ u01/app/oracle/racdg_standy/datafile/users.295.874603647

/ u01/app/oracle/racdg_standy/datafile/undotbs2.300.874604699

SQL >

7. Configure standby DB to accept redo log

Prepare the Standby Database to Receive RedoData

ALTERDATABASE ADD STANDBY LOGFILE THREAD 1 GROUP 5

('/ u01appActionoracleandracdelogstandyandracdlelogandracdelogandslog5standards 1.rdogram SIZE 50m

ALTER DATABASE ADD STANDBY LOGFILE THREAD 1 GROUP 6

('/ u01appActionoracleandracdelogstandyandracdlelogandracdlelogstandyUnigram SIZE 50m

ALTER DATABASE ADD STANDBY LOGFILE THREAD 2 GROUP 7

('/ u01appActionoracleandracdelogstandyandracdlelogandracdlelogandslog7standards 1.rdogram SIZE 50m

ALTER DATABASE ADDSTANDBY LOGFILE THREAD 2 GROUP 8

('/ u01appActionoracleandracdelogstandyandracdlelog.rdogram SIZE 50m

SQL > select member from v$logfile

MEMBER

/ u01/app/oracle/racdg_standy/onlinelog/group_2.298.874604079

/ u01/app/oracle/racdg_standy/onlinelog3/group_2.428.874604089

/ u01/app/oracle/racdg_standy/onlinelog/group_1.297.874604065

/ u01/app/oracle/racdg_standy/onlinelog3/group_1.427.874604073

/ u01/app/oracle/racdg_standy/onlinelog/group_3.301.874604969

/ u01/app/oracle/racdg_standy/onlinelog3/group_3.429.874604987

/ u01/app/oracle/racdg_standy/onlinelog/group_4.302.874604999

/ u01/app/oracle/racdg_standy/onlinelog3/group_4.431.874605055

/ u01/app/oracle/racdg_standy/onlinelog/slog5_1.rdo

/ u01/app/oracle/racdg_standy/onlinelog3/slog5_2.rdo

/ u01/app/oracle/racdg_standy/onlinelog/slog6_1.rdo

MEMBER

/ u01/app/oracle/racdg_standy/onlinelog3/slog6_2.rdo

/ u01/app/oracle/racdg_standy/onlinelog/slog7_1.rdo

/ u01/app/oracle/racdg_standy/onlinelog3/slog7_2.rdo

/ u01/app/oracle/racdg_standy/onlinelog/slog8_1.rdo

/ u01/app/oracle/racdg_standy/onlinelog3/slog8_2.rdo

16 rows selected.

Start Redo Apply on the backup node

Execute:

ALTER DATABASE RECOVER MANAGED STANDBYDATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION

8 、 Verify the PhysicalStandby Database Is Performing Properly

View the results:

SQL > SELECTSEQUENCE#,APPLIED FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#

SEQUENCE# APPLIED

--

57 YES

58 YES

SQL >

Log switching is performed on each node of the PrimaryDB:

SQL > alter system switch logfile

System altered.

SQL > SELECT SEQUENCE#,APPLIED FROMV$ARCHIVED_LOG ORDER BY SEQUENCE#

SEQUENCE# APPLIED

--

57 YES

58 YES

59 YES

60 YES

61 YES

62 YES

85 YES

86 YES

87 YES

88 YES

89 YES

Delete tablespace test:

View the dbf file on the standby node:

SQL > select name from v$datafile

/ u01/oracle/racdg_standy/datafile/system.256.875118467

/ u01/oracle/racdg_standy/datafile/sysaux.257.875118471

/ u01/oracle/racdg_standy/datafile/undotbs1.258.875118473

/ u01/oracle/racdg_standy/datafile/users.259.875118473

/ u01/oracle/racdg_standy/datafile/undotbs2.264.875119141

/ u01/oracle/racdg_standy/datafile/vav.268.875198681

/ u01/oracle/racdg_standy/datafile/vav1.269.875553481

View the delete tablespace vav1 on the primary node

SQL > drop tablespace vav1 includingcontents and datafiles cascade constraints

Tablespace dropped.

SQL > select name from v$datafile

NAME

- -+ DATA2/racdg/datafile/system.256.875118467

+ DATA2/racdg/datafile/sysaux.257.875118471

+ DATA2/racdg/datafile/undotbs1.258.875118473

+ DATA2/racdg/datafile/users.259.875118473

+ DATA2/racdg/datafile/undotbs2.264.875119141

+ DATA2/racdg/datafile/vav.268.875198681

Each node executes

SQL > alter system switch logfile

System altered.

SQL >

View on the Standby node:

SQL > select name from v$datafile

NAME

- -/ u01/oracle/racdg_standy/datafile/system.256.875118467

/ u01/oracle/racdg_standy/datafile/sysaux.257.875118471

/ u01/oracle/racdg_standy/datafile/undotbs1.258.875118473

/ u01/oracle/racdg_standy/datafile/users.259.875118473

/ u01/oracle/racdg_standy/datafile/undotbs2.264.875119141

/ u01/oracle/racdg_standy/datafile/vav.268.875198681

By this time the tablespace vav1 has been deleted.

2. SwitchoverDB (primaryDB-> standbyDB)

1. In the environment, primaryDB is a two-node Rac cluster and standbyDB is a single node. You need to close the rac_dg2 node instance in the rac node during the switch. As to why the rac_dg2 node is closed, the reason is that the receiving point is configured as rac_dg1 in standbyDB Initialization Parameters

SQL > show parameter log_archive_dest_2

NAME TYPE VALUE

-

Log_archive_dest_2 string service=rac_dg1 async

Valid_for= (online_logfiles,pri

Mary_role)

Db_unique_name=racdg

[grid@racdg2] $srvctl stop instance-d racdg-I racdg2

View alter_racdg2.log

2. Check the main library switchover_status

PrimaryDB

SQL > select SWITCHOVER#,SWITCHOVER_STATUS,DATABASE_ROLE fromv$database

SWITCHOVER# SWITCHOVER_STATUS DATABASE_ROLE

1110966030 TO STANDBY PRIMARY

SQL >

StandbyDB

SQL > select SWITCHOVER#,SWITCHOVER_STATUS,DATABASE_ROLE fromv$database

SWITCHOVER#SWITCHOVER_STATUS DATABASE_ROLE

1110966030 NOT ALLOWED PHYSICAL STANDBY

3. Open switch primaryDB

ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBYWITH SESSION SHUTDOWN

After the switch is completed, check the instance status.

4. Close the instance racdg1 and start it to mount state

SQL > SHUTDOWN IMMEDIATE

SQL > STARTUP MOUNT

5. Check the standbyDB status and view

SQL > SELECT SWITCHOVER_STATUS FROMV$DATABASE

SWITCHOVER_STATUS

-

TOPRIMARY

SQL >

6. Switch physicalstandby DB to prmary role

ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSIONSHUTDOWN

7. Create a receive log file

View logfile

Add log file

ALTERDATABASE ADD STANDBY LOGFILE THREAD 1 GROUP 5

('+ DATA1/racdg/onlinelog/slog5_1.rdo','+DATA2/racdg/onlinelog/slog5_2.rdo') SIZE 50m

ALTERDATABASE ADD STANDBY LOGFILE THREAD 1 GROUP 6

('+ DATA1/racdg/onlinelog/slog6_1.rdo','+DATA2/racdg/onlinelog/slog6_2.rdo') SIZE 50m

ALTERDATABASE ADD STANDBY LOGFILE THREAD 2 GROUP 7

('+ DATA1/racdg/onlinelog/slog7_1.rdo','+DATA2/racdg/onlinelog/slog7_2.rdo') SIZE 50m

ALTERDATABASE ADD STANDBY LOGFILE THREAD 2 GROUP 8

('+ DATA1/racdg/onlinelog/slog8_1.rdo','+DATA2/racdg/onlinelog/slog8_2.rdo') SIZE 50m

8. Open a new primaryDB

SQL > alter database open

9. Star redo log on the new physicalstandby DB

SQL > ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE

2 DISCONNECT FROM SESSION

Database altered.

SQL >

10. View status

New physical standby DB

New primary DB

At this point, the handover is complete.

View and verify:

The first kind:

View on the new primary DB node

SQL > SELECT SEQUENCE#,APPLIED FROMV$ARCHIVED_LOG ORDER BY SEQUENCE#

SQL > alter system switch logfile

View on the new standby DB node

SQL > SELECT SEQUENCE#,APPLIED FROMV$ARCHIVED_LOG ORDER BY SEQUENCE#

This shows that 142,140,141 are synchronized with 140,141 after an alter system switch logfile on primary.

The second kind:

Delete tablespace DBF

Drop tablespace VAV1 including contents anddatafiles cascade constraints

1. View

New primary node

New physical standby DB

2. Delete VAV1 tablespace

Drop tablespace VAV1 including contentsand datafiles cascade constraints

3. Check in the new physicalstandby DB node.

This shows that switchoverprimary to standby is successful.

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

Database

Wechat

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

12
Report