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

Hand in hand to teach you to install Data Guard

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

(1)

The main library installs the database, and the standby library only installs the software. we can copy the virtual machine when the main library finishes installing the software.

When the main library uses dbca to build the database, the global database chooses szscpdb,sid and szsc.

(2)

Configure main and standby database information

Main library:

Operating system: oracle liunx 5.6

Hostname: SZSCPDB

Ip address: 192.168.1.21

Oracle_sid:szsc

Db_unqiue_name:szscpdb

Service_name:szscpdb

Global_name:szscpdb

Listener name, port: listener, 1521

Prepare the library:

Operating system: oracle liunx 5.6

Hostname: SZSCSTB

Ip address: 192.168.1.22

Oracle_sid:szsc

Db_unqiue_name:szscstb

Service_name:szscstb

Global_name:szscstb

Listener name, port: listener, 1521

(3)

Check the hosts files of the primary and secondary libraries to determine the resolution of ip and hostname:

Main library:

[oracle@SZSCPDB szscpdb] $cat / etc/hosts

# Do not remove the following line, or various programs

# that require network functionality will fail.

127.0.0.1 localhost.localdomain localhost

:: 1 localhost6.localdomain6 localhost6

192.168.1.21 SZSCPDB

192.168.1.22 SZSCSTB

Prepare the library:

[oracle@SZSCSTB szscstb] $cat / etc/hosts

# Do not remove the following line, or various programs

# that require network functionality will fail.

127.0.0.1 localhost.localdomain localhost

:: 1 localhost6.localdomain6 localhost6

192.168.1.21 SZSCPDB

192.168.1.22 SZSCSTB

(4)

Make sure that the monitoring of the main library is turned on

[oracle@SZSCPDB szscpdb] $lsnrctl status

LSNRCTL for Linux: Version 11.2.0.3.0-Production on 15-DEC-2013 15:30:42

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

Connecting to (DESCRIPTION= (ADDRESS= (PROTOCOL=TCP) (HOST=SZSCPDB) (PORT=1521)

STATUS of the LISTENER

-

Alias LISTENER

Version TNSLSNR for Linux: Version 11.2.0.3.0-Production

Start Date 15-DEC-2013 14:24:29

Uptime 0 days 1 hr. 6 min. 12 sec

Trace Level off

Security ON: Local OS Authentication

SNMP OFF

Listener Parameter File / u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora

Listener Log File / u01/app/oracle/diag/tnslsnr/SZSCPDB/listener/alert/log.xml

Listening Endpoints Summary...

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

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

Services Summary...

Service "szscXDB" has 1 instance (s).

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

Service "szscpdb" has 2 instance (s).

Instance "szsc", status UNKNOWN, has 1 handler (s) for this service...

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

The command completed successfully

(5)

Configure the main library to be in archive mode:

SQL > archive log list

Database log mode Archive Mode

Automatic archival Enabled

Archive destination / arch/szscpdb

Oldest online log sequence 3

Next log sequence to archive 5

Current log sequence 5

(6)

Change the main library to force logging

SQL > alter database force logging

Database altered.

(7)

Create a password file for the main library

[root@SZSCPDB dbs] # cd / u01/app/oracle/product/11.2.0/db_1/dbs/

[root@SZSCPDB dbs] # orapwd file=$ORACLE_HOME/dbs/orapwszsc password=oracle entries=30

(8)

To modify the listening file of the main library, make sure that there is a SID_LIST_LISTENER:

[root@SZSCPDB dbs] # cd / u01/app/oracle/product/11.2.0/db_1/network/admin/

[root@SZSCPDB admin] # vi listener.ora

# listener.ora Network Configuration File: / u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora

# Generated by Oracle configuration tools.

SID_LIST_LISTENER =

(SID_LIST =

(SID_DESC =

(GLOBAL_DBNAME = szscpdb)

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

(SID_NAME = szsc)

)

)

LISTENER =

(DESCRIPTION_LIST =

(DESCRIPTION =

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

)

(DESCRIPTION =

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

)

)

ADR_BASE_LISTENER = / u01/app/oracle

(9)

Modify the tnsname file of the main library:

[root@SZSCPDB admin] # vi tnsnames.ora

# tnsnames.ora Network Configuration File: / u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora

# Generated by Oracle configuration tools.

SZSCPDB =

(DESCRIPTION =

(ADDRESS_LIST =

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

)

(CONNECT_DATA =

(SERVICE_NAME = szscpdb)

)

)

SZSCSTB =

(DESCRIPTION =

(ADDRESS_LIST =

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

)

(CONNECT_DATA =

(SERVICE_NAME = szscstb)

)

)

(10)

Modify the parameter file of the main library:

[root@SZSCPDB admin] # cd / u01/app/oracle/product/11.2.0/db_1/dbs/

Szsc.__db_cache_size=192937984

Szsc.__java_pool_size=4194304

Szsc.__large_pool_size=4194304

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

Szsc.__pga_aggregate_target=209715200

Szsc.__sga_target=306184192

Szsc.__shared_io_pool_size=0

Szsc.__shared_pool_size=96468992

Szsc.__streams_pool_size=0

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

* .audit_trail='db'

* .compatible='11.2.0.0.0'

* .control_files='/u01/app/oracle/oradata/szscpdb/control01.ctl','/u01/app/oracle/oradata/szscpdb/control02.ctl'

* .db_block_size=8192

* .db_domain=''

* .db_name='szscpdb'

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

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

* .log_archive_config='dg_config= (szscpdb,szscstb)'

* .log_archive_dest_1='LOCATION=/arch/szscpdb LGWR VALID_FOR= (ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=szscpdb'

* .log_archive_dest_2='SERVICE=SZSCSTB ASYNC VALID_FOR= (ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=szscstb'

* .DB_FILE_NAME_CONVERT='/u01/app/oracle/oradata/szscstb/','/u01/app/oracle/oradata/szscpdb/'

* .LOG_FILE_NAME_CONVERT='/u01/app/oracle/oradata/szscstb/','/u01/app/oracle/oradata/szscpdb/'

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

* .memory_target=512753664

* .open_cursors=300

* .processes=150

* .remote_login_passwordfile='EXCLUSIVE'

* .undo_tablespace='UNDOTBS1'

* .standby_file_management='AUTO'

* .log_archive_dest_state_1=enable

* .log_archive_dest_state_2=enable

* .fal_server=szscstb

* .fal_client=szscpdb

* .db_unique_name=szscpdb

Note:

1 、

Log_archive_dest_2='SERVICE=SZSCSTB

This parameter is the alias of tnsnames, the uppercase name at the beginning of the file.

2 、

* .fal_server=szscstb

* .fal_client=szscpdb

These two parameters are their respective service_name.

(11)

Transfer the parameter file, password file and tnsname file of the main library to the slave library:

[oracle@SZSCPDB dbs] $cd / u01/app/oracle/product/11.2.0/db_1/dbs

Scp initszsc.ora orapwszsc SZSCSTB:$ORACLE_HOME/dbs

[oracle@SZSCPDB ~] $cd / u01/app/oracle/product/11.2.0/db_1/network/admin/

Scp tnsnames.ora SZSCSTB:$ORACLE_HOME/network/admin

(12)

Modify the parameter file of the slave library:

[root@SZSCSTB admin] # cd / u01/app/oracle/product/11.2.0/db_1/dbs/

[root@SZSCSTB dbs] # vi initszsc.ora

Szsc.__db_cache_size=192937984

Szsc.__java_pool_size=4194304

Szsc.__large_pool_size=4194304

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

Szsc.__pga_aggregate_target=209715200

Szsc.__sga_target=306184192

Szsc.__shared_io_pool_size=0

Szsc.__shared_pool_size=96468992

Szsc.__streams_pool_size=0

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

* .audit_trail='db'

* .compatible='11.2.0.0.0'

* .control_files='/u01/app/oracle/oradata/szscstb/control01.ctl','/u01/app/oracle/oradata/szscstb/control02.ctl'

* .db_block_size=8192

* .db_domain=''

* .db_name='szscpdb'

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

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

* .log_archive_config='dg_config= (szscpdb,szscstb)'

* .log_archive_dest_1='LOCATION=/arch/szscstb LGWR VALID_FOR= (ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=szscstb'

* .log_archive_dest_2='SERVICE=SZSCPDB ASYNC VALID_FOR= (ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=szscpdb'

* .DB_FILE_NAME_CONVERT='/u01/app/oracle/oradata/szscpdb/','/u01/app/oracle/oradata/szscstb/'

* .LOG_FILE_NAME_CONVERT='/u01/app/oracle/oradata/szscpdb/','/u01/app/oracle/oradata/szscstb/'

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

* .memory_target=512753664

* .open_cursors=300

* .processes=150

* .remote_login_passwordfile='EXCLUSIVE'

* .undo_tablespace='UNDOTBS1'

* .standby_file_management='AUTO'

* .log_archive_dest_state_1=enable

* .log_archive_dest_state_2=enable

* .fal_server=szscpdb

* .fal_client=szscstb

* .db_unique_name=szscstb

(13)

Create the appropriate directories on the repository, because the repository did not create the database at first, and some directories are not in the parameter file.

1 、

Audit_file_dest:

[oracle@SZSCSTB] $mkdir-p / u01/app/oracle/admin/szscstb/adump/

2 、

Control_files:

[oracle@SZSCSTB] $mkdir-p / u01/app/oracle/oradata/szscstb

3 、

Create a location for the backup file, and the master library will pass the backup over later:

[root@SZSCSTB ~] # mkdir / backup

[root@SZSCSTB] # chown-R oracle:oinstall / backup

4 、

Create an archive directory to receive the archive logs passed by the main library:

[root@SZSCSTB] # mkdir-p / arch/szscstb

[root@SZSCSTB] # chown-R oracle:oinstall / arch/szscstb

(15)

Make a complete backup with rman on the main database, and you also need to create a backup directory:

[root@SZSCPDB ~] # mkdir / backup

[root@SZSCPDB] # chown-R oracle:oinstall / backup

RMAN > backup device type disk format'/ backup/%U' database plus archivelog

(16)

Transfer the backup file of the primary library to the standby library:

[oracle@SZSCPDB admin] $cd / backup/

[oracle@SZSCPDB backup] $scp * SZSCSTB:/backup

(17)

Start the slave library to the nomount state:

[root@SZSCSTB ~] # su-oracle

[oracle@SZSCSTB ~] $sqlplus / as sysdba

SQL > startup nomount

(18)

Modify the listening file of the standby library.

[oracle@SZSCSTB admin] $vi listener.ora

# listener.ora Network Configuration File: / u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora

# Generated by Oracle configuration tools.

SID_LIST_LISTENER =

(SID_LIST =

(SID_DESC =

(GLOBAL_DBNAME = szscstb)

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

(SID_NAME = szsc)

)

)

LISTENER =

(DESCRIPTION_LIST =

(DESCRIPTION =

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

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

)

)

ADR_BASE_LISTENER = / u01/app/oracle

(19)

Start monitoring to ensure that the service name is registered correctly)

[oracle@SZSCSTB ~] $lsnrctl start

LSNRCTL for Linux: Version 11.2.0.3.0-Production on 15-DEC-2013 07:42:41

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

Connecting to (DESCRIPTION= (ADDRESS= (PROTOCOL=TCP) (HOST=SZSCSTB) (PORT=1521)

STATUS of the LISTENER

-

Alias LISTENER

Version TNSLSNR for Linux: Version 11.2.0.3.0-Production

Start Date 15-DEC-2013 06:13:05

Uptime 0 days 1 hr. 29 min. 36 sec

Trace Level off

Security ON: Local OS Authentication

SNMP OFF

Listener Parameter File / u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora

Listener Log File / u01/app/oracle/diag/tnslsnr/SZSCSTB/listener/alert/log.xml

Listening Endpoints Summary...

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

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

Services Summary...

Service "szscXDB" has 1 instance (s).

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

Service "szscstb" has 2 instance (s).

Instance "szsc", status UNKNOWN, has 1 handler (s) for this service...

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

The command completed successfully

(20)

The master library applies backup files to the standby library, using duplicate mode (executed on the main library)

RMAN > connect auxiliary sys/oracle@SZSCSTB

Connected to auxiliary database: SZSCPDB (not mounted)

RMAN > duplicate target database for standby

Starting Duplicate Db at 08-MAR-13

Using target database control file instead of recovery catalog

Allocated channel: ORA_AUX_DISK_1

Channel ORA_AUX_DISK_1: SID=10 device type=DISK

Contents of Memory Script.:

{

Restore clone standby controlfile

}

Executing Memory Script

Starting restore at 08-MAR-13

Using channel ORA_AUX_DISK_1

Channel ORA_AUX_DISK_1: starting datafile backup set restore

Channel ORA_AUX_DISK_1: restoring control file

Channel ORA_AUX_DISK_1: reading from backup piece / BACKUP/0lo3vm4i_1_1

Channel ORA_AUX_DISK_1: piece handle=/backup/0lo3vm4i_1_1 tag=TAG20130308T022752

Channel ORA_AUX_DISK_1: restored backup piece 1

Channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02

Output file name=/u01/app/oracle/oradata/szscstb/control01.ctl

Output file name=/u01/app/oracle/oradata/szscstb/control02.ctl

Finished restore at 08-MAR-13

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/oracle/oradata/szscstb/temp01.dbf"

Switch clone tempfile all

Set newname for datafile 1 to

"/ u01/app/oracle/oradata/szscstb/system01.dbf"

Set newname for datafile 2 to

"/ u01/app/oracle/oradata/szscstb/sysaux01.dbf"

Set newname for datafile 3 to

"/ u01/app/oracle/oradata/szscstb/undotbs01.dbf"

Set newname for datafile 4 to

"/ u01/app/oracle/oradata/szscstb/users01.dbf"

Restore

Clone database

}

Executing Memory Script

Executing command: SET NEWNAME

Renamed tempfile 1 to / u01/app/oracle/oradata/szscstb/temp01.dbf in control file

Executing command: SET NEWNAME

Executing command: SET NEWNAME

Executing command: SET NEWNAME

Executing command: SET NEWNAME

Starting restore at 08-MAR-13

Using channel ORA_AUX_DISK_1

Channel ORA_AUX_DISK_1: starting datafile backup set restore

Channel ORA_AUX_DISK_1: specifying datafile (s) to restore from backup set

Channel ORA_AUX_DISK_1: restoring datafile 00001 to / / u01/app/oracle/oradata/szscstb/system01.dbf

Channel ORA_AUX_DISK_1: restoring datafile 00002 to / u01/app/oracle/oradata/szscstb/sysaux01.dbf

Channel ORA_AUX_DISK_1: restoring datafile 00003 to / u01/app/oracle/oradata/szscstb/undotbs01.dbf

Channel ORA_AUX_DISK_1: restoring datafile 00004 to / u01/app/oracle/oradata/szscstb/users01.dbf

Channel ORA_AUX_DISK_1: reading from backup piece / backup/0ko3vm18_1_1

Channel ORA_AUX_DISK_1: piece handle=/backup/0ko3vm18_1_1 tag=TAG20130308T022752

Channel ORA_AUX_DISK_1: restored backup piece 1

Channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:02:05

Finished restore at 08-MAR-13

Contents of Memory Script.:

{

Switch clone datafile all

}

Executing Memory Script

Datafile 1 switched to datafile copy

Input datafile copy RECID=2 STAMP=809491977 file name=/u01/app/oracle/oradata/szscstb/system01.dbf

Datafile 2 switched to datafile copy

Input datafile copy RECID=3 STAMP=809491977 file name=/u01/app/oracle/oradata/szscstb/sysaux01.dbf

Datafile 3 switched to datafile copy

Input datafile copy RECID=4 STAMP=809491977 file name=/u01/app/oracle/oradata/szscstb/undotbs01.dbf

Datafile 4 switched to datafile copy

Input datafile copy RECID=5 STAMP=809491977 file name=/u01/app/oracle/oradata/szscstb/users01.dbf

Finished Duplicate Db at 08-MAR-13

(21)

Execute the standby library recovery model. (execute on repository)

SQL > select instance_name,status from v$instance

INSTANCE_NAME STATUS

--

Szsc MOUNTED

SQL > alter database recover managed standby database disconnect from session

Database altered.

(22)

Check the log synchronization to make sure that the logs are applied.

SQL > SELECT SEQUENCE#, REGISTRAR, FIRST_TIME, NEXT_TIME, APPLIED

2 FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#

SEQUENCE# REGISTR FIRST_TIM NEXT_TIME APPLIED

--

13 RFS 15-DEC-13 15-DEC-13 YES

14 RFS 15-DEC-13 15-DEC-13 YES

15 RFS 15-DEC-13 15-DEC-13 YES

16 RFS 15-DEC-13 15-DEC-13 YES

17 RFS 15-DEC-13 15-DEC-13 YES

18 RFS 15-DEC-13 15-DEC-13 YES

19 RFS 15-DEC-13 15-DEC-13 YES

20 RFS 15-DEC-13 15-DEC-13 YES

21 RFS 15-DEC-13 15-DEC-13 YES

22 RFS 15-DEC-13 15-DEC-13 YES

(23)

Create a standby logfile. Both the main library and the standby library should be added.

Main library:

SQL > ALTER DATABASE ADD STANDBY LOGFILE'/ u01 size size 512m

SQL > ALTER DATABASE ADD STANDBY LOGFILE'/ u01 size size 512m

SQL > ALTER DATABASE ADD STANDBY LOGFILE'/ u01 size size 512m

SQL > ALTER DATABASE ADD STANDBY LOGFILE'/ u01 size size 512m

Prepare the library:

SQL > ALTER DATABASE ADD STANDBY LOGFILE'/ u01 size size 512m

SQL > ALTER DATABASE ADD STANDBY LOGFILE'/ u01 size size 512m

SQL > ALTER DATABASE ADD STANDBY LOGFILE'/ u01 size size 512m

SQL > ALTER DATABASE ADD STANDBY LOGFILE'/ u01 size size 512m

(24)

Achieve log synchronization. (execute on the repository)

SQL > alter database recover managed standby database disconnect from session

When complete, end the recovery process:

SQL > alter database recover managed standby database cancel

Launch the slave library to the state of open read only.

SQL > alter database open read only

(25)

Check the log synchronization between the main database and the standby database to make sure that it has been synchronized. (if there is no synchronization, continue to step 24)

Main library:

SQL > archive log list

Database log mode Archive Mode

Automatic archival Enabled

Archive destination / arch/szscpdb

Oldest online log sequence 21

Next log sequence to archive 23

Current log sequence 23

Prepare the library:

SQL > archive log list

Database log mode Archive Mode

Automatic archival Enabled

Archive destination / arch/szscstb

Oldest online log sequence 21

Next log sequence to archive 0

Current log sequence 23

Execute on the repository:

SQL > SELECT SEQUENCE#, REGISTRAR, FIRST_TIME, NEXT_TIME, APPLIED

2 FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#

SEQUENCE# REGISTR FIRST_TIM NEXT_TIME APPLIED

--

13 RFS 15-DEC-13 15-DEC-13 YES

14 RFS 15-DEC-13 15-DEC-13 YES

15 RFS 15-DEC-13 15-DEC-13 YES

16 RFS 15-DEC-13 15-DEC-13 YES

17 RFS 15-DEC-13 15-DEC-13 YES

18 RFS 15-DEC-13 15-DEC-13 YES

19 RFS 15-DEC-13 15-DEC-13 YES

20 RFS 15-DEC-13 15-DEC-13 YES

21 RFS 15-DEC-13 15-DEC-13 YES

22 RFS 15-DEC-13 15-DEC-13 YES

(26)

Make sure that the data can be synchronized, create a table on the main database and see if it can be seen on the backup database.

Main library:

SQL > create table zsx (id number)

Table created.

Prepare the library:

SQL > desc zsx

ERROR:

ORA-04043: object zsx does not exist

Note:

It is found that the data is not synchronized, please execute the following 27 to receive the data.

(27)

Data is received on the standby database and automatically synchronized:

SQL > alter database recover managed standby database using current logfile disconnect from session

Database altered.

SQL > desc zsx

Name Null? Type

-

ID NUMBER

(28)

Verify that the data is synchronized again.

Main library:

SQL > insert into zsx values (1)

1 row created.

SQL > commit

Commit complete.

Prepare the library:

SQL > select * from zsx

ID

-

one

(29)

If there is no problem with the 28 steps, then your DG configuration is successful. The next stage is to implement switchover.

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: 264

*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