Easy Tutorial
❮ Memcached Get Cas Data Memcached Set Data ❯

Linux Memcached Installation

Memcached supports many platforms: Linux, FreeBSD, Solaris, Mac OS, and can also be installed on Windows.

To install memcached on a Linux system, you must first install the libevent library.

sudo apt-get install libevent libevent-dev         Automatic download and installation (Ubuntu/Debian)

yum install libevent libevent-devel                Automatic download and installation (Redhat/Fedora/Centos)

Installing Memcached

Automatic Installation

Ubuntu/Debian

sudo apt-get install memcached

Redhat/Fedora/Centos

yum install memcached

FreeBSD

portmaster databases/memcached

After installation, you can use whereis to check the command path:

whereis memcached

The installation location is found to be /usr/bin/memcached.

Source Code Installation

Download the latest version of memcached from its official website (http://memcached.org).

wget http://memcached.org/latest                    Download the latest version

tar -zxvf memcached-1.x.x.tar.gz                    Extract the source code

cd memcached-1.x.x                                  Navigate to the directory

./configure --prefix=/usr/local/memcached           Configure

make && make test                                   Compile

sudo make install                                   Install

Running Memcached

Running the Memcached command:

$ /usr/local/memcached/bin/memcached -h                           Command help

Note: If using automatic installation, the memcached command is located at /usr/local/bin/memcached.

Startup Options:

(1) Running as a Foreground Process:

Start memcached by entering the following command in the terminal:

/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

... (omitted)

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)

This displays debugging information. Memcached is now running in the foreground, listening on TCP port 11211 with a maximum memory usage of 64M. The debugging information mostly pertains to storage details.

(2) Running as a Background Service:

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

Or

/usr/local/memcached/bin/memcached -d -m 64M -u root -l 192.168.0.200 -p 11211 -c 256 -P /tmp/memcached.pid
❮ Memcached Get Cas Data Memcached Set Data ❯