Monday, December 21, 2009

Installing MogileFS server from source on Ubuntu 8.04 LTS

Install dependencies:
sudo apt-get install libdbd-mysql-perl
cpan
install IO::AIO
install BSD::Resource

Download latest version from cpan repository at http://search.cpan.org/dist/mogilefs-server/ :
wget http://search.cpan.org/CPAN/authors/id/D/DO/DORMANDO/mogilefs-server-2.34.tar.gz

Unpack it:
tar xvf mogilefs-server-2.34.tar.gz

Compile and install
cd mogilefs-server-2.34
perl Makefile.PL && make && make install

Create configs:

For tracker

mkdir /etc/mogilefs
nano /etc/mogilefs/mogilefsd.conf

db_dsn = DBI:mysql:mogilefs:host=mogiledb.yourdomain.com;port=3306;mysql_connect_timeout=5;mysql_ssl=1;mysql_compression=1
db_user = mogile
db_pass = sekrit
conf_port = 7001
listener_jobs = 5
node_timeout = 5
rebalance_ignore_missing = 1

For mogstored
nano /etc/mogilefs/mogstored.conf

maxconns = 10000
httplisten = 0.0.0.0:7500
mgmtlisten = 0.0.0.0:7501
docroot = /var/mogdata

Create users and init scripts

For tracker

adduser mogilefsd
sudo nano /etc/default/mogilefsd
and input
#!/bin/sh
# Defaults for the mogilefsd package
MOGILEFSD_RUNASUSER=mogilefsd


sudo nano /etc/init.d/mogilefsd

Put this in there:

#! /bin/sh
### BEGIN INIT INFO
# Provides:          mogilefsd
# Required-Start:    $local_fs $remote_fs $network $syslog
# Required-Stop:     $local_fs $remote_fs $network $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start/Stop the mogilefsd daemon
# Description:       Start/Stop the mogilefsd daemon.
### END INIT INFO

# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/local/bin/mogilefsd
NAME=mogilefsd
DESC=mogilefsd
DEFAULTS=/etc/default/$NAME
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0

# Read configuration variable file if it is present
if [ -r $DEFAULTS ] ; then

    . $DEFAULTS

    if [ -z "$MOGILEFSD_RUNASUSER" ]; then
        echo "Cannot determine user to run as, even though defaults file ($DEFAULTS) exists."
        echo "Please run dpkg-reconfigure $NAME to correct the problem."
        exit 0
    fi
else
    echo "Can't start $NAME. Defaults file ($DEFAULTS) doesn't exist."
    echo "Please run dpkg-reconfigure $NAME to correct the problem."
    exit 0
fi

# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh

set -e

#
# Function that starts the daemon/service
#
do_start()
{
 if [ -e $PIDFILE ]
  then

  if [ -d /proc/`cat $PIDFILE`/ ]
  then

   echo "$NAME already running."
   exit 0;
  else
   rm -f $PIDFILE
  fi

 fi

 start-stop-daemon --start --quiet --exec $DAEMON --pidfile $PIDFILE -b -m --name $NAME --chuid $MOGILEFSD_RUNASUSER
}

#
# Function that stops the daemon/service
#
do_stop()
{
 start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE --name $NAME --user $MOGILEFSD_RUNASUSER
 rm -f $PIDFILE
}

case "$1" in
  start)
 echo -n "Starting $DESC: "
 do_start
 echo "$NAME."
 ;;
  stop)
 echo -n "Stopping $DESC: "
 do_stop
 echo "$NAME."
 ;;

  restart|force-reload)
 #
 # If the "reload" option is implemented, move the "force-reload"
 # option to the "reload" entry above. If not, "force-reload" is
 # just the same as "restart".
 #
 echo -n "Restarting $DESC: "
 do_stop
 sleep 1
 do_start
 echo "$NAME."
 ;;
  *)
 #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
 echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
 exit 3
 ;;
esac

:

For mogstored

sudo adduser mogstored
sudo nano /etc/default/mogstored
and enter
#!/bin/sh
# Defaults for the mogstored package
MOGSTORED_RUNASUSER=mogstored

sudo nano /etc/init.d/mogstored

and put this in there:

#! /bin/sh
### BEGIN INIT INFO
# Provides:          mogstored
# Required-Start:    $local_fs $remote_fs $network $syslog
# Required-Stop:     $local_fs $remote_fs $network $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start/Stop the mogstored daemon
# Description:       Start/Stop the mogstored daemon.
### END INIT INFO

# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/local/bin/mogstored
NAME=mogstored
DESC=mogstored
DEFAULTS=/etc/default/$NAME
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0

# Read configuration variable file if it is present
if [ -r $DEFAULTS ] ; then

    . $DEFAULTS

    if [ -z "$MOGSTORED_RUNASUSER" ]; then
        echo "Cannot determine user to run as, even though defaults file ($DEFAULTS) exists."
        echo "Please run dpkg-reconfigure $NAME to correct the problem."
        exit 0
    fi
else
    echo "Can't start $NAME. Defaults file ($DEFAULTS) doesn't exist."
    echo "Please run dpkg-reconfigure $NAME to correct the problem."
    exit 0
fi

# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh

set -e

#
# Function that starts the daemon/service
#
do_start()
{
 if [ -e $PIDFILE ]
  then

  if [ -d /proc/`cat $PIDFILE`/ ]
  then

   echo "$NAME already running."
   exit 0;
  else
   rm -f $PIDFILE
  fi

 fi

 start-stop-daemon --start --quiet --exec $DAEMON --pidfile $PIDFILE -b -m --name $NAME --chuid $MOGSTORED_RUNASUSER
}

#
# Function that stops the daemon/service
#
do_stop()
{
 start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE --name $NAME --user $MOGSTORED_RUNASUSER
 rm -f $PIDFILE
}

case "$1" in
  start)
 echo -n "Starting $DESC: "
 do_start
 echo "$NAME."
 ;;
  stop)
 echo -n "Stopping $DESC: "
 do_stop
 echo "$NAME."
 ;;

  restart|force-reload)
 #
 # If the "reload" option is implemented, move the "force-reload"
 # option to the "reload" entry above. If not, "force-reload" is
 # just the same as "restart".
 #
 echo -n "Restarting $DESC: "
 do_stop
 sleep 1
 do_start
 echo "$NAME."
 ;;
  *)
 #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
 echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
 exit 3
 ;;
esac

:

Make it executable, and enable it to run at boot:

sudo chmod +x /etc/init.d/mogilefsd
sudo chmod +x /etc/init.d/mogstored
sudo update-rc.d mogilefsd defaults 
sudo update-rc.d mogstored defaults 


You can install utils from cpan without much hassle:
install MogileFS::Utils

but to get mogstats working you need give it a separate config file:
cp /etc/mogilefs/mogilefsd.conf /etc/mogilefs/mogilefs.conf

No comments:

Post a Comment