码迷,mamicode.com
首页 > 系统相关 > 详细

【转】Memcached安装

时间:2016-11-19 12:51:55      阅读:290      评论:0      收藏:0      [点我收藏+]

标签:编写   etc   需要   负载   software   local   .gz   允许   select   

 

 

解析:Memcached是什么?

Memcached是由Danga Interactive开发的,高性能的,分布式的内存对象缓存系统,用于在动态应用中减少数据库负载,提升访问速度。

一、软件版本
    libevent 稳定版
wget http://monkey.org/~provos/libevent-1.4.14b-stable.tar.gz

    memcached 稳定版
wget  http://memcached.googlecode.com/files/memcached-1.4.5.tar.gz

二、软件安装
    Libevent安装
[root@jw-test01 software]# tar zxvf libevent-1.4.14b-stable.tar.gz
[root@jw-test01 software]# cd libevent-1.4.14b-stable
[root@jw-test01 libevent]# ./configure --prefix=/usr/local/libevent/
[root@jw-test01 libevent]# make
[root@jw-test01 libevent]# make install

  Memcached安装
[root@jw-test01 software]# tar -zxvf memcached-1.4.5.tar.gz
[root@jw-test01 software]# cd memcached-1.4.5
[root@jw-test01 memcached]# ./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent/
[root@jw-test01 memcached]# make
[root@jw-test01 memcached]# make install

三、编写Memcached启动脚本
#!/bin/bash
# author:kuangl
# date:2013-05-30
# description: Starts and stops the Memcached services.
# pidfile: /tmp/memcached1.pid
# config:  /usr/local/memcached
# chkconfig: - 55 45
# source function library
. /etc/rc.d/init.d/functions
memcached="/usr/local/memcached/bin/memcached"
[ -e $memcached ] || exit 1
start()
{
echo "Starting memcached:"
daemon $memcached -d -m 1000 -u root -l 127.0.0.1 -p 11211 -c 1500 -P /tmp/memcached1.pid
}
stop()
{
echo "Shutting down memcached"
killproc memcached
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 3
start
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
exit $?

四、将脚本复制到init.d目录下
[root@jw-test01 scripts]# cp memcached.sh /etc/init.d/memcached

五、将memcached加入系统启项
[root@jw-test01 scripts]# chkconfig  --add memcached
[root@jw-test01 scripts]# chkconfig --level 35 memcached on

六、启动memcached
[root@jw-test01 scripts]# service memcached restart
Shutting down memcached      [确定]
Starting memcached:          [确定]
[root@jw-test01 scripts]# ps -ef |grep memcached
root    27616    1  0 22:18 ?        00:00:00 /usr/local/memcached/bin/memcached -d -m 1000 -u root -l 127.0.0.1 -p 11211 -c 1500 -P /tmp/memcached1.pid

七、Memcached常用参数

 

参数 说明
-p <num> 设置端口号(默认不设置为: 11211)
-U <num> UDP监听端口(默认: 11211, 0 时关闭)
-l <ip_addr> 绑定地址(默认:所有都允许,无论内外网或者本机更换IP,有安全隐患,若设置为127.0.0.1就只能本机访问)
-d 独立进程运行
-u <username> 绑定使用指定用于运行进程<username>
-m <num> 允许最大内存用量,单位M (默认: 64 MB)
-P <file> PID写入文件<file>,这样可以使得后边进行快速进程终止, 需要与-d 一起使用
错误信息:
/usr/local/memcacheq/bin/memcacheq: error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such file or directory
 
查找链接包 :
LD_DEBUG=libs /usr/local/memcacheq/bin/memcacheq -v | grep libevent
     27382: find library=libm.so.6 [0]; searching
     27382: search cache=/etc/ld.so.cache
     27382:  trying file=/lib64/libm.so.6
     27382:
     27382: find library=libdb-4.7.so [0]; searching
     27382: search cache=/etc/ld.so.cache
     27382:  trying file=/lib64/libdb-4.7.so
     27382:
     27382: find library=libevent-2.0.so.5 [0]; searching
     27382: search cache=/etc/ld.so.cache
     27382: search path=/lib64/tls/x86_64:/lib64/tls:/lib64/x86_64:/lib64:/usr/lib64/tls/x86_64:/usr/lib64/tls:/usr/lib64/x86_64:/usr/lib64 (system search path)
     27382:  trying file=/lib64/tls/x86_64/libevent-2.0.so.5
     27382:  trying file=/lib64/tls/libevent-2.0.so.5
     27382:  trying file=/lib64/x86_64/libevent-2.0.so.5
     27382:  trying file=/lib64/libevent-2.0.so.5
     27382:  trying file=/usr/lib64/tls/x86_64/libevent-2.0.so.5
     27382:  trying file=/usr/lib64/tls/libevent-2.0.so.5
     27382:  trying file=/usr/lib64/x86_64/libevent-2.0.so.5
     27382:  trying file=/usr/lib64/libevent-2.0.so.5
     27382:
建立 链接 :
sudo ln -s /usr/lib/libevent-2.0.so.5.1.7 /lib64/libevent-2.0.so.5

【转】Memcached安装

标签:编写   etc   需要   负载   software   local   .gz   允许   select   

原文地址:http://www.cnblogs.com/dsc65749924/p/6080233.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!