Oracle DataGuard Master-slave stepping over the pit

Source: Internet
Author: User
Tags sqlplus

First, the host description

dbprimary:192.168.1.57 Host name DB1
DBSTANDBY:192.168.1.58 Host name DB2
Sid:orcl

Second, the configuration of TNS, the configuration of the file content:

Dbprimary Listener.ora (/db/app/oracle/product/11.2.0/network/admi directory):
# Generated by Oracle configuration tools.
Sid_list_listener =
(Sid_list =
(Sid_desc =
(Sid_name = ORCL)
(Oracle_home =/db/app/oracle/product/11.2.0)
(Global_dbname = ORCL)
)
)

LISTENER =
(Description_list =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = db1) (PORT =1521))
)
)

Dbstandby's Listener.ora:
# Generated by Oracle configuration tools.

Sid_list_listener =
(Sid_list =
(Sid_desc =
(Sid_name = ORCL)
(Oracle_home =/db/app/oracle/product/11.2.0)
(Global_dbname = ORCL)
)
)

LISTENER =
(Description_list =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = DB2) (PORT =1521))
)
)

Dbprimary and Dbstandby on the Tnsnames.ora are the same
# Generated by Oracle configuration tools.

Dbstandby =
(DESCRIPTION =
(Address_list =
(ADDRESS = (PROTOCOL = TCP) (HOST = DB2) (PORT =1521))
)
(Connect_data =
(service_name = ORCL)
)
)

Dbprimary =
(DESCRIPTION =
(Address_list =
(ADDRESS = (PROTOCOL = TCP) (HOST = db1) (PORT =1521))
)
(Connect_data =
(service_name = ORCL)
)
)

Then check the configuration correctly on both machines
Oracle>lsnrctl stop
Oracle>lsnrctl start
Oracle>lsnrctl status
Oracle>tnsping dbprimary
Oracle>tnsping Dbstandby
Oracle>sqlplus sys/[email protected] as Sysdba
Oracle>sqlplus sys/[email protected] as Sysdba

Third, operate on the Dbprimary
1. Oracle> mkdir/db/app/oracle/oradata/archive
2. Cd/db/app/oracle/product/11.2.0/dbs

oracle> CP ORAPWORCL Orapworcl.bak
oracle> orapwd file=orapw$oracle_sid password=oracle entries=30 force=y

Generate password file Oraworcl, must be copied to from the library, even if the same command from the library does not work
3. Back up and recreate the Pfile file

ORACLE>MV Initorcl.ora Initorcl.ora.bak

Oracle>sqlplus Sys/password as Sysdba
Sql>create pfile from SPFile;

Generate Initorcl.ora under/db/app/oracle/product/11.2.0/dbs to add content after the Initorcl.ora file:
*. Db_unique_name= ' Dbprimary '
*. Log_archive_config= ' dg_config= (dbprimary, Dbstandby) '
*. Log_archive_dest_1= ' location=/db/app/oracle/oradata/archive/valid_for= (all_logfiles,all_roles) DB_UNIQUE_NAME= Dbprimary '
*. Log_archive_dest_2= ' Service=dbstandby lgwr asyncvalid_for= (online_logfiles,primary_role) DB_UNIQUE_NAME=dbstandby ‘
*. log_archive_dest_state_1= ' ENABLE '
*. Log_archive_dest_state_2= ' ENABLE '
*. log_archive_format= '%t_%s_%r.arc '
*. Log_archive_max_processes=30
*. Fal_server= ' Dbstandby '
*. Fal_client= ' Dbprimary '

*. Db_file_name_convert= ' Dbstandby ', ' dbprimary '
*. Standby_file_management= ' AUTO '

4. Back up and recreate the SPFile file

Oracle>mvspfileorcl.ora Spfileorcl.ora.bak

Oracle>sqlplus Sys/password as Sysdba

Sql>create SPFile from Pfile;
Sql>startup Mount;
Sql>alter database Archivelog;
Sql>alter database open;
Sql>archive log list; See if it is in log mode, if not execute the following command
Sql>alter database force logging; Change to logging mode
Sql>alter Database Create standby controlfile as '/db/app/oracle/oradata/standby01.ctl '; creating a control file on Dbstandby
Sql>shutdown immediate;

5. Pack the/db/app/oracle/oradata to the Dbstandby server and pass the/DB/APP/ORACLE/PRODUCT/11.2.0/DBS/ORAWORCL over.


Iv. operating on the Dbstandby server
1. Oracle>sqlplus Sys/password as Sysdba
Sql>shutdown immediate;
2. Oracle>cd/db/app/oracle
ORACLE>MV Oradata Oradata.bak
Unzip the bag you just passed over.
ORACLE>CD Oradata
ORACLE>CP Standby01.ctl Standby02.ctl
ORACLE>CP Standby01.ctl Standby03.ctl
3. Back up and recreate the Pfile file

ORACLE>MV Initorcl.ora Initorcl.ora.bak

Sql>create Pfile from SPFile
Modifying the *.control_files parameter in Initorcl.ora
*.control_files= '/db/app/oracle/oradata/standby01.ctl ', '/db/app/oracle/oradata/standby02.ctl ', '/db/app/oracle/ Oradata/standby03.ctl '
Increase
*. Db_unique_name= ' Dbstandby '
*. Log_archive_config= ' dg_config= (dbprimary, Dbstandby) '
*. Log_archive_dest_1= ' location=/db/app/oracle/oradata/archive/valid_for= (all_logfiles,all_roles) DB_UNIQUE_NAME= Dbstandby '
*. Log_archive_dest_2= ' service=dbprimary lgwr asyncvalid_for= (online_logfiles,primary_role) DB_UNIQUE_NAME=dbprimary ‘
*. log_archive_dest_state_1= ' ENABLE '
*. Log_archive_dest_state_2= ' ENABLE '
*. log_archive_format= '%t_%s_%r.arc '
*. Log_archive_max_processes=30
*. Fal_server= ' Dbprimary '
*. Fal_client= ' Dbstandby '

*. Db_file_name_convert= ' Dbstandby ', ' dbprimary '
*. Standby_file_management= ' AUTO '

4. Back up and recreate the SPFile file

Oracle>mvspfileorcl.ora Spfileorcl.ora.bak

Oracle>sqlplus Sys/password as Sysdba

Sql>create SPFile from Pfile;
Sql>shutdown immediate;

To this end, all configurations for Oracle Dataguard master are completed

V. Primary and Standby configuration verification, and database restart steps

(focus) Open two command windows on the main library (DB1) server, using Sqlplus to log in to the main and standby libraries respectively

Log in to the main library

Sqlplus Sys/[email protected] as Sysdba

Log in to the standby library

Sqlplussys/[email protected] as Sysdba

1. Close the main library

Shutdownimmediate;

2. Close the Standby library

Shutdownimmediate;

3. Start the standby library to mount

startup Mount;

4. Start the main library

Startup

5. Open the Standby library

ALTER DATABASE open;

6. Open the synchronization service on the standby library

ALTER DATABASE recover managed Standbydatabase disconnect from session;

7. Check if it's working properly

(prepared) Sql>select max (sequence#) Fromv$archived_log;
(master) sql>alter system switch logfile;
(master) sql>select Max (sequence#) from V$archived_log; View current sequence
(prepared) Sql>select Max (sequence#) from V$archived_log;
If Dbstandby's sequence changes, it's good.

8. Select Dest_name,status,error fromv$archive_dest; Check that the status of the corresponding archive path is valid, otherwise it will be processed according to the error information

9. Can view alert log file
/db/app/oracle/diag/rdbms/dbprimary/orcl/alert/log.xml
/db/app/oracle/diag/rdbms/dbprimary/orcl/trace/alert_orcl.log

Oracle DataGuard Master-slave stepping over the pit

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.