linux操作系统-memcache安装

安装配置

1. 安装libevent

# tar zxf libevent-1.4.6-stable.tar.gz
# cd libevent-1.4.6-stable
# ./configure
# make && make install

2. 安装memcached

# tar zxvf memcached-1.2.6.tar.gz
# cd memcached-1.2.6
# ./configure --prefix=/usr/local/memcached-1.2.6
# make && make install

3. 运行memcached

# /usr/local/memcached-1.2.6/bin/memcached -d -m 128 -l localhost -p 11211 -u root
参数说明:

-d 以守护程序(daemon)方式运行 memcached;
-m 设置 memcached 可以使用的内存大小,单位为 M;
-l 设置监听的 IP 地址,如果是本机的话,通常可以不设置此参数;
-p 设置监听的端口,默认为 11211,所以也可以不设置此参数;
-u 指定用户;

4.设置memcache开机自启动

#!/bin/sh   
#   
# memcached:    MemCached Daemon   
#   
# chkconfig:    - 90 25    
# description:  MemCached Daemon   
#   
# Source function library.   
. /etc/rc.d/init.d/functions
. /etc/sysconfig/network
    
start()
{
        echo -n $"Starting memcached: "
        daemon /usr/local/bin/memcached -u daemon -d -m 4096 -l 10.10.10.220 -p 58728
        echo
}   

stop()
{
        echo -n $"Shutting down memcached: "
        killproc memcached
        echo
}   
    
[ -f /usr/local/bin/memcached ] || exit 0

# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart|reload)
        stop
        start
        ;;
  condrestart)
        stop
        start
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart|reload|condrestart}"
        exit 1
esac
exit 0

chmod +x /etc/init.d/memcached
chkconfig --level 2345 memcached on
service memcached start

 

你可能感兴趣的:(linux操作系统-memcache安装)