Script for OpenSwitch on Windows for warm standby failover

Posted on 2008-11-10
Last Modified: 2012-05-05
Dear ASE Experts,

Am new to Sybase/OpenSwitch,  I sucessfully installed Sybase WarmStandby 15.x and OpenSwitch 15.x for Windows 2003.  Now am looking for a simple script to  fail over my Primary database to
Secondray (warm standby) to be used in OpenSwitch  to automate the process. (Replication Coordination Module  RCM)

the script should have following steps:

sp_stop_rep_agent on Primary
switch active for Primary.db to Secondry.db
sp_start_rep_agent on New Primary (secondry)
wait for switch for logical_ds.logical_db

I really appreciate if someone can give me script for windows and steps to use it in Open Switch

Thanks in advance,
Question by:Bola20705
    LVL 19

    Expert Comment

    Check out Chapter 4 of the Open Switch Coordination Module Reference Manual at...

    There are no scripts; it is all accomplished with configuration.  You need to create the resource pool with your two servers in it and configure the RCM module to do it's thing with OpenSwitch.  It will handle making sure the replication queues are processed before allowing connections to fail over.

    It looks pretty straight forward and should be platform independent.  There are some examples in the manual.


    Author Comment

    Hello Bill,  Appreciate your reply and thanks for RTFM advise,  well I managed to configure OpenSwitch
    and sucessfully failed over the users to secondry server. But I have few imp. questions if you can please advise.

     Users sucssfully failed over to secondry server.
    1. I had to sp_start_rep_agent on all 4 databases on my new Primary (secondry)
    2. I had to resume connections on Replication server.
    Is there a way to automate these steps.

     When my orginally Primary server was up and running..
    I need to issue  rp_switch to switch back to orginal server.
    And the manually follow all the steps to switch over my warm standby.

    Do you have any script  to automate this either on windows or unix ?

    Part II
    I have 4 databases on my server, what if one of the databases is corrupted, is there a way to
    switch over to secondry server, just that database  using OpenSwitch ?

    Appreciate all your inputs.

    TIA & Have a great day,
    LVL 19

    Expert Comment

    I'm not sure what to tell you about the need to script stuff.

    Normally, if you fail over, you would not start/restart rep server automatically.  Your secondary server becomes the primary indefinitely and your old primary becomes the secondary.  After you fix it, you then restart the rep server stuff manually with things headed the opposite direction from what they were originally.  You have to do it that way or you will switch back to a potentially stale (old) primary server.

    You can shell script to your heart's content on UNIX/LINUX.  Just use ISQL and the -i switch to pick up commands from a file.  Windblows is a tougher issue since the stock scripting environment sucks.  You will probably have to look at an add on scripting environment such as Cygwin bash or Win-bash.  If you run a mixed shop, you can do everything in bash that way.

    Part II:
    Failover is by the SERVER, not the database.  You connect to a Server via the IP address and you cannot "split the difference" and fail over only for a particular database.

    Take into account also that databases on the same server can share queries and transactions.  It would not make sense to split it at that level.


    Author Comment

    Hello Bill,
    Thanks much for your prompt replies,  I agree with all your points mentioned above. I created batch files.
    But here is my managment requirment:
    We have warm standby/HA  between  Server  A & B.
    Now with OpenSwitch it suceussfully fails over from A to B. And all users are able to connect to B.
    OpenSwitch issues 'Switch Active' command and I can see now  Server B is Primary.
    Now B is New Primary and A is Secondry.  To enable replication from B to A  (which is requirment)

    I need to issue these commands manually:-
    1. Start rep_agents on B (new Primary)
    2. Resume connections on Rep.Server for A.

    I have batch files for above 2 steps. My question is : is there anyway we can incorporate these
    2 steps into OpenSwitch.  That way the whole failover is automated. i.e one way  A to B.
    and replication (warm standby) happening   B to A.  That way if failover happends in middle of nite
    its more easier to deal.

    TIA & Have a good day
    LVL 19

    Expert Comment

    Let me think about what you are asking to do....

    "Primary server A fails in the middle of the night.  Everything switches over automagically to Secondary server B which becomes the new primary.  Now I want to automatically start up replication to the dead server A to make it the new secondary."

    If Server A is dead, you cannot/should not/don't want to try and turn replication to it on.  It has to be done after you have resolved whatever issues/problems/hardware failures there were with the Primary.  For that matter, if you loose the master DB for some reason, you will have to rebuild the server from scratch and ten do a complete re-sync.  There won't be anything automatic about getting A up as the new secondary.

    Am I missing something here?


    Author Comment

    Hello Bill,
    :)  thats a good point,  i dont know why I didnt ask them about the "midnite switchover to dead server"  when they told me requirment's.  
    But do I need my Rep.Agents started in my new Primary (server B)  to avoid trans.log issues  ??

    LVL 19

    Accepted Solution

    Well, that depends I guess on how long server A is down, how active things are, what kind of recovery you have to do on server A, and whether or not you can guarantee you can get the rep agents up and running prior to loosing any transactions on server B.

    The bottom line is that if the database needs to be rebuilt or restored, you are probably going to have to plan on doing a complete re-sync.

    If the server is out of commission for any length of time and/or your database traffic is very update/insert/delete intensive, you are probably going to be better off doing the re-sync since that will be faster than applying a bunch of individual transactions.  Remember that any time spent getting your secondary server in sync with the primary is additional exposure time where you don't have a fail-over.  If you are down for a day and it takes two to get caught up, you are actually exposed for 3 days.

    Joe Woodhouse is the real experts expert on replication.  Maybe we can get him to weigh in on the correct methodology for doing this.

    BTW, if you are using stored procedures and SP replication, you are much more efficient than you are replicating individual rows.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
    Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now