Talk about the ORACLE11GR2 Dataguard deployment test ____oracle

Source: Internet
Author: User
Tags mkdir sqlplus
Build the Environment:
OS:SOLARIS10 x86-64
Db:oracle 11.2.0
Main Library Host: Sol01
Repository Host: Sol02

2 Master Library Deployment steps
2.1 Master Library Operations
Create an archive directory and open archive mode.
Su–oracle
Mkdir/orahome/oracle/archivelog
Sqlplus/as SYSDBA
Shutdown immediate
Startup Mount

ALTER DATABASE Archivelog;

See if Force_logging mode
Sql> select log_mode,force_logging from V$database;
Open force_logging Mode
ALTER DATABASE force logging;

Create Pfile from SPFile;

Create a Standby control file
ALTER DATABASE create standby Controlfile as '/orahome/oracle/bak/controlfile01.ctl ';

Create a repository Log group path
ALTER DATABASE ADD standby logfile Group 4 '/orahome/oracle/app/oradata/test/standbyredo04.log ' size 50m;
ALTER DATABASE ADD standby logfile Group 5 '/orahome/oracle/app/oradata/test/standbyredo05.log ' size 50m;
ALTER DATABASE ADD standby logfile Group 6 '/orahome/oracle/app/oradata/test/standbyredo06.log ' size 50m;
ALTER DATABASE ADD standby logfile Group 7 '/orahome/oracle/app/oradata/test/standbyredo07.log ' size 50m;

CD $ORACLE _home/dbs
Backing Up parameter files
CP Inittest.ora INITTEST.ORA.BK
2.2 In the Inittest.ora parameter file, add:
To modify a parameter file:
Db_unique_name=test
Log_archive_config= ' dg_config= (TEST,TEST_DG) '
Log_archive_dest_1= ' Location=/orahome/oracle/archivelog valid_for= (all_logfiles,all_roles) db_unique_name=test '
Log_archive_dest_2= ' SERVICE=TEST_DG lgwr async valid_for= (online_logfiles,primary_role) DB_UNIQUE_NAME=TEST_DG '
Log_archive_dest_state_1=enable
Log_archive_dest_state_2=enable
Fal_server=test_dg
Fal_client=test
Db_file_name_convert= '/orahome/oracle/app/oradata/test ', '/orahome/oracle/app/oradata/test '
Log_file_name_convert= '/orahome/oracle/app/oradata/test ', '/orahome/oracle/app/oradata/test '
Standby_file_management=auto

2.3 Make the change parameter effective:
Sqlplus/as SYSDBA
Startup Nomount pfile= ' $ORACLE _home/dbs/inittest.ora ';
Create SPFile from Pfile;
Shutdown immediate
Startup Mount


2.4 The corresponding document SCP to the standby host:
Control file:
Scp/orahome/oracle/bak/controlfile01.ctl 192.168.0.22: $ORACLE _base/oradata/$ORACLE _sid/control01.ctl
Scp/orahome/oracle/bak/controlfile01.ctl 192.168.0.22: $ORACLE _base/oradata/$ORACLE _sid/control02.ctl
Oracle Password file:
SCP ORAPWGISDB1 192.168.111.129:/HOME/ORACLE/U01/11.2.3/DBHOME_1/DBS/ORAPWGISDB2
Oracle Data files:
SCP $ORACLE _base/oradata/$ORACLE _sid/*.dbf 192.168.0.22: $ORACLE _base/oradata/$ORACLE _sid/
Oracle Redo log files (excluding Standyredo.log)
SCP $ORACLE _base/oradata/$ORACLE _sid/*.log 192.168.0.22: $ORACLE _base/oradata/$ORACLE _sid/
Parameter file
SCP $ORACLE _home/dbs/inittest.ora 192.168.0.22: $ORACLE _home/dbs/
2.5 Change the Pfile:inittest.ora used by the repository
Db_unique_name=test_dg
Log_archive_config= ' dg_config= (TEST,TEST_DG) '
Log_archive_dest_1= ' Location=/orahome/oracle/archivelog valid_for= (all_logfiles,all_roles) db_unique_name=test_ dg
Log_archive_dest_2= ' service=test lgwr async valid_for= (online_logfiles,primary_role) db_unique_name=test '
Log_archive_dest_state_1=enable
Log_archive_dest_state_2=enable
Fal_server=test
Fal_client=test_dg
Db_file_name_convert= '/orahome/oracle/app/oradata/test ', '/orahome/oracle/app/oradata/test '
Log_file_name_convert= '/orahome/oracle/app/oradata/test ', '/orahome/oracle/app/oradata/test '
Standby_file_management=auto
2.6 Configuration Monitor:
bash-3.00$ more Tnsnames.ora
Test =

(DESCRIPTION =

(Address_list =

(address = (PROTOCOL = TCP) (HOST =192.168.0.21) (PORT = 1521))

)

(Connect_data =

(service_name = test)

)

)

TEST_DG =

(DESCRIPTION =

(Address_list =

(address = (PROTOCOL = TCP) (HOST = 192.168.0.22) (PORT = 1521))

)

(Connect_data =

(service_name = TEST_DG)

)

)
Copy the Tnsnames.ora file to the same location as the repository.
2.7 Open the main library:

Alter database open;
The log is as follows:


3 operation from the library:
3.1 Creating the desired directory
Mkdir-p $ORACLE _base/oradata/test
Mkdir-p $ORACLE _base/admin/test/{a,dp}dump
Sqlplus/as SYSDBA
Startup Nomount pfile= ' $ORACLE _home/dbs/inittest.ora ';
Create SPFile from Pfile;
Startup Nomount


3.2 Configuring network Services
Start the Listener (Lsnrctl start) and add the following Tnsnames.ora
bash-3.00$ more Tnsnames.ora
Test =

(DESCRIPTION =

(Address_list =

(address = (PROTOCOL = TCP) (HOST =192.168.0.21) (PORT = 1521))

)

(Connect_data =

(service_name = test)

)

)

TEST_DG =

(DESCRIPTION =

(Address_list =

(address = (PROTOCOL = TCP) (HOST = 192.168.0.22) (PORT = 1521))

)

(Connect_data =

(service_name = TEST_DG)

)

)

See if Tnsping is interoperable

To boot a standby to the Mount state
ALTER DATABASE Mount;

Add a repository log group
ALTER DATABASE ADD standby logfile Group 4 '/orahome/oracle/app/oradata/test/standbyredo04.log ' size 50m;
ALTER DATABASE ADD standby logfile Group 5 '/orahome/oracle/app/oradata/test/standbyredo05.log ' size 50m;
ALTER DATABASE ADD standby logfile Group 6 '/orahome/oracle/app/oradata/test/standbyredo06.log ' size 50m;
ALTER DATABASE ADD standby logfile Group 7 '/orahome/oracle/app/oradata/test/standbyredo07.log ' size 50m;
3.3 Open Log Application
ALTER DATABASE recover managed standby database disconnect from session;
Related log:

ALTER DATABASE recover managed standby database disconnect from session
Attempt to start background Managed Standby Recovery process (test)
Thu Sep 24 09:01:44 2015
MRP0 started with pid=26, OS id=3901
Mrp0:background Managed Standby Recovery process started (test)
Serial Media Recovery started
Managed Standby Recovery not using real time Apply
Waiting for all non-current orls to is archived ...
All non-current orls have been archived.
Media Recovery log/orahome/oracle/archivelog/1_79_891106389.dbf
Completed:alter database recover managed standby database disconnect from session
Media Recovery waiting for thread 1 sequence (in transit)
4 test:
4.1 Main Library:
Conn Scott/tiger
Sql> CREATE Table A as SELECT * from EMP;
Table created.
Sql> Conn/as SYSDBA
Connected.
sql> alter system switch logfile;
System altered.
Sql>
4.2 operation from the library:
sql> ALTER DATABASE recover managed standby database cancel;
Database altered.
Sql> ALTER DATABASE open read only;
Database altered.
Sql> Conn Scott/tiger
Connected.
Sql> select * from tab;

Tname Tabtype Clusterid
------------------------------ ------- ----------
A TABLE
BONUS TABLE
DEPT TABLE
EMP TABLE
Salgrade TABLE

Synchronization completed successfully

5 Convert to ADG (active Dataguard)
Prepare database Database mounted.///////////////
sql> ALTER DATABASE recover managed standby database disconnect from session;
Database altered.
sql> ALTER DATABASE recover managed standby database cancel;
Database altered.
sql> ALTER DATABASE open;
Database altered.
sql> ALTER DATABASE recover managed standby database using current logfile disconnect;
Database altered.
Sql> SELECT Open_mode from V$database;

Open_mode
--------------------
READ only with APPLY

6 Swithover Test:
6.1 Check the Master library information:
Query on Main Library:
Sql> Select Status, Gap_status from V$archive_dest_status where dest_id in (1,2);

STATUS Gap_status
--------- ------------------------
VALID
VALID NO GAP
Sql> select Switchover_status from V$database;

Switchover_status
--------------------
To STANDBY
The information here must be shown as "to standby"
From library information:
Sql> Select Status,gap_status from V$archive_dest_status where dest_id in (1,2);

STATUS Gap_status
--------- ------------------------
VALID
VALID NO GAP

6.2 Starting Switchover:
--Execution of the main library:
Sql> ALTER DATABASE commit to switchover to physical standby with session shutdown;

Database altered.
sql> shutdown abort;
ORACLE instance shut down.
Sql> Startup Mount
ORACLE instance started.

Total System Global area 413372416 bytes
Fixed Size 2228904 bytes
Variable Size 339742040 bytes
Database buffers 62914560 bytes
Redo buffers 8486912 bytes
Database mounted.
Sql> select Switchover_status from V$database;

Switchover_status
--------------------
To PRIMARY

sql> ALTER DATABASE open;

Database altered.

Sql> select Switchover_status from V$database;

Switchover_status
--------------------
To PRIMARY

---worry from the library:
Sql> select Switchover_status from V$database;

Switchover_status
--------------------
To PRIMARY

Sql> ALTER DATABASE commit to switchover to primary with the session shutdown;

Database altered.
Sql> select Open_mode from V$database;

Open_mode
--------------------
Mounted

sql> ALTER DATABASE open;

Database altered.


----on the current from the library (previous main library execution):
Sql> select Open_mode from V$database;

Open_mode
--------------------
READ only

sql> ALTER DATABASE recover managed standby database using current logfile disconnect;

Database altered.
Sql> select Open_mode from V$database;

Open_mode
--------------------
READ only with APPLY

6.3 After the switch test again:
---the Lord executes:
Sql> Conn Scott/tiger
Connected.
Sql> CREATE TABLE B as select * from Tab;

Table created.

Sql> Conn/as SYSDBA
Connected.
sql> alter system switch logfile;

System altered.

Sql> Conn Scott/tiger
Connected.
Sql> Select COUNT (*) from A;

COUNT (*)
----------
14

sql> INSERT into a select * from A;

Rows created.

Sql> R
1* INSERT into a select * from a

Rows created.

Sql> R
1* INSERT into a select * from a

Rows created.

Sql> R
1* INSERT into a select * from a

112 rows created.

Sql> Select COUNT (*) from A;

COUNT (*)
----------
224
Sql> Conn/as SYSDBA
Connected.
sql> alter system switch logfile;

System altered.

View the main library role
Sql> select Database_role from V$database;

Database_role
----------------
PRIMARY
And then query from the library:
Sql> Conn Scott/tiger
Connected.
Sql> select * from tab;

Tname Tabtype Clusterid
------------------------------ ------- ----------
A TABLE
TABLE B
BONUS TABLE
DEPT TABLE
EMP TABLE
Salgrade TABLE

6 rows selected.
Sql> R
1* Select COUNT (*) from a

COUNT (*)
----------
224
View the repository role
Sql> select Database_role from V$database;

Database_role
----------------

Physical STANDBY

Dataguard is a database-level HA scheme, the most important function is redundancy, data protection, fault recovery and so on. It is the synchronization between the main node and the standby node to ensure the synchronization of the data, which can realize the fast handover and the disaster recovery efficiency of the database. The data guard only sets the database on the software. There is no need to purchase any additional components. The user can achieve synchronization of the primary database with little impact on the primary database. The data difference between the main standby machine is limited to the online log, so it is used by many enterprises as data disaster-tolerant solution. While the RAC is generally translated as "real application cluster", it generally has two or more homogeneous computers and shared storage devices, which can provide a powerful difference in database processing capabilities. Simply say Dataguard is an automated backup for security, RAC is a cluster of computers that are working together to improve efficiency and are now used in conjunction with each other.

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.