Centos7编译安装memcached

http://libevent.org/ 下载地址
http://www.memcached.org/  下载地址

tar -xf libevent-2.1.10-stable.tar.gz 			安装必要的依赖
cd libevent-2.1.10-stable/
./configure -prefix=/usr/local/libevent
make && make install
cd
tar -xf memcached-1.5.16.tar.gz 
cd memcached-1.5.16/
./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent
make && make install
ln -s  /usr/local/memcached/bin/memcached /usr/local/bin/
vim /etc/init.d/memcached										做服务脚本
		#! /bin/sh
		# chkconfig: 12345 80 90
		# description:  The memcached daemon is a network memory cache service.
		# processname: memcached
		# config: /etc/sysconfig/memcached
		# Source function library - for other linux
		#. /etc/rc.d/init.d/functions
		# Source function library - for suse linux
		ip="0.0.0.0"
		port="11211"
		username="root"
		max_memory=64
		max_connection=1024
		# Check that networking is up.
		if [ "$NETWORKING" = "no" ]
		then
				exit 0
		fi
		RETVAL=0
		prog="memcached"
		pidfile=/tmp/memcached.pid
		basedir=/usr/local/memcached
		cmd=${basedir}/bin/memcached
		start () {
			 	echo -n $"Starting service:$prog "
				chown $username $basedir
				$cmd -d -p $port -u $username  -m $max_memory -c $max_connection -P $pidfile $OPTIONS
				RETVAL=$?
				echo
				[ $RETVAL -eq 0 ] && touch /var/lock/subsys/memcached
				return $retval
		}
		stop() {
				echo -n $"Stopping service: $prog  "
				current_user=$(whoami)
				pidlist=$(ps -ef | grep $current_user | grep memcached | grep -v grep | awk '{print $2}')
				for pid in $pidlist ; do
				        kill -9 $pid
				        if [ $? -ne 0 ]; then
				           return 1
				        fi
				done
				RETVAL=$?
				echo
				[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/memcached
		}
		case "$1" in
				  start)
				  		start
				  ;;
				  stop)
						stop
				  ;;
				  status)
				  		status memcached
				  ;;
				  restart)
				 		 stop
				 		 start	
				  ;;
				  *)
				  echo $"Usage: $0 {start|stop|status|restart}"
				  exit 1
		  esac
	      exit $?
chmod a+x /etc/init.d/memcached
systemctl daemon-reload
systemctl start memcached
chkconfig --add memcached
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值