locked
Script to run before SQL failover RRS feed

  • Question

  • Hi,

    I have sql 2012 cluster environment. And I need to run some apps scripts before sql server initiate the failover for monthly maintenance activity.

    Is there any way to setup the script in SQL instance ? or any way to setup OS level scripts before the failover .

    Please help me to solve this.

    Thanks,


    Vinodh Selvaraj

    Thursday, December 10, 2015 1:16 PM

Answers

All replies

  • What specific scripts are you looking for ?

    Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it

    My Wiki Articles

    MVP

    Thursday, December 10, 2015 1:52 PM
    Answerer
  • I have some application like apache, i have a batch & VBS to stop that application.

    But now i need to run these script in OS level or SQL level in the time of SQL failover.

    Thanks,


    Vinodh Selvaraj

    Friday, December 11, 2015 12:47 PM
  • If I understood you correctly, you need script out all logins for two node cluster but that script ruins once...If you mean something else please explain ?

    Best Regards,Uri Dimant SQL Server MVP, http://sqlblog.com/blogs/uri_dimant/

    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting: Large scale of database and data cleansing
    Remote DBA Services: Improves MS SQL Database Performance
    SQL Server Integration Services: Business Intelligence

    Friday, December 11, 2015 4:55 PM
  • Its not about SQL logins. I have vb script to stop an application service (not SQL server).

    SQL server service is in cluster with few disks in dependency. And my application is also running from one of the dependent disks. So when ever SQL service fails over, i need that vb script to be executed before failover.

    I am asking, is there any way to make it possible ?

    Note : Either on in SQL Store Procedure or in Windows config settings

    Thanks,


    Vinodh Selvaraj

    Monday, December 14, 2015 10:21 AM
  • How do you know when a failed over will happen? Permit me to ask you why do you need the application service to stop? 

    Best Regards,Uri Dimant SQL Server MVP, http://sqlblog.com/blogs/uri_dimant/

    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting: Large scale of database and data cleansing
    Remote DBA Services: Improves MS SQL Database Performance
    SQL Server Integration Services: Business Intelligence

    Monday, December 14, 2015 11:53 AM
  • Hi Uri,

    Yes we dont know when the failover will happen, because of that only, i need to have an automated mechanism to stop the applications service.

    And now, we the application does not shutdown gracefully , so i just want them to stop gracefully in step by step.

    Thanks,


    Vinodh Selvaraj

    Tuesday, December 15, 2015 11:10 AM
  • I'm not so sure you can set a mechanism to run before a failure; as a failover can happen for any reason; such as a manual failover or a hardware failure on the node.

    You could however set up a SQL Server Agent Job to perform some tasks at Startup; would this be of any use?


    Please click "Mark As Answer" if my post helped. Tony C.

    Tuesday, December 15, 2015 11:36 AM
  • Tony, I already setup a SP in sql server with startup option to bring up the services in the time of sql services startup.

    EXEC sp_procoption with startup 1. But i need to bring down the services in the time of failover.

    Thanks Tony.



    Vinodh Selvaraj

    Tuesday, December 15, 2015 12:37 PM
  • Hi, 

    I think you have to manage that from Application. Whenever the DB Connection is failing initiate the command to stop services. 

    Thanks

    Shabeer

    Tuesday, December 15, 2015 12:57 PM
  • Yes this is a general 'technique' to redirect application if one node is failed over

    Best Regards,Uri Dimant SQL Server MVP, http://sqlblog.com/blogs/uri_dimant/

    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting: Large scale of database and data cleansing
    Remote DBA Services: Improves MS SQL Database Performance
    SQL Server Integration Services: Business Intelligence

    Tuesday, December 15, 2015 1:01 PM
  • You can create a Generic Script Resource or Generic Application Resource and add it as dependencies of your SQL Server resource.

    The cluster will bring your custom resource online before SQL Server.

    David


    David http://blogs.msdn.com/b/dbrowne/

    Tuesday, December 15, 2015 5:44 PM