Difference between revisions of "GBrowse Administration"

From WormBaseWiki
Jump to navigationJump to search
 
(164 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
= Overview =
 
= Overview =
  
GBrowse is one of the central -- and most heavily used -- components of the WormBase site.  To meet this demand, we use a number of dedicated servers using GBrowse's built in master/slave configuration. This document describes how to build and configure these servers.
+
GBrowse is one of the central -- and most heavily used -- components of the WormBase site.  To meet this demand, we use a number of dedicated servers using GBrowse's built in renderfarm capability. This document describes how to install GBrowse and configure these servers.
  
 
= Hardware Topology =
 
= Hardware Topology =
Line 11: Line 11:
 
   |    gb1    |              \              \
 
   |    gb1    |              \              \
 
   |          |        -------------    -------------   
 
   |          |        -------------    -------------   
   |* * * * * *| <----- |   gb2    |    |   gb2    |   Slaves
+
  |          |        |  gb2    |    |    gb3    |  Slaves
 +
   |* * * * * *|       |* * * * * *|    |* * * * * *|
 
   -------------        -------------    -------------   
 
   -------------        -------------    -------------   
 +
  * * * * * = relational databases running on each node.
  
Where:
+
Note that although this topology presents a single master with multiple slave servers, in reality each node is redundant with each other.  This makes failover easier in case the master server dies.  See the Administration & Troubleshooting section for details.
  * * * * * = relational databases running under mysql on gb1.
 
  
= Node Configuration =
+
 
 +
=== Quick Overview ===
 +
 
 +
1. GBrowse is included with our application and configured as follows.
 +
 
 +
2. $app_root/$app/wormbase.env sets the GBROWSE_CONF and GBROWSE_HTDOCS environment variables.
 +
 
 +
3. Configuration is located at $app_root/$app/conf/gbrowse
 +
 
 +
4. GBrowse is installed at: $app_root/$app/root/gbrowse
 +
 
 +
5. wormbase.psgi file mounts
 +
 
 +
* /tools/genome => gbrowse CGIs
 +
* /gbrowse-static => $app_root/$app/root/gbrowse
 +
 
 +
6. Even though every node can host gbrowse, nginx proxy passes requests to dedicated nodes.
 +
 
 +
= Basic Server Configuration =
  
 
== Create groups ==
 
== Create groups ==
 
''Both master and slave servers.''
 
  
 
  sudo addgroup wormbase
 
  sudo addgroup wormbase
Line 28: Line 45:
 
  sudo usermod -a -G gbrowse, wormbase tharris
 
  sudo usermod -a -G gbrowse, wormbase tharris
  
== Create Directories ==
+
== Create directories ==
  
''Both master and slave servers.''
+
''Create a directory for GBrowse's temporary files.''
  
''Create a directory for GBrowse. For now, we're maintaining GBrowse on dedicated hardware completely distinct from the rest of the web application. This makes updates significantly easier, although it increases maintenance (ie of boilerplate). We'll also keep gbrowse inside a wormbase/ directory should we wish to install other components on these servers at a later date.''
+
  > mkdir -p /usr/local/wormbase/tmp
 +
  > sudo chown -R www-daemon /usr/local/wormbase/tmp
  
Let $ROOT = /usr/local/wormbase
+
== Install prerequisites (Debian) ==
 
 
$ sudo mkdir -p ${ROOT}
 
$ sudo chgrp -R wormbase $ROOT
 
$ sudo chmod 2775 $ROOT
 
 
 
== Debian preparation ==
 
 
 
''Both master and slave servers.''
 
  
 +
// Update apt
 
  $ sudo apt-get update
 
  $ sudo apt-get update
  
Line 59: Line 70:
  
 
== Install Perl 5.10.1 or greater ==
 
== Install Perl 5.10.1 or greater ==
 
''Both master and slave servers.''
 
  
 
''You'll need Perl version 5.10.1 or greater.''
 
''You'll need Perl version 5.10.1 or greater.''
Line 67: Line 76:
 
  $ sudo apt-get install perl
 
  $ sudo apt-get install perl
  
NOTE: This version of Perl on Debian Lenny doesn't ship with perl.h. You won't be able to build mod_perl without it!
+
NOTE: This version of Perl on Debian Lenny doesn't ship with perl.h. You won't be able to build mod_perl without it! You should probably build from source.
  
Or from source:
+
Building from source:
  
bash> mkdir ~/website/perl
 
 
  bash> cd ~/src
 
  bash> cd ~/src
 
  bash> curl -O http://www.cpan.org/src/perl-5.10.1.tar.gz
 
  bash> curl -O http://www.cpan.org/src/perl-5.10.1.tar.gz
 
  bash> cd ~/build
 
  bash> cd ~/build
  bash> tar xzf ../src.perl-5.10.1.tar.gz
+
  bash> tar xzf ../src/perl-5.10.1.tar.gz
 
  bash> cd perl-5.10.1
 
  bash> cd perl-5.10.1
 
  bash> ./Configure -des
 
  bash> ./Configure -des
Line 82: Line 90:
 
  bash> make
 
  bash> make
 
  bash> make test
 
  bash> make test
  bash> make install
+
  bash> sudo make install
  
Be sure to set up your your system to preferentially use this newly installed Perl:
 
  
bash> export PATH=~/wormbase/perl/5.10.1/bin:${PATH}
+
== Install Requisite Perl Modules ==
  
== Install Apache2 and mod_perl ==
+
''All libraries specific for GBrowse are maintained in a local shared directory.  This makes it easier and faster to upgrade GBrowse, but more difficult to test multiple versions simultaneously.  To test a new version of GBrowse, place extlib inside of the gbrowse-current directory and modify the apache configuration and commands below as appropriate.''
  
''Master server only - the slaves do not need apache/mod_perl''
+
Install local::lib to make things easier:
  
First, if you're running Debian, get rid of the installed apache. The default layout is just plain annoying.
+
$ sudo perl -MCPAN -e 'CPAN::install(local::lib)'
 +
$ mkdir /usr/local/wormbase/extlib
 +
$ cd /usr/local/wormbase/extlib
  
$ sudo apt-get remove apache2
+
To install modules to this path:
  
''Assuming you have already fetched the source into ~/src:''
+
$ perl -Mlocal::lib=.
 +
$ eval $(perl -Mlocal::lib=./)
 +
$ sudo rm -rf ~/.cpan
 +
$ perl -MCPAN -e shell
  
  # Build httpd 2.2.11
+
  cpan> install YAML DBI DBD::mysql CGI::Session JSON Storable FreezeThaw FCGI SVG GD::SVG Text::Shellwords \
cd ~/src
+
            Algorithm::Munkres Array::Compare Clone Convert::Binary::C Error Graph GraphViz HTML::Entities HTML::HeadParser HTTP::Request::Common LWP::UserAgent \
  tar xzf httpd-2.2.11.tar.gz
+
            List::MoreUtils Math::Random PostScript::TextBlock SOAP::Lite SVG::Graph Set::Scalar Sort::Naturally Spreadsheet::ParseExcel URI::Escape \
  cd httpd-2.2.11
+
            XML::DOM::XPath XML::Parser XML::Parser::PerlSAX XML::SAX XML::SAX::Writer XML::Simple XML::Twig XML::Writer \
./configure --enable-mods-shared=all
+
            Capture::Tiny Template Term::ReadKey
make
 
sudo make install
 
  
  # Install mod_perl 2-0.4
+
  cpan> install Bio::Perl        // may be necessary to install from source
  $ perl -MCPAN -e 'CPAN::install(mod_perl2)'
+
  cpan> install Bio::Graphics    // may be necessary to install from source
  
Fetch the appropriate values for @INC:
+
== Install SamTools and Bio::SamTools ==
$ cd /usr/local/wormbase/gbrowse-current/extlib
 
$ perl -Mlocal::lib=./
 
  
  cd ~/src
+
  > cd /usr/local/wormbase/services/gbrowse2/src
cd mod_perl-2.0.4
+
> wget http://sourceforge.net/projects/samtools/files/samtools/0.1.16/samtools-0.1.16.tar.bz2/download
perl -I/usr/local/wormbase/website-classic/extlib Makefile.PL INSTALL_BASE=/usr/local/wormbase/website-classic/extlib
+
> bunzip2 samtools*
  // When prompted for the apxs path, enter: /usr/local/apache2/bin/apxs
+
> cd samtools*
make
+
> make CXXFLAGS=-fPIC CFLAGS=-fPIC CPPFLAGS=-fPIC
sudo make install
+
  > sudo cp misc/*.pl /usr/local/bin/
  
''If make fails, you may need to symlink libperl.so -> libperl.so.5.10.0 in /usr/lib''
+
> wget http://search.cpan.org/CPAN/authors/id/L/LD/LDS/Bio-SamTools-1.28.tar.gz
 +
> tar xzf Bio*
 +
> cd Bio*
 +
> export SAMTOOLS=/usr/local/wormbase/src/samtools-0.1.16
 +
> perl Build.PL --install_base=/usr/local/wormbase/extlib
 +
> ./Build
 +
> ./Build test
 +
> (sudo) ./Build install
  
=== Configuration ===
+
== Install Bio::BigFile.pm ==
  
* Set httpd to listen on your desired port. In the examples below, we assume port 8080.
+
To compile this module, you must first download, unpack and compile Jim Kent's source tree to create the main library file jkweb.a:
 +
 
 +
  > wget http://hgdownload.cse.ucsc.edu/admin/jksrc.zip
 +
  > unzip jksrc.zip
 +
  > cd kent/src/lib
 +
  > export MACHTYPE=x86_64
 +
  > mkdir $MACHTYPE
 +
  > make CXXFLAGS=-fPIC CFLAGS=-fPIC CPPFLAGS=-fPIC
 +
 
 +
Download and build Bio::BigFile, eg v1.06:
 +
 
 +
  > wget http://search.cpan.org/CPAN/authors/id/L/LD/LDS/Bio-BigFile-1.06.tar.gz
 +
  > tar xzf Bio-* ; cd Bio-Big*
 +
  > export KENT_SRC=/usr/local/wormbase/src/kent/src/
 +
  > perl Build.PL --install_base=/usr/local/wormbase/extlib
 +
  > ./Build
 +
  > ./Build test
 +
  > (sudo) ./Build install
 +
 
 +
== Install GBrowse ==
 +
 
 +
GBrowse CGI components are distributed as part and parcel of the WormBase site.  Thus each version of the site is directly associated with a distinct version of GBrowse, too.  This means that installing new versions will necessarily overwrite old and need to be recommitted to the repository.
 +
 
 +
Substitute the symbolic name for the site you are installing into.
 +
 
 +
$ cd /usr/ocal/wormbase/shared/src
 +
$ wget http://sourceforge.net/projects/gmod/files/Generic%20Genome%20Browser/GBrowse-2.39/GBrowse-2.39.tar.gz/download
 +
// GBROWSE_ROOT = /usr/local/wormbase/website/YOURSITE
 +
$ perl ./Build.PL --install_base ${GBROWSE_ROOT}
 +
$ perl ./Build --reconfig
 +
Directory for GBrowse's config and support files? ${GBROWSE_ROOT}/conf/gbrowse
 +
Directory for GBrowse's static images & HTML files? ${GBROWSE_ROOT}/root/gbrowse
 +
Directory for GBrowse's temporary data /usr/local/wormbase/tmp/gbrowse
 +
Directory for GBrowse's sessions, uploaded tracks and other persistent data: /usr/local/wormbase/tmp/gbrowse/persistent
 +
Directory for GBrowse's example databases /usr/local/wormbase/tmp/gbrowse/databases
 +
Directory for GBrowse's CGI script executables? ${GBROWSE_ROOT}/root/cgi/gbrowse
 +
Internet port to run demo web site on (for demo)? [8000]
 +
Apache loadable module directory (for demo)? [/usr/local/apache2/modules]
 +
User account under which Apache daemon runs? [www-data] www-data
 +
Automatically update Apache config files to run GBrowse? [n]
 +
Automatically update system config files to run gbrowse-slave? [n] y
 +
 
 +
To fetch suggested apache configuration:
 +
./Build apache_conf
 +
 
 +
Install dependencies
 +
./Build installdeps
 +
 
 +
To install:
 +
./Build install
  
# Unnecessary if running on the default port.
+
You may need to create directories and fix permissions.
  $ sudo perl -p -i -e's|Listen 80|Listen 8080|' /usr/local/apache2/conf/httpd.conf
+
  chmod 777 /usr/local/wormbase/tmp
  
Set up a virtual host on your port. Adjust PerlSwitches as appropriate.
+
=== Install gbrowse-slave components on all servers ===
 +
  sudo ./Build install_slave
  
<pre>
+
Edit /etc/default/gbrowse_slave:
<VirtualHost *:80>
+
 
    ErrorLog "/usr/local/wormbase/logs/error_log"
+
# Make sure that Perl5Lib includes that path to our external aggregator modules:
    CustomLog "/usr/local/wormbase/logs/access_log" common
+
  export PERL5LIB=/usr/local/wormbase/extlib/lib/perl5/x86_64-linux-gnu-thread-multi:\
 
+
    /usr/local/wormbase/extlib/lib/perl5:\
# Support files: the wormbase css file for gbrowse, banner image, etc
+
    /usr/local/wormbase/services/gbrowse2/current/lib/perl5:\
Alias      "/support/     "/usr/local/wormbase/support-files/"
+
    /usr/local/wormbase/services/gbrowse2/current/website-gbrowse2-support/lib:\
 +
    /usr/local/wormbase/services/gbrowse2/current/website-gbrowse2-support/lib/Bio:\
 +
    /usr/local/wormbase/services/gbrowse2/current/website-gbrowse2-support/lib/Bio/Graphics:\
 +
    /usr/local/wormbase/services/gbrowse2/current/website-gbrowse2-support/lib/Bio/Graphics/Glyph
  
# Include /usr/local/wormbase/gbrowse-current/conf/httpd.conf
+
  DAEMON=/usr/local/bin/gbrowse_slave
 +
# Be certain this matches the httpd daemon user on the master!
 +
USER=www-data
 +
#PRELOAD=/etc/gbrowse2/slave_preload.conf
 +
RUNDIR=/usr/local/wormbase/logs
 +
LOGDIR=/usr/local/wormbase/logs
 +
PORT="8101 8102 8103"
 +
VERBOSITY=3
 +
NICE=0
  
Alias        "/gbrowse2/i/" "/usr/local/wormbase/gbrowse-current/tmp/images/"
+
Then set up the slave server to start automatically:
Alias        "/gbrowse2"    "/usr/local/wormbase/gbrowse-current/html"
 
ScriptAlias  "/gb2"      "/usr/local/wormbase/gbrowse-current/cgi/gb2"
 
  
<Directory "/usr/local/wormbase/support-files">
+
$ cd /etc/rc3.d
  Options -Indexes -MultiViews +FollowSymLinks
+
$ sudo ln -s ../init.d/gbrowse-slave S99gbrowse-slave
  Order allow,deny
+
$ cd /etc/rc5.d
  Allow from all
+
$ sudo ln -s ../init.d/gbrowse-slave S99gbrowse-slave
</Directory>
 
  
<Directory "/usr/local/wormbase/gbrowse-current/tmp">
+
=== Configure sessions and locks databases ===
Allow from all
 
</Directory>
 
  
<Directory "/usr/local/wormbase/gbrowse-current/html">
+
''Sessions and locks will be stored in the sessions database.''
  Options -Indexes -MultiViews +FollowSymLinks
 
  Order allow,deny                                             
 
  Allow from all
 
</Directory>
 
  
<Directory "/usr/local/wormbase/gbrowse-current/cgi/gb2">
+
> mysql -u root -p -e 'create database sessions'
  SetEnv PERL5LIB "/usr/local/wormbase/gbrowse-2.01/extlib/lib/perl5/x86_64-linux-gnu-thread-multi:/usr/local/wormbase/gbrowse-2.01/extlib/lib/pe$
+
> mysql -u root -p -e 'grant select on sessions.* to nobody@localhost' identified by '3l3g@nz'    // or whatever
  SetEnv GBROWSE_CONF  "/usr/local/wormbase/gbrowse-current/conf"
+
> mysql -u root -p -e 'grant all privileges on `userdata\_%`.* to 'nobody'@localhost identified by '3l3g@nz';
    AllowOverride None
 
    Options None
 
    Order allow,deny
 
    Allow from all
 
</Directory>
 
  
<IfModule mod_fcgid.c>
+
== Install Apache2 ==
  Alias /fgb2 "/usr/local/wormbase/gbrowse-current/cgi/gb2"
 
  <Location /fgb2>
 
    SetHandler  fcgid-script
 
    Options      ExecCGI
 
  </Location>
 
  DefaultInitEnv GBROWSE_CONF /usr/local/wormbase/gbrowse-current/conf
 
  DefaultInitEnv PERL5LIB /usr/local/wormbase/gbrowse-2.01/extlib/lib/perl5/x86_64-linux-gnu-thread-multi:/usr/local/wormbase/gbrowse-2.01/extlib$
 
</IfModule>
 
  
<IfModule mod_fastcgi.c>
+
''Technically, none of the slave renderers require Apache. We install it anyways just in case the primary master server dies.''
  Alias /fgb2 "/usr/local/wormbase/gbrowse-current/cgi/gb2"
 
  <Location /fgb2>
 
    SetHandler  fastcgi-script
 
    Options      ExecCGI
 
  </Location>
 
  FastCgiConfig -initial-env PERL5LIB=/usr/local/wormbase/gbrowse-2.01/extlib/lib/perl5/x86_64-linux-gnu-thread-multi:/usr/local/wormbase/gbrowse$
 
</IfModule>
 
  
<IfModule mod_perl.c>
 
  Alias /mgb2 "/usr/local/wormbase/gbrowse-current/cgi/gb2"
 
  PerlSwitches -I/usr/local/wormbase/gbrowse-2.01/extlib/lib/perl5/x86_64-linux-gnu-thread-multi -I/usr/local/wormbase/gbrowse-2.01/extlib/lib/p$
 
  <Location /mgb2>
 
    SetHandler perl-script
 
    PerlResponseHandler ModPerl::Registry
 
    PerlOptions +ParseHeaders
 
  </Location>
 
</IfModule>
 
  
</VirtualHost>
+
=== Apache Configuration ===
</pre>
 
  
Enable virtual hosts in httpd.conf
+
Edit the primary httpd.conf file (/usr/local/apache2/conf/httpd.conf) with the appropriate port, virtual host, and fcgi settings:
  
$ sudo perl -p -i -e's|\#Include conf/extra/httpd-hosts.conf|Include conf/extra/httpd_hosts.conf|' \
+
* Set httpd to listen on your desired port. In the examples below, we assume port 8080.
      /usr/local/apache2/conf/httpd.conf
 
  
=== Set up httpd to run under inet.d ===
+
# Edit "Listen 80" to read
 +
Listen 8080
  
Remove /etc/init.d/apache2.  It just confuses things.
+
Enable virtual hosts by uncommenting out the following line:
  
''Save the following file to /etc/init.d/httpd:''
+
#Include conf/extra/httpd_hosts.conf
  
<pre>
+
Set up a virtual host on your port by editing /usr/local/apache2/conf/extras/httpd-vhosts.conf:
#!/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.
+
# GBrowse_syn
. /etc/rc.d/init.d/functions
+
# Running under it's own virtual host since it has some weird configuration quirks.
 +
<VirtualHost *:8080>
 +
  PerlSwitches -Mlib=/usr/local/wormbase/extlib/lib/perl5/x86_64-linux-gnu-thread-multi \
 +
              -Mlib=/usr/local/wormbase/extlib/lib/perl5
  
if [ -f /etc/sysconfig/httpd ]; then
+
  ScriptAlias  "/db/gb2"    "/usr/local/wormbase/services/gbrowse2/current/cgi/gb2"
        . /etc/sysconfig/httpd
+
  Alias      "/gb2-support/"    "/usr/local/wormbase/services/gbrowse2/support-files/"
fi
+
  Alias      "/gbrowse2/i" "/usr/local/wormbase/tmp/gbrowse/images"
 +
  Alias      "/gbrowse2"  "/usr/local/wormbase/services/gbrowse2/current/html"
  
# This will prevent initlog from swallowing up a pass-phrase prompt if
+
  LogFormat "%h %l %u %t \"%r\" %s %b" common
# mod_ssl needs a pass-phrase from the user.
+
  LogFormat "%h %l %u %t %{Referer}i \"%{User-Agent}i\" \"%r\" %s %b" combined_format
INITLOG_ARGS=""
+
  #LogFormat "%h %l %u %t %{Referer}i \"%{User-Agent}i\" \"%r\" %s %b %P" combined_format
 +
  LogFormat "witheld %l %u %t \"%r\" %s %b" anonymous
  
# Path to the apachectl script, server binary, and short-form for messages.
+
  ErrorLog    /usr/local/wormbase/logs/gbrowse_syn/error.log
apachectl=/usr/local/apache2/bin/apachectl
+
  CustomLog    /usr/local/wormbase/logs/gbrowse_syn access.log combined_format
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
+
  SetEnv DOCUMENT_ROOT "/usr/local/wormbase/services/gbrowse2/current/html"
# things -- attempting to start while running is a failure, and shutdown
+
    <Directory "/usr/local/wormbase/services/gbrowse2/current/cgi/gb2">
# when not running is also a failure.  So we just do it the way init scripts
+
      SetEnv PERL5LIB "/usr/local/wormbase/extlib/lib/perl5:/usr/local/wormbase/extlib/lib/perl5/x86_64-linux-gnu-thread-multi:/usr/local/wormbase/services/gb\
# are expected to behave here.
+
rowse2/support-files/lib:/usr/local/wormbase/services/gbrowse2/support-files/lib/Bio:/usr/local/wormbase/services/gbrowse2/support-files/lib/Bio/Graphics:/usr/\
start() {
+
local/wormbase/services/gbrowse2/support-files/lib/Bio/Graphics/Glyph"
        echo -n $"Starting $prog: "
+
      SetEnv GBROWSE_CONF  "/usr/local/wormbase/services/gbrowse2/support-files/conf"
        daemon $httpd $OPTIONS
+
      SetEnv DOCUMENT_ROOT "/usr/local/wormbase/services/gbrowse2/current/html"
        RETVAL=$?
+
    </Directory>
        echo
+
</VirtualHost>
        [ $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
 
 
</pre>
 
</pre>
  
''Set which runlevels httpd will run under:''
+
=== Set up httpd to run under inet.d ===
 +
 
 +
''Only required for the master server.''
 +
 
 +
Remove /etc/init.d/apache2.  It just confuses things.
 +
 
 +
''Set which runlevels httpd will run under by chkconfig or command line:''
  
 
  chkconfig --add httpd
 
  chkconfig --add httpd
 
  chkconfig --level 2345 httpd on
 
  chkconfig --level 2345 httpd on
 
  chkconfig --list
 
  chkconfig --list
 +
 +
sudo cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd
 +
cd /etc/rc3.d
 +
sudo ln -s ../init.d/httpd S90httpd
 +
cd /etc/rc5.d
 +
sudo ln -s ../init.d/httpd S90httpd
 +
 +
== Install mod_fcgid ==
 +
 +
> wget http://apache.sunsite.ualberta.ca/httpd/mod_fcgid/mod_fcgid-2.3.6.tar.gz
 +
> tar zxvf mod_fcgid-2.3.6.tar.gz
 +
> cd mod_fcgid-2.3.6
 +
> perl -pi.bak -e 's/INITENV_VAL_LEN 128/INITENV_VAL_LEN 512/' modules/fcgid/fcgid_conf.h
 +
> APXS=/usr/bin/apxs2 ./configure.apxs
 +
> make
 +
> sudo make install
 +
 +
Configure apache as described above.
 +
 +
For additional notes, see:
 +
http://gmod.org/wiki/Recompiling_mod_fcgid_to_avoid_truncated_Perl_library_paths
  
 
== MySQL ==
 
== MySQL ==
  
''For both master and slave servers, although databases are currently only hosted on the master. In the future, we might consider having giving each slave its own dedicated mysql resources.''
+
''Each node in the renderfarm has its own MySQL databases.''
  
 
=== Installation (>= 5.1) ===
 
=== Installation (>= 5.1) ===
Line 337: Line 341:
 
  // Copy the configuration file
 
  // Copy the configuration file
 
  $ sudo cp support_files/my-medium.cnf /etc/my.cnf
 
  $ sudo cp support_files/my-medium.cnf /etc/my.cnf
 +
 +
// It may be necessary to add the following to my.cnf if back end nodes
 +
// don't have fully qualified domain names
 +
skip-name-resolve
  
 
  // Set up mysql to start up automatically
 
  // Set up mysql to start up automatically
Line 349: Line 357:
 
  $ mysqladmin -u root password 'PASSWORD'
 
  $ mysqladmin -u root password 'PASSWORD'
  
=== Databases ===
+
== Fetch configuration and support files ==
  
''MySQL databases will be mirrored over directly as part of the production update processThey should be located in /usr/local/mysql/data. Symlinks, using the symbolic name of the database, point to the current version:''
+
Configuration files are maintained within the "website" git repository.
 +
 
 +
  $ cd /usr/local/wormbase/website
 +
$ git clone git@github.com/WormBase/website.git
 +
$ mv website production // for example
 +
 
 +
Continue with the apache configuration as appropriate.
 +
 
 +
== Configure NFS for load balancing ==
 +
 
 +
In lieue of the built-in GBrowse master/slave renderfarm configuration, we load balance across a pool of servers using a shared filesystem.  See the NFS documentation in the main WormBase Production environment for details on how to install NFS.
 +
 
 +
=== NFS Server ===
 +
 
 +
The master server (wb-gb1.oicr.on.ca) provides an NFS mount of core GBrowse files and temporary session data.
 +
 
 +
  /usr/local/wormbase/services/gbrowse2
  
  c_elegans -> c_elegans_WS211
+
This directory will be mounted at the same path for each client.
  
=== Privileges ===
+
Contents:
  
''Be sure to grant privileges to both master and slave servers to the databases:''
+
''' Specify what to share, to whom, and with which privileges '''
  
$ mysql -u root -p -e 'grant select on c_elegans.* to www-data@localhost'
+
Share mounts are configured through /etc/exports on wb-gb1.oicr.on.ca.
$ mysql -u root -p -e 'grant select on c_elegans.* to www-data@Wb-www2.oicr.on.ca'
 
  
== Install Requisite Perl Modules ==
+
# WormBase NFS for temporary and static content
 +
/usr/local/wormbase/services/gbrowse2 206.108.125.174(rw,no_root_squash)
  
''Both master and slave servers.''
+
After making changes to /etc/exports, load them by:
  
''All libraries specific for GBrowse are maintained in a local directory, specific to the version of gbrowse being run.  This means that prerequisites need to be installed for '''each''' version of Gbrowse.''
+
sudo exportfs -a
  
$ cd /usr/local/wormbase
+
''' Lock down access to NFS from most hosts '''
$ mkdir gbrowse-2.01  // eg
 
$ ln -s gbrowse-2.01 gbrowse-current
 
$ mkdir gbrowse-current/extlib
 
$ mkdir logs gbrowse-support-files build
 
$ chmod 666 logs
 
  
Install local::lib to make things easier:
+
We can use /etc/hosts.deny to quickly lock down NFS:
  
  $ sudo perl -MCPAN -e 'CPAN::install(local::lib)'
+
  portmap:ALL
  $ cd /usr/local/wormbase/gbrowse-current/extlib
+
lockd:ALL
 +
mountd:ALL
 +
rquotad:ALL
 +
  statd:ALL
  
To install modules to this path:
+
''' Allow access to select hosts '''
  
$ perl -Mlocal::lib=.
+
We can use /etc/hosts.allow to specifically allow access to NFS:
$ eval $(perl -Mlocal::lib=--self-contained,./)
 
$ sudo rm -rf ~/.cpan
 
$ perl -MCPAN -e shell
 
cpan> install Bio::Perl        // may be necessary to install from source
 
cpan> install Bio::Graphics    // may be necessary to install from source
 
  
And for GBrowse:
+
# WormBase NFS services
  cpan> install CGI::Session
+
portmap: ***.***.***.***
  cpan> install JSON
+
  lockd: ***.***.***.***
 +
rquotad: ***.***.***.***
 +
  mountd: ***.***.***.***
 +
statd: ***.***.***.***
  
Optional:
+
=== NFS clients ===
cpan> Crypt::SSLeay
 
cpan> DBD::Pg
 
cpan> DB_File::Lock
 
cpan> FCGI
 
cpan> File::NFSLock
 
cpan> GD::SVG
 
cpan> Net::OpenID::Consumer
 
cpan> Net::SMTP::SSL
 
cpan> Safe::World
 
  
== Install SamTools ==
+
On secondary GBrowse nodes, mount the gbrowse share. The gbrowse2 directory must exist.
 
  
== Install GBrowse2 ==
+
sudo mount 206.108.125.173:/usr/local/wormbase/services/gbrowse2 /usr/local/wormbase/services/gbrowse2
  
$ perl ./Build.PL --install_base /usr/local/wormbase/gbrowse-current
+
''' Unmounting the NFS share '''
$ perl ./Build --reconfig
 
Directory for GBrowse's config and support files? /usr/local/wormbase/gbrowse-current/conf
 
Directory for GBrowse's static images & HTML files? /usr/local/wormbase/gbrowse-current/html
 
Directory for GBrowse's temporary data /usr/local/wormbase/gbrowse-current/tmp
 
Directory for GBrowse's example databases /usr/local/wormbase/gbrowse-current/databases
 
Directory for GBrowse's CGI script executables? /usr/local/wormbase/gbrowse-current/cgi/gb2 
 
Internet port to run demo web site on (for demo)? [8000]
 
Apache loadable module directory (for demo)? [/usr/local/apache2/modules]
 
User account under which Apache daemon runs? [www-data]
 
Automatically update Apache config files to run GBrowse? [n]
 
Automatically update system config files to run gbrowse-slave? [n] y
 
  
To fetch suggested apache configuration:
+
  sudo umount /usr/local/wormbase/services/gbrowse2
  ./Build apache_conf
 
  
To install:
+
''' Setting up NFS share to mount at boot '''
./Build install
 
  
You may need to fix permissions:
+
  sudo emacs /etc/fstab
  chmod 777 /usr/local/wormbase/gbrowse-current/tmp
 
  
For slave servers, you should also:
+
Add
sudo ./Build install_slave
 
  
= Configuration =
+
wb-gb1.oicr.on.ca:/usr/local/wormbase/services/gbrowse2 /usr/local/wormbase/services/gbrowse2 nfs rw  0 0
  
== Support files ==
+
== Configure the master server ==
  
The WormBase-specific installation requires a number of support files: css and an image or two. We keep these files -- and all configuration files -- outside of the gbrowse installation path.  This makes upgrades much, much easier.
+
The configuration file of the master server should be set up with appropriate render slaves in the TRACK DEFAULTS section of each genome-level configuration file.
  
Support files are maintained in WormBase CVSThe directory looks like:
+
# wb-www1: XXX.XXX.XXX.173 (master)                                                             
 +
# wb-www2: XXX.XXX.XXX.174 (slave)
 +
  # wb-www3: XXX.XXX.XXX.175 (slave)
  
  bash> cd /usr/local/wormbase/gbrowse-support-files
+
  remote renderer = http://XXX.XXX.XXX.173:8101 http://XXX.XXX.XXX.173:8102 http://XXX.XXX.XXX.173:8103
bash> ls -1
+
                  http://XXX.XXX.XXX.174:8101 http://XXX.XXX.XXX.174:8102 http://XXX.XXX.XXX.174:8103
  conf/
+
                  http://XXX.XXX.XXX.175:8101 http://XXX.XXX.XXX.175:8102 http://XXX.XXX.XXX.175:8103
  banner-image.jpg
 
  wormbase-gbrowse.css
 
  
bash> ls -1 conf/
+
Define dsn arguments (here we specify that the MySQL databases are running on the localhost).
  GBrowse.conf    // The main gbrowse config file, #included by the primary GBrowse.conf file.
 
  c_elegans.conf
 
  c_remanei.conf
 
  etc...
 
  
See the Apache configuration section for details.
+
db_args    = -dsn DBI:mysql:c_elegans;user=nobody;host=localhost
  
== GBrowse Master server ==
+
# Here's a second example with all databases running on the master server.
 +
db_args    = -dsn DBI:mysql:c_elegans;user=nobody;host=XXX.XXX.XXX.173
  
 
== GBrowse slave servers ==
 
== GBrowse slave servers ==
  
 +
To add an additional slave server, simply follow the steps above, adding the name of the server to the TRACK DEFAULTS section of the genome-level configuration file.
 +
 +
No special configuration is required for GBrowse slave servers.  Simply ensure that the slave has access to the MySQL databases using the username and password supplied in the primary configuration file.
 +
 +
Make sure the slave servers are running by:
 +
 +
sudo /etc/init.d/gbrowse_slave start
 +
 +
== Databases ==
 +
 +
''MySQL databases will be mirrored over directly as part of the production update process.  They should be located in /usr/local/mysql/data. Symlinks, using the symbolic name of the database, point to the current version:''
 +
 +
  c_elegans -> c_elegans_WS211
 +
 +
== Database Privileges ==
 +
 +
''Be sure to grant privileges to both master and slave servers to the databases:''
 +
 +
$ mysql -u root -p -e 'grant select on c_elegans.* to nobody@localhost'
 +
$ mysql -u root -p -e 'grant select on c_elegans.* to nobody@render-slave-ip'
 +
 +
= Administration =
 +
 +
== Updating GBrowse ==
 +
 +
To update GBrowse:
 +
 +
# Check out the source to /usr/local/wormbase/build
 +
# Follow the directions above to install GBrowse, resetting the ''current'' symlink
 +
# Check out the "wormbase-gbrowse2" configuration repository
 +
 +
== Maintenance ==
 +
 +
=== Purging Temporary Files ===
 +
 +
GBrowse generates a slew of temporary files.  Under production, these temporary files can quickly exhaust the ulimit of a machine.  Set up the following cronjob to purge them periodically.
 +
 +
  3 4,16 * * * find /usr/local/wormbase/tmp/gbrowse/cache -type f -mtime +2 -delete
 +
  26 6,18 * * * find /usr/local/wormbase/tmp/gbrowse/images -type f -mtime +1 -delete
 +
  31 10,22 * * * find /usr/local/wormbase/tmp/gbrowse/sessions -type f -mtime +60 -delete
 +
  40 2,14 * * * find /var/www/synteny/images -type f -mtime +1 -delete
 +
  5 3 * * 6 find /usr/local/wormbase/tmp/gbrowse/cache -type d -empty -delete
 +
  35 3 * * 6 find /usr/local/wormbase/tmp/gbrowse/images -type d -empty -delete
 +
  5 5 * * 6 find find /usr/local/wormbase/tmp/gbrowse/sessions -type d -empty -delete
 +
  35 5 * * 6 find /var/www/synteny/images -type d -empty -delete
 +
 +
<!--
 +
1 1 * * * /usr/local/wormbase/gbrowse-support-files/purge_temporary_files.cron.sh
 +
 +
The contents of this script are:
 +
 +
cd /usr/local/wormbase/gbrowse-current/tmp
 +
find . -type f -atime +20 -print -exec rm {} \;
 +
-->
  
 +
=== Log Rotation ===
 +
 +
<code>gbrowse-support-files/</code> contains two configuration files for the unix <code>logrotate</code> command. For the master server copy <code>logrotate-gbrowse-httpd.conf</code> and <code>logrotate-gbrowse-slave.conf</code> to <code>/etc/logrotate.d/gbrowse-httpd and gbrowse-slave</code>.  The slave nodes obviously only require the gbrowse-slave file.
 +
 +
The contents of these files are included here for reference:
 +
<pre>
 +
# logrotate-gbrowse-httpd.conf
 +
# GBrowse httpd logrotate conf file
 +
/usr/local/wormbase/logs/*.log {
 +
daily
 +
missingok
 +
rotate 7
 +
compress
 +
delaycompress
 +
notifempty
 +
create 640 root adm
 +
sharedscripts
 +
postrotate
 +
                /usr/local/apache2/bin/apachectl graceful
 +
endscript
 +
}
 +
 +
# logrotate-gbrowse-slave.conf
 +
# GBrowse slave files
 +
/usr/local/wormbase/logs/*_slave {
 +
daily
 +
missingok
 +
rotate 7
 +
compress
 +
delaycompress
 +
notifempty
 +
sharedscripts
 +
postrotate
 +
/etc/init.d/gbrowse-slave stop
 +
            /etc/init.d/gbrowse-slave start
 +
        endscript
 +
}
 +
</pre>
 +
 +
== Establishing a new slave node ==
 +
 +
Here's how to build a new slave node:
 +
 +
1. Set up directories, users, groups
 +
2. Install apache, fastcgi, mysql
 +
3. Copy /usr/local/wormbase from an existing node
 +
 +
=References =
 +
 +
* The official [http://gmod.org/wiki/GBrowse_Install_HOWTO GBrowse Install HOWTO]
 +
* The [http://gmod.org/wiki/Running_a_GBrowse2_render_farm GBrowse 2.0 renderfarm HowTO] at [http://gmod.org GMOD.org]
  
 
= Author =
 
= Author =
 +
 +
Todd Harris, PhD (info@toddharris.net)
 +
 +
 +
 +
[[Category:User Guide]]
 +
[[Category:Developer documentation]]
 +
[[Category: Architecture (Web Dev)]]

Latest revision as of 15:25, 4 August 2016

Overview

GBrowse is one of the central -- and most heavily used -- components of the WormBase site. To meet this demand, we use a number of dedicated servers using GBrowse's built in renderfarm capability. This document describes how to install GBrowse and configure these servers.

Hardware Topology

The GBrowse topology looks like this:

 Master
 ------------- -----------------------------
 |    gb1    |              \               \
 |           |        -------------    -------------   
 |           |        |   gb2     |    |    gb3    |   Slaves
 |* * * * * *|        |* * * * * *|    |* * * * * *|
 -------------        -------------    -------------  
 * * * * * = relational databases running on each node.

Note that although this topology presents a single master with multiple slave servers, in reality each node is redundant with each other. This makes failover easier in case the master server dies. See the Administration & Troubleshooting section for details.


Quick Overview

1. GBrowse is included with our application and configured as follows.

2. $app_root/$app/wormbase.env sets the GBROWSE_CONF and GBROWSE_HTDOCS environment variables.

3. Configuration is located at $app_root/$app/conf/gbrowse

4. GBrowse is installed at: $app_root/$app/root/gbrowse

5. wormbase.psgi file mounts

  • /tools/genome => gbrowse CGIs
  • /gbrowse-static => $app_root/$app/root/gbrowse

6. Even though every node can host gbrowse, nginx proxy passes requests to dedicated nodes.

Basic Server Configuration

Create groups

sudo addgroup wormbase
sudo addgroup gbrowse
# Add yourself to the groups
sudo usermod -a -G gbrowse, wormbase tharris

Create directories

Create a directory for GBrowse's temporary files.

> mkdir -p /usr/local/wormbase/tmp
> sudo chown -R www-daemon /usr/local/wormbase/tmp

Install prerequisites (Debian)

// Update apt
$ sudo apt-get update
// Make tools
$ sudo apt-get install gcc make
// expat
$ sudo apt-get install expat libexpat1 libexpat1-dev
// GD support
$ sudo apt-get install libgd2-noxpm libgd2-noxpm-dev
// Graphviz, now apparently required by BioPerl
$ sudo apt-get install graphviz

Install Perl 5.10.1 or greater

You'll need Perl version 5.10.1 or greater.

Debian:

$ sudo apt-get install perl

NOTE: This version of Perl on Debian Lenny doesn't ship with perl.h. You won't be able to build mod_perl without it! You should probably build from source.

Building from source:

bash> cd ~/src
bash> curl -O http://www.cpan.org/src/perl-5.10.1.tar.gz
bash> cd ~/build
bash> tar xzf ../src/perl-5.10.1.tar.gz
bash> cd perl-5.10.1
bash> ./Configure -des
  // Or, to install in a local path:
bash> ./Configure -des -Dprefix=$HOME/website/perl/5.10.1
bash> make
bash> make test
bash> sudo make install


Install Requisite Perl Modules

All libraries specific for GBrowse are maintained in a local shared directory. This makes it easier and faster to upgrade GBrowse, but more difficult to test multiple versions simultaneously. To test a new version of GBrowse, place extlib inside of the gbrowse-current directory and modify the apache configuration and commands below as appropriate.

Install local::lib to make things easier:

$ sudo perl -MCPAN -e 'CPAN::install(local::lib)'
$ mkdir /usr/local/wormbase/extlib
$ cd /usr/local/wormbase/extlib

To install modules to this path:

$ perl -Mlocal::lib=.
$ eval $(perl -Mlocal::lib=./)
$ sudo rm -rf ~/.cpan
$ perl -MCPAN -e shell
cpan> install YAML DBI DBD::mysql CGI::Session JSON Storable FreezeThaw FCGI SVG GD::SVG Text::Shellwords \
           Algorithm::Munkres Array::Compare  Clone Convert::Binary::C Error Graph GraphViz HTML::Entities  HTML::HeadParser HTTP::Request::Common LWP::UserAgent \
           List::MoreUtils Math::Random PostScript::TextBlock SOAP::Lite SVG::Graph Set::Scalar Sort::Naturally Spreadsheet::ParseExcel URI::Escape \
           XML::DOM::XPath XML::Parser XML::Parser::PerlSAX XML::SAX XML::SAX::Writer XML::Simple XML::Twig XML::Writer \
           Capture::Tiny Template Term::ReadKey
cpan> install Bio::Perl        // may be necessary to install from source
cpan> install Bio::Graphics    // may be necessary to install from source

Install SamTools and Bio::SamTools

> cd /usr/local/wormbase/services/gbrowse2/src
> wget http://sourceforge.net/projects/samtools/files/samtools/0.1.16/samtools-0.1.16.tar.bz2/download
> bunzip2 samtools*
> cd samtools*
> make CXXFLAGS=-fPIC CFLAGS=-fPIC CPPFLAGS=-fPIC
> sudo cp misc/*.pl /usr/local/bin/
> wget http://search.cpan.org/CPAN/authors/id/L/LD/LDS/Bio-SamTools-1.28.tar.gz
> tar xzf Bio*
> cd Bio*
> export SAMTOOLS=/usr/local/wormbase/src/samtools-0.1.16
> perl Build.PL --install_base=/usr/local/wormbase/extlib
> ./Build
> ./Build test
> (sudo) ./Build install

Install Bio::BigFile.pm

To compile this module, you must first download, unpack and compile Jim Kent's source tree to create the main library file jkweb.a:

 > wget http://hgdownload.cse.ucsc.edu/admin/jksrc.zip
 > unzip jksrc.zip
 > cd kent/src/lib
 > export MACHTYPE=x86_64
 > mkdir $MACHTYPE
 > make CXXFLAGS=-fPIC CFLAGS=-fPIC CPPFLAGS=-fPIC
 

Download and build Bio::BigFile, eg v1.06:

 > wget http://search.cpan.org/CPAN/authors/id/L/LD/LDS/Bio-BigFile-1.06.tar.gz
 > tar xzf Bio-* ; cd Bio-Big*
 > export KENT_SRC=/usr/local/wormbase/src/kent/src/
 > perl Build.PL --install_base=/usr/local/wormbase/extlib
 > ./Build
 > ./Build test
 > (sudo) ./Build install

Install GBrowse

GBrowse CGI components are distributed as part and parcel of the WormBase site. Thus each version of the site is directly associated with a distinct version of GBrowse, too. This means that installing new versions will necessarily overwrite old and need to be recommitted to the repository.

Substitute the symbolic name for the site you are installing into.

$ cd /usr/ocal/wormbase/shared/src
$ wget http://sourceforge.net/projects/gmod/files/Generic%20Genome%20Browser/GBrowse-2.39/GBrowse-2.39.tar.gz/download
// GBROWSE_ROOT = /usr/local/wormbase/website/YOURSITE
$ perl ./Build.PL --install_base ${GBROWSE_ROOT}
$ perl ./Build --reconfig
Directory for GBrowse's config and support files? ${GBROWSE_ROOT}/conf/gbrowse
Directory for GBrowse's static images & HTML files? ${GBROWSE_ROOT}/root/gbrowse
Directory for GBrowse's temporary data /usr/local/wormbase/tmp/gbrowse
Directory for GBrowse's sessions, uploaded tracks and other persistent data: /usr/local/wormbase/tmp/gbrowse/persistent
Directory for GBrowse's example databases /usr/local/wormbase/tmp/gbrowse/databases
Directory for GBrowse's CGI script executables? ${GBROWSE_ROOT}/root/cgi/gbrowse
Internet port to run demo web site on (for demo)? [8000] 
Apache loadable module directory (for demo)? [/usr/local/apache2/modules] 
User account under which Apache daemon runs? [www-data] www-data
Automatically update Apache config files to run GBrowse? [n] 
Automatically update system config files to run gbrowse-slave? [n] y

To fetch suggested apache configuration:

./Build apache_conf

Install dependencies

./Build installdeps

To install:

./Build install

You may need to create directories and fix permissions.

chmod 777 /usr/local/wormbase/tmp

Install gbrowse-slave components on all servers

sudo ./Build install_slave

Edit /etc/default/gbrowse_slave:

# Make sure that Perl5Lib includes that path to our external aggregator modules:
 export PERL5LIB=/usr/local/wormbase/extlib/lib/perl5/x86_64-linux-gnu-thread-multi:\
    /usr/local/wormbase/extlib/lib/perl5:\
    /usr/local/wormbase/services/gbrowse2/current/lib/perl5:\
    /usr/local/wormbase/services/gbrowse2/current/website-gbrowse2-support/lib:\
    /usr/local/wormbase/services/gbrowse2/current/website-gbrowse2-support/lib/Bio:\
    /usr/local/wormbase/services/gbrowse2/current/website-gbrowse2-support/lib/Bio/Graphics:\
    /usr/local/wormbase/services/gbrowse2/current/website-gbrowse2-support/lib/Bio/Graphics/Glyph
DAEMON=/usr/local/bin/gbrowse_slave
# Be certain this matches the httpd daemon user on the master!
USER=www-data
#PRELOAD=/etc/gbrowse2/slave_preload.conf
RUNDIR=/usr/local/wormbase/logs
LOGDIR=/usr/local/wormbase/logs
PORT="8101 8102 8103"
VERBOSITY=3
NICE=0

Then set up the slave server to start automatically:

$ cd /etc/rc3.d
$ sudo ln -s ../init.d/gbrowse-slave S99gbrowse-slave
$ cd /etc/rc5.d
$ sudo ln -s ../init.d/gbrowse-slave S99gbrowse-slave

Configure sessions and locks databases

Sessions and locks will be stored in the sessions database.

> mysql -u root -p -e 'create database sessions'
> mysql -u root -p -e 'grant select on sessions.* to nobody@localhost' identified by '3l3g@nz'    // or whatever
> mysql -u root -p -e 'grant all privileges on `userdata\_%`.* to 'nobody'@localhost identified by '3l3g@nz';

Install Apache2

Technically, none of the slave renderers require Apache. We install it anyways just in case the primary master server dies.


Apache Configuration

Edit the primary httpd.conf file (/usr/local/apache2/conf/httpd.conf) with the appropriate port, virtual host, and fcgi settings:

  • Set httpd to listen on your desired port. In the examples below, we assume port 8080.
# Edit "Listen 80" to read
Listen 8080

Enable virtual hosts by uncommenting out the following line:

#Include conf/extra/httpd_hosts.conf

Set up a virtual host on your port by editing /usr/local/apache2/conf/extras/httpd-vhosts.conf:

  1. GBrowse_syn
  2. Running under it's own virtual host since it has some weird configuration quirks.

<VirtualHost *:8080>

 PerlSwitches -Mlib=/usr/local/wormbase/extlib/lib/perl5/x86_64-linux-gnu-thread-multi \
              -Mlib=/usr/local/wormbase/extlib/lib/perl5
  ScriptAlias  "/db/gb2"     "/usr/local/wormbase/services/gbrowse2/current/cgi/gb2"
  Alias       "/gb2-support/"     "/usr/local/wormbase/services/gbrowse2/support-files/"
  Alias       "/gbrowse2/i" "/usr/local/wormbase/tmp/gbrowse/images"
  Alias       "/gbrowse2"   "/usr/local/wormbase/services/gbrowse2/current/html"
  LogFormat "%h %l %u %t \"%r\" %s %b" common
  LogFormat "%h %l %u %t %{Referer}i \"%{User-Agent}i\" \"%r\" %s %b" combined_format
  #LogFormat "%h %l %u %t %{Referer}i \"%{User-Agent}i\" \"%r\" %s %b %P" combined_format
  LogFormat "witheld %l %u %t \"%r\" %s %b" anonymous
  ErrorLog     /usr/local/wormbase/logs/gbrowse_syn/error.log
  CustomLog    /usr/local/wormbase/logs/gbrowse_syn access.log combined_format
  SetEnv DOCUMENT_ROOT "/usr/local/wormbase/services/gbrowse2/current/html"
   <Directory "/usr/local/wormbase/services/gbrowse2/current/cgi/gb2">
      SetEnv PERL5LIB "/usr/local/wormbase/extlib/lib/perl5:/usr/local/wormbase/extlib/lib/perl5/x86_64-linux-gnu-thread-multi:/usr/local/wormbase/services/gb\

rowse2/support-files/lib:/usr/local/wormbase/services/gbrowse2/support-files/lib/Bio:/usr/local/wormbase/services/gbrowse2/support-files/lib/Bio/Graphics:/usr/\ local/wormbase/services/gbrowse2/support-files/lib/Bio/Graphics/Glyph"

      SetEnv GBROWSE_CONF   "/usr/local/wormbase/services/gbrowse2/support-files/conf"
      SetEnv DOCUMENT_ROOT "/usr/local/wormbase/services/gbrowse2/current/html"
   </Directory>

</VirtualHost>


Set up httpd to run under inet.d

Only required for the master server.

Remove /etc/init.d/apache2. It just confuses things.

Set which runlevels httpd will run under by chkconfig or command line:

chkconfig --add httpd
chkconfig --level 2345 httpd on
chkconfig --list
sudo cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd
cd /etc/rc3.d
sudo ln -s ../init.d/httpd S90httpd
cd /etc/rc5.d
sudo ln -s ../init.d/httpd S90httpd

Install mod_fcgid

> wget http://apache.sunsite.ualberta.ca/httpd/mod_fcgid/mod_fcgid-2.3.6.tar.gz
> tar zxvf mod_fcgid-2.3.6.tar.gz
> cd mod_fcgid-2.3.6
> perl -pi.bak -e 's/INITENV_VAL_LEN 128/INITENV_VAL_LEN 512/' modules/fcgid/fcgid_conf.h
> APXS=/usr/bin/apxs2 ./configure.apxs
> make
> sudo make install

Configure apache as described above.

For additional notes, see:

http://gmod.org/wiki/Recompiling_mod_fcgid_to_avoid_truncated_Perl_library_paths

MySQL

Each node in the renderfarm has its own MySQL databases.

Installation (>= 5.1)

We need a newer version of mysql than is available from the package manager. We'lll install the binary for x86_64.

$ sudo groupadd mysql
$ sudo useradd -g mysql mysql
$ sudo usermod -a -G mysql tharris
$ cd /usr/local
$ sudo gunzip < /path/to/mysql-VERSION-OS.tar.gz | sudo tar xvf -
$ sudo ln -s full-path-to-mysql-VERSION-OS mysql
$ cd mysql
$ sudo chown -R mysql .
$ sudo chgrp -R mysql .
$ sudo scripts/mysql_install_db --user=mysql  // may be necessary to remove /etc/mysql/my.cnf first
$ sudo chown -R root .
$ sudo chown -R mysql data
$ sudo chmod 2775 data // I like to be able to write to my datadir
// Copy the configuration file
$ sudo cp support_files/my-medium.cnf /etc/my.cnf
// It may be necessary to add the following to my.cnf if back end nodes
// don't have fully qualified domain names
skip-name-resolve
// Set up mysql to start up automatically
$ sudo cp support_files/mysql.server /etc/init.d/.
$ cd /etc/rc3.d
$ sudo ln -s ../init.d/mysql.server S90mysql
$ cd ../rc5.d
$ sudo ln -s ../init.d/mysql.server S90mysql
// Start it up and set a root password.
$ sudo /etc/init.d/mysql.server start
$ mysqladmin -u root password 'PASSWORD'

Fetch configuration and support files

Configuration files are maintained within the "website" git repository.

$ cd /usr/local/wormbase/website
$ git clone git@github.com/WormBase/website.git
$ mv website production // for example

Continue with the apache configuration as appropriate.

Configure NFS for load balancing

In lieue of the built-in GBrowse master/slave renderfarm configuration, we load balance across a pool of servers using a shared filesystem. See the NFS documentation in the main WormBase Production environment for details on how to install NFS.

NFS Server

The master server (wb-gb1.oicr.on.ca) provides an NFS mount of core GBrowse files and temporary session data.

 /usr/local/wormbase/services/gbrowse2

This directory will be mounted at the same path for each client.

Contents:

Specify what to share, to whom, and with which privileges

Share mounts are configured through /etc/exports on wb-gb1.oicr.on.ca.

# WormBase NFS for temporary and static content
/usr/local/wormbase/services/gbrowse2 206.108.125.174(rw,no_root_squash)

After making changes to /etc/exports, load them by:

sudo exportfs -a

Lock down access to NFS from most hosts

We can use /etc/hosts.deny to quickly lock down NFS:

portmap:ALL
lockd:ALL
mountd:ALL
rquotad:ALL
statd:ALL

Allow access to select hosts

We can use /etc/hosts.allow to specifically allow access to NFS:

# WormBase NFS services 
portmap: ***.***.***.***
lockd: ***.***.***.***
rquotad: ***.***.***.***
mountd: ***.***.***.***
statd: ***.***.***.***

NFS clients

On secondary GBrowse nodes, mount the gbrowse share. The gbrowse2 directory must exist.

sudo mount 206.108.125.173:/usr/local/wormbase/services/gbrowse2 /usr/local/wormbase/services/gbrowse2

Unmounting the NFS share

sudo umount /usr/local/wormbase/services/gbrowse2

Setting up NFS share to mount at boot

sudo emacs /etc/fstab

Add

wb-gb1.oicr.on.ca:/usr/local/wormbase/services/gbrowse2 /usr/local/wormbase/services/gbrowse2 nfs rw   0 0

Configure the master server

The configuration file of the master server should be set up with appropriate render slaves in the TRACK DEFAULTS section of each genome-level configuration file.

# wb-www1: XXX.XXX.XXX.173 (master)                                                              
# wb-www2: XXX.XXX.XXX.174 (slave) 
# wb-www3: XXX.XXX.XXX.175 (slave) 
remote renderer = http://XXX.XXX.XXX.173:8101 http://XXX.XXX.XXX.173:8102 http://XXX.XXX.XXX.173:8103
                  http://XXX.XXX.XXX.174:8101 http://XXX.XXX.XXX.174:8102 http://XXX.XXX.XXX.174:8103
                  http://XXX.XXX.XXX.175:8101 http://XXX.XXX.XXX.175:8102 http://XXX.XXX.XXX.175:8103

Define dsn arguments (here we specify that the MySQL databases are running on the localhost).

db_args     = -dsn DBI:mysql:c_elegans;user=nobody;host=localhost
# Here's a second example with all databases running on the master server.
db_args     = -dsn DBI:mysql:c_elegans;user=nobody;host=XXX.XXX.XXX.173

GBrowse slave servers

To add an additional slave server, simply follow the steps above, adding the name of the server to the TRACK DEFAULTS section of the genome-level configuration file.

No special configuration is required for GBrowse slave servers. Simply ensure that the slave has access to the MySQL databases using the username and password supplied in the primary configuration file.

Make sure the slave servers are running by:

sudo /etc/init.d/gbrowse_slave start

Databases

MySQL databases will be mirrored over directly as part of the production update process. They should be located in /usr/local/mysql/data. Symlinks, using the symbolic name of the database, point to the current version:

 c_elegans -> c_elegans_WS211

Database Privileges

Be sure to grant privileges to both master and slave servers to the databases:

$ mysql -u root -p -e 'grant select on c_elegans.* to nobody@localhost'
$ mysql -u root -p -e 'grant select on c_elegans.* to nobody@render-slave-ip'

Administration

Updating GBrowse

To update GBrowse:

  1. Check out the source to /usr/local/wormbase/build
  2. Follow the directions above to install GBrowse, resetting the current symlink
  3. Check out the "wormbase-gbrowse2" configuration repository

Maintenance

Purging Temporary Files

GBrowse generates a slew of temporary files. Under production, these temporary files can quickly exhaust the ulimit of a machine. Set up the following cronjob to purge them periodically.

 3 4,16 * * * find /usr/local/wormbase/tmp/gbrowse/cache -type f -mtime +2 -delete
 26 6,18 * * * find /usr/local/wormbase/tmp/gbrowse/images -type f -mtime +1 -delete
 31 10,22 * * * find /usr/local/wormbase/tmp/gbrowse/sessions -type f -mtime +60 -delete
 40 2,14 * * * find /var/www/synteny/images -type f -mtime +1 -delete
 5 3 * * 6 find /usr/local/wormbase/tmp/gbrowse/cache -type d -empty -delete
 35 3 * * 6 find /usr/local/wormbase/tmp/gbrowse/images -type d -empty -delete
 5 5 * * 6 find find /usr/local/wormbase/tmp/gbrowse/sessions -type d -empty -delete
 35 5 * * 6 find /var/www/synteny/images -type d -empty -delete


Log Rotation

gbrowse-support-files/ contains two configuration files for the unix logrotate command. For the master server copy logrotate-gbrowse-httpd.conf and logrotate-gbrowse-slave.conf to /etc/logrotate.d/gbrowse-httpd and gbrowse-slave. The slave nodes obviously only require the gbrowse-slave file.

The contents of these files are included here for reference:

# logrotate-gbrowse-httpd.conf
# GBrowse httpd logrotate conf file
/usr/local/wormbase/logs/*.log {
	daily
	missingok
	rotate 7
	compress
	delaycompress
	notifempty
	create 640 root adm
	sharedscripts
	postrotate
                /usr/local/apache2/bin/apachectl graceful
	endscript
}

# logrotate-gbrowse-slave.conf
# GBrowse slave files 
/usr/local/wormbase/logs/*_slave {
	daily
	missingok
	rotate 7
	compress
	delaycompress
	notifempty
	sharedscripts
	postrotate
		/etc/init.d/gbrowse-slave stop
      	      	/etc/init.d/gbrowse-slave start
        endscript
}

Establishing a new slave node

Here's how to build a new slave node:

1. Set up directories, users, groups
2. Install apache, fastcgi, mysql
3. Copy /usr/local/wormbase from an existing node

References

Author

Todd Harris, PhD (info@toddharris.net)