Tag Archive for 'debian etch'

HowTo install memcached from sources on Linux

This article will explain how you can install the latest memcached daemon (including the libevent library) on a linux system. The only prerequisite for memcached is libevent so we will have to install this first.

Note: the output of the commands in this article are taken from a Debian Etch system. They should work on any recent linux distribution, but depending from your version you might need to make some changes. The versions of memcached and libevent used in this article are the latest stable one existing at the time this was written. Check the download pages bellow, and if newer versions exists you will probably want to use them.

Install Libevent 1.3e

I will assume that you don’t have libevent installed already on your system. Your system might already have libevent installed, but normally you will have a very old version (for ex. on debian etch the packaged libevent is 1.1a that was released in 2005); in this case you will want to remove the system package first (for ex. on debian run: aptitude purge libevent1). If you have a recent version packaged by your linux distribution you should keep it and move on the next step to install directly memcached.

Download, and install the latest version of libevent (check for the latest version, and change if needed the versions bellow):
cd /usr/local/src
wget http://monkey.org/~provos/libevent-1.3e.tar.gz
cd libevent-1.3e
./configure
make
make install

This will install by default the libraries under /usr/local/lib/. If you want it in another place you can do that by passing to configure a different prefix.

Depending on your system you might have already /usr/local/lib included in your ld configuration. If this is not the case (like on my test debian box) you can add it inside /etc/ld.so.conf, or as a nice debian “thing†you can just create a new file inside /etc/ld.so.conf.d/ like:

vim /etc/ld.so.conf.d/libevent.conf
##add a line containing:
/usr/local/lib/

Regardless of your choice you should run ldconfig to complete this step:
ldconfig -v
(and check the output to be sure that the /usr/local/lib has been properly included).

Install Memcached 1.2.4

After we have libevent properly installed on the system we can proceed and install memcached. Download the latest stable version and install it using the following steps:

cd /usr/local/src
wget http://danga.com/memcached/dist/memcached-1.2.4.tar.gz
tar zxvf memcached-1.2.4.tar.gz
cd memcached-1.2.4
./configure
make
make install

The memcached binary will be also installed by default under /usr/local/bin/. You can start the daemon by simply running: /usr/local/bin/memcached. The basic memcached options are:
memcached -d [-m memory_in_megabytes [-l listen_ip_address [-p listen_port]]]
For ex:
memcached -d -m 256 -u nobody -p 11211 -l 192.168.0.1
will be used to run a memcached daemon bind on 192.168.0.1 on the default port 11211 using max 256MB memory.

Mount remote folders via SSH

This document describes how to install and use sshfs, a FUSE based filesystem that uses SSH to mount remote folders. Since it is based on FUSE (userspace filesystem framework for Linux) your kernel will need to have the fuse module available. FUSE is included in kernel newer than 2.6.14, so I will assume that you will have it already included in your kernel.

Fuse is included in the stock debian etch kernel (2.6.18) but if you install this on a older debian system you could easily use module-assistant to add FUSE support to your kernel:
apt-get install kernel-headers-`uname -r` fuse-source module-assistant
module-assistant clean fuse
module-assistant build fuse
module-assistant install fuse

Installing sshfs

The only thing left is to install sshfs. In debian etch this is as simple as:
aptitude install sshfs
This will install also the required dependencies: fuse-utils, libfuse2

Now, we should be able to use sshfs, and we can try to mount a remote server’s /data folder with:
sshfs 192.168.0.1:/data ~/mnt
(depending how you connect to the remote ssh server, this will ask you for a user or key password, etc.). You will need to have proper permissions. If you require you can also use -o idmap=user to translate the remote ssh user to the local user specified in the command.

Troubleshooting

If you get this error:
fusermount: failed to open /dev/fuse: No such file or directory
fuse_mount failed.

this means that even if your kernel uses udev to dynamically create devices, in this case it has not done that. The solution for this is to load first the fuse kernel module. This will take care and create the device /dev/fuse:
modprobe fuse
This will work until the first reboot, and if you want to make this change permanent you will have to add the fuse module to the automatically loaded module list. For ex. in debian you would add to your /etc/modules a line containing the word “fuse†.

Note: - you can unmount the remote folder using the regular umount command like:
umount ~/mnt
or using fuse:
fusermount -u /mnt