Difference between revisions of "GBrowse Administration"

From WormBaseWiki
Jump to navigationJump to search
 
(94 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 renderfarm capability. 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 17: Line 17:
  
 
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.
 
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 =
 
= Basic Server Configuration =
Line 29: Line 47:
 
== Create directories ==
 
== Create directories ==
  
''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 boilerplate headers and footers are maintained in two places).  We'll also keep gbrowse inside a wormbase/ directory should we wish to install other components on these servers at a later date.''
+
''Create a directory for GBrowse's temporary files.''
  
  $ sudo mkdir -p /usr/local/wormbase
+
  > mkdir -p /usr/local/wormbase/tmp
  $ sudo chgrp -R wormbase /usr/local/wormbase
+
  > sudo chown -R www-daemon /usr/local/wormbase/tmp
$ sudo chmod 2775 /usr/local/wormbase
 
 
 
$ mkdir logs gbrowse-support-files build extlib
 
$ chmod 666 logs
 
  
 
== Install prerequisites (Debian) ==
 
== Install prerequisites (Debian) ==
Line 78: Line 92:
 
  bash> sudo make install
 
  bash> sudo make install
  
== Install Apache2 ==
 
  
''Technically, none of the slave renderers require Apache. We install it anyways just in case the primary master server dies.''
+
== 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:
  
If you're running Debian, get rid of the installed apache. The default layout is just plain annoying.
+
  > 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:
  
$ sudo apt-get remove apache2
+
  > 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
  
''Assuming you have already fetched the source into ~/src:''
+
== Install GBrowse ==
  
# Build httpd 2.2.11
+
GBrowse CGI components are distributed as part and parcel of the WormBase siteThus 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.
cd ~/src
 
tar xzf httpd-2.2.11.tar.gz
 
  cd httpd-2.2.11
 
./configure --enable-mods-shared=all
 
make
 
sudo make install
 
  
=== Apache Configuration ===
+
Substitute the symbolic name for the site you are installing into.
  
Edit the primary httpd.conf file (/usr/local/apache2/conf/httpd.conf) with the appropriate port, virtual host, and fcgi settings:
+
$ 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
  
* Set httpd to listen on your desired port. In the examples below, we assume port 8080.
+
To fetch suggested apache configuration:
 +
./Build apache_conf
  
# Edit "Listen 80" to read
+
Install dependencies
  Listen 8080
+
  ./Build installdeps
  
Enable virtual hosts by uncommenting out the following line:
+
To install:
 +
./Build install
  
  #Include conf/extra/httpd_hosts.conf
+
You may need to create directories and fix permissions.
 +
  chmod 777 /usr/local/wormbase/tmp
  
Enable FastCGI module (installed later)     
+
=== Install gbrowse-slave components on all servers ===
  LoadModule fastcgi_module modules/mod_fastcgi.so
+
sudo ./Build install_slave
  
Add FastCGI config from GBrowse (see the GBrowse section below for details).  Note that we tweak the Location Aliases to place the fast CGI-enabled GBrowse under /db/gb2.
+
Edit /etc/default/gbrowse_slave:
  
<pre>
+
# Make sure that Perl5Lib includes that path to our external aggregator modules:
<IfModule mod_fcgid.c>
+
   export PERL5LIB=/usr/local/wormbase/extlib/lib/perl5/x86_64-linux-gnu-thread-multi:\
  Alias /db/gb2 "/usr/local/wormbase/gbrowse-current/cgi/gb2"
+
    /usr/local/wormbase/extlib/lib/perl5:\
  <Location /db/gb2>
+
    /usr/local/wormbase/services/gbrowse2/current/lib/perl5:\
    SetHandler  fcgid-script
+
    /usr/local/wormbase/services/gbrowse2/current/website-gbrowse2-support/lib:\
    Options      ExecCGI
+
    /usr/local/wormbase/services/gbrowse2/current/website-gbrowse2-support/lib/Bio:\
  </Location>
+
    /usr/local/wormbase/services/gbrowse2/current/website-gbrowse2-support/lib/Bio/Graphics:\
  DefaultInitEnv GBROWSE_CONF /usr/local/wormbase/gbrowse-current/conf
+
    /usr/local/wormbase/services/gbrowse2/current/website-gbrowse2-support/lib/Bio/Graphics/Glyph
   DefaultInitEnv PERL5LIB /usr/local/wormbase/extlib/lib/perl5/x86_64-linux-gnu-thread-multig:/usr/local/wormbase/extlib/lib/perl5:/usr/local/wormbase/gbrowse-current/lib/perl5:/usr/local/wormbase/gbrowse-support-files/lib:/usr/local/wormbase/gbrowse-support-files/lib/Bio:/usr/local/wormbase/gbrowse-support-files/lib/Bio/Graphics:/usr/local/wormbase/gbrowse-support-files/lib/Bio/Graphics/Glyph
 
</IfModule>
 
  
<IfModule mod_fastcgi.c>
+
DAEMON=/usr/local/bin/gbrowse_slave
  Alias /db/gb2 "/usr/local/wormbase/gbrowse-current/cgi/gb2"
+
# Be certain this matches the httpd daemon user on the master!
  <Location /db/gb2>
+
USER=www-data
    SetHandler  fastcgi-script
+
#PRELOAD=/etc/gbrowse2/slave_preload.conf
    Options      ExecCGI
+
RUNDIR=/usr/local/wormbase/logs
  </Location>
+
LOGDIR=/usr/local/wormbase/logs
  FastCgiConfig -initial-env PERL5LIB=/usr/local/wormbase/extlib/lib/perl5/x86_64-linux-gnu-thread-multig:/usr/local/wormbase/extlib/lib/perl5:/usr/local/wormbase/gbrowse-current/lib/perl5:/usr/local/wormbase/gbrowse-support-files/lib:/usr/local/wormbase/gbrowse-support-files/lib/Bio:/usr/local/wormbase/gbrowse-support-files/lib/Bio/Graphics:/usr/local/wormbase/gbrowse-support-files/lib/Bio/Graphics/Glyph
+
PORT="8101 8102 8103"
</IfModule>
+
VERBOSITY=3
</pre>
+
NICE=0
  
 +
Then set up the slave server to start automatically:
  
Set up a virtual host on your port by editing /usr/local/apache2/conf/extras/httpd-vhosts.conf:
+
$ 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
  
<pre>
+
=== Configure sessions and locks databases ===
<VirtualHost *:80>
 
    ErrorLog "/usr/local/wormbase/logs/error_log"
 
    CustomLog "/usr/local/wormbase/logs/access_log" common
 
  
    # Everything for GBrowse2 will be served from under a url of either
+
''Sessions and locks will be stored in the sessions database.''
    #      /db/gb2  or /gbrowse2
 
    # This makes proxying from CSHL more convenient.
 
    # Note that /db is historical and required for mapping the old site to the new
 
    Alias        "/gbrowse2/i/" "/usr/local/wormbase/gbrowse-current/tmp/images/"
 
  
    # NOTE: this MUST be different from the ScriptAlias.
+
> mysql -u root -p -e 'create database sessions'
    Alias        "/gbrowse2"   "/usr/local/wormbase/gbrowse-current/html"
+
> mysql -u root -p -e 'grant select on sessions.* to nobody@localhost' identified by '3l3g@nz'   // or whatever
    ScriptAlias "/db/gb2"      "/usr/local/wormbase/gbrowse-current/cgi/gb2"
+
  > mysql -u root -p -e 'grant all privileges on `userdata\_%`.* to 'nobody'@localhost identified by '3l3g@nz';
  
    # Support files: the wormbase css file for gbrowse, banner image, etc
+
== Install Apache2 ==
    Alias      "/gb2-support/    "/usr/local/wormbase/gbrowse-support-files/"
 
  
  <Directory "/usr/local/wormbase/gbrowse-support-files">
+
''Technically, none of the slave renderers require Apache. We install it anyways just in case the primary master server dies.''
      Options -Indexes -MultiViews +FollowSymLinks
 
      Order allow,deny
 
      Allow from all
 
  </Directory>
 
  
  # The temporary GBrowse directory
 
  <Directory "/usr/local/wormbase/gbrowse-current/tmp">
 
      Allow from all
 
  </Directory>
 
  
  <Directory "/usr/local/wormbase/gbrowse-current/html">
+
=== Apache Configuration ===
      Options -Indexes -MultiViews +FollowSymLinks
 
      Order allow,deny                                             
 
      Allow from all
 
  </Directory>
 
  
  <Directory "/usr/local/wormbase/gbrowse-current/cgi/gb2">
+
Edit the primary httpd.conf file (/usr/local/apache2/conf/httpd.conf) with the appropriate port, virtual host, and fcgi settings:
      SetEnv PERL5LIB "/usr/local/wormbase/extlib/lib/perl5/x86_64-linux-gnu-thread-multi:/usr/local/wormbase/extlib/lib/perl5:/usr/local/wormbase/gbrowse-current/lib/perl5"
 
      SetEnv GBROWSE_CONF  "/usr/local/wormbase/gbrowse-current/conf"
 
  </Directory>
 
  </VirtualHost>
 
</pre>
 
  
=== Set up httpd to run under inet.d ===
+
* Set httpd to listen on your desired port. In the examples below, we assume port 8080.
  
''Only required for the master server.''
+
# 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
Line 288: Line 296:
 
  chkconfig --list
 
  chkconfig --list
  
== Install Fast CGI ==
+
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
  
$ cd /usr/local/wormbase/build
+
Configure apache as described above.
  $ wget http://www.fastcgi.com/dist/mod_fastcgi-2.4.6.tar.gz
+
 
$ tar xzf mod_fastcgi.*.tar.gz
+
For additional notes, see:
$ cd mod_fastcgi*
+
  http://gmod.org/wiki/Recompiling_mod_fcgid_to_avoid_truncated_Perl_library_paths
$ cp Makefile.AP2 Makefile
 
$ make
 
$ sudo make install
 
  
 
== MySQL ==
 
== MySQL ==
Line 338: 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 process. They 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.
  
  c_elegans -> c_elegans_WS211
+
$ cd /usr/local/wormbase/website
 +
$ git clone git@github.com/WormBase/website.git
 +
$ mv website production // for example
  
=== Privileges ===
+
Continue with the apache configuration as appropriate.
  
''Be sure to grant privileges to both master and slave servers to the databases:''
+
== Configure NFS for load balancing ==
  
$ mysql -u root -p -e 'grant select on c_elegans.* to nobody@localhost'
+
In lieue of the built-in GBrowse master/slave renderfarm configuration, we load balance across a pool of servers using a shared filesystemSee the NFS documentation in the main WormBase Production environment for details on how to install NFS.
$ mysql -u root -p -e 'grant select on c_elegans.* to nobody@render-slave-ip'
 
 
 
== 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 simultaneouslyTo 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)'
 
$ 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 Bio::Perl        // may be necessary to install from source
 
cpan> install Bio::Graphics    // may be necessary to install from source
 
  
And for GBrowse:
+
=== NFS Server ===
cpan> install DBI
 
cpan> install DBD::mysql
 
cpan> install CGI::Session
 
cpan> install JSON
 
cpan> install Storable
 
cpan> install FreezeThaw
 
cpan> intsall FCGI
 
cpan> install SVG GD::SVG
 
cpan> install Text::Shellwords
 
  
Optional:
+
The master server (wb-gb1.oicr.on.ca) provides an NFS mount of core GBrowse files and temporary session data.
cpan> Crypt::SSLeay
 
cpan> DBD::Pg
 
cpan> DB_File::Lock
 
cpan> File::NFSLock
 
cpan> Net::OpenID::Consumer
 
cpan> Net::SMTP::SSL
 
cpan> Safe::World
 
  
== Install SamTools ==
+
  /usr/local/wormbase/services/gbrowse2
/usr/local/wormbase/build/samtools-0.1.7a/
 
  
== Install GBrowse2 ==
+
This directory will be mounted at the same path for each client.
  
$ mkdir /usr/local/wormbase/gbrowse-version // ie gbrowse-2.03
+
Contents:
$ ln -s gbrowse-version gbrowse-current
 
$ perl ./Build.PL --install_base /usr/local/wormbase/gbrowse-current
 
$ 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] daemon
 
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:
+
''' Specify what to share, to whom, and with which privileges '''
./Build apache_conf
 
  
To install:
+
Share mounts are configured through /etc/exports on wb-gb1.oicr.on.ca.
./Build install
 
  
You may need to fix permissions:
+
# WormBase NFS for temporary and static content
  chmod 777 /usr/local/wormbase/gbrowse-current/tmp
+
  /usr/local/wormbase/services/gbrowse2 206.108.125.174(rw,no_root_squash)
  
Install gbrowse-slave components on all servers:
+
After making changes to /etc/exports, load them by:
sudo ./Build install_slave
 
  
Edit /etc/default/gbrowse_slave:
+
sudo exportfs -a
  
# Make sure that Perl5Lib includes that path to our external aggregator modules:
+
''' Lock down access to NFS from most hosts '''
  export PERL5LIB=/usr/local/wormbase/extlib/lib/perl5/x86_64-linux-gnu-thread-multi:\
 
    /usr/local/wormbase/extlib/lib/perl5:\
 
    /usr/local/wormbase/gbrowse-current/lib/perl5:\
 
    /usr/local/wormbase/gbrowse-support-files/lib:\
 
    /usr/local/wormbase/gbrowse-support-files/lib/Bio:\
 
    /usr/local/wormbase/gbrowse-support-files/lib/Bio/Graphics:\
 
    /usr/local/wormbase/gbrowse-support-files/lib/Bio/Graphics/Glyph
 
  
DAEMON=/usr/local/bin/gbrowse_slave
+
We can use /etc/hosts.deny to quickly lock down NFS:
USER=daemon    // Be certain this matches the httpd daemon user on the master!
 
#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:
+
portmap:ALL
 +
lockd:ALL
 +
mountd:ALL
 +
rquotad:ALL
 +
statd:ALL
  
$ cd /etc/rc3.d
+
''' Allow access to select hosts '''
$ sudo ln -s ../init.d/gbrowse-slave S99gbrowse-slave
 
$ cd /etc/rc5.d
 
$ sudo ln -s ../init.d/gbrowse-slave S99gbrowse-slave
 
  
== Fetch support files ==
+
We can use /etc/hosts.allow to specifically allow access to NFS:
  
The WormBase-specific installation requires a number of support files outside of the gbrowse installation path for simpler upgrades.
+
# WormBase NFS services
 +
portmap: ***.***.***.***
 +
lockd: ***.***.***.***
 +
rquotad: ***.***.***.***
 +
mountd: ***.***.***.***
 +
statd: ***.***.***.***
  
bash> cd /usr/local/wormbase
+
=== NFS clients ===
bash> scp wb-dev:/usr/local/wormbase/private/gbrowse-support-files.tgz
 
bash> tar xzf gbrowse-support-files.tgz ; rm -rf gbrowse-support-files.tgz
 
bash> ls -1
 
  banner-gbrowse.jpg
 
  wormbase-gbrowse.css
 
  
These files are available at the following URLs:
+
On secondary GBrowse nodes, mount the gbrowse share. The gbrowse2 directory must exist.
  
  /gb2-support/wormbase-gbrowse.css
+
sudo mount 206.108.125.173:/usr/local/wormbase/services/gbrowse2 /usr/local/wormbase/services/gbrowse2
  /gb2-support/banner-gbrowse.jpg
 
  
See the Apache configuration section for details for setting up appropriate DIRECTORY and ALIAS directives.
+
''' Unmounting the NFS share '''
  
Finally, the WormBase instance of GBrowse requires a few custom glyphs that seem to have disappeared in GB2. These are all contained in the support_files.tgz file.
+
sudo umount /usr/local/wormbase/services/gbrowse2
  
lib/Bio/Graphics/Glyph/full_transcript.pm
+
''' Setting up NFS share to mount at boot '''
lib/Bio/Graphics/Glyph/wormbase_transcript.pm
 
lib/Bio/DB/GFF/Aggregator/
 
    blastz_alignment_briggsae.pm
 
    blastz_alignment_elegans.pm
 
    waba_alignment_briggsae.pm
 
    waba_alignment_elegans.pm
 
    waba_alignment.pm
 
  
== Fetch configuration files ==
+
sudo emacs /etc/fstab
  
Copy all necessary configuration files into gbrowse-current/conf.
+
Add
  
  GBrowse.conf    // Replace the default version
+
  wb-gb1.oicr.on.ca:/usr/local/wormbase/services/gbrowse2 /usr/local/wormbase/services/gbrowse2 nfs rw  0 0
c_elegans.conf
 
c_briggsae.conf  // ...etc
 
  
 
== Configure the master server ==
 
== Configure the master server ==
Line 513: Line 459:
  
 
  sudo /etc/init.d/gbrowse_slave start
 
  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 =
 
= Administration =
Line 521: Line 480:
  
 
# Check out the source to /usr/local/wormbase/build
 
# Check out the source to /usr/local/wormbase/build
# Follow the directions above to install GBrowse, resetting the gbrowse-current symlink
+
# Follow the directions above to install GBrowse, resetting the ''current'' symlink
# Copy GBrowse.conf and all appropriate *.conf files into the new GBrowse directory
+
# Check out the "wormbase-gbrowse2" configuration repository
  
 
== Maintenance ==
 
== Maintenance ==
Line 530: Line 489:
 
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.
 
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
 
  1 1 * * * /usr/local/wormbase/gbrowse-support-files/purge_temporary_files.cron.sh
  
Line 536: Line 505:
 
  cd /usr/local/wormbase/gbrowse-current/tmp
 
  cd /usr/local/wormbase/gbrowse-current/tmp
 
  find . -type f -atime +20 -print -exec rm {} \;
 
  find . -type f -atime +20 -print -exec rm {} \;
 +
-->
  
 
=== Log Rotation ===
 
=== Log Rotation ===
Line 592: Line 562:
  
 
Todd Harris, PhD (info@toddharris.net)
 
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)