13 May 2011 @ 1:45 PM 

Memcached is a service that allows entire database tables to be stored in memory, drastically speeding up queries to those tables and alleviating database load. In Drupal, the Memcached module allows you to store all cache tables in memory.

This guide can be used to set up Memcached on Red Hat Enterprise Linux (RHEL) or CentOS, which are architecturally the same.
Install memcached through RPM

The easiest way to install Memcached is through a package manager such as yum or apt. However, Memcached is not available from the default collection of packages, so the first thing we need to do is add a new RPM (Red Hat Package Manager) server so that we can install Memcached through yum.

One of the best 3rd-party RPM servers is provided by Dag Wieers, which will provide us with up-to-date packages that are not provided by Red Hat directly. The one tricky part of setting up an RPM server is making sure you get the repository that matches your server version and architecture (32-bit or 64-bit). So we need to collect that information first.

From a shell prompt, get the CentOS/RedHat version number:
cat /etc/redhat-release
CentOS release 5.6 (Final)

Then get the server architecture information. This is a typical response for 64-bit machine:
uname -a
Linux test.server.com 2.6.18-194.32.1.el5 #1 SMP Wed Jan 5 17:52:25 EST 2011 x86_64 x86_64 x86_64 GNU/Linux

Now install the RPM server that matches your architecture and CentOS version from http://dag.wieers.com/rpm/FAQ.php#B2.

The server I was using when I wrote this was a 64-bit machine running CentOS version 5.x. So my particular server was:

http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.5.2-2.el5.rf.i386.rpm

To install a new RPM server, we can just use the rpm command. Note that you must find the RPM server string that matches your architecture and software. Do not use the URL unless you have a 32-bit machine running CentOS 5.x, instead get the server that’s appropriate from http://dag.wieers.com/rpm/FAQ.php#B2.

rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.5.2-2.el5.rf.i386.rpm

Now we can simply use yum (or apt) to install Memcached:
yum install memcached

Afterwards you can confirm memcached is up and running by calling it.
memcached -h
memcached 1.2.6

Install the Memcache PECL Extension

Even though memcached is happily running on the server, it’s not accessible from PHP without the PECL extension. Fortunately this is a very easy process, just use the pecl command.

pecl install memcache

Then add the memcache extension to your php.ini file, usually at /etc/php.ini.
extension=memcache.so

And finally restart Apache so that it will pick up the new extension:
/etc/init.d/httpd restart

Running phpinfo() on your webserver should now confirm that memcache is installed:

memcache-phpinfo

And finally restart Memcached:
/etc/init.d/memcached restart

Then register the script to start up with the server:
chkconfig --add memcached

And you can confirm that memcached has fired up several instances by checking ps:
ps -auxf | grep memcached

There should be something like this
mysql 5059 0.0 0.0 71176 3664 ? Ssl May 13 7:15 \_ memcached -d -p 11211 -u memcached -m 64 -c 1024 -P /var/run/memcached/memcached.pid

Posted By: lvlind
Last Edit: 06 Oct 2016 @ 04:14 PM

EmailPermalink
Tags
Tags: ,
Categories: How to?


 

Responses to this post » (None)

 

Sorry, but comments are closed. Check out another post and speak up!

Tags
Comment Meta:
RSS Feed for comments

 Last 50 Posts
Change Theme...
  • Users » 1
  • Posts/Pages » 34
  • Comments » 0
Change Theme...
  • VoidVoid « Default
  • LifeLife
  • EarthEarth
  • WindWind
  • WaterWater
  • FireFire
  • LightLight

About



    No Child Pages.

Need Help?



    No Child Pages.

Check your IP



    No Child Pages.