What is Memcached ?
According to the Memcached website :
“Free & open source, high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.
Memcached is an in-memory key-value store for small chunks of arbitrary data (strings, objects) from results of database calls, API calls, or page rendering.
Memcached is simple yet powerful. Its simple design promotes quick deployment, ease of development, and solves many problems facing large data caches. Its API is available for most popular languages.”
Dependencies :
Memcached depends only on libevent, an event notification library, and is available in libevent website.
In Linux, we need a kernel with epoll, and epoll isn’t included in Linux 2.4, but don’t worry a backport available through epoll-lt patch.
Before installing memcached make sure that you have installed libevent library properly.
Following are the are the steps to install libevent :
-
Download the libevent source code from http://libevent.org/
-
uncompress the file and change the directory to it.
-
Then do './configure && make' and 'make install' (as root) $ ./configure --enable-64bit --prefix=/opt/memcached $
make
$ su -c "make install
" password :
In Slackware 14.1 /usr/local/lib ( which is the default installation path for libevent) is already included in the ld configuration. If in case you are referring this guide for other distributions you might have check it. If it is not included in the ld configuration you can add it by editing /etc/ld.so.conf
If tetc/ld.so.conf is not available create one by
vim /etc/ld.so.conf.d/libevent.conf or nano
/etc/ld.so.conf.d/libevent.conf
and
## add a line containing:
/usr/local/lib/
then update ld.so.cache by the issuing the command ‘ldconfig -v’
Installation steps :
Step 1 : Download the latest version of Memcached.
$ wget -r -P /home/dev/Software/ http://www.memcached.org/files/memcached-1.4.17.tar.gz
Step 2 : Uncompress the file.
$ cd /home/dev/Software $ tar -xvzf
/home/dev/Software/ http://www.memcached.org/files/memcached-1.4.17.tar.gz
Step 3 : Change the directory to the current uncompressed file directory.
$ cd
/home/dev/Software/memcached-1.4.17
Step 4 : run the ./configure with appropriate parameters
$ ./configure --prefix=/opt/memcached
Step 5 : run the make script
$ make && make test
Step 6 : run make install
$ su -c "make install" password :
Step 7 : run memcached
$ memcached -d -m 256 -u dev -p 11211
Possible pitfalls :
Sometimes an error is shown which says ‘cannot open shared object file : libevent-x.x.so.x : No such file or directory‘.
Problems can be
- You forgot to install libevent.Solution : install libevent library.
- You compiled libevent and memcached from source package and did that for different hardware platform’s x86/64 using lib/lib64 folders.Solution : uninstall the current installation using ‘make uninstall’ and reinstall the library properly.
- Something is messed up and synlink wasn’t properly generatedSolution : create the symlink for libevent library properly.
On a 32 bit system:ln -s /usr/local/lib/libevent-
x.x.so.x
/usr/lib/libevent-x.x.so.xOn a 64 bit system:
ln -s /usr/local/lib/libevent-
-x.x.so.x
/usr/lib64/libevent-x.x.so.x
References :
- http://code.google.com/p/memcached/wiki/NewInstallFromSource
- http://www.ducea.com/2008/01/10/howto-install-memcached-from-sources-on-linux/
- http://www.liquidweb.com/kb/how-to-install-memcached-on-centos-6/
- http://www.itwebsupport.com/blog/memcached-error-while-loading-shared-libraries-libevent-2-0-so-5
- http://www.nigeldunn.com/2011/12/11/libevent-2-0-so-5-cannot-open-shared-object-file-no-such-file-or-directory/