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
Centos7编译安装memcached
最新推荐文章于 2022-04-27 09:10:11 发布