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 ibevent-dev 自动下载安装(Ubuntu/Debian) yum install libevent libevent-devel 自动下载安装(Redhat/Fedora/Centos)
Install 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 view the path of the command:
whereis memcached
The installation location is found at:/usr/bin/memcached。
Source Code Installation
Download the latest version of memcached from its official website (http://memcached.org).
wget http://memcached.org/latest 下载最新版本 tar -zxvf memcached-1.x.x.tar.gz 解压源码 cd memcached-1.x.x 进入目录 ./configure --prefix=/usr/local/memcached 配置 make && make test 编译 sudo make install 安装
Running Memcached
Running Memcached commands:
$ /usr/local/memcached/bin/memcached -h 命令帮助
Note:If using automatic installation, the memcached command is located at/usr/local/bin/memcached。
Startup options:
- -d is to start a daemon process;
- -m is the amount of memory allocated for Memcache, in MB;
- -u is the user running Memcache;
- -l is the server IP address to listen on; there can be multiple addresses;
- -p is to set the port for Memcache to listen on; preferably a port above 1024;
- -c is the maximum number of concurrent connections, the default is 1024;
- -P is to set the pid file for Memcache.
(1) Run as a foreground process:
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 debug information is displayed here. This starts memcached in the foreground, listening on TCP port 11211, with maximum memory usage of 64M. Most of the debug information is about storage.
(2) Run as a background service process:
# /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.pidOther Extensions