Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Script for OpenSwitch on Windows for warm standby failover

Posted on 2008-11-10
Medium Priority
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
  • 4
  • 3
LVL 19

Expert Comment

ID: 22933267
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

ID: 22987568
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

ID: 22988057
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.

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.


Author Comment

ID: 23005245
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

ID: 23006791
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

ID: 23007902
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

grant300 earned 375 total points
ID: 23008340
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.


Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Conducting a customer service survey used to be as straightforward as sending a template email out using checkboxes and numerical rating systems to measure satisfaction.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?

577 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