Script for OpenSwitch on Windows for warm standby failover

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,
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.

Bola20705Author Commented:
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,
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.

Active Protection takes the fight to cryptojacking

While there were several headline-grabbing ransomware attacks during in 2017, another big threat started appearing at the same time that didn’t get the same coverage – illicit cryptomining.

Bola20705Author Commented:
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
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?

Bola20705Author Commented:
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  ??

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.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Sybase Database

From novice to tech pro — start learning today.