这篇文档描述的是在linux环境下安装部署memcached服务
操作系统:
Red Hat Enterprise Linux Server release 5.4 (Tikanga)
内存:4G
1.验证gcc是否安装命令行执行gcc -v 看是否输出gcc版本信息,如果没有,则需要通知运维人员安装
附:gcc正常安装时的输出
[root@TYFFHOP01 bin]# gcc -v
Using built-in specs.
Target: x86_64-RedHat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,Java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=x86_64-redhat-linux
Thread model: posix
gcc version 4.1.2 20080704 (Red Hat 4.1.2-46)
[root@TYFFHOP01 bin]#
2.下载memcached的源码包 3.下载libevent包 4.解压memcached和libevent包将memcached-1.4.12.tar.gz 和libevent-2.0.16-stable.tar.gz包上传到服务器上
如/home/kevin/software/
命令行切换到该目录下分别运行
tar -zxvf memcached-1.4.12.tar.gz
tar -zxvf ibevent-2.0.16-stable.tar.gz
将两个压缩包解压
命令行进入解压后的libevent目录/home/kevin/software/libevent-2.0.16-stable
依次运行以下运行命令:
./configure --prefix=/usr/
make
make install #(注意运行该命令的用户必须有安装软件的权限-申请root用户)
验证安装
ls /usr/lib |grep libevent
如果安装正确,会有输出
libevent-2.0.so.5
libevent-2.0.so.5.1.4
libevent.a
libevent_core-2.0.so.5
libevent_core-2.0.so.5.1.4
libevent_core.a
libevent_core.la
libevent_core.so
libevent_extra-2.0.so.5
libevent_extra-2.0.so.5.1.4
libevent_extra.a
libevent_extra.la
libevent_extra.so
libevent.la
libevent_pthreads-2.0.so.5
libevent_pthreads-2.0.so.5.1.4
libevent_pthreads.a
libevent_pthreads.la
libevent_pthreads.so
libevent.so
切换到memcached解压目录
cd /home/kevin/software/memcached-1.4.12
依次执行以下命令
./configure --prefix=/usr/local/memcached --with-libevent=/usr/
make
make install
验证memcached是否安装成功
ls -al /usr/local/memcached/bin
提示:
[root@TYFFHOP01 memcached-1.4.12]# ls -al /usr/local/memcached/bin
total 296
drwxr-xr-x 2 root root 4096 Feb 2 14:07 .
drwxr-xr-x 5 root root 4096 Feb 2 14:07 ..
-rwxr-xr-x 1 root root 288370 Feb 2 14:07 memcached
cd /usr/local/memcached/bin
./memcached -d -m 3072
7.其他查看memcached进程
ps -e|grep memcache
memcached启动参数
-d选项是启动一个守护进程,
-m是分配给Memcache使用的内存数量,单位是MB,这里是3072MB(3G),
-u是运行Memcache的用户,这里是kevin,
-l是监听的服务器IP地址
-p是设置Memcache监听的端口,默认不指定为11211,最好是1024以上的端口
-c选项是最大运行的并发连接数,默认是1024,按照你服务器的负载量来设定。
-P是设置保存Memcache的pid文件,我这里是保存在/tmp/memcached.pid