Quantcast
Channel: Technology: Learn and Share » Caching
Viewing all articles
Browse latest Browse all 2

Memcached: How do you install memcached? (CentOS 64 bit, Linux, Redhat, Fedora)

0
0

[updated 5/16/2010]

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 update to this post 1.4.5 was the latest)

wget http://memcached.googlecode.com/files/memcached-1.4.5.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.


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images