Linux Memcached installation

May 17, 2021 05:00 Memcached

Table of contents

Memcached supports many platforms: Linux, FreeBSD, Solaris, Mac OS, or installed on Windows.

The Linux system installs memcached, starting with the libevent library.

sudo apt-get install libevent libevent-deve          自动下载安装(Ubuntu/Debian

yum install libevent libevent-deve                      自动下载安装(Redhat/Fedora/Centos

Install Memcached

Automatic installation


sudo apt-get install memcached


yum install memcached


portmaster databases/memcached

Source code installation

Download the latest version of from its official website (the website).

wget                    下载最新版本

tar -zxvf memcached-1.x.x.tar.gz                    解压源码

cd memcached-1.x.x                                  进入目录

./configure --prefix=/usr/local/memcached           配置

make && make test                                   编译

sudo make install                                   安装

Memcached runs

Operation of the Memcached command:

$ /usr/local/memcached/bin/memcached -h                           命令帮助

Note: If you use the auto-install memcached command located at /usr/local/bin/memcached .

Start options:

  • -d is the start of a daemon;
  • -m is the amount of memory allocated to Memcache, in MB;
  • -u is a user running Memcache;
  • -l is the ip address of the listening server, which can have multiple addresses;
  • -p is the port for setting Up Memcache listening, preferably more than 1024 ports;
  • -c is the maximum number of running synth connections, the default is 1024;
  • -P is the pid file set to save Memcache.

(1) Run as a foretime program:

Enter the following command from the terminal to start memcached:

/usr/local/memcached/bin/memcached -p 11211 -m 64m -vv

slab class   1: chunk size     88 perslab 11915

slab class   2: chunk size    112 perslab  9362

slab class   3: chunk size    144 perslab  7281


slab class  38: chunk size 391224 perslab     2

slab class  39: chunk size 489032 perslab     2

<23 server listening

<24 send buffer was 110592, now 268435456

<24 server listening (udp)

<24 server listening (udp)

<24 server listening (udp)

<24 server listening (udp)

The debugging information is shown here. T his starts the memcached at the fore desk, listening to TCP port 11211 with a maximum memory usage of 64M. Debug information is mostly about stored information.

(2) Run as a background service program:

# /usr/local/memcached/bin/memcached -p 11211 -m 64m -d


/usr/local/memcached/bin/memcached -d -m 64M -u root -l -p 11211 -c 256 -P /tmp/