Openfire update with minimal downtime (CentOS, tar.gz-Version)

Requirements

This guide is for CentOS Linux with tar.gz-Version of Openfire. It might work also on Fedora or other Linux distributions. **I’m using an external database. It is always a good idea to make an full database backup before updating.
**

For all instructions here: Turn your brain on, there might be changes in new Openfire versions!

Idea

Prepare the update while Openfire is running. First prepare a second Openfire directory and copy openfire and plugins. Then shutdown Openfire, switch Openfire directories and start the new version. Total downtime is only the time Openfire needs for shutdown / startup which can’t be avoided.

Preparation step

Assuming your old Openfire is located in /opt/openfire, extract the new version to /opt/openfire_new

Further assumptions are that your Openfire user is called “openfire”. During this step Openfire can be running all the time.

cd /opt

% set access rights correctly
chown -R openfire openfire_new/
chgrp -R openfire openfire_new/
chmod -R go-rwx openfire_new/conf

chmod -R go-rwx openfire_new/resources/security

% copy SSL certificates and config file

cp openfire/resources/security/* openfire_new/resources/security/

cp openfire/conf/openfire.xml openfire_new/conf/

% copy all your plugins, do not overwrite search.jar since it is already supplied with Openfire
cp openfire/plugins/*.jar openfire_new/plugins/
chown -R openfire openfire_new/plugins/
chgrp -R openfire openfire_new/plugins/
``

% create symbolic link: openfire -> openfire.sh
cd /opt/openfire_new/bin
ln -s openfire openfire.sh

% open file openfire with your favorite editor and change the following parameters according to your needs

INSTALL4J_JAVA_HOME_OVERRIDE=/usr/java/jdk1.6.0_07
INSTALL4J_ADD_VM_PARAMS="-Xms384m -Xmx384m"

% give execution right to openfired script
cd /opt/openfire_new/bin/``extra
chmod u+x openfired

% open file openfired with your favorite editor and change the following two things
% change user to openfire
export OPENFIRE_USER=openfire
% add the following at the beginning of function ‘start()’. This is required for automatic startup/shutdown.
touch /var/lock/subsys/openfired

Update step

This is a really quick and simple step.

cd /opt

% stop Openfire
/opt/openfire/bin/extra/openfired stop

% switch directories
mv openfire openfire_old
mv openfire_new openfire

% start Openfire again
/opt/openfire/bin/extra/openfired start

% check your logfiles for possible problems. If serious problems appear switch back directories and restore your last database backup.

Do you really need to chown so many times? I usually download and upgrade with the same openfire user, so the owner is the same after overwriting. chgrp is for a group change? maybe chwon -R openfire:openfire openfire_new is the same for those two lines. In overall it’s a good example.