Install memcache perfectly on Linux (including self-starting memcache)

Source: Internet
Author: User
Install memcache perfectly on Linux (including self-starting) 1. install the dependent Library libevent1. go to the/usr/lib directory and run the command: ls-allibevent to check whether memcache is installed, if the version is already installed and earlier than 2.0.21, uninstall it through: rpm-elibevent & mdash; nodeps. 2 .. install memcache perfectly on Linux (including self-starting)

1. install the dependent Library libevent
1. go to the/usr/lib directory and run the command: ls-al libevent to check whether it has been installed. if the installed version is earlier than 2.0.21, run: rpm-e libevent-nodeps to uninstall it.
2. Upload libevent-2.0.21-stable.tar.gz to a non-usr Directory (because libevent will be installed in the usr directory, you 'd better store the installation file in another directory, such as/home) and decompress the package.

3. switch to the decompressed libevent home directory: cd libevent-2.0.21-stable
4. execute the following commands in sequence:
1)./configure-prefix =/usr (or./configure -- program-prefix =/usr)
2) make
3) make install
Note:
1) the root permission may be required for executing make install.
2) the libevent will be installed under/usr/lib.
5. test whether the libevent is successfully installed: ls-al/usr/lib | grep libevent. if a similar result is displayed, the installation is successful:



6. sometimes, the libevent will be installed in the/usr/local/lib Directory (installed in this directory by default). In this case, in addition to the steps 1-5, you also need to establish a soft connection from the libevent-2.0.so.5 to/usr/lib so that other programs can find the libevent Library:
Ln-s/usr/local/lib/libevent-2.0.so.5/usr/lib/libevent-2.0.so.5
7. create a link to the 64-bit database on the 64-bit machine. Otherwise, the error message "libevent cannot be found" will be reported during memcache running.
Ln-s/usr/lib/libevent-2.0.so.5/usr/lib64/libevent-2.0.so.5

II. install memcache (source code installation)
1. Upload memcached-1.4.15.tar.gz to a non-usr Directory (because the memcached-1.4.15 will install to the usr directory, it is best to change the directory to store the installation file, such as/home), and decompress.
2. switch to the decompressed memcache home directory: cd memcached-1.4.15
3. execute the following commands in sequence:
1)./configure-prefix =/usr/local/memcached -- with-libevent =/usr
2) make
3) make install

Note:
1) the root permission may be required for executing make install.
2) memcache will be installed under/usr/local/memcached
III. install memcache (installation package)-to be supplemented
4. configure as self-starting service
1. Compile the memcached self-start script or directly use the script in the memcached installation package (the location is as follows. This article uses the script that comes with the official website)
 
2. modify the self-launch script (marked in red, Chinese comments are only available in this article, and the installation package does not exist)

#! /Bin/sh
#
# Chkconfig:-55 45
# 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
# Maximum number of connections, which can be modified as needed
MAXCONN = 1024
# Maximum memory size, in MB
CACHESIZE = 128
OPTIONS = ""

If [-f/etc/sysconfig/memcached]; then
./Etc/sysconfig/memcached
Fi

# Check that networking is 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. 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. pid
Fi
}

Restart (){
Stop
Start
}


# See how we were called.
Case "$1" in
Start)
Start
;;
Stop)
Stop
;;
Status)
Status memcached
;;
Restart | reload)
Restart
;;
Condrestart)
[-F/var/lock/subsys/memcached] & restart |:
;;
*)
Echo $ "Usage: $0 {start | stop | status | restart | reload | condrestart }"
Exit 1
Esac

Exit $?

Shell> cp memcached. sysv/etc/init. d/memcached3. run the script cp to/etc/init. d directory and rename it memcached, and then execute chmod a + x memcached, as shown below:
Shell> chmod 755/etc/init. d/memcached

4. add memcached to the system service:
Shell> chkconfig -- add memcached
Shell> chkconfig memcached on
5. run memcached as a Service
Shell> service memcached start
If the above is successful, restart the system and check whether memcached has been started with the system.
Related Article

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.