Administration:Installing WormBase

From WormBaseWiki
Revision as of 18:52, 2 September 2009 by Tharris (talk | contribs) (→‎Directories)
Jump to navigationJump to search

Address

wb-dev.oicr.on.ca

Hardware

The WormBase development server at OICR is a virtual server with the following stats:

  • Debian Linux
  • 500 GB disk space (mounted at /dev/hda1)
  • 4 GB RAM

Server Configuration

Basic Directory Layout

All WormBase components are collected under a single directory: /usr/local/wormbase

$ ls /usr/local/wormbase
     acedb/                     // The Acedb database (including bin directory)
     util/                       // Utility components such as e-pcr and wublast
     extlib/                   // Third party Perl libraries   
     website-classic  // The classic WormBase website
     website                  // The new-and-improved website!
Apache2: /usr/local/apache2
MySQL data directory: /usr/local/mysql/data

Installing Libraries

Assuming a vanilla Debian installation, install the following libaries and all of their dependencies via sudo apt-get install. Some of these libraries are discussed below.

     gcc
     curl
     wget
     bzip2
     mysql-server
     mysql-server-5.0
     libgd2-xpm-dev
     libgd2-xpm
     xinetd
     libdbd-mysql
     libdbd-mysql-perl
     apache2
     libapache2-mod-perl2
     libgtk2.0-0
     libgtk2.0-dev
     libglib
     byacc
     libreadline5-dev
     flex
     libdb4.6
     libdb-dev
     emacs

Preparing directories and users

WormBase uses several user accounts for directory and server permissions. You will need to create these users and several preliminary directories. Creating a new user and group varies among Unix flavors. On most Linux systems, the following commands will create the new groups. You should have sudo privilege to execute these commands.

User and group accounts

These users should not have a login password. They are to establish privileges only.

  • acedb group

This is the group that will have write privileges to the acedb directory tree. Acedb administrators should be added to this group.

$ /usr/sbin/groupadd acedb
  • acedb user

This is the user that the acedb server will run as. It should be a member of the acedb group.

$ /usr/sbin/useradd -g acedb -d /usr/local/wormbase/acedb acedb

This useradd command also adds the new acedb user to the acedb group. Note that the acedb user's home directory was set to /usr/local/acedb, a directory which will be created in the next step.

  • wormbase group

This is a group that will have write privileges to the wormbase directory tree. WormBase administrators and authors should be added to this group.

$ /usr/sbin/groupadd wormbase

This would be a good time to add yourself to the acedb and wormbase groups.

$ /usr/sbin/usermod -a -G acedb,wormbase [your_login_name]

[The '-a' argument keeps this command from deleting other, preexisting group memberships.]

You may need to re-login for these changes to take effect. Use the groups command to check which groups you are a member of:

% groups

Directories

The root container for all things WormBase:

  • /usr/local/wormbase, owner=root group=wormbase mode=drwxrwsr-x
$ mkdir /usr/local/wormbase
$ chgrp wormbase /usr/local/wormbase
$ chmod 2775 /usr/local/wormbase
  • The "classic" website: /usr/local/wormbase/website-classic, owner=root group=wormbase mode=drwxrwsr-x
$ mkdir /usr/local/wormbase/website-classic
$ chgrp wormbase /usr/local/wormbase/website-classic
$ chmod 2775 /usr/local/wormbase/website-classic
  • External Perl libraries: /usr/local/wormbase/website-classic/extlib, owner=tharris group=wormbase mode=drwxrwsr-x
$ mkdir /usr/local/wormbase/website-classic/extlib
$ chgrp wormbase /usr/local/wormbase/website-classic/extlib
$ chmod 2775 /usr/local/wormbase/website-classic/extlib
  • /usr/local/wormbase/logs, owner=root group=wormbase mode=drwxrwsr-x
$ mkdir /usr/local/wormbase/logs
$ chgrp wormbase /usr/local/wormbase/logs
$ chmod 2775 /usr/local/wormbase/logs
  • /usr/local/wormbase/website-classic/cache, owner=nobody group=nobody mode=drwxrwsr-x
$ mkdir /usr/local/wormbase/website-classic/cache
$ chown nobody:nobody /usr/local/wormbase/website-classic/cache
$ chmod 2775 /usr/local/wormbase/website-classic/cache
  • The "util" directory contains components that apply to both the classic and updated site, like wublast and e-pcr.
  • /usr/local/wormbase/util/wublast, owner=root group=wormbase mode=drwxrwsr-x
$ mkdir /usr/local/wormbase/util/wublast
$ chgrp wormbase /usr/local/wormbase/util/wublast
$ chmod 2775 /usr/local/wormbase/util/wublast
  • /usr/local/wormbase/acedb, owner=acedb group=acedb,mode=drwxrwsr-x
$ mkdir /usr/local/wormbase/acedb
$ chown acedb:acedb /usr/local/wormbase/acedb
$ chmod 2775 /usr/local/wormbase/acedb

Configure the FTP/Mirroring directory THIS IS NOT DONE YET

  • ~ftp/pub/wormbase, owner=root group=wormbase mode=drwxrwsr-x
$ mkdir ~ftp/pub/wormbase
$ chgrp wormbase ~ftp/pub/wormbase
$ chmod 2775 ~ftp/pub/wormbase

You may ignore this step if you do not plan to mirror the WormBase FTP site. In the examples below, the -p option is used to create the intermediate parents of directories if they don't already exist. If your mkdir doesn't support this option, you will need to create the intermediate directories manually.

Perl modules

See Managing Perl Libraries for details on how to build and install required Perl modules.

Generic Genome Browser

See Managing GBrowse for details on how to build and install GBrowse.

3rd-party Support Applications

Apache2 and mod_perl

I prefer to build httpd and mod_perl from source; it seems easier than waiting for package repositories to be updated.

Installation

Assuming you have already fetched the source into ~/src:

# Build httpd 2.2.11
cd ~/src
tar xzf httpd-2.2.11.tar.gz
cd httpd-2.2.11
./configure --enable-mods-shared=all   // We can enable modules in httpd.conf later
make
sudo make install
# Build mod_perl2-0.4
cd ~/src
cd mod_perl-2.0.4
// Get rid of some (possible) cruft
sudo rm -rf /usr/local/wormbase/extlib/lib/perl5/i686-linux-thread-multi/Apache2 \
                     /usr/local/wormbase/extlib/lib/perl5/i686-linux-thread-multi/ModPerl \
                     /usr/local/wormbase/extlib/lib/perl5/i686-linux-thread-multi/mod_perl2.pm
make clean
perl -I/usr/local/wormbase/extlib Makefile.PL INSTALL_BASE=/usr/local/wormbase/extlib
// When prompted for the apxs path, enter: /usr/local/apache2/bin/apxs
make
sudo make install

Configuration

  • Set httpd to listen on port 8080.
$ sudo perl -p -i -e's|Listen 80|Listen 8080|' /usr/local/apache2/conf/httpd.conf
  • Set up a virtual host for WormBase on port 8080
$ sudo emacs /usr/local/apache2/conf/extra/httpd-vhosts.conf
<VirtualHost *:8080>
   Include /usr/local/wormbase/website-classic/conf/httpd.conf
   PerlOptions +Parent
   PerlSwitches  -Mlib=/usr/local/wormbase/extlib/lib/perl5/x86_64-linux-gnu-thread-multi \
                -Mlib=/usr/local/wormbase/extlib/gbrowse1/i686-linux-thread-multi \
                -Mlib=/usr/local/wormbase/extlib/gbrowse1 \
                -Mlib=/usr/local/wormbase/extlib/lib/perl5/i686-linux-thread-multi
#   PerlInterpStart 2
#   PerlInterpMax 2
   <Directory "/usr/local/wormbase/website-classic/html">
        DirectoryIndex index.html
#       Order deny,allow
#       Deny from all
   </Directory>
</VirtualHost>
  • Enable virtual hosts in httpd.conf
$ sudo perl -p -i -e's|\#Include conf/extra/httpd-hosts.conf|Include conf/extra/httpd_hosts.conf|' \
     /usr/local/apache2/conf/httpd.conf

Set up httpd to run under inet.d

Save the following file to /etc/init.d/httpd:

#!/bin/bash
#
# Startup script for the Apache Web Server
#
# chkconfig: - 85 15
# description: Apache is a World Wide Web server.  It is used to serve \
#              HTML files and CGI.
# processname: httpd
# pidfile: /usr/local/apache2/logs/httpd.pid
# config: /usr/local/apache2/conf/httpd.conf

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

if [ -f /etc/sysconfig/httpd ]; then
        . /etc/sysconfig/httpd
fi

# This will prevent initlog from swallowing up a pass-phrase prompt if
# mod_ssl needs a pass-phrase from the user.
INITLOG_ARGS=""

# Path to the apachectl script, server binary, and short-form for messages.
apachectl=/usr/local/apache2/bin/apachectl
httpd=/usr/local/apache2/bin/httpd
pid=/usr/local/apache2/logs/httpd.pid
prog=httpd
RETVAL=0

# The semantics of these two functions differ from the way apachectl does
# things -- attempting to start while running is a failure, and shutdown
# when not running is also a failure.  So we just do it the way init scripts
# are expected to behave here.
start() {
        echo -n $"Starting $prog: "
        daemon $httpd $OPTIONS
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && touch /var/lock/subsys/httpd
        return $RETVAL
}
stop() {
        echo -n $"Stopping $prog: "
        killproc $httpd
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && rm -f /var/lock/subsys/httpd $pid
}
reload() {
        echo -n $"Reloading $prog: "
        killproc $httpd -HUP
        RETVAL=$?
        echo
}

# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  status)
        status $httpd
        RETVAL=$?
        ;;
  restart)
        stop
        start
        ;;
  condrestart)
        if [ -f $pid ] ; then
                stop
                start
        fi
        ;;
  reload)
        reload
        ;;
  graceful|help|configtest|fullstatus)
        $apachectl $@
        RETVAL=$?
        ;;
  *)
        echo $"Usage: $prog {start|stop|restart|condrestart|reload|status"
		echo $"|fullstatus|graceful|help|configtest}"
        exit 1
esac

exit $RETVAL

Set which runlevels httpd will run under:

chkconfig --add httpd
chkconfig --level 2345 httpd on
chkconfig --list

Important Fix for mod_perl2/mod_dir incompatibility (the index.html problem)

mod_perl2 intercepts Apache requests before any other modules. This means that for locations/directories configured with PerlHandlers that requests for dir or dir/ will NOT automatically redirect to the value of DirectoryIndex. To fix this problem, the lib/Apache/AddWormBaseBanner.pm needs to be modified:

Insert the following:

# We need two additional modules:
use Apache2::Const -compile => qw(DIR_MAGIC_TYPE OK DECLINED);
use Apache2::SubRequest;
sub handler {
   my $r = shift;
 # --> Copy and paste starting here...
 # A directory request has content-type = httpd/unix directory                                                             
 # we check that the uri ends in a slash, since only in that case                                            
 # do we want to redirect, and finally to avoid redirect loops                                                                                      
 # we only do this on the initial request.                                                                                                
 # You must load Apache2::SubRequest in order to run internal_redirect                                                                                                        
 if ($r->content_type eq 'httpd/unix-directory'
     && $r->uri =~ '/$' && $r->is_initial_req ) {
     #        print STDERR "Accepting Directory Request\n";                                                                                                          
      # warn "internal request";                                                                                                                                                                                
       $r->internal_redirect($r->uri . 'index.html');
       return OK;
   }

AceDB

I always build acedb from source.

$ tar xzf ACEDB-source*    // CAUTION: Tarbomb.
// Requires installation of a whole bunch of things first: libgtk2.0-0 libgtk2.0-dev libglib, byacc, etc, etc
// Modify the makefile: create a target for server programs (xace tace saceserver sgifacerver)
// This is all I care about:
   SERVERS = xace tace saceserver sgifaceserver saceclient
   servers: $(SERVERS)
$ export ACEDB_MACHINE=LINUX_4
$ make servers
$ cd ~acedb
$ ln -s bin-VERSION bin 
$ cp tace xace sgifaceserver saceserver saceclient ~acedb/bin/.
$ sudo chown root:root ~acedb/bin/*

Testing the ACeDB Installation

At this point, you can test whether the socket server runs correctly. Provided that you have added yourself to the acedb group, you can run the following command:

 % ~acedb/bin/sgifaceserver ~acedb/wormbase
 // Database directory: /usr/local/wormbase/acedb/wormbase
 // Shared files: /usr/local/acedb
 // #### Server started at 2001-07-23_16:42:31
 // #### host=mondseer.cshl.org  listening port=23100
 // #### Database dir=/usr/local/acedb/elegans
 // ####  Working dir=/usr/local/acedb/elegans
 // #### clientTimeout=600 serverTimeout=600 maxKbytes=0 autoSaveInterval=600
 // Server listening socket 28 created

The line "listening port=23100" indicates that the server is listening to port 23100. Open a new terminal window and use saceclient to confirm that you can communicate with the server:

% ~acedb/bin/saceclient localhost -port 23100
Please enter userid: anonymous
Please enter passwd:
acedb@localhost> find Sequence
// Response: 65 bytes.
// Found 236493 objects in this class
// 236493 Active Objects
acedb@localhost> quit
// Closing connection to server.
// Client sent termination signal by server.
// Response: 13 bytes.
// A bientot
// Please report problems to acedb@sanger.ac.uk
// Bye

Configuring Acedb to start automatically under xinetd

Install xinetd (not standard in Debian) if you didn't already:

  $ sudo apt-get install xinetd

Create a configuration file for acedb:

 $ sudo emacs /etc/xinetd.d/acedb-wormbase 

 # file: /etc/xinetd.d/acedb-wormbase
 # default: on
 # description: wormbase acedb database
 service acedb
 {
        protocol                = tcp
        socket_type             = stream
        port                    = 2005
        flags                   = REUSE
        wait                    = yes
        user                    = acedb
        group                   = acedb
        log_on_success          += USERID DURATION
        log_on_failure          += USERID HOST
        server                  = /usr/local/wormbase/acedb/bin/sgifaceserver
        server_args             = /usr/local/wormbase/acedb/wormbase 1200:1200:0
 }
 

Edit /etc/services. Although xinetd is not supposed to use /etc/services, the following line must be added:

acedb-wormbase           2005/tcp

Restart xinetd with the following command:

$ sudo /etc/init.d/xinetd reload (or restart)

You should now be able to talk to the database using saceclient:

$ ~acedb/bin/saceclient localhost -port 2005

MySQL

Installation

Install mysql and various libraries via apt-get if you haven't already:

 $ sudo apt-get install mysql-server-5.0 mysql-server libdbd-mysql libdbd-mysql-perl

If it fails, then disable innodb by default. edit /etc/mysql/my.cnf file (uncomment the line):

 #skip-innodb
 $ sudo apt-get purge   mysql-server-5.0 mysql-server  
 $ sudo apt-get install mysql-server-5.0 mysql-server

With this installation, databases are located at /var/lib/mysql. We want to able to write to this directory from the command line, so:

 $ sudo chmod 2775 /var/lib/mysql

Mysqld will automatically be setup to launch at server boot (rc3 and rc5).

Set up mysql permissions

$ mysql -u root -pPASSWORD
mysql> grant select on elegans.* to nobody@localhost;

Repeat for:

  • c_briggsae
  • c_japonica
  • c_remanei
  • c_brenneri
  • p_pacificus
  • b_malayi
  • c_elegans_gmap
  • c_elegans_pmap
  • autocomplete
  • h_bacteriophora

e-PCR

  • e-PCR (modified version, required for e-PCR search page)

This is located in the directory /usr/local/wormbase/e-PCR, which will come into existence after the WormBase site update program wb_update_wormbase.pl has been successfully run (see below for details). Once the directory has been generated, run:

   $ cd /usr/local/wormbase/e-PCR
   # Edit 'makefile' to run install rather than ginstall, which doesn't exist on Fedora Linux
   $ make
   $ make install   # or just run 'install e-PCR /usr/local/bin'

The file /usr/local/wormbase/e-PCR/README-Wormbase describes the changes that were made to the original e-PCR distribution.

BLAT

Jim Kent's BLAT (blast-like alignment tool) is a fast nucleotide aligner used by the blast search page. If you do not plan to support blast searches, you may safely skip this step.

# mkdir -p /usr/local/blat/bin ; cd /usr/local/blat/bin
 % wget http://www.soe.ucsc.edu/~kent/exe/linux/blatSuite.33.zip  (for Intel Linux)
% unzip blatSuite.33.zip
% rm blatSuite.33.zip version.doc 11.ooc

Note that this choice gives precompiled binaries for an Intel-based Linux distribution as of March 2006. It would probably be worth checking http://www.soe.ucsc.edu/~kent/exe/linux to see if there is a more up-to-date version than 33. Also, other operating systems will need other binaries. E.g., for Mac OS X, instead run:

 % wget http://www.soe.ucsc.edu/~kent/exe/osX/blatSuite.33.zip

For other types of operating systems (e.g., Linux on Opteron-based machines), see http://www.soe.ucsc.edu/~kent/exe/ for the available choices.

The blat server will be started automatically by the update script. For reference, the blat server is launched using the following command.

% /usr/local/blat/bin/gfServer start localhost 2003 \
     /usr/local/wormbase/blat/*.nib & > /dev/null 2>&1

BLAST

The Blast page requires WU-BLAST. This is a closed-source derivative of NCBI's BLAST. However, WU-BLAST is free to academic users (with licensing) and is thought to have performance advantages over NCBI-BLAST; it can be downloaded from http://blast.wustl.edu/. A typical choice of WU-BLAST for Linux is blast2.linux26-i686.tar.gz.

Conversely, the Blast page can be deactivated if you don't want to provide BLAST searches at your site.

By default, WormBase expects WU-BLAST to be installed in /usr/local/wublast. This is the directory structure used by WormBase:

% ls -l /usr/local/wublast
ls -l /usr/local/wublast
total 72
lrwxrwxrwx  1 root  root     18 May  7 12:26  BLOSUM62 -> matrix/aa/BLOSUM62
-rw-r--r--  1 root  root  46789 Feb  5  1998  HISTORY
-rw-r--r--  1 root  root   6648 Mar  4  1997  README
drwxr-xr-x  2 root  root   4096 May  7  12:46 bin/
lrwxrwxrwx  1 root  root     25 Jul 24  08:20 databases -> /usr/local/wormbase/blast/
drwxr-xr-x  2 root  root   4096 Jan 27  2000  filter/
drwxr-xr-x  4 root  root   4096 Oct  4  1998  matrix/

which can be set up in this manner (adapt to your system):

$ cd /usr/local/wublast
$ zcat /usr/local/TGZ/blast2.linux26-i686.tar.gz | tar xf -
$ chown -R root:root *
$ mkdir bin
$ mv *fasta tblast* blast* *db xd* memfile pam wu-blastall bin
$ ln -s /usr/local/wormbase/blast databases

The important thing to note is that the databases directory is a symbolic link to /usr/local/wormbase/blast. This is where the update_wormbase.pl script (described in the next section) dumps its BLAST databases.

The WormBase Software

Check out the WormBase software from CVS:

 $ cd /usr/local/wormbase
 $ cvs -d formaggio.cshl.org:/usr/local/cvs_repository co wormbase-website
 $ mv wormbase-website website-classic

Configure localsdef.pm

  • $HOST

This is the name of the host where the socket server runs. It is set to "localhost" by default.

  • $PORT

This is the port on which the socket server runs, 2005 by default.

  • $ACEPASS, $USERNAME, $PASSWORD

These three items define the acedb username and password.

  • $MYSQL_HOST, $MYSQL_USER, $MYSQL_PASS

These three items define the mysql host, username, and password.

  • $MASTER

This is used only for the WormBase master site. Should be set to 0.

  • $MIRROR

Whether or not the site is a mirror. Should be set to the name of the mirror.

  • $DEVELOPMENT

Whether or not the site is a development site. Internally, this controls the nature of caching on the site. Should be set to 0.

  • $BLAST2WORMBASE, $WORMBASE2BLAST

These two options control where the blast script directs queries, and where those queries are returned. This is provided in the event that a second standalone blast server is provided. If not, these two options should point to:

$WORMBASE2BLAST=http://your.hostname.org/





Cronjobs

Set up the following cronjobs:

Log Rotation (root cron)

# Rotate WormBase logs
10 1 * * * /home/todd/projects/wormbase/admin/maintenance/rotate_httpd_logs.pl

For nodes running acedb, add the following entry which deals with its massive log files:

# Purge epic ACEDB logs
35 * * * * /home/todd/projects/wormbase/admin/maintenance/purge_acedb_logs.sh


The final step is to arrange for Acedb to start automatically and for MySQL to restart if necessary.

Installing MySQL and BLAT monitoring scripts

Run:

   $ cp -i /usr/local/wormbase/util/admin/blat_server.initd /etc/rc.d/init.d/blat_server

Then run:

   $ crontab -u root -e

to add the following entries to root's crontab:

   0 * * * * /usr/local/wormbase/util/admin/restart_mysqld.pl
   0 * * * * /usr/local/wormbase/util/admin/restart_blat.pl


Installing scripts to verify that the servers are running

Two scripts in the WormBase directory can be used to ensure that the mysql and blat servers are running. To install, them:

% sudo cp /usr/localwormbase/util/admin/blat_server.initd \
          /etc/rc.d/init.d/blat_server

Place the restart scripts under cron control of a privileged user. These commands will check every hour to see that the servers are running.

 % sudo crontab -u root -e
0 * * * * /usr/local/wormbase/util/admin/restart_mysqld.pl
0 * * * * /usr/local/wormbase/util/admin/restart_blat.pl

At the same time, you might also wish to automate the rotatation of logs to prevent them from growing to an unwieldy size. You'll find an appropriate log rotation configuration stanza in util/rotate_wormbase_logs and a log rotate script in /usr/local/wormbase/bin/rotatelogs.pl. You will need both.

# Rotate httpd logs
 10 1 * * * /usr/local/wormbase/bin/rotatelogs.pl
 # Rotate acedb logs
 10 1 * * * logrotate /usr/local/wormbase/util/rotate_wormbase_logs
 

This stanza will check that the acedb server logs do not grow larger than 100 MB.

Testing The Site

At this point, all components of a WormBase installation have been installed. You can test your installation by restarting the various server components of WormBase.

Restarting AceDB

# Via xinetd:
 $ /etc/init.d/xinetd reload (or restart)
 
# ...or using saceclient
 % saceclient localhost -port 2005
 acedb> password:
 acedb> shutdown now
 

Restarting MySQL

# Via mysqladmin...
 % mysqladmin -uroot -pPASSWORD shutdown
 
 # or using init.d
 $ /etc/init.d/mysql restart
 

Restarting Apache

When the configuration files have been checked and adjusted, restart Apache with the following command:

 $ /etc/init.d/apache restart

Check /usr/local/wormbase/logs/classic-error_log for WormBase-specific errors and /var/log/apache2/error_log for general errors.

BLAT

% /usr/local/blat/bin/gfServer start localhost 2003 \
     /usr/local/wormbase/blat/*.nib & > /dev/null 2>&1

Blocking robots

It can be useful to block search engines (such as Google) from crawling over one's mirror. To do this, go to /usr/local/wormbase/html, and make a file called "robots.txt" with the following contents:

   User-agent: *
   Disallow: /

Updating Production Nodes to match this reality

1. Create /usr/local/wormbase/website-classic

2. Move all website files into website-classic

3. Move database to /usr/local/wormbase

4. Create /usr/local/wormbase/logs

5. Install Perl Modules as described above

6. Install GBrowse as described above

7. Update admin module for pushing software to production (and for maintaining staging module)

AUTHOR

Todd Harris (toddwharris@gmail.com)