【DG】dg中如何配置多個後臺observer

lhrbest發表於2018-10-26


How to run Observer process as a background process (文件 ID 1084681.1)


In this Document
   Goal
   Solution




APPLIES TO:

Oracle Server - Enterprise Edition - Version: 10.1.0.2  and later   [Release: 10.1 and later ]
Information in this document applies to any platform.

GOAL

When setup DataGuard Fast Start Failover, the Observer is a continuous foreground process. How to run it as a background process instead? 

SOLUTION

There are a few methods to achieve this:

1. start the dgmgrl process with nohup command, eg:

nohup dgmgrl -logfile /tmp/dgmgrl.log <<eof
connect sys/passwd@connect_string
start observer
EOF


2. create a shell script and run the shell script at background:

create observer.sh like:

#!/bin/ksh
## Script to start observer via DGMGRL
dgmgrl -echo -logfile /tmp/dgmgrl.log << EOF
connect sys/passwd@connect_string
start observer
EOF



chmod +x observer.sh
./observer.sh &


3. From 11.2 onwards, one can use the following command to start observer:

% dgmgrl -logfile /tmp/observer.log sys/passwd@connect_string "start observer" &



ORACLE 12.2 - Starting the Oracle Data Guard Broker OBSERVER in the BACKGROUND (文件 ID 2285158.1)


In this Document


Goal

Solution


1. Before configuring the wallet check the configuration

2. Create the wallet

3. Start the observer on the Observer system

4. Check the observer log

5. In case of any issues enable tracing


APPLIES TO:

Oracle Database - Enterprise Edition - Version 12.2.0.1 and later
Information in this document applies to any platform.

GOAL

 Explain the new Oracle Data Guard 12.2 enhancement to Fast_Start Failover (FSFO) allowing the observer to be started in the background.

SOLUTION

From Oracle 12.2 onward the Fast_Start Failover observer can be started as a background process.To start the OBSERVER in the background, the observer uses wallet authentication to connect to primary and target standby databases. The first step is to configure the WALLET and add credentials for the connect string that the OBSERVER will use to connect to the databases.


By default the observer uses the dgconnectidentifier specified by the user to connect to the primary and standby databases. However if the Broker property 'OBSERVERCONNECTIDENTIFIER' is configured on a database then the observer uses the observerconnectidentifier to connect to the that database.


1. Before configuring the wallet check the configuration

   


show database verbose <primary>;
show database verbose <standby>;

Example:

DGMGRL> show configuration
Configuration - 122
Protection Mode: MaxProtection
Members:
prod - Primary database
pstdby - (*) Physical standby database

Fast-Start Failover: ENABLED
Configuration Status:
SUCCESS (status updated 30 seconds ago)


a. Primary configuration,

DGMGRL> show database verbose prod;

Database - prod

Role: PRIMARY
Intended State: TRANSPORT-ON
Instance(s):
prod

Properties:
DGConnectIdentifier = ' prod '
ObserverConnectIdentifier = ''

   

Note: The OBSERVERCONNECTIDENTIFIER property is not set hence the observer will use dgconnectidentifier 'prod' to connect to primary

   

b. Standby configuration,

DGMGRL> show database verbose pstdby;

Database - pstdby

Role: PHYSICAL STANDBY
Intended State: APPLY-ON
Transport Lag: 0 seconds (computed 0 seconds ago)
Apply Lag: 0 seconds (computed 0 seconds ago)
Average Apply Rate: 5.00 KByte/s
Active Apply Rate: 1.08 MByte/s
Maximum Apply Rate: 2.08 MByte/s
Real Time Query: ON
Instance(s):
pstdby

Properties:
DGConnectIdentifier = 'pstdby'
ObserverConnectIdentifier = ' pstdby_observer '

 

   

Note: Here the OBSERVERCONNECTIDENTIFIER property is set and the observer will use the 'pstdby_observer' connection string instead.

   

2. Create the wallet

2.1 Create the wallet on the Primary system

   

mkstore -wrl /u01/app/oracle/wallet/ -create
mkstore -wrl /u01/app/oracle/wallet/ -createCredential 'prod' sys sys
mkstore -wrl /u01/app/oracle/wallet/ -createCredential 'pstdby_dgmgrl' sys sys

   

2.2 Add the wallet location entry in the SQLNET.ora on the Primary system

SQLNET.ora
------------

NAMES.DIRECTORY_PATH= (TNSNAMES, ONAMES, HOSTNAME,EZCONNECT)
WALLET_LOCATION=(SOURCE=(METHOD=FILE)(METHOD_DATA=(DIRECTORY=/u01/app/oracle/wallet/)))
SQLNET.WALLET_OVERRIDE=TRUE

2.3 Copy the wallet file to the standby system and add the wallet location to the standby SQLNET.ORA

SQLNET.ora
------------

NAMES.DIRECTORY_PATH= (TNSNAMES, ONAMES, HOSTNAME,EZCONNECT)
WALLET_LOCATION=(SOURCE=(METHOD=FILE)(METHOD_DATA=(DIRECTORY=/u01/app/oracle/wallet/)))
SQLNET.WALLET_OVERRIDE=TRUE

 

 2.4 Reload the listener(s)

On the primary and target standby systems.

   

lsnrctl reload

   

3. Start the observer on the Observer system

From Oracle 12.2 onward each Oracle Data Guard Broker configuration can have a maximum of 3 OBSERVERs. The OBSERVER started first will act as master observer.  In this configuration there are three observers, 'dg-workshop1', 'ob3' and  'abc'.  In the following example the 'ob3' observer is started and added to the configuration as a 'backup' observer.  The other two were started previously.

 

dgmgrl sys/sys@prod

DGMGRL>  start observer ob3 in background logfile is '/u01/observerlog' connect identifier is prod;

Submitted command "START OBSERVER" using connect identifier "prod"

Observer 'ob3' started

DGMGRL>  show observer;

Configuration - 122

Primary: prod
Target: pstdby

Observer "dg-workshop1" - Master

Host Name: dg-observer
Last Ping to Primary: 3 seconds ago
Last Ping to Target: 3 seconds ago

Observer "ob3" - Backup

Host Name: dg-prod
Last Ping to Primary: 3 seconds ago
Last Ping to Target: 3 seconds ago

Observer "abc" - Backup

Host Name: dg-standby
Last Ping to Primary: 574 seconds ago
Last Ping to Target: 538 seconds ago

 

4. Check the observer log

$ tail -f /u01/observerlog

[W000 07/11 14:06:59.63] FSFO target standby is pstdby
[W000 07/11 14:07:02.15] Observer 'ob3' started
[W000 07/11 14:07:02.15] Observer trace level is set to USER
[W000 07/11 14:07:02.15] Try to connect to the primary.
[W000 07/11 14:07:02.15] Try to connect to the primary prod.
[W000 07/11 14:07:02.16] The standby pstdby is ready to be a FSFO target
[W000 07/11 14:07:04.16] Connection to the primary restored!
[W000 07/11 14:07:07.18] Disconnecting from database prod.

5. In case of any issues enable tracing

Disconnect from the existing DGMGRL session and reconnect

dgmgrl -debug sys/sys@prod

DGMGRL> start observer ob3 in background logfile is '/u01/observerlog' connect identifier is prod trace_level is support;

 

The trace_level support will clearly explain why observer was not able to connect to primary or target standby.

NOTE: With trace_level support we get additional details of what connect string OBSERVER using to connect to primary and target standby.

[W000 07/11 14:02:44.78] Observer successfully registered with obid=0x3ba51662 (1000674914)
[W000 07/11 14:02:44.78] FSFO target standby is pstdby
[W000 07/11 14:02:44.78] State written: local_obid=0x3ba51662 (1000674914), version=0, svrflgs=0x0, target=2, cltflgs=0x60, FSFO_MIV=41.
[W000 07/11 14:02:44.79] Sending command CONNECT to thread P001
[S002 07/11 14:02:44.79] New thread started.
[P001 07/11 14:02:44.79] New thread started.
[P001 07/11 14:02:44.79] Executing CONNECT command.
[P001 07/11 14:02:44.79] Connecting to database using prod. <<<<<<<<<<<<<<<<<<for primary observer using prod
[B003 07/11 14:02:44.79] New thread started.
[P001 07/11 14:02:44.79] Attempt logon as SYSDG
[P001 07/11 14:02:45.88] Attempt logon as SYSDBA
[P001 07/11 14:02:45.92] Executing query [select db_unique_name from v$database].
[P001 07/11 14:02:45.92] Query result is 'prod'
Connected to "prod"
[P001 07/11 14:02:45.92] Checking broker version [BEGIN :version := dbms_drs.dg_broker_info('VERSION'); END;].
[P001 07/11 14:02:45.92] Oracle database version is '12.2.0.1.0'
[W000 07/11 14:02:45.92] Command CONNECT to thread P001 returned status=0
[W000 07/11 14:02:45.92] Sending command CONNECT to thread S002
[S002 07/11 14:02:45.92] Executing CONNECT command.
[S002 07/11 14:02:45.92] Connecting to database using pstdby_observer. <<<<<<<<<<for standby observer using pstdby_observer
[S002 07/11 14:02:45.92] Attempt logon as SYSDG
[S002 07/11 14:02:47.05] Attempt logon as SYSDBA
[S002 07/11 14:02:47.14] Executing query [select db_unique_name from v$database].
[S002 07/11 14:02:47.15] Query result is 'pstdby'
Connected to "pstdby"
[S002 07/11 14:02:47.15] Checking broker version [BEGIN :version := dbms_drs.dg_broker_info('VERSION'); END;].
[S002 07/11 14:02:47.15] Oracle database version is '12.2.0.1.0'
[W000 07/11 14:02:47.15] Command CONNECT to thread S002 returned status=0
[W000 07/11 14:02:47.15] Observer 'ob3' started

 


Oracle 12.2 - Simplified OBSERVER Management for Multiple Fast-Start Failover Configurations (文件 ID 2285891.1)

In this Document


Goal

Solution

 1. Check what connect string observer using to connect to Primary and target standby

  1.1 DG configuration - I

    1.1.a. Primary configuration

    1.1.b. Standby configuration

  1.2 DG configuration - II

    1.2.a Primary configuration

    1.2.b Standby configuration

2. TNS Alias on OBSERVER HOST

3. Configure Wallet from the OBSERVER host

  3.1 Create wallet Key

  3.2 Make entry in SQLNET

  3.3 Reload all the listeners on all DG configuration.

4. Create ObserverConfigFile

5. Connect to dgmgrl and start the observer(s)

  5.1 From observer host

  5.2 Start the observer(s) for two DG broker configurations

  5.3 Check the OBSERVERs status 

6. Troubleshooting
  6.1. OBSERVER status shows UNKNOWN

  6.2. Starting OBSERVER failing with ORA-01017


APPLIES TO:

Oracle Database - Enterprise Edition - Version 12.2.0.1 to 12.2.0.1 [Release 12.2]
Information in this document applies to any platform.

GOAL

Simplified observer management :- One command to manage multiple observers on different FSFO configuration. Separate observers are must to manage each FSFO configuration but the management of Observers are done in a group via single dgmgrl prompt. Users can either manage the observer separately like pre 12.2 case or manage observers in a group.

SOLUTION

  1. Check what connect string observer using to connect to Primary and target standby

show configuration
show database verbose <primary>
show database verbose <standby>

Configuration Example: Here two DG configuration with FSFO taken as an example namely ‘122’ and ‘ora122’.

Example:

  1.1 DG configuration - I

DGMGRL> show configuration
Configuration - 122
Protection Mode: MaxProtection
Members:
prod - Primary database
pstdby - (*) Physical standby database

Fast-Start Failover: ENABLED
Configuration Status:
SUCCESS (status updated 30 seconds ago)

    1.1.a. Primary configuration

DGMGRL> show database verbose prod;

Database - prod

Role: PRIMARY
Intended State: TRANSPORT-ON
Instance(s):
prod

Properties:
DGConnectIdentifier = 'prod'
ObserverConnectIdentifier = '' <<<<OBSERVERCONNECTIDENTIFIER is not set hence observer will use dgconnectidentifier 'prod' to connect to primary

    1.1.b. Standby configuration

DGMGRL> show database verbose pstdby;

Database - pstdby

Role: PHYSICAL STANDBY
Intended State: APPLY-ON
Transport Lag: 0 seconds (computed 0 seconds ago)
Apply Lag: 0 seconds (computed 0 seconds ago)
Average Apply Rate: 5.00 KByte/s
Active Apply Rate: 1.08 MByte/s
Maximum Apply Rate: 2.08 MByte/s
Real Time Query: ON
Instance(s):
pstdby

Properties:
DGConnectIdentifier = 'pstdby'
ObserverConnectIdentifier = 'pstdby_dgmgrl' <<<<OBSERVERCONNECTIDENTIFIER is set

  1.2 DG configuration - II

DGMGRL> show configuration

Configuration - ora122

Protection Mode: MaxPerformance
Members:
ora122 - Primary database
stby122 - (*) Physical standby database

Fast-Start Failover: ENABLED

Configuration Status:
SUCCESS (status updated 57 seconds ago)
ora122_observer is a configurationwiseservicename which is common to both priamry and standby

    1.2.a Primary configuration

DGMGRL> show database verbose ora122;

Database - ora122

Role: PRIMARY
Intended State: TRANSPORT-ON
Instance(s):
ORA122

Properties:
DGConnectIdentifier = 'ora122'
ObserverConnectIdentifier = 'ora122_observer'

    1.2.b Standby configuration

DGMGRL> show database verbose stby122

Database - stby122

Role: PHYSICAL STANDBY
Intended State: APPLY-ON
Transport Lag: 0 seconds (computed 1 second ago)
Apply Lag: 0 seconds (computed 1 second ago)
Average Apply Rate: 14.00 KByte/s
Active Apply Rate: 1.56 MByte/s
Maximum Apply Rate: 6.49 MByte/s
Real Time Query: ON
Instance(s):
stby122

Properties:
DGConnectIdentifier = 'stby122'
ObserverConnectIdentifier = 'stby122_observer'

2. TNS Alias on OBSERVER HOST


prod =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.184.32.130)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = prod)
)
)

pstdby_observer =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.184.32.130)(PORT = 1526))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = pstdby_observer)
)
)
ORA122_observer =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = ha.idc.oracle.com)(PORT = 1520))
(ADDRESS = (PROTOCOL = TCP)(HOST = ha.idc.oracle.com)(PORT = 1522))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ora122_observer)
)
)
stby122_observer=
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = ha.idc.oracle.com)(PORT = 1522))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = stby122)
)
)

3. Configure Wallet from the OBSERVER host

  3.1 Create wallet Key

mkdir –p /u01/app/oracle/wallet/
mkstore –wrl /u01/app/oracle/wallet/ -create
mkstore -wrl /u01/app/oracle/wallet/ -createCredential 'prod' sys sys
mkstore -wrl /u01/app/oracle/wallet/ -createCredential 'pstdby_observer' sys sys
mkstore -wrl /u01/app/oracle/wallet/ -createCredential 'ora122_observer' sys oracle
mkstore -wrl /u01/app/oracle/wallet/ -createCredential 'stby122_observer' sys oracle

NOTE: sys password on DG configuration ora122 is oracle

  3.2 Make entry in SQLNET

NAMES.DIRECTORY_PATH= (TNSNAMES, ONAMES, HOSTNAME,EZCONNECT)
WALLET_LOCATION=(SOURCE=(METHOD=FILE)(METHOD_DATA=(DIRECTORY=/u01/app/oracle/wallet/)))
SQLNET.WALLET_OVERRIDE=TRUE

 

  3.3 Reload all the listeners on all DG configuration.

4. Create ObserverConfigFile

Observerconfigfile has two parts
– Configuration Declaration : Mandatory section. Used to define the different FSFO configuration
– Group Definition : Optional section. If provided each group needs to have at least one broker configuration defined


vi observer.ora <<default name

BROKER_CONFIGS = (
(CONFIG = (NAME=ORDER) (CONNECT_ID=PROD_observer)(config_home=/u01/app/oracle/oradata/))
(CONFIG = (NAME=REPORTING) (CONNECT_ID=ORA122_observer)(config_home=/u01/app/oracle/oradata/)))
CONFIG_GROUPS = (
(GROUP =(NAME=GRP_A )
(CONFIG_LIST = (NAME=ORDER)(NAME=REPORTING)))
(GROUP= (NAME=GRP_B)
(CONFIG_LIST = (NAME=REPORTING)))
(GROUP= (NAME=GRP_C)
(CONFIG_LIST = (NAME=ORDER))))

5. Connect to dgmgrl and start the observer(s)

  5.1 From observer host


dgmgrl sys/sys@prod
DGMGRL>show observerconfigfile;

observer.ora is the default file name. For different file names first set the observerconfigfile using set observerconfigfile

  5.2 Start the observer(s) for two DG broker configurations

DGMGRL> start observing grp_a

 

DGMGRL> start observing grp_a
ObserverConfigFile=observer.ora
observer configuration file parsing succeeded
Submitted command "START OBSERVER" using connect identifier "PROD"
Submitted command "START OBSERVER" using connect identifier "ORA122_observer"

Check superobserver.log and individual observer logs for execution details.

  5.3 Check the OBSERVERs status 


Show observers or show observers for grp_a

DGMGRL> show observers
ObserverConfigFile=observer.ora
observer configuration file parsing succeeded
Submit command SHOW OBSERVER using the connect identifier 'PROD'.
Connected to "prod"

Configuration - 122

Primary: prod
Target: pstdby

Observer "dg-workshop1" - Master

Host Name: dg-workshop
Last Ping to Primary: 1 second ago
Last Ping to Target: 4 seconds ago

Submit command SHOW OBSERVER using the connect identifier 'ORA122_observer'.
Connected to "ORA122"
Configuration - ora122
Primary: ora122
Target: stby122

Observer "dg-workshop1" - Master

Host Name: dg-workshop
Last Ping to Primary: 3 seconds ago
Last Ping to Target: 6 seconds ago

 

6. Troubleshooting
  6.1. OBSERVER status shows UNKNOWN


DGMGRL> show observers;
ObserverConfigFile=observer.ora
observer configuration file parsing succeeded
Submit command SHOW OBSERVER using the connect identifier 'PROD'.
Connected to "prod"
Configuration - 122
Primary: prod
Target: pstdby
Observer "dg-workshop1" - Master
Host Name: dg-workshop
Last Ping to Primary: (unknown)
Last Ping to Target: (unknown)


CAUSE : Last ping to Primary and Last ping to Target is UNKNOWN if OBSERVER host not able to ping to observerconnectidentifier(if defined) or dgconnectidentifier.

SOLUTION : Make sure to have connect string entry on OBSERVER host for all the databases in the DG configurations.

  6.2. Starting OBSERVER failing with ORA-01017

DGMGRL> start observer new in background connect identifier is prod_observer;
Submitted command "START OBSERVER" using connect identifier "prod_observer"
DGMGRL> DGMGRL for Linux: Release 12.2.0.1.0 - Production on Fri Jul 7
15:32:37 2017

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

Welcome to DGMGRL, type "help" for information.
ORA-01017: invalid username/password; logon denied

Warning: You are no longer connected to ORACLE.
not logged on
Failed to start the observer.

CAUSE : While starting observer from the observerconfigfile as a group OBSERVER uses wallet authentication to connect to primary and standby databases even though SYS credentials are used while connecting to DGMGR.

SOLUTION : Check the wallet configuration. Verify any errors observed while doing listener reload.








About Me

........................................................................................................................

● 本文作者:小麥苗,部分內容整理自網路,若有侵權請聯絡小麥苗刪除

● 本文在itpub( http://blog.itpub.net/26736162 )、部落格園( http://www.cnblogs.com/lhrbest )和個人weixin公眾號( xiaomaimiaolhr )上有同步更新

● 本文itpub地址: http://blog.itpub.net/26736162

● 本文部落格園地址: http://www.cnblogs.com/lhrbest

● 本文pdf版、個人簡介及小麥苗雲盤地址: http://blog.itpub.net/26736162/viewspace-1624453/

● 資料庫筆試面試題庫及解答: http://blog.itpub.net/26736162/viewspace-2134706/

● DBA寶典今日頭條號地址: http://www.toutiao.com/c/user/6401772890/#mid=1564638659405826

........................................................................................................................

● QQ群號: 230161599 (滿) 、618766405

● weixin群:可加我weixin,我拉大家進群,非誠勿擾

● 聯絡我請加QQ好友 646634621 ,註明新增緣由

● 於 2018-10-01 06:00 ~ 2018-10-31 24:00 在魔都完成

● 最新修改時間:2018-10-01 06:00 ~ 2018-10-31 24:00

● 文章內容來源於小麥苗的學習筆記,部分整理自網路,若有侵權或不當之處還請諒解

● 版權所有,歡迎分享本文,轉載請保留出處

........................................................................................................................

小麥苗的微店 https://weidian.com/s/793741433?wfr=c&ifr=shopdetail

小麥苗出版的資料庫類叢書 http://blog.itpub.net/26736162/viewspace-2142121/

小麥苗OCP、OCM、高可用網路班 http://blog.itpub.net/26736162/viewspace-2148098/

小麥苗騰訊課堂主頁 https://lhr.ke.qq.com/

........................................................................................................................

使用 weixin客戶端 掃描下面的二維碼來關注小麥苗的weixin公眾號( xiaomaimiaolhr )及QQ群(DBA寶典)、新增小麥苗weixin, 學習最實用的資料庫技術。

........................................................................................................................

歡迎與我聯絡

 

 



來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26736162/viewspace-2217586/,如需轉載,請註明出處,否則將追究法律責任。

相關文章