Installing Memcache on your VPS

To install memcached on a WE VPS the following steps should be performed.

1. Download libevent-1.4.14b-owlx1.i386.rpm and memcached-1.4.5-owlx1.i386.rpm

Note: The version and release can be different, but the point is that only two files are required.

lftpget https://www.webenabled.com/download/owl-packages/libevent-1.4.14b-owlx1.i686.rpm
lftpget https://www.webenabled.com/download/owl-packages/memcached-1.4.5-owlx1.i686.rpm
2. Install the packages
$ rpm -Uvh libevent-1.4.14b-owlx1.i386.rpm memcached-1.4.5-owlx1.i386.rpm'
3. Review and customize /etc/sysconfig/memcached file

Add your own settings as needed.

4a. If just one instance is needed

Issue the following commands to start the daemon and enable it in the startup scripts (this should be performed under the root account).

$ service memcached start
$ chkconfig memcached on
4b. it also possible to start an instance from a non-privileged account

Copy /etc/sysconfig/memcached to ~/.memcachedrc, then by executing 'service memcached start' under the non-privileged account (the startup script will pick config parameters from /etc/sysconfig/memcached first, then will read ~/.memcachedrc), and finally, if automatic startup is required one can created a crontab entry like the following.

$ cp /etc/sysconfig/memcached to ~/.memcachedrc
$ /sbin/service memcached start
4c. There is also an option to use Vsevolod's memcmgr to manage multiple instances of memcached, but this manager wasn't packaged yet.

Update coming soon.

Example session installing and starting memcache

Below is a transcript of my test session on the Owl 2.0-stable system:

sh-3.1# su - sources
we-pkg-testing!sources:~$ lftp packages.webenabled.biz/pub/i386
cd ok, cwd=/pub/i386
lftp packages.webenabled.biz:/pub/i386> mget libevent-1.4.14b-owlx1.i386.rpm memcached-1.4.5-owlx1.i386.rpm
212490 bytes transferred
Total 2 files transferred
lftp packages.webenabled.biz:/pub/i386> exit
we-pkg-testing!sources:~$ logout
sh-3.1# rpm -Uvh ~sources/libevent-1.4.14b-owlx1.i386.rpm ~sources/memcached-1.4.5-owlx1.i386.rpm
Preparing... ########################################### [100%]
1:libevent ########################################### [ 50%]
Updating '/etc/ld.so.conf.d/libevent.conf' ... done
2:memcached ########################################### [100%]
Adding the _mcached account ... done
sh-3.1# chkconfig --list memcached
memcached 0:off 1:off 2:off 3:off 4:off 5:off 6:off
sh-3.1# service memcached start
Starting memcached
sh-3.1# echo $?
0
sh-3.1# service memcached status
memcached is running
sh-3.1# netstat -lpn --ip | fgrep memcached
tcp 0 0 127.0.0.1:11211 0.0.0.0:* LISTEN 19910/memcached
udp 0 0 127.0.0.1:11211 0.0.0.0:* 19910/memcached
sh-3.1# service memcached stop
Stopping memcached
sh-3.1# netstat -lpn --ip | fgrep memcached
sh-3.1# service memcached status
memcached is stopped
sh-3.1# chkconfig memcached on
sh-3.1# chkconfig --list memcached
memcached 0:off 1:off 2:on 3:on 4:on 5:on 6:off
sh-3.1# service memcached start
Starting memcached
sh-3.1# rpm -e libevent memcached
memcached is running, stopping ... stopped
Updating '/etc/ld.so.conf.d/libevent.conf' ... removed
sh-3.1#