Starting the Observer in the background

One question that I get asked often in my Data Guard courses (also this week) is, how to start the observer for Fast-Start Failover in the background.

Many customers use a remote terminal emulation to manage their Data Guard configuration, so it would be a problem if it would be required to keep the window open on which they started the dgmgrl-shell for the observer. This is also not very well documented in our – apart from that very helpful – Online Documentation. On the Linux command line, it works like this:

nohup dgmgrl -silent sys/oracle@prima "start observer" &

This gives you a text file on your current directory called nohup.out on which you can do a tail -f later on, if you would like to see te actions of the observer. The Data Guard Observer is kind of quiet, it waits with messages until there is actually something to do. You can verify its presence with dgmgrl from the primary site with the command

DGMGRL> show configuration verbose
Configuration
 Name:                myconf
 Enabled:             YES
 Protection Mode:     MaxAvailability
 Fast-Start Failover: ENABLED
 Databases:
 prima - Primary database
 physt - Physical standby database
 - Fast-Start Failover target
Fast-Start Failover
 Threshold: 30 seconds
 Observer:  uhesse
Current status for "myconf":
SUCCESS

Alternatively, you can query v$database like this:

SQL> select FS_FAILOVER_STATUS,FS_FAILOVER_OBSERVER_PRESENT,FS_FAILOVER_OBSERVER_HOST 
     from v$database;
About these ads

  1. #1 by Uwe Hesse on September 27, 2010 - 09:47

    During one of my Data Guard courses, I got aware that there is a very nice alternative to nohup here: screen can also be used (not only) to start the observer in the background. Look at http://www.gnu.org/software/screen/manual/screen.html for the documentation of screen.

  2. #2 by Rico on November 17, 2010 - 15:37

    Here an example to start the “observer” in background using “screen”:

    su - oracle -c 'screen -dmS observer -s /bin/bash dgmgrl -logfile /path/observer_$(date '+%d%m%Y').log sys/password@db "start observer"'

    Put this in "rc.local" to start the observer automaticaly.

    Rico

  3. #3 by sunilbhola on February 10, 2011 - 07:04

    nohup dgmgrl -silent sys/oracle@DB_NAME “start observer” &

    OR

    nohup dgmgrl -silent sys/XXXXXXX@DB_NAME “start observer” & >> observer_jan_26.log

  4. #4 by tom on February 15, 2011 - 11:43

    hmmm. this solutions suck since the sys password is visible with a simple ps -ef

  5. #5 by Uwe Hesse on February 15, 2011 - 12:45

    Mr “realtom”, apparently you are one of the many guys who just claim things without ever checking not to speak proving them. That differentiates you from the real Tom, by the way.

    The password of sys is not exposed by a ps -ef if the observer is started in the background as with the demonstration in the posting. Although I thought so before, I have just checked that again (with 11.2 – probably it is the same with 10g also).

    Please refrain from using insultive language in the future or I will delete your comments.

  6. #6 by Troy Meyerink on March 25, 2011 - 16:26

    Thanks for the information! Do you know how this might translate to Windows? I am alos trying to use the -logfile parameter in conjunction with having it run in the background.

  7. #7 by Uwe Hesse on March 29, 2011 - 20:43

    Troy,
    I have limited experience with Data Guard on Windows. Once at a customers site, the DBA told me that they just call the observer in a DOS-Box and then terminate that window while the observer continues. I haven’t tested that, though.

  8. #8 by Frank on January 9, 2012 - 16:41

    Uwe Hesse:

    Thank you so much to pay attention on this topic. It is very useful. The reqular Oracle Documentation didn’t descripbe this issue. Your solution help many DBAs to handle this effciently.

  9. #9 by Uwe Hesse on January 9, 2012 - 16:48

    Frank,
    you’re welcome :-)
    Thanks for stopping by and leaving the nice comment!

  10. #10 by Frank on January 9, 2012 - 18:14

    Uwe Hesse:

    When I log into Linux box as oracle user, then type this command line in prompt

    $nohup dgmgrl -silent sys/password@primary_db “start observer” &

    The system return this:
    $-bash: @primary_db: event not found.

    However, if I connect like this, it will do:

    $dgmgrl
    DGMGRL> connect sys/passowrd@primary_db
    DGMGRL> connected
    DGMGRL>

    Can you give some tips on this? Thanks a lot.

  11. #11 by Uwe Hesse on January 9, 2012 - 18:34

    Frank,
    I just did this:
    nohup dgmgrl -silent sys/oracle@prima “start observer” &
    and it works (with at least my Linux):
    [oracle@uhesse]$ uname -a
    Linux uhesse 2.6.32-100.28.5.el6.x86_64 #1 SMP Wed Feb 2 18:40:23 EST 2011 x86_64 x86_64 x86_64 GNU/Linux

    Should be the same at your site also.

  12. #12 by Frank on January 9, 2012 - 19:10

    Uwe:

    I checked my command line with yours. I couldn’t find why it runs on your Linux, not on mine. Here is my command lines:

    oracle@myserver:/opt/oracle/scripts
    $ uname -a
    Linux myserver.domain.com 2.6.18-194.32.1.0.1.el5 #1 SMP Tue Jan 4 16:26:54 EST 2011 x86_64 x86_64 x86_64 GNU/Linux

    oracle@myserver:/opt/oracle/scripts
    $ nohup dgmgrl -silent sys/password@primary ‘start observer’ &
    -bash: !@primary: event not found

    The issue is shell bash? or anything else? Sorry to bother you by this.

  13. #13 by Frank on January 9, 2012 - 19:38

    Uwe:

    I guess it is caused by oracle user password. I loginto Linux with my individual passowrd, Then I
    $sudo su – oracle
    enter my individual passowrd again into oracle user login path. probably my individual password has no privilege to run nohup. Does this make sense?

  14. #14 by Frank on January 9, 2012 - 22:27

    Uwe:

    I am sorry to post so many here. I just want to tell you that your command is working. The problem is my sys password. It contains a “!”. Then bash think command want to repeat last command. But it couldn’t find last command. So return ‘back ” !@primary: event not found’. I changed sys password. It run through. Observer is started and run in background. Thanks for your help.

  15. #15 by Uwe Hesse on January 10, 2012 - 10:05

    Frank,
    no need to apologize! I appreciate comments and especially that you took the time to tell about the solution of this problem :-)

  16. #16 by omid on July 2, 2013 - 13:45

    hi
    after observer failover to standby and stand by role changed to primary what should i do for set my old primary to my real primary db?

  17. #17 by Uwe Hesse on July 9, 2013 - 20:11

    Omid, I suppose you mean a reinstate of the old primary? The Observer tries that automatically after you start the instance. If it succeeds, you just need to switchover.

  18. #18 by omid on July 13, 2013 - 09:11

    ok thank you
    its fix ok
    i have more question
    i know that we can just have one observer in ADG
    what should i do if i want have a back up for my observer?

  19. #19 by Uwe Hesse on July 19, 2013 - 19:21

    Omid, you may write your on watchdog for that – we have none on the command line. But that is actually an option with Grid Control, where you can specify an alternate observer host. The Grid Control Agent starts the observer there if the original host fails.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 2,889 other followers

%d bloggers like this: