Have a Question?

If you have any question you can ask below or enter what you are looking for!

Install and configure memcached on CentOS 6


Memcached is an open source, high-performance memory object cache system which it is widely used in dynamic web applications to reduce load on database systems and as a fast storage for frequency accessed data. Its simple design promotes quick deployment and ease of development. Memcached stores data as key-value pairs in memory, thus very fast.


Installation and configuration steps described here require root user privilege on the CentOS 6 Linux server.

Install memcached

Mecached is available on CentOS base YUM repository and can be installed as follows:

yum -y install memcached

Start the service and enable it on server boot:

service memcached start
chkconfig memcached on

Configure memcached

By default, memcached service listens to port 11211 of all IP addresses available on server and has a maximum concurrent connections limit of 1024 and mamimum memory allocation of 64MB for the in-memory datastore. These settings can be changed in the configuration file /etc/sysconfig/memcached. It has following default configuration:


PORT – port to which memcached service listens
USER – user ownership of memcached service
MAXCONN – maximum number of concurrent connections that memcached accepts
CACHESIZE – size of in-memory datastore
OPTIONS – additional options given to memcached service

To make memcached to listen to a specific IP address available in the server, use -l switch in OPTIONS setting. For example, to restrict memcached to listen to loopback IP address on port 11211 with a maximum concurrent connections of 10240 and a maximum in-memory datastore of 1024MB, use following settings:


Change in configuration settings in /etc/sysconfig/memcached requires a service restart:

service memcached restart

To check status of memcached service, type following:

service memcached status

A status message similar to following shows that service is running fine:

memcached (pid 1934) is running...

If service is stopped, following status message is shown:

memcached is stopped

If there is any error in configuration values given to memcached, service fails to start and shows following status message:

memcached dead but pid file exists


In this article, we described the installation and configuration of memcached in-memory object cache system on a CentOS 6 Linux server. When properly configured and integrated with the web application, memcached can alleviate load on database server and can serve fast storage and retrieval of frequently accessed data, thus greatly improving application response time.

Leave a Reply

Your email address will not be published. Required fields are marked *

You can use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>