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

Build DG by Linux6.4+Oracle11.2.0.4

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

Share

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

Test environment description hardware information

The virtual environment used in this test environment is shown in the following figure. Two Oracle Linux 6.64-bit operating systems built by VMware Workstation 11 are bridged to a virtual network card by two machines.

System information

Server one (master)

Server 2 (standby)

Hostname: zhanky

IP: 192.168.214.10

Database version: oracle 11.2.0.4

Library name: zky TNSNAME:DGZ

Hostname: zhanky

IP: 192.168.214.11

Database version: oracle 11.2.0.4

Library name: zky TNSNAME:DGB

DG failover hint

Master and standby database normally, client access traffic accesses the main database, and data is automatically synchronized to the standby database. When the primary library fails, the administrator manually switches the standby library to the primary library. At this point, the client accesses the slave database to achieve normal access without interrupting the business.

Test flow

We mimic the formal environment by preparing the primary server and then installing only the database software on the standby server. In this test, we use rman to back up the database, and then restore it on standby. The key implementation steps are as follows

Primary

1. Open the archive mode and enable forced logging.

2. Create a log group

3. Add static monitoring and tns

4. Generate password file

5. Generate pfile and add DG content

6. Restart is started through pfile to update spfile.

7. Backup via rman duplicate

8. Generate control files

Standby

1. Copy the backup file to the corresponding location of standby.

2. Test the password file to the corresponding position

3. Modify the listening file and test it to the corresponding location, and then turn on the monitoring.

4. Copy the pfile file to standby after change

5. Create an instance through oradim and load the changed pfile to nomount mode

6. Update pfile to spfile, then restart the database

7. Reply to the database through rman, and open after completion

8. Replace the control file

9. Then enable DG to standby mode

DG master server settings check database archiving

Check whether the archive log is turned on

SQL > archive log list

The above picture shows that the library turns on the archiving mode. If it is not turned on, follow these steps to turn on the archive mode

SQL > shutdown immediate

SQL > startup mount

SQL > alter database archivelog

SQL > alter database force logging

SQL > alter database open

Create a log group

Create a log group

[oracle@zhanky /] $mkdir / u01/archive

SQL > alter database add standby logfile group 4'/ u01Universe archiveUniverse STAN04.LOG' size 50m

SQL > alter database add standby logfile group 5'/ u01Universe archiveUniverse STAN05.LOG' size 50m

SQL > alter database add standby logfile group 6'/ u01Universe archiveUniverse STAN06.LOG' size 50m

SQL > alter database add standby logfile group 7'/ u01Universe archiveUniverse STAN07.LOG' size 50m

Check the password file

The password file should be copied to the DG backup library to keep the password files consistent on both sides.

[oracle@zhanky ~] $ls / u01/app/oracle/product/11.2.0/db_1/dbs/

If there is no password file, you can create it manually.

SQL > orapwd file=/u01/app/oracle/product/11.2.0/db_1/dbs/orapwzky password=manager entries=10

It is recommended that the password never expire.

SQL > alter profile default limit password_life_time unlimited

Configure the listening file

Configure static snooping and add static snooping to listener.ora files

[oracle@zhanky ~] $vi / u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora

SID_LIST_LISTENER=

(SID_LIST =

(SID_DESC =

(GLOBAL_DBNAME = zky)

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

(SID_NAME = zky)

)

)

Note that changes to listening in linux environment need to be modified by stop first, otherwise the listening service cannot be started and shut down normally.

Configure the TNS file

Configure tnsname.ora, set DG master and DG standby server to listen

[oracle@zhanky ~] $vi / u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora

DGZ =

(DESCRIPTION =

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

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = zky)

)

)

DGB =

(DESCRIPTION =

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

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = zky)

)

)

Configure DG parameters

Let's start to configure the dg file, and remember to restart the database after configuration.

SQL > alter system set db_unique_name=dgz scope=spfile

SQL > alter system set LOG_ARCHIVE_CONFIG='DG_CONFIG= (DGZ,DGB) 'scope=both

SQL > alter system set LOG_ARCHIVE_DEST_1='LOCATION=/u01/app/oracle/oradata/zky/ VALID_FOR= (ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=DGZ' scope=spfile

SQL > alter system set LOG_ARCHIVE_DEST_2= 'service=DGB lgwr async VALID_FOR= (ONLINE_LOGFILES,PRIMARY_ROLES) DB_UNIQUE_NAME=DGB' scope=both

SQL > alter system set LOG_ARCHIVE_DEST_STATE_1=ENABLE scope=both

SQL > alter system set LOG_ARCHIVE_DEST_STATE_2=ENABLE scope=both

SQL > alter system set FAL_SERVER='DGZ' scope=both

SQL > alter system set STANDBY_FILE_MANAGEMENT=AUTO scope=both

SQL > alter system set DB_FILE_NAME_CONVERT='/u01/app/oracle/oradata/zky/','/u01/app/oracle/oradata/zky/' scope=spfile

SQL > alter system set LOG_FILE_NAME_CONVERT='/u01/archive/','/u01/archive/' scope=spfile

Create a parameter file

Create a parameter file for the library

SQL > create pfile='/u01/zk.int' from spfile

DG standby server settings replication files

Copy the password file and parameter file to the corresponding location of the DG backup library and grant read and write permission

[oracle@zhanky ~] $scp oracle@192.168.214.10:/u01/zk.int / u01/bk.int

[oracle@zhanky ~] $scp oracle@192.168.214.10:/u01/app/oracle/product/11.2.0/db_1/dbs/orapwzky / u01/app/oracle/product/11.2.0/db_1/dbs/orapwzky

[oracle@zhanky ~] $chmod 777 / u01/bk.int

[oracle@zhanky ~] $chmod 777 / u01/app/oracle/product/11.2.0/db_1/dbs/orapwzky

Create a folder

[oracle@zhanky /] $mkdir-p / u01/archive/

[oracle@zhanky /] $mkdir-p / u01/app/oracle/admin/zky/adump/

[oracle@zhanky /] $mkdir-p / u01/app/oracle/oradata/zky/

[oracle@zhanky /] $mkdir-p / u01/app/oracle/fast_recovery_area/zky/

Configure the listening file

Configure static snooping and add static snooping to listener.ora files

[oracle@zhanky ~] $vi / u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora

SID_LIST_LISTENER=

(SID_LIST =

(SID_DESC =

(GLOBAL_DBNAME = zky)

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

(SID_NAME = zky)

)

)

Note that changes to listening in linux environment need to be modified by stop first, otherwise the listening service cannot be started and shut down normally.

Configure the TNS file

Configure tnsname.ora, set DG master and DG standby server to listen

[oracle@zhanky ~] $vi / u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora

DGZ =

(DESCRIPTION =

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

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = zky)

)

)

DGB =

(DESCRIPTION =

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

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = zky)

)

)

Configure DG parameters

Change the copied parameter file to the following red mark

[oracle@zhanky ~] $vi / u01/bk.int

Db_unique_name=dgb scope=spfile

LOG_ARCHIVE_CONFIG='DG_CONFIG= (DGZ,DGB) 'scope=both

LOG_ARCHIVE_DEST_1='LOCATION=/u01/app/oracle/oradata/zky/ VALID_FOR= (ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=DGZ' scope=spfile

LOG_ARCHIVE_DEST_2= 'service=DGB lgwr async VALID_FOR= (ONLINE_LOGFILES,PRIMARY_ROLES) DB_UNIQUE_NAME=DGB' scope=both

FAL_SERVER='DGZ' scope=both

After completing the changes, go to the database to create spfile, restart to the nomount state and prepare to restore the database.

[oracle@zhanky /] $sqlplus / as sysdba

SQL > create spfile from pfile='/u01/bk.int'

SQL > startup nomount

Restore database

[oracle@zhanky ~] $rman target sys/manager@DGZ auxiliary sys/manager@DGB

RMAN > duplicate target database for standby from active database nofilenamecheck

Tip: restore the database in nomount mode

DG configuration

Configure the library as a standby library, turn it on to read-only mode, and enable real-time application log.

SQL > shutdown immediate

SQL > startup nomount

SQL > alter database mount standby database

SQL > alter database open read only

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

Test DG synchronization

Main library insert

SQL > create table zkydg as (select username from dba_users where username='SYSTEM')

Prepare database query

SQL > select * from zkydg

Test the operation of switching between primary and secondary libraries

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

SQL > startup nomount

SQL > alter database mount standby database

SQL > alter database open read only

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

View switching status

SQL > select switchover_status from v$database

Reserve database operation

SQL > alter database recover managed standby database cancel

SQL > alter database commit to switchover to primary

SQL > shutdown immediate

SQL > startup

Test whether the handover is successful or not. DG synchronization

New main library insert

SQL > create table zkydgqh as (select username from dba_users where username='SYS')

Old main database query

SQL > select * from zkydgqh

Commonly used check commands to view switching status

SQL > select switchover_status from v$database

Check whether to synchronize or not

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

Force to switch to the main library

When the main database is out of control, you can force the database to take over directly on the standby database.

SQL > RECOVER MANAGED STANDBY DATABASE FINISH force

SQL > shutdown immediateSQL > startup nomount;SQL > alter database mount standby database;SQL > alter database open read only;SQL > alter database recover managed standby database using current logfile disconnect from session

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