wuliws 发表于 2018-12-25 07:23:21

linux服务之memcached

  系统环境:
# cat /etc/redhat-release
CentOS release 6.5 (Final)
#uname -a
Linux memcached 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
# lsb_release -a
LSB Version:    :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: CentOS
Description:    CentOS release 6.5 (Final)
Release:    6.5
Codename:   Final  开始安装:
# yum -y install libevent-devel
# mkdir soft
# cd soft
# wget http://www.memcached.org/files/memcached-1.4.17.tar.gz
# cd memcached-1.4.17
# ./configure --prefix=/usr/local/memcached
# make -j2 && make install
# cd /usr/local/memcached/bin/
# ./memcached -d -u root -m 1024-p 11211 -c 500
# netstat -tulnpan|grep memcached
tcp      0      0 0.0.0.0:11211               0.0.0.0:*                   LISTEN      5797/./memcached   
tcp      0      0 :::11211                  :::*                        LISTEN      5797/./memcached   
udp      0      0 0.0.0.0:11211               0.0.0.0:*                               5797/./memcached   
udp      0      0 :::11211                  :::*                                    5797/./memcached
# vim /etc/init.d/memcached
# chmod +x /etc/init.d/memcached
#!/bin/bash
# chkconfig: 2345 96 14
# description: shell init script for Linux.
# created by nowsafe
. /etc/init.d/functions
source /etc/bashrc
source /etc/profile
start() {
/usr/local/memcached/bin/memcached -d -u root -m 1024-p 11211 -c 500 >> /dev/null
echo "start"
}
stop() {
killall memcached >> /dev/null
echo "stop"
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
version)
exec$1
;;
*)
echo $"Usage: $0 {start|stop|restart|version}"
exit 1
esac
# netstat -tulnpan |grep mem
tcp      0      0 0.0.0.0:11211               0.0.0.0:*                   LISTEN      5892/memcached   
tcp      0      0 :::11211                  :::*                        LISTEN      5892/memcached   
udp      0      0 0.0.0.0:11211               0.0.0.0:*                               5892/memcached   
udp      0      0 :::11211                  :::*                                    5892/memcached   
# /etc/init.d/memcached stop
Terminated
# netstat -tulnpan |grep mem
#
# chkconfig memcached on  




页: [1]
查看完整版本: linux服务之memcached