Home Database Mysql Tutorial 最简单的11g Active DataGuard(ADG)搭建配置过程(项目步骤)

最简单的11g Active DataGuard(ADG)搭建配置过程(项目步骤)

Jun 07, 2016 pm 03:21 PM

我在db01和db02两台Linux虚拟机上首先分别安装了一套数据库软件,在db01主机上创建了名为woo的数据库;我们这次的实验是要搭建了

一、环境介绍:
    我在db01和db02两台Linux虚拟机上首先分别安装了一套数据库软件,,在db01主机上创建了名为woo的数据库;我们这次的实验是要搭建了一套Oracle 11g Active DataGuard;目的是为了实现数据库同步的功能,并且了解Oracle 11g DG的基本功能。

db01:192.168.1.50
db02:192.168.1.51

Oracle 11g Active DataGuard初探 

Oracle Data Guard 重要配置参数

基于同一主机配置 Oracle 11g Data Guard

探索Oracle之11g DataGuard

Oracle Data Guard (RAC+DG) 归档删除策略及脚本

Oracle Data Guard 的角色转换

Oracle Data Guard的日志FAL gap问题

Oracle 11g Data Guard Error 16143 Heartbeat failed to connect to standby 处理方法

二、11g ADG部署:

1、pri端和sty端配置静态监听

[oracle@sty admin]$ cat listener.ora
 
# listener.ora Network Configuration File: /DBSoft/oracle/product/11.2.4/dbhome_1/network/admin/listener.ora

# Generated by Oracle configuration tools.

SID_LIST_LISTENER =

  (SID_LIST =

    (SID_DESC =

      (SID_NAME = PLSExtProc)

      (ORACLE_HOME = /DBSoft/oracle/product/11.2.4/dbhome_1)

    (PROGRAM = extproc)

    )

      (SID_DESC =

    (SID_NAME = Woo )

    (ORACLE_HOME = /DBSoft/oracle/product/11.2.4/dbhome_1)

    )

  )

 

[oracle@sty admin]$cat tnsname.ora

# tnsnames.ora Network Configuration File: /DBSoft/oracle/product/11.2.4/dbhome_1/network/admin/tnsnames.ora

# Generated by Oracle configuration tools.

STY =

  (DESCRIPTION =

    (ADDRESS_LIST =

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

    )

    (CONNECT_DATA =

      (SERVICE_NAME = woo)

    )

  )

PRI =

  (DESCRIPTION =

    (ADDRESS_LIST =

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

    )

    (CONNECT_DATA =

      (SERVICE_NAME = woo)

    )

  )

2、修改primary端初始化参数文件

startup mount;
 
alter database archivelog;

alter database force logging;

alter database open;

alter system set log_archive_config = 'DG_CONFIG=(pri,sty)' scope=spfile;

alter system set log_archive_dest_1 = 'LOCATION=/DBBackup/Archive VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=pri' scope=spfile;

alter system set log_archive_dest_2 = 'SERVICE=sty LGWR SYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=sty' scope=spfile;

alter system set log_archive_dest_state_1 = ENABLE;

alter system set log_archive_dest_state_2 = ENABLE;

alter system set fal_server=sty scope=spfile;

alter system set fal_client=pri scope=spfile;

alter system set standby_file_management=AUTO scope=spfile;

3、在primary端pfile参数文件和密码文件,并且拷贝到standby段相应位置

SQL> create pfile from spfile;
 

File created.

[oracle@db01 dbs]$ scp initwoo.ora orapwwoo db02:/DBSoft/oracle/product/11.2.4/dbhome_1/dbs

oracle@192.168.1.51's password:
 initwoo.ora                                                                                    100% 1260    1.2KB/s  00:00   
 orapwwoo                                                                                      100% 1536    1.5KB/s  00:00

 [oracle@db01 oracle]$ scp -r admin/ diag/ fast_recovery_area/ oradata/ 192.168.1.51:$ORACLE_BASE
 oracle@192.168.1.51's password:
 init.ora.512201522543                                                                          100% 1778    1.7KB/s  00:01   
 dp.log                                                                                        100%  116    0.1KB/s  00:00   
 ........

   

4、修改standby端的监听文件及初始化参数文件

--修改监听文件
 
[oracle@db02 ~]$ cd $ORACLE_HOME/network/admin

[oracle@db02 admin]$ vi listener.ora

# listener.ora Network Configuration File: /DBSoft/oracle/product/11.2.4/dbhome_1/network/admin/listener.ora

# Generated by Oracle configuration tools.

LISTENER =

  (DESCRIPTION_LIST =

    (DESCRIPTION =

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

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

    )

  )

SID_LIST_LISTENER =

  (SID_LIST =

    (SID_DESC =

      (SID_NAME = PLSExtProc)

      (ORACLE_HOME = /DBSoft/oracle/product/11.2.4/dbhome_1)

      (PROGRAM = extproc)

    )

    (SID_DESC =

      (GLOBAL_DBNAME = woo)

      (ORACLE_HOME = /DBSoft/oracle/product/11.2.4/dbhome_1)

      (SID_NAME = woo)

    )

  )

ADR_BASE_LISTENER = /DBSoft/oracle

--启动监听

[oracle@db02 dbs]$ lsnrctl start

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 17-JUN-2015 21:29:57

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

Starting /DBSoft/oracle/product/11.2.4/dbhome_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.4.0 - Production

System parameter file is /DBSoft/oracle/product/11.2.4/dbhome_1/network/admin/listener.ora

Log messages written to /DBSoft/oracle/diag/tnslsnr/db02/listener/alert/log.xml

Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=db02)(PORT=1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))

STATUS of the LISTENER

------------------------

Alias LISTENER

Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production

Start Date 17-JUN-2015 21:29:57

Uptime 0 days 0 hr. 0 min. 1 sec

Trace Level off

Security ON: Local OS Authentication

SNMP OFF

Listener Parameter File /DBSoft/oracle/product/11.2.4/dbhome_1/network/admin/listener.ora

Listener Log File /DBSoft/oracle/diag/tnslsnr/db02/listener/alert/log.xml

Listening Endpoints Summary...

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

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

Services Summary...

Service "PLSExtProc" has 1 instance(s).

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

Service "woo" has 1 instance(s).

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

The command completed successfully

--查看监听状态

[oracle@db02 dbs]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 17-JUN-2015 21:30:02

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))

STATUS of the LISTENER

------------------------

Alias LISTENER

Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production

Start Date 17-JUN-2015 21:29:57

Uptime 0 days 0 hr. 0 min. 4 sec

Trace Level off

Security ON: Local OS Authentication

SNMP OFF

Listener Parameter File /DBSoft/oracle/product/11.2.4/dbhome_1/network/admin/listener.ora

Listener Log File /DBSoft/oracle/diag/tnslsnr/db02/listener/alert/log.xml

Listening Endpoints Summary...

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

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

Services Summary...

Service "PLSExtProc" has 1 instance(s).

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

Service "woo" has 1 instance(s).

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

The command completed successfully

[oracle@db02 dbs]$

--修改参数文件

[oracle@db02 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Wed Jun 17 21:35:54 2015

Copyright (c) 1982, 2013, Oracle. All rights reserved.

Connected to an idle instance.

SQL> startup nomount;

ORACLE instance started.

Total System Global Area 1188511744 bytes

Fixed Size 1364228 bytes

Variable Size 754978556 bytes

Database Buffers 419430400 bytes

Redo Buffers 12738560 bytes

SQL> create spfile from pfile='/DBSoft/oracle/product/11.2.4/dbhome_1/dbs/initwoo.ora';

File created.

SQL>

SQL> shutdown abort;

ORACLE instance shut down.

SQL> startup nomount;

ORACLE instance started.

Total System Global Area 1188511744 bytes

Fixed Size 1364228 bytes

Variable Size 754978556 bytes

Database Buffers 419430400 bytes

Redo Buffers 12738560 bytes

SQL>

alter system set db_unique_name=sty scope=spfile;

alter system set log_archive_config='DG_CONFIG=(pri,dg)' scope=spfile;

alter system set log_archive_dest_1 ='LOCATION=/DBBackup/Archive VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=sty' scope=spfile;

alter system set log_archive_dest_2 ='SERVICE=pri LGWR SYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=pri' scope=spfile;

alter system set fal_server=pri scope=spfile;

alter system set fal_client=sty scope=spfile;

SQL> shutdown abort;

ORACLE instance shut down.

SQL> startup nomount

ORACLE instance started.

Total System Global Area 1188511744 bytes

Fixed Size 1364228 bytes

Variable Size 754978556 bytes

Database Buffers 419430400 bytes

Redo Buffers 12738560 bytes

SQL>

SQL>

 5、在primary端通过Rman Duplicate创建备库,在db01上执行如下命令

rman target sys/oracle@pri auxiliary sys/oracle@sty nocatalog
 duplicate target database for standby from active database nofilenamecheck;

 [oracle@db01 ~]$ rman target sys/oracle@pri auxiliary sys/oracle@sty nocatalog

 Recovery Manager: Release 11.2.0.4.0 - Production on Wed Jun 17 22:33:54 2015

 Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

 connected to target database: WOO (DBID=4221729487)
 using target database control file instead of recovery catalog
 connected to auxiliary database: WOO (not mounted)

 RMAN>

 RMAN> duplicate target database for standby from active database nofilenamecheck;

 Starting Duplicate Db at 17-JUN-15
 allocated channel: ORA_AUX_DISK_1
 channel ORA_AUX_DISK_1: SID=19 device type=DISK

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

When might a full table scan be faster than using an index in MySQL? When might a full table scan be faster than using an index in MySQL? Apr 09, 2025 am 12:05 AM

Full table scanning may be faster in MySQL than using indexes. Specific cases include: 1) the data volume is small; 2) when the query returns a large amount of data; 3) when the index column is not highly selective; 4) when the complex query. By analyzing query plans, optimizing indexes, avoiding over-index and regularly maintaining tables, you can make the best choices in practical applications.

Can I install mysql on Windows 7 Can I install mysql on Windows 7 Apr 08, 2025 pm 03:21 PM

Yes, MySQL can be installed on Windows 7, and although Microsoft has stopped supporting Windows 7, MySQL is still compatible with it. However, the following points should be noted during the installation process: Download the MySQL installer for Windows. Select the appropriate version of MySQL (community or enterprise). Select the appropriate installation directory and character set during the installation process. Set the root user password and keep it properly. Connect to the database for testing. Note the compatibility and security issues on Windows 7, and it is recommended to upgrade to a supported operating system.

Explain InnoDB Full-Text Search capabilities. Explain InnoDB Full-Text Search capabilities. Apr 02, 2025 pm 06:09 PM

InnoDB's full-text search capabilities are very powerful, which can significantly improve database query efficiency and ability to process large amounts of text data. 1) InnoDB implements full-text search through inverted indexing, supporting basic and advanced search queries. 2) Use MATCH and AGAINST keywords to search, support Boolean mode and phrase search. 3) Optimization methods include using word segmentation technology, periodic rebuilding of indexes and adjusting cache size to improve performance and accuracy.

Difference between clustered index and non-clustered index (secondary index) in InnoDB. Difference between clustered index and non-clustered index (secondary index) in InnoDB. Apr 02, 2025 pm 06:25 PM

The difference between clustered index and non-clustered index is: 1. Clustered index stores data rows in the index structure, which is suitable for querying by primary key and range. 2. The non-clustered index stores index key values ​​and pointers to data rows, and is suitable for non-primary key column queries.

MySQL: Simple Concepts for Easy Learning MySQL: Simple Concepts for Easy Learning Apr 10, 2025 am 09:29 AM

MySQL is an open source relational database management system. 1) Create database and tables: Use the CREATEDATABASE and CREATETABLE commands. 2) Basic operations: INSERT, UPDATE, DELETE and SELECT. 3) Advanced operations: JOIN, subquery and transaction processing. 4) Debugging skills: Check syntax, data type and permissions. 5) Optimization suggestions: Use indexes, avoid SELECT* and use transactions.

Explain different types of MySQL indexes (B-Tree, Hash, Full-text, Spatial). Explain different types of MySQL indexes (B-Tree, Hash, Full-text, Spatial). Apr 02, 2025 pm 07:05 PM

MySQL supports four index types: B-Tree, Hash, Full-text, and Spatial. 1.B-Tree index is suitable for equal value search, range query and sorting. 2. Hash index is suitable for equal value searches, but does not support range query and sorting. 3. Full-text index is used for full-text search and is suitable for processing large amounts of text data. 4. Spatial index is used for geospatial data query and is suitable for GIS applications.

The relationship between mysql user and database The relationship between mysql user and database Apr 08, 2025 pm 07:15 PM

In MySQL database, the relationship between the user and the database is defined by permissions and tables. The user has a username and password to access the database. Permissions are granted through the GRANT command, while the table is created by the CREATE TABLE command. To establish a relationship between a user and a database, you need to create a database, create a user, and then grant permissions.

Can mysql and mariadb coexist Can mysql and mariadb coexist Apr 08, 2025 pm 02:27 PM

MySQL and MariaDB can coexist, but need to be configured with caution. The key is to allocate different port numbers and data directories to each database, and adjust parameters such as memory allocation and cache size. Connection pooling, application configuration, and version differences also need to be considered and need to be carefully tested and planned to avoid pitfalls. Running two databases simultaneously can cause performance problems in situations where resources are limited.

See all articles