Casper Failover + Database Recovery Plan

Currently we are using 2 mac mini as our Casper servers, and we want to setup casper failover + database recovery plan.  When the main Casper server failed(east), we want to quickly do the failover and database recovery.

Here is my plan:

At normal times DNS will send west coast users to casper server west, and east coast users to casper server east(main JSS server, with MYSQL installed).

Casper server west is using MYSQL data from Casper server east;

Weekly MYSQL database backup from server east to server west;

 

When server east fails, we change server west MYSQL connection to local instead of remote(points to server east), and recover database data from weekly backup, restart Tomcat. and all casper users will checkin with our server west.

When server east is back to normal, we transfer current database data from server west to server east, and then change server west database connection from local to remote. and then server east back to act as our main casper server.

One thing we need to make sure is that the SSL certificate should be the same for both casper servers. Otherwise when the backup server act as the main server, clients will see the certificate not valid.

 

To change Casper database connection info, you can change the database.xml located at:

/Library/JSS/Tomcat/webapps/ROOT/WEB-INF/xml/DataBase.xml

I created two database.xml files, one for server west to act as main server, the other is to act as the secondary load balancing server.

and here is my script to switch the backup server as main server:

#/bin/bash
# Casper Database Recovery Script
# Rui Qiu
# 06172016

# Unload the Tomcat web application process
sudo launchctl unload /Library/LaunchDaemons/com.jamfsoftware.tomcat.plist

# Restore Database
sudo java -jar /Library/JSS/bin/JSSDatabaseUtil.jar restore -file /Path/to/yourdatabasefile/test.sql.gz -server localhost -port 3306 -database jamfsoftware -user jss -pass

# Change Database location to local
cp -rf /Library/JSS/Tomcat/webapps/ROOT/WEB-INF/xml/DataBase-2.xml /Library/JSS/Tomcat/webapps/ROOT/WEB-INF/xml/DataBase.xml

# Reload the Tomcat web application process
sudo launchctl load /Library/LaunchDaemons/com.jamfsoftware.tomcat.plist

 

and here is the script to switch server west back to the load balancing server:

#/bin/bash
# Casper Database Recovery Script
# Rui Qiu
# 06172016

# Unload the Tomcat web application process
sudo launchctl unload /Library/LaunchDaemons/com.jamfsoftware.tomcat.plist

# Change Database location to remote
cp -rf /Library/JSS/Tomcat/webapps/ROOT/WEB-INF/xml/DataBase-1.xml /Library/JSS/Tomcat/webapps/ROOT/WEB-INF/xml/DataBase.xml

# Reload the Tomcat web application process
sudo launchctl load /Library/LaunchDaemons/com.jamfsoftware.tomcat.plist

Leave a Comment