1. 安装memcached 依赖文件
安装libevent函数库
下载地址:http://libevent.org/old-releases.html
[root@iZm5e7zks238u7wqud0v75Z ~]# cd /opt/src/
[root@iZm5e7zks238u7wqud0v75Z src]# ls
apache-tomcat-7.0.94.tar.gz jdk-7u80-linux-x64.tar.gz libevent-2.0.22-stable.tar.gz memcached-1.6.10.tar.gz
[root@iZm5e7zks238u7wqud0v75Z src]# tar -zxvf libevent-2.0.22-stable.tar.gz -C /opt/
[root@iZm5e7zks238u7wqud0v75Z src]# cd /opt/libevent-2.0.22-stable
[root@iZm5e7zks238u7wqud0v75Z libevent-2.0.22-stable]# ./configure --prefix=/opt/libevent-2.0.22-stable/
[root@iZm5e7zks238u7wqud0v75Z libevent-2.0.22-stable]# make
[root@iZm5e7zks238u7wqud0v75Z libevent-2.0.22-stable]# make install
[root@iZm5e7zks238u7wqud0v75Z libevent-2.0.22-stable]# ln -s /opt/libevent-2.0.22-stable /opt/libevent
[root@iZm5e7zks238u7wqud0v75Z libevent-2.0.22-stable]# echo "/opt/libevent/lib/" > /etc/ld.so.conf.d/libevent.conf
[root@iZm5e7zks238u7wqud0v75Z libevent-2.0.22-stable]# ldconfig
#检查是否安装成功
[root@iZm5e7zks238u7wqud0v75Z libevent-2.0.22-stable]# ls -al /opt/libevent-2.0.22-stable/lib | grep libevent
2.安装memcached
[root@iZm5e7zks238u7wqud0v75Z ~]# cd /opt/src/
[root@iZm5e7zks238u7wqud0v75Z src]# ls
apache-tomcat-7.0.94.tar.gz jdk-7u80-linux-x64.tar.gz libevent-2.0.22-stable.tar.gz memcached-1.6.10.tar.gz
[root@iZm5e7zks238u7wqud0v75Z src]# tar -zxvf memcached-1.6.10.tar.gz -C /opt/
[root@iZm5e7zks238u7wqud0v75Z src]# cd /opt/memcached-1.6.10/
[root@iZm5e7zks238u7wqud0v75Z memcached-1.6.10]# ./configure --prefix=/opt/memcached-1.6.10 --enable-64bit --with-libevent=/opt/libevent
[root@iZm5e7zks238u7wqud0v75Z memcached-1.6.10]# make && make install
[root@iZm5e7zks238u7wqud0v75Z memcached-1.6.10]# ln -sv /opt/memcached-1.6.10/ /opt/memcached
3.启动memcahced
[root@iZm5e7zks238u7wqud0v75Z ~]# /opt/memcached/bin/memcached -d -m 1024 -u root -l 127.0.0.1 -p 11211 -c 1024 -P /tmp/memcached.pid
[root@iZm5e7zks238u7wqud0v75Z ~]# ps -ef | grep memcached
启动参数说明:
-d 选项是启动一个守护进程。
-m 是分配给Memcache使用的内存数量,单位是MB,默认64MB。
-u 是运行Memcache的用户,如果当前为root 的话,需要使用此参数指定用户
-p <num>是设置Memcache的TCP监听的端口,最好是1024以上的端口。
-c 选项是最大运行的并发连接数,默认是1024。
-P <file> 是设置保存Memcache的pid文件
网友评论