Memcached: How do you install memcached? (CentOS 64 bit, Linux, Redhat, Fedora)
Memcached is a very popular open source object caching server. It was developed to speed up livejournal.com by Danga Interactive. We use memcached for a lot of our sites. We use it for different purposes but one main purpose is to cache query results so we don’t have to keep hitting database. As most of the people who work with databases know it is costly to keep hitting database for same information over and over.
When you run the Memcached daemon, it runs and listens on a specific port. One of the things Memcached does lack is security. Memcached will let anybody who can make a connection to its port have full access to all objects. So you would have to run a firewall to block unauthorized access. It is usually wise to do put firewall on it even if you trust everybody on the same network since accidents do happen. That said, let’s get memcached installed!
Let’s get libevent which is required by Memcached:
wget http://monkey.org/~provos/libevent-1.3e.tar.gz
tar zxpfv libevent*
cd libevent*
./configure
make install
Now let’s download the newest Memcached source (at time of writing this was 1.2.4)
wget http://www.danga.com/memcached/dist/memcached-1.2.4.tar.gz
tar zxpfv memcached*
cd memcached*
./configure
make install
Let’s add Memcached user to run daemon as since we don’t need it to run as root privileges.
adduser memcached
We will start the server to use 48 megs of ram (-m 48), listen on ip 10.0.0.2 (-l 10.0.0.2) and run on port 11211 (-p 11211) as user memcached (-u memcached)
./memcached -u memcached -d -m 48 -l 10.0.0.2 -p 11211
If you get the following error (which you will get if you are doing this under CentOS 64 bit):
./memcached: error while loading shared libraries: libevent-1.3e.so.1: cannot open shared object file: No such file or directory
You can fix this by simply doing this:
ln -s /usr/local/lib/libevent-1.3e.so.1 /lib64/
That is all there is to it. You can see if daemon is running by telneting to the port.
————————————-
DISCLAIMER: Please be smart and use code found on internet carefully. Make backups often. And yeah.. last but not least.. I am not responsible for any damage caused by this posting. Use at your own risk.


(4 votes, average: 3.75 out of 5)

i hate centos because of the package management. dag usually has a lot of extra packages: http://dag.wieers.com/rpm/packages/memcached/
looks like the latest there might be 1.2.2 though.
On Fedora, a simple yum install memcached works better.
For Redhat 4 and 5, the same packages are available in the EPEL repositories:
http://fedoraproject.org/wiki/EPEL
Most of the times, using package managers to install won’t get you the latest version. With yum, it tried to download/install 1.2.3-7 on my fedora install. Thanks for the tip though. I am sure for people who don’t care, it would work out just fine.
Of course, you have to run the latest distro version to get the latest packages
memcached 1.2.4 is in Fedora 8.
Got the error: ./memcached: error while loading shared libraries: libevent-1.3e.so.1: cannot open shared object file: No such file or directory
The solution for me: libevent files where installed at /usr/local/lib, I had to move them to /usr/lib and check if symbolic links were correct.
On CentOs 5.1 libevent may be installed like:
yum install libevent
but ‘yum install memcached’ still cant.
After this, you can download last version memcached
http://www.danga.com/memcached/dist/memcached-1.2.5.tar.gz
and go on as described abow, in some cases may apper this error
checking build system type… Invalid configuration `x86_64-unknown-linux-’: machine `x86_64-unknown-linux’ not recognized
configure: error: /bin/sh ./config.sub x86_64-unknown-linux- failed
for now, I duno how to deal against it, but will dig
I Just finished installing on CentOS 5.1. Downloaded and built both libevent and memcached as instructed.
However memcached could not load the shared library libevent-1.3e.so.1.
Next I tried a “make clean” followed by
“./configure –with-libeven=/usr/local/lib” however I received the same error as before.
I was able to solve the problem by creating a symlink between /usr/local/lib/libevent-1.3e.so.1 and /usr/lib “ln -s /usr/local/lib/libevent-1.3e.so.1 /usr/lib”
Hopefully this will help someone else.
Update to my last comment:
–with-libeven should have been –with-libevent
Also, I did remember to run make install after I ran configure.
Shannon
Shannon, just for everybody’s knowledge here, are you using 32bit CentOS?
You can do following to check:
# uname -p
[...] are the steps you will need to install memcache on linux: These direction are from: Crazytoon.com site, go there to read more about memcache and what people have suggested in the comments on this [...]
Sunny, I am using 32Bit CentOS.
Cheers,
Shannon