• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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: 27764
196
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!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic