• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

User Database Failover

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Greetings!

I'm still relatively new to Tomcat configuration and have search for an answer, but cannot find anything specific, so please let me know if there is a resource for the following.

We have a read/write users (MySQL) database and a read-only backup database (also MySQL). We use the read-only as a failover if we lose connection to the primary to maintain operations. I have successfully configured my Tomcat (6.0.35) with a DataSourceRealm to connect to the primary database by adding the boilerplate in the server.xml file and the specific connection information to a container in it's context.xml

I know I can manually change the context.xml to point to the backup database and restart the server if need be, but is there a way to automate this failover switch?

We currently write a zero-length file to a particular directory every (X) minutes to indicate the heartbeat of the primary (and backup) database servers. I can imagine writing something (in an extended Realm Class, perhaps or "further up" the Tomcat chain?) that checks on these heartbeat files, but I'm not sure how to tell Tomcat to switch over to the backup and restart itself, if this is even possible.

Any input is much appreciated!

-kevin.
 
Saloon Keeper
Posts: 24330
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Kevin!

Have you considered using full MySQL clustering? If I'm not mistaken, recent versions of MySQL can do failovers automatically.
 
Kevin Manross
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for the welcome and response Tim! I have long referred to CodeRanch, and am looking forward to contributing where I can.

You ask a good question which I have forward on to our MySQL admin. I'll report on his response when I get it.

[UPDATE - 20130625]

I spoke with our db admin and he tells me that the resources needed to do MySQL clustering are beyond what we can do. If there is a way that tomcat can automatically check for some sort of "heartbeat" that indicates the health of the user db (as well as the backup db), perform the necessary configuration switch, and restart itself, I would be eager to hear it.

I feel pretty comfortable with extending existing classes, or writing new ones to accomplish this if it is possible. I just don't know enough about the internals of tomcat to know where to start if it is possible.

Many thanks!
 
Sunglasses. AKA Coolness prosthetic. This tiny ad doesn't need shades:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic