Notice: register_sidebar的调用方法不正确。“边栏1”侧边栏的参数数组中未设置id,缺省为“sidebar-1”。要消除此通知并保持现有的侧边栏内容,请手动将id设置为“sidebar-1”。 请查阅调试WordPress来获取更多信息。 (这个消息是在4.2.0版本添加的。) in /data/htdocs/seven2_blog/wp-includes/functions.php on line 3838
编译安装 Memcached | Seventwo Blog
Warning: Parameter 1 to wp_default_scripts() expected to be a reference, value given in /data/htdocs/seven2_blog/wp-includes/plugin.php on line 601

编译安装 Memcached

2014-11-17 | 分类: CentOS

1、准备文件

cd /data/src
wget wget http://memcached.org/latest

libeven官网 http://libevent.org/
wget https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz

2、安装libevent

tar zxvf libevent-2.0.21-stable.tar.gz
cd libevent-2.0.21-stable
//用./configure命令进行配置,检查当前的环境
./configure --prefix=/data/apps/libs
make
make install


3、安装Memcached

tar -zxvf memcached-1.4.21.tar.gz
cd memcached-1.4.21
./configure --prefix=/data/apps/memcached  --with-libevent=/data/apps/libs
make
make install

4、验证安装

 /usr/local/bin | grep memcached

5、启动Memcached

ln -s /data/apps/libs/libevent-2.0.so.5 /lib64/libevent-2.0.so.5
/data/apps/memcached/bin/memcached -d -m 128 -c 128 -p 11211 -u root -t 10 -l 192.168.0.200
-d选项是启动一个守护进程;
-m是分配给Memcached使用的内存数量,单位是MB,我这里是128MB;
-u是运行Memcached的用户,我这里是root;
-l是监听的服务器IP地址,如果有多个地址的话,我这里指定了服务器的IP地址192.168.0.200;
-p是设置Memcached监听的端口,我这里设置了12000,最好是1024以上的端口;
-c选项是最大运行的并发连接数,默认是1024,我这里设置了128,按照你服务器的负载量来设定;
-P是设置保存Memcached的pid文件,我这里是保存在 /tmp/memcached.pid;
-t 指定进程数,默认是4;

6 Memcached启动停止脚本
vi /etc/rc.d/init.d/memcached

内容如下:

#!/bin/sh 
# 
# memcached: MemCached Daemon 
# 
# chkconfig: - 90 25 
# description: MemCached Daemon 
# 
# Source function library. 
. /etc/rc.d/init.d/functions 
. /etc/sysconfig/network 
#[ ${NETWORKING} = "no" ] && exit 0 
#[ -r /etc/sysconfig/dund ] || exit 0 
#. /etc/sysconfig/dund 
#[ -z "$DUNDARGS" ] && exit 0 
start() 
{ 
echo -n $"Starting memcached: "

daemon $MEMCACHED -u daemon -d -m 1024 -p 11211

echo 
} 
stop() 
{ 
echo -n $"Shutting down memcached: " 
killproc memcached 
echo 
}

MEMCACHED="/data/apps/memcached/bin/memcached"

[ -f $MEMCACHED ] || exit 1 
# See how we were called. 
case "$1" in 
start) 
start 
;; 
stop) 
stop 
;; 
restart) 
stop 
sleep 3 
start 
;; 
*) 
echo $"Usage: $0 {start|stop|restart}" 
exit 1 
esac 
exit 0

然后执行如下命令:

chmod 755 /etc/rc.d/init.d/memcached

chkconfig  --add memcached 

chkconfig  --level 235  memcached  on

chkconfig  --list | grep mem

建议:最好使用chkconfig --level 235 memcached on 这样的话与apache级别相同,
即只要有apache,就有memcached
标签: