memcached安装

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了memcached安装相关的知识,希望对你有一定的参考价值。

一、安装memcached

1、分别把memcached和libevent下载回来,放在/data/src目录下

cd /data/src

wget https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz

wget http://www.memcached.org/files/memcached-1.4.34.tar.gz


2、先安装libevent

tar zxvf libevent-2.1.8-stable.tar.gz

cd libevent-2.1.8-stable

./configure --prefix=/usr/

 make

make install


3、测试libevent是否安装成功

ll /usr/lib | grep libevent

lrwxrwxrwx   1 root root      21 Feb 14 10:42 libevent-2.1.so.6 -> libevent-2.1.so.6.0.2

-rwxr-xr-x   1 root root 1128436 Feb 14 10:42 libevent-2.1.so.6.0.2

-rw-r--r--   1 root root 1817720 Feb 14 10:42 libevent.a

lrwxrwxrwx   1 root root      26 Feb 14 10:42 libevent_core-2.1.so.6 -> libevent_core-2.1.so.6.0.2

-rwxr-xr-x   1 root root  722476 Feb 14 10:42 libevent_core-2.1.so.6.0.2

-rw-r--r--   1 root root 1194990 Feb 14 10:42 libevent_core.a

-rwxr-xr-x   1 root root     969 Feb 14 10:42 libevent_core.la

lrwxrwxrwx   1 root root      26 Feb 14 10:42 libevent_core.so -> libevent_core-2.1.so.6.0.2

lrwxrwxrwx   1 root root      27 Feb 14 10:42 libevent_extra-2.1.so.6 -> libevent_extra-2.1.so.6.0.2

-rwxr-xr-x   1 root root  426194 Feb 14 10:42 libevent_extra-2.1.so.6.0.2

-rw-r--r--   1 root root  622802 Feb 14 10:42 libevent_extra.a

-rwxr-xr-x   1 root root     976 Feb 14 10:42 libevent_extra.la

lrwxrwxrwx   1 root root      27 Feb 14 10:42 libevent_extra.so -> libevent_extra-2.1.so.6.0.2

-rwxr-xr-x   1 root root     934 Feb 14 10:42 libevent.la

lrwxrwxrwx   1 root root      30 Feb 14 10:42 libevent_pthreads-2.1.so.6 -> libevent_pthreads-2.1.so.6.0.2

-rwxr-xr-x   1 root root   18502 Feb 14 10:42 libevent_pthreads-2.1.so.6.0.2

-rw-r--r--   1 root root   18694 Feb 14 10:42 libevent_pthreads.a

-rwxr-xr-x   1 root root     997 Feb 14 10:42 libevent_pthreads.la

lrwxrwxrwx   1 root root      30 Feb 14 10:42 libevent_pthreads.so -> libevent_pthreads-2.1.so.6.0.2

lrwxrwxrwx   1 root root      21 Feb 14 10:42 libevent.so -> libevent-2.1.so.6.0.2


ok,安装成功了


4、安装memcached,同时需要安装中指定libevent的安装位置

tar zxvf memcached-1.4.34.tar.gz

cd memcached-1.4.34

./configure --with-libevent=/usr/

make

make install


如果中间出现报错,请仔细检查错误信息,按照错误信息来配置或者增加相应的库或者路径。

安装完成后会把memcached放到 /usr/local/bin/memcached 


5、测试是否成功安装memcached

ll /usr/local/bin/mem*

-rwxr-xr-x 1 root root 456873 Feb 14 10:43 /usr/local/bin/memcached


二、启动memcached

1、启动memcached服务器端

/usr/local/bin/memcached -d -m 10 -u root -l 10.132.162.106 -p 11211-c 256 -P /usr/local/memcached/memcached.pid


-d选项是启动一个守护进程,

-m是分配给Memcache使用的内存数量,单位是MB,我这里是10MB,

-u是运行Memcache的用户,我这里是root,

-l是监听的服务器IP地址,如果有多个地址的话,我这里指定了服务器的IP地址192.168.0.200,

-p是设置Memcache监听的端口,我这里设置了12000,最好是1024以上的端口,

-c选项是最大运行的并发连接数,默认是1024,我这里设置了256,按照你服务器的负载量来设定,

-P是设置保存Memcache的pid文件,我这里是保存在 /tmp/memcached.pid,


2.如果要结束Memcache进程,执行

kill `cat /tmp/memcached.pid`


也可以启动多个守护进程,不过端口不能重复


三、测试memcached

[[email protected] local]# telnet 10.132.162.106 11211

Trying 10.132.162.106...

Connected to 10.132.162.106.

Escape character is ‘^]‘.

set key1 0 60 4

1234

STORED

get key1

VALUE key1 0 4

1234

END




以上是关于memcached安装的主要内容,如果未能解决你的问题,请参考以下文章

memcache安装

memcache安装

C# 使用memcache(memcache安装)

memcached 安装使用

Memcached安装和PHP连接Memcached

Memcached和Memcache安装(64位win7)