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

Oracle 10G DataGuard building

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

Share

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

Earlier we talked about the construction of Oracle 11G DataGuard, while the construction of 10G is more or less the same. However, Oracle 10G does not support Standby open.

Environment:

Role hostname IP database version operating system version Primaryfdb1192.168.10.810.2.0.1CentOS 5.11 x86_64Standbyfdb2192.168.10.910.2.0.1CentOS 5.11 x86room64

Add (fdb1) to / etc/hosts of fdb1

127.0.0.1 fdb1192.168.10.9 fdb2

Add (fdb2) to / etc/hosts of fdb2

127.0.0.1 fdb2192.168.10.8 fdb1

Create the necessary directories (fdb1,fdb2)

Mkdir-p / opt/oracle/flash_recovery_areamkdir-p / opt/oracle/admin/fengdb/ {a _ r _ r _ c _ r _ r _ u} dumpmkdir / opt/oracle/oradata/fengdb-pmkdir-p / opt/oracle/dbackupmkdir-p / opt/oracle/flash_recovery_area/fengdb/archivelog

View the current redo group (fdb1)

Select group#,member from vault log database add standby logfile / add standby log group alter database add standby logfile ('/ opt/oracle/oradata/fengdb/standby04.log') size 50m alter database add standby logfile ('/ opt/oracle/oradata/fengdb/standby05.log') size 50m alter database add standby logfile ('/ opt/oracle/oradata/fengdb/standby06.log') size 50m alter database add standby logfile ('/ opt/oracle/oradata/fengdb/standby07.log') size 50m

Create the original parameter file for backup (fdb1)

Create pfile='/tmp/fengdb.pfile.ori' from spfile

Modify the relevant parameters for the DataGuard environment, note that this is different from Oracle 11G (fdb1)

Alter system set db_unique_name=fdb1 scope=spfile;alter system set log_archive_config='dg_config= (fdb1,fdb2) 'scope=spfile;alter system set log_archive_dest_1=' location=/opt/oracle/flash_recovery_area/fengdb/archivelog valid_for= (all_logfiles,all_roles) db_unique_name=fdb1' scope=spfile;alter system set log_archive_dest_2= 'service=fdb2 async valid_for= (online_logfiles,primary_role) db_unique_name=fdb2' scope=spfile;alter system set log_archive_dest='' scope=spfile Alter system set log_archive_dest_state_1=enable scope=spfile;alter system set log_archive_dest_state_2=enable scope=spfile;alter system set standby_file_management=auto scope=spfile;alter system set fal_server=fdb2 scope=spfile;alter system set fal_client=fdb1 scope=spfile;alter system set db_file_name_convert='/opt/oracle/flash_recovery_area','/opt/oracle/flash_recovery_area' scope=spfile;alter system set log_file_name_convert='/opt/oracle/flash_recovery_area','/opt/oracle/flash_recovery_area' scope=spfile

Note: unlike Oracle 11G, there are:

Alter system set log_archive_dest='' scope=spfile

Otherwise, ORA-16019: cannot use LOG_ARCHIVE_DEST_1 with LOG_ARCHIVE_DEST or LOG_ARCHIVE_DUPLEX_DEST may appear

And all of the above modify spfile directly, without modifying the currently running parameters.

Scope=spfile

To execute the above statement is to change some of the following parameters

* .db_unique_name='fdb1'

* .log_archive_config='dg_config= (fdb1,fdb2)'

* .log_archive_dest_1='location=/opt/oracle/flash_recovery_area/fengdb/archivelog valid_for= (all_logfiles,all_roles) db_unique_name=fdb1'

* .log_archive_dest_2='service=fdb2 async valid_for= (online_logfiles,primary_role) db_unique_name=fdb2'

* .log_archive_dest_state_1='ENABLE'

* .log_archive_dest_state_2='ENABLE'

* .standby_file_management='AUTO'

* .fal_client='fdb1'

* .fal_server='fdb2'

* .db_file_name_convert='/opt/oracle/flash_recovery_area','/opt/oracle/flash_recovery_area'

* .log_file_name_convert='/opt/oracle/flash_recovery_area','/opt/oracle/flash_recovery_area'

* .log_archive_dest=''

Restart the database for the database to work (fdb1)

Shutdown immediatestartup

Modify Monitoring (fdb1)

Vim $ORACLE_HOME/network/admin/tnsnames.ora

Fdb1 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (HOST = fdb1) (PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = fdb1) fdb2 = (DESCRIPTION = (ADDRESS_LIST = (PROTOCOL = TCP) (HOST = fdb2) (PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) ) (SERVICE_NAME = fdb2)

RMAN backup (fdb1)

Rman target / run {allocate channel C1 type disk;backup format'/ opt/oracle/dbackup/fengdb_%T_%s_%p' database;sql 'alter system archivelog current';backup format' / opt/oracle/dbackup/archive_log_%T_%s_%p' archivelog all;backup spfile format'/ opt/oracle/dbackup/spfile_%u_%T.bak';release channel C1;} copy current controlfile for standby to'/ opt/oracle/dbackup/standby.ctl'

Copy all backup and monitoring files and password files to fdb2 (fdb1)

Scp-r / opt/oracle/dbackup/* fdb2:/opt/oracle/dbackup

Scp-r $ORACLE_HOME/network/admin/* fdb2:$ORACLE_HOME/network/admin/

Scp-r $ORACLE_HOME/dbs/* fdb2:$ORACLE_HOME/dbs/

Perform the following recovery of the database on fdb2 (fdb2)

RMAN > startup nomount

RMAN > restore spfile to pfile' / tmp/fengdb.pfile' from'/ opt/oracle/dbackup/spfile_rmrioont_20161019.bak'

RMAN > shutdown immediate

Then modify / etc/fengdb.pfile to the following red section

* .db_unique_name='fdb2'

* .fal_client='fdb2'

* .fal_server='fdb1'

* .log_archive_config='dg_config= (fdb2,fdb1)'

* .log_archive_dest_1='location=/opt/oracle/flash_recovery_area/fengdb/archivelog valid_for= (all_logfiles,all_roles) db_unique_name=fdb2'

* .log_archive_dest_2='service=fdb1 async valid_for= (online_logfiles,primary_role) db_unique_name=fdb1'

* .log_archive_dest_state_1='ENABLE'

* .log_archive_dest_state_2='ENABLE'

Prepare library replication control files (fdb2)

Cp / opt/oracle/dbackup/standby.ctl / opt/oracle/oradata/fengdb/control01.ctl

Cp / opt/oracle/dbackup/standby.ctl / opt/oracle/oradata/fengdb/control02.ctl

Cp / opt/oracle/dbackup/standby.ctl / opt/oracle/oradata/fengdb/control03.ctl

Start to mount state for data recovery

RMAN > startup mount;RMAN > restore database

Start the backup database application log

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

Create a parameter file

SQL > create spfile from pfile='/tmp/fengdb.pfile'

Note: the difference between Oracle 10G and 11G:

10g standby library can only boot to mount state, while 11G can boot to open read only.

Check whether the log is synchronized (fdb1,fdb2)

Select sequence#,applied from v$archived_log

You can also try to switch logs.

/ / switch log alter system switch logfile;select sequence#,applied from v$archived_log

In the main library: (fdb1)

Select dest_name,status,error from vastly archived destinationalter system set log_archive_dest_state_2= enable

Query role (fdb1,fdb2)

Select open_mode,database_role from v$database

If you are on the reserve library

SQL > select sequence#,applied from v$archived_log

No rows selected

And the monitoring is normal, then it is possible that the password has not been copied.

Keep the password of the main database consistent with that of the standby database

Copy password file (fdb1)

Scp $ORACLE_HOME/dbs/orapw$ORACLE_SID fdb2:$ORACLE_HOME/dbs/orapw$ORACLE_SID

Oracle 10G master / standby handoff

Db1---primary/db2---standby = "db2--primary/db1--standby

[oracle@fdb1 ~] $lsnrctl stop

(fdb1) SQL > alter database commit to switchover to physical standby with session shutdown

(fdb1) SQL > shutdown immediate

(fdb1) SQL > startup mount

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

/ / when executing this article, if it appears

ERROR at line 1:

ORA-01665: control file is not a standby control file

The alter database commit to switchover to physical standby with session shutdown is not executed.

If ORA-38500: USING CURRENT LOGFILE option not available without stand appears

This situation occurs after the master / slave switch, and the standby switch back to the master.

SQL > select member from v$logfile

MEMBER

/ opt/oracle/oradata/fengdb/redo03.log

/ opt/oracle/oradata/fengdbredo02.log

/ opt/oracle/oradata/fengdb/redo01.log

Just add standby flog.

Alter database add standby logfile ('/ opt/oracle/oradata/fengdb/standby04.log') size 50m

Alter database add standby logfile ('/ opt/oracle/oradata/fengdb/standby05.log') size 50m

Alter database add standby logfile ('/ opt/oracle/oradata/fengdb/standby06.log') size 50m

Alter database add standby logfile ('/ opt/oracle/oradata/fengdb/standby07.log') size 50m

[oracle@fdb1 ~] $lsnrctl start

(fdb2) SQL > alter database commit to switchover to primary

Note:

If ORA-16139: media recovery required appears, execute the following statement:

SQL > ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION

SQL > alter database commit to switchover to primary

If so, it may be that the session is already open, plus with session shutdown forces painting to be closed

ERROR at line 1:

ORA-01093: ALTER DATABASE CLOSE only permitted with no sessions connected

SQL > alter database commit to switchover to primary WITH SESSION SHUTDOWN

(fdb2) SQL > shutdown immediate

(fdb2) SQL > startup

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