Tuesday, July 27, 2004

Tomcat 5 with mod_jk2 on Plesk 7 - Redhat

Finally! I got this
working so you can have jsp pages in your root directory. It is
actually pretty simple, along the lines of the following:

This is on Redhat version of Plesk 7.0

  1. install latest jdk

  2. install tomcat 5

  3. download jk2 connectors Fedora Core binaries

  4. copy the mod_jk2.so file into httpd modules dir

  5. add the LoadModule line for mod_jk2

  6. Remove at_domains_index.html from the DirectoryIndex line!

  7. make your hosts in server.xml ( see http://jakarta.apache.org/tomcat/to...vhosthowto.html )

  8. make workers2.properties file in /etc/httpd/conf directory ( see link above )
I think that's the jist of it for the most part.

Saturday, January 17, 2004

Daily (Nightly) MySQL Backups


This document will explain how to do automated daily MySQL backups to a remote using Cron and SCP.

These instructions will walk you through what it takes.

1. Follow the steps in our Cron and SCP Backup Document


2. Create a user in mysql to use for backups

This user should only have SELECT privileges on the particular database to backup and only from localhost.

mysql -uroot -p mysql

> Enter password

mysql> GRANT SELECT,LOCK TABLES ON databasename.* TO backupuser@localhost;

The LOCK TABLES is required for doing a mysqldump.

3. Now create a script for cron to run

This sample script below will dump the entire database identified by databasename

mysqldump --opt -ubackupuser DATABASENAME > /home/temp/databasename.sql

scp /home/temp/databasename.sql REMOTE_USER@REMOTE_HOST:BACKUPS/

Make sure the BACKUPS/ directory is available under the REMOTE_USER directory on the REMOTE_HOST computer that you wish to backup to. Save the script, call it backups.sh or something. chmod 644 ~/.ssh/authorized_keys

4. Test the script

Test the script to see if it works ok.


After it completes, you should check the BACKUPS directory on the remote host and make sure the backup file is there.

5. Move script to /etc/cron.daily/ directory

mv backups.sh /etc/cron.daily/

That should run every night at some point, whenever the cron.daily is set to run in your crontab. Voila!

Friday, January 09, 2004

Starting Tomcat as a Service on Linux


This document will teach you how to setup Tomcat to run as a service (startup when booted) on Linux.
Intended Audience
System admins.
This is actually pretty easy and will be presented step by step.

1. Save tomcat start / stop script

Copy and paste the following script into your text editor:

# This is the init script for starting up the
# Jakarta Tomcat server
# chkconfig: 345 91 10
# description: Starts and stops the Tomcat daemon.

# Source function library.
. /etc/rc.d/init.d/functions

# Get config.
. /etc/sysconfig/network

# Check that networking is up.
[ "${NETWORKING}" = "no" ] && exit 0

export JAVA_HOME=/usr/local/jdk

echo -n $"Starting Tomcat service: "
#daemon -c

action $"Stopping Tomcat service: " $shutdown


# See how we were called.
case "$1" in
# This doesn't work ;)
status tomcat
echo $"Usage: $0 {start|stop|status|restart}"
exit 1

exit 0

Edit the lines that start with tomcat and export to match where you installed
tomcat and your jdk.

Note: I can't remember where I first got the original version of this script
so if you deserve credit for this, let us know.

2. Save to /etc/init.d and chmod

Save the edited file above to /etc/init.d directory as "tomcat" (at
least on most newer releases since /etc/init.d is a standard now). Then
you have to allow execute access to the script, so run:

chmod a+x tomcat

3. Add to appropriate run level directories

The easy way to do this is to just simply run:

chkconfig --add tomcat

And that's all she wrote.