Wednesday 10 July 2013

How to install Memcache from source code

How to install Memcache from source code


There are two ways to install memcache :
  1. From some repository (CentOS,RHEL etc). [e.g: yum install memcached]
  2. From source code –> I would prefer this method because sometimes the CentOS or RHEL repository   doesn't have the latest version . I had personally faced this issue.

To cross check and verify that memcahe is installed and running fine. Try below command:


#netstat -nap |grep LISTEN |grep 11211
(No info could be read for "-p": geteuid()=507 but you should be root.)
tcp        0      0 0.0.0.0:11211               0.0.0.0:*                   LISTEN      -
tcp        0      0 :::11211                    :::*                        LISTEN      -

Note: If you are installing using source code the Libevent would be required. Install that using Yum command. http://libevent.org/

As I write the latest Memcahed version is 1.4.15 . Pick up the latest version from below link: https://code.google.com/p/memcached/wiki/ReleaseNotes

Start memcahe from command prompt :
Command : nohup /usr/bin/memcached -p 11211 -u memcached -m 4096 -vv -I 10 &
Alternative way : /etc/init.d/memcached start/stop

It's preferred to install memcache in /opt/ directory, if you are installing memcache from source code. So that you don't overwrite other version of any other software running on the machine.


Steps to install memcache from source code:

# wget http://memcached.googlecode.com/files/memcached-1.4.15.tar.gz
# wget https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
# tar -xzf memcached-1.4.15.tar.gz
# tar -xzf libevent-2.0.21-stable.tar.gz
# tar -xzf memcache-3.0.6.tgz

# cd libevent-2.0.21-stable [ you can get it from http://libevent.org/ ]
# ./configure --prefix=/usr --libdir=/usr/lib64
# make
# make install

# cd ..

# cd memcached-1.4.15
# ./configure --prefix=/usr --libdir=/usr/lib64
# make
# make install



Classes, sizes, and chunks are shown best by starting up memcached with -vv:

[kulshresht@server123 bin]$ ./memcached -vv
slab class   1: chunk size        96 perslab   10922
slab class   2: chunk size       120 perslab    8738
slab class   3: chunk size       152 perslab    6898
slab class   4: chunk size       192 perslab    5461
slab class   5: chunk size       240 perslab    4369
slab class   6: chunk size       304 perslab    3449
slab class   7: chunk size       384 perslab    2730
slab class   8: chunk size       480 perslab    2184
slab class   9: chunk size       600 perslab    1747
slab class  10: chunk size       752 perslab    1394
slab class  11: chunk size       944 perslab    1110


Please feel free to drop me a mail if you are facing any issue(s) with installation.

If you want to explore further about how to monitor and debug memcache, please got to below link:
http://kulshresht-gautam.blogspot.in/2013/08/how-to-monitor-and-debug-memcached.html

References:


No comments:

Post a Comment