memcached安装步骤

版本:memcached-1.4.13

由于memcahced使用 libevent库,libevent是个程序库,它将Linux的epoll、BSD类操作系统的kqueue等事件处理功能封装成统一的接口。即使对服务器的连接数增加,也能发挥O(1)的性能。 为了发挥memcached在Linux、BSD、Solaris等操作系统上的高性能,因此这里先安装libevent库,版本是libevent-2.0.19。

一、安装libevent-2.0.19

tar -xzvf libevent-2.0.19-stable.tar.gz

./configure --prefix=/usr/lib/libevent

make

make install

二、安装memcached-1.4.13

tar -xzvf memcached-1.4.13.tar.gz

./configure --prefix=/usr/local/memcached --with-libevent=/usr/lib/libevent

make

make install

启动一个memcached

  [root@localhost bin]# ./memcached -u root -m 32 -p 11211 -d -P ./memcache1.pid 

三、在同一个节点上启动多个memcached进程

由于是测试且没有那么多的机子,所以在虚拟机上启动多个memcached进程来模拟memcached分布式。

[plain] view plaincopyprint?

    [root@localhost bin]# ./memcached -u root -m 32 -p 11211 -d -P ./memcache1.pid   

    [root@localhost bin]# ./memcached -u root -m 32 -p 11212 -d -P ./memcache2.pid  

在/usr/local/memcached/bin下在端口11211和11212下分别启动了两个demaon进程。查看是否成功:

[plain] view plaincopyprint?

    [root@localhost bin]# ps -ef | grep "memcache"  

    root      9456     1  0 22:26 ?        00:00:00 ./memcached -u root -m 32 -p 11211 -d -P ./memcache1.pid  

    root      9464     1  0 22:26 ?        00:00:00 ./memcached -u root -m 32 -p 11212 -d -P ./memcache2.pid  

[plain] view plaincopyprint?

    [root@localhost bin]# netstat -lanp | grep "112"  

    tcp        0      0 0.0.0.0:11211               0.0.0.0:*                   LISTEN      9456/memcached        

    tcp        0      0 0.0.0.0:11212               0.0.0.0:*                   LISTEN      9464/memcached        

    tcp        0      0 :::11211                    :::*                        LISTEN      9456/memcached        

    tcp        0      0 :::11212                    :::*                        LISTEN      9464/memcached        

    udp        0      0 0.0.0.0:11211               0.0.0.0:*                               9456/memcached        

    udp        0      0 0.0.0.0:11212               0.0.0.0:*                               9464/memcached        

    udp        0      0 :::11211                    :::*                                    9456/memcached        

    udp        0      0 :::11212                    :::*                                    9464/memcached       

猜你喜欢

转载自nassir.iteye.com/blog/1922843