Linux下的Memcache安装

Linux下的Memcache安装
 

Linux下Memcache主要是安装memcache服务器端,libevent的最新版本是libevent-1.3

 

下载地址

官网:http://www.monkey.org/~provos/libevent/

下载:http://www.monkey.org/~provos/libevent-1.3.tar.gz

 

1.先安装libevent在配置时需要指定libevent一个安装路径,即./configure –prefix=/usr;然后make;然后make install;

2.安装memcached,只是需要在配置时需要指定libevent的安装路径即./configure –with-libevent=/usr;然后make&&make install;

这样就完成了Linux下Memcache服务器端的安装。

详细的方法如下:

1.分别下载memcached和libevent tar包,ftp传到 /LinuxCached/目录下:

[root@servyou_web ]# cd /LinuxCached/

 

2.先安装libevent准备:

首先卸载系统自带libevent

[root@servyou_web]# rpm -e --nodeps --allmatches libevent-1.1a-3.2.1*

[root@servyou_web]# rpm -e --nodeps --allmatches libevent-devel-1.1a-3.2.1

3.解压并编译安装下载好的libevent

[root@servyou_web LinuxCached]# tar  -zxvf libevent-2.0.11-stable.tar.gz

[root@servyou_web LinuxCached]# cd libevent-2.0.11-stable

[root@servyou_web LinuxCached]#  ./configure –prefix=/usr

[root@servyou_web LinuxCached]#  make &&  make   install

 

4.测试libevent是否安装成功:

[root@servyou_web LinuxCached]# ls -al /usr/lib | grep libevent

lrwxrwxrwx   1 root root          22 05-10 18:09 libevent-1.1a.so.1 -> libevent-1.1a.so.1.0.2

-rwxr-xr-x    1 root root       31736 2006-07-13 libevent-1.1a.so.1.0.2

lrwxrwxrwx   1 root root          21 05-10 17:58 libevent-2.0.so.5 -> libevent-2.0.so.5.1.0

-rwxr-xr-x    1 root root      946738 05-10 17:58 libevent-2.0.so.5.1.0

-rw-r--r--     1 root root       39928 2006-07-13 libevent.a

lrwxrwxrwx   1 root root          26 05-10 17:58 libevent_core-2.0.so.5 -> libevent_core-2.0.so.5.1.0

-rwxr-xr-x    1 root root      555307 05-10 17:58 libevent_core-2.0.so.5.1.0

-rw-r--r--     1 root root      930310 05-10 17:58 libevent_core.a

-rwxr-xr-x    1 root root         971 05-10 17:58 libevent_core.la

lrwxrwxrwx   1 root root          26 05-10 17:58 libevent_core.so -> libevent_core-2.0.so.5.1.0

lrwxrwxrwx   1 root root          27 05-10 17:58 libevent_extra-2.0.so.5 -> libevent_extra-2.0.so.5.1.0

-rwxr-xr-x    1 root root      413593 05-10 17:58 libevent_extra-2.0.so.5.1.0

-rw-r--r--     1 root root      610874 05-10 17:58 libevent_extra.a

-rwxr-xr-x    1 root root         978 05-10 17:58 libevent_extra.la

lrwxrwxrwx   1 root root          27 05-10 17:58 libevent_extra.so -> libevent_extra-2.0.so.5.1.0

-rwxr-xr-x    1 root root         936 05-10 17:58 libevent.la

lrwxrwxrwx   1 root root          29 05-10 17:58 libevent_openssl-2.0.so.5 -> libevent_openssl-2.0.so.5.1.0

-rwxr-xr-x    1 root root       85523 05-10 17:58 libevent_openssl-2.0.so.5.1.0

-rw-r--r--     1 root root      120644 05-10 17:58 libevent_openssl.a

-rwxr-xr-x    1 root root        1007 05-10 17:58 libevent_openssl.la

lrwxrwxrwx   1 root root          29 05-10 17:58 libevent_openssl.so -> libevent_openssl-2.0.so.5.1.0

lrwxrwxrwx   1 root root          30 05-10 17:58 libevent_pthreads-2.0.so.5 -> libevent_pthreads-2.0.so.5.1.0

-rwxr-xr-x    1 root root       18086 05-10 17:58 libevent_pthreads-2.0.so.5.1.0

-rw-r--r--     1 root root       18678 05-10 17:58 libevent_pthreads.a

-rwxr-xr-x    1 root root         999 05-10 17:58 libevent_pthreads.la

lrwxrwxrwx   1 root root          30 05-10 17:58 libevent_pthreads.so -> libevent_pthreads-2.0.so.5.1.0

lrwxrwxrwx   1 root root          22 05-10 18:09 libevent.so -> libevent-1.1a.so.1.0.2

 

5.安装memcached,同时需要安装中指定libevent的安装位置:

 [root@servyou_web ]# tar  zxvf memcached-1.4.5.tar.gz

# cd memcached-1.2.0

# ./configure –with-libevent=/usr

# make

# make install

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

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

 

测试是否成功安装memcached:

[root@servyou_web LinuxCached]#  ls -al /usr/local/bin/mem*

-rwxr-xr-x 1 root root 249785 05-10 18:09 /usr/local/bin/memcached

 

7.memcached的基本设置:

1.启动Memcache的服务器端:

/usr/local/bin/memcached -d -m 100 -u root -l 192.168.70.178 -p 12000 -c 512 -P /MEMPID/ memcached.pid

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

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

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

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

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

-c选项是最大运行的并发连接数,默认是1024,此次512,按照服务器的负载量来设定,

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

 

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

 

# kill ‘cat MEMPID/ memcached.pid’

 

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

你可能感兴趣的:(linux,Web,memcached,服务器,测试,kill)