Skip to content

Instantly share code, notes, and snippets.

@jdeathe
Last active February 28, 2018 12:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdeathe/01f58378c2881498a9a5341cf7c05c02 to your computer and use it in GitHub Desktop.
Save jdeathe/01f58378c2881498a9a5341cf7c05c02 to your computer and use it in GitHub Desktop.
Installing Memcached with support for max_item_size > 1M on CentOS-6

Installing modern memcached on CentOS-6

The version of memcached available in the CentOS-6 repositories is currently 1.4.4. This performs well with small items however there is a limit of 1M and an issue with slab imbalance.

Install the remi repository and install memcached

# rpm -q remi-release-6.8-2.el6.remi.noarch \
  &> /dev/null \
|| yum -y install \
  http://rpms.famillecollet.com/enterprise/6/remi/x86_64/remi-release-6.8-2.el6.remi.noarch.rpm \
&& yum -y --enablerepo=remi install \
  memcached

Configure

Increase from 64M to 512M memory, bind to loopback IP address and increase item_size_max to 2M.

We bind to the loopback address to prevent exposing the Memcached service since it can contain sensitive infomation. If binding to any other address measures should be taken to ensure access is limited to the necessary hosts.

# sed -i -r \
  -e 's~^(CACHESIZE=).+$~\1"512"~' \
  -e 's~^(MAXCONN=).+$~\1"1024"~' \
  -e 's~^(OPTIONS=).+$~\1"-I 2m -l 127.0.0.1 -o modern"~' \
  /etc/sysconfig/memcached

Set to start on server starup and start the service.

# chkconfig memcached on \
&& service memcached restart

Verify

$ memcached-tool 127.0.0.1:11211 settings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment