User:Rootwyrm/FreeBSD Server
Configuring MusicBrainz Server on FreeBSD 8.x and 9.x
What you'll need:
- FreeBSD 8.x or FreeBSD 9.x with root or sudo access
- Optionally, the ability to create a new user as well.
- An up to date ports tree
- Some very basic Perl and shell scripting (at this time)
First Steps
First, you'll need to add or choose a user to run the MusicBrainz Server as. The username and group doesn't matter too much (don't put them in wheel obviously.) Never run the server as root.
Ensure your ports tree is up to date (either using portsnap update or csup.) You must build some packages from ports to ensure options are set correctly. The options presented are intended for a 'bare minimums' install.
It is very important that you follow the steps in this guide in the exact order in which they are written. If you build things out of order, this can result in options being set incorrectly or dependencies not being installed correctly.
Local Database Server - Building Ports
- bash shell - use defaults when prompted by dependencies.
cd /usr/ports/shells/bash && make install OPTIONALLY: pkg_add -r bash
- Perl 5.14
cd /usr/ports/lang/perl5.14 make -DWITH_SITECUSTOMIZE install
- PostgreSQL 9.1 - gcc, ICC; clang builds should omit -DWITH_OPTIMIZED_CFLAGS for now.
cd /usr/ports/databases/postgresql91-server make -DWITH_NLS -DWITH_OPTIMIZED_CFLAGS -DWITH_XML -DWITH_TZDATA -DWITH_INTDATE -DWITH_SSL make install cd /usr/ports/databases/postgresql91-contrib make install cd /usr/ports/databases/postgresql91-plperl make install
- Memcached - use defaults (No REPCACHED, No SASL)
cd /usr/ports/databases/memcached && make install
- Git
Ensure only the following options are selected:
- CONTRIB
- ETCSHELLS
- ICONV
- NLS
- PERL
cd /usr/ports/devel/git make config -- this is where you select options make install
- GNU Make
cd /usr/ports/devel/gmake && make install
- expat libraries
cd /usr/ports/textproc/expat2 && make install
- Gnome XML libraries (libxml2)
cd /usr/ports/textproc/libxml2 && make install
- Carton - this will pull in a number of Perl dependencies as well
cd /usr/ports/devel/p5-carton && make install
- DBD::Pg - this must be installed
cd /usr/ports/databases/p5-DBD-Pg && make install
At this point, you should now add any additional packages you desire for flavor (such as editors, additional shells, interpreters and so on.)
Remote Database Server - Building Ports
This is for configurations where the database will reside on a separate system. You will need to know how to use scp, and also to consult the documentation for your database system to ensure you have the correct packages and libraries installed and have configured Memcached correctly. No assumptions are made about PostgreSQL version or host operating system for the remote server in this scenario.
- bash shell - use defaults when prompted by dependencies.
cd /usr/ports/shells/bash && make install OPTIONALLY: pkg_add -r bash
- Perl 5.14
cd /usr/ports/lang/perl5.14 make -Dusesitecustomize install
- PostgreSQL 9.1 - gcc, ICC; clang builds should omit -DWITH_OPTIMIZED_CFLAGS for now.
cd /usr/ports/databases/postgresql91-client make -DWITH_NLS -DWITH_OPTIMIZED_CFLAGS -DWITH_XML -DWITH_TZDATA -DWITH_INTDATE -DWITH_SSL make install
- Git
Ensure only the following options are selected:
CONTRIB, ETCSHELLS, ICONV, NLS, PERL
This will also pull in Python and IO::Socket::SSL - the default options should be accepted when prompted.
cd /usr/ports/devel/git make config -- this is where you select options make install
- expat libraries
cd /usr/ports/textproc/expat2 && make install
- Carton - this will pull in a number of Perl dependencies as well
cd /usr/ports/devel/p5-carton && make install
- DBD::Pg - this must be installed
cd /usr/ports/databases/p5-DBD-Pg && make install
At this point, you should now add any additional packages you desire for flavor (such as editors, additional shells, interpreters and so on.)
Setting up the MusicBrainz Server
You must change the default shell for the musicbrainz user to /usr/local/bin/bash and ensure this user's .bash_login includes a path statement which includes /usr/local/bin:/usr/local/sbin.
Change to the user which you will run musicbrainz-server as.
Clone the current Git repository:
git clone git://git.musicbrainz.org/musicbrainz-server.git
Now perform FreeBSD specific configuration for your .gitignore file. You will add the following line to the end of the .gitignore file:
echo "/admin/cron/freebsd*" >> musicbrainz-server/.gitignore
NOTE: This is a temporary solution until the various cron scripts are fixed to be path neutral.
You will now need to perform more than a little dancing with Carton to ensure packages are installed correctly. And yes, it is necessary to run 'install --deployment' twice.
cd musicbrainz-server carton install --deployment carton install --deployment cp carton.lock carton.lock.save carton install DateTime::Set DateTime::Event::ICal carton install Catalyst::Runtime Catalyst::Plugin::AutoRestart carton install REST::Utils Function::Parameters carton install XML::Parser::Lite
Installation is now complete. You should configure MusicBrainz Server as you would on any other system.
Configuring crontab for a MusicBrainz Slave
You will need a separate crontab script which is path neutral for operating a MusicBrainz Slave server on FreeBSD, which is currently not in git.
Install /usr/ports/sysutils/logrotate either by building or by using pkg_add -r logrotate
Create the file musicbrainz-server/admin/cron/freebsd_slave.sh: #!/usr/local/bin/bash PATH="$PATH:/usr/local/bin:/usr/local/sbin" mb_server=`dirname $0`/../.. cd $mb_server eval `carton exec -- ./admin/ShowDBDefs` carton exec -- ./admin/config.sh X=${SLAVE_LOG:=$MB_SERVER_ROOT/slave.log} X=${LOGROTATE:=logrotate --state $MB_SERVER_ROOT/.logrotate-state} carton exec -- ./admin/replication/LoadReplicationChanges >> $SLAVE_LOG 2>&1 || { RC=$? echo `date`" : LoadReplicationChanges failed (rc=$RC) - see $SLAVE_LOG" } $LOGROTATE /dev/stdin <<EOF $SLAVE_LOG { daily rotate 30 } EOF #eof
Then perform chmod +x musicbrainz-server/admin/cron/freebsd_slave.sh followed by crontab -e as the user running the MusicBrainz Server. This example runs every 2 hours at 35 minutes past the hour. #Crontab for MusicBrainz Server Slave on FreeBSD Min Hr MDay Month WDay Command 35 */2 * * * ~/musicbrainz-server/admin/cron/freebsd_slave.sh