Install Memcache__linux on Linux

Source: Internet
Author: User
First, install dependent library libevent

1. Enter the/usr/lib directory, use the command: Ls-al libevent to see if the installation, if installed and version less than 2.0.21, first through: Rpm-e libevent-nodeps to uninstall.

2. Upload libevent-2.0.21-stable.tar.gz to non-USR directory (because libevent will be installed to the USR directory, so it is best to change the directory to store the installation files, such as/home), and then extract.

3. Switch to the extracted libevent home directory: CD libevent-2.0.21-stable

4. Execute sequentially:

1)./CONFIGURE-PREFIX=/USR (or./configure--program-prefix=/usr)

2) Make

3) make install

Attention:

1 You may need root permission to perform make install.

2) Libevent will be installed under/usr/lib

5. Test Libevent Whether the installation is successful: Ls-al/usr/lib|grep libevent appears similar to the following figure results indicate installation success:

6. Sometimes, Libevent will be installed in the directory to/usr/local/lib (installed by default installation to this directory), in this case in addition to the 1-5 step operation, also need to establish libevent-2.0.so.5 to/usr/lib soft connection, This allows other programs to run to find the Libevent library:

Ln–s/usr/local/lib/libevent-2.0.so.5/usr/lib/libevent-2.0.so.5

7. On the 64-bit machine also need to do a 64-bit library link, otherwise run memcache will be reported to find libevent error

Ln-s/usr/lib/libevent-2.0.so.5/usr/lib64/libevent-2.0.so.5 II, installation memcache (source code installation)

1. Upload memcached-1.4.15.tar.gz to non-USR directory (because memcached-1.4.15 will be installed to the USR directory, so it is best to change the directory to store the installation files, such as/home), and then extract.

2. Switch to the extracted memcache home directory: CD memcached-1.4.15

3. Execute sequentially:

1)./configure-prefix=/usr/local/memcached--with-libevent=/usr

2) Make

3) make install

Attention:

1 You may need root permission to perform make install.

2) Memcache will be installed to/usr/local/memcached the next three, configured to start the service

1. Write memcached from the startup script or use the script directly in the Memcached installation package (the location is as follows, this article uses the official script)
\memcached-1.4.20\scripts\memcached.sysv

2. Modify the self-startup script

Modify the Memcached.sysv file and change it to memcached file modifications are as follows:

#!
/BIN/SH # chkconfig:-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 #. /lib/lsb/init-functions port=11211 user=root #最大连接数, modify maxconn=1024 #最大内存量 according to actual requirements, Unit m cachesize=128 options= "" If [-f/et C/sysconfig/memcached];then.
/etc/sysconfig/memcached fi # Check that networking are up.  If ["$NETWORKING" = "no"] then Exit 0 fi retval=0 prog= "memcached" Start () {echo-n $ "starting $prog:" # Insure that/usr/local/memcached has proper permissions chown $USER/usr/local/memcached/usr/local/memcached/bin
    /memcached-d-P $PORT-u $USER-M $CACHESIZE-C $MAXCONN-P/usr/local/memcached/memcached.pid $OPTIONS retval=$?
    echo [$RETVAL-eq 0] && touch/var/lock/subsys/memcached} stop () {echo-n $ "stopping $prog:" Killproc mEmcached retval=$? echo if [$RETVAL-eq 0];
    Then rm-f/var/lock/subsys/memcached rm-f/usr/local/memcached/memcached.pid fi} restart () {
Stop start} # How we were called.
    Case "in Start" start;;
    stop) stop;;
    status) status memcached;;
    restart|reload) restart;; Condrestart) [-f/var/lock/subsys/memcached] && Restart | |
    :
    ;; * echo $ "Usage: $ {Start|stop|status|restart|reload|condrestart}" Exit 1 Esac exit $?

Basically these are the direct paste can be, but still contrast with a few changes in the path and parameters

3. Place this script CP into the/ETC/INIT.D directory and rename it to memcached, then execute chmod a+x memcached as follows:

Shell > CP memcached.sysv/etc/init.d/memcached

Shell > Chmod 755/etc/init.d/memcached

4. Add memcached to System services:

Shell > Chkconfig--add memcached

Shell > Chkconfig memcached on

5. Run memcached in service mode
Shell > Service memcached Start

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.