Memcached installation script (with server self-booting)

Source: Internet
Author: User
Tags memcached

First, the purpose

To simplify the memcached rapid installation deployment, and add to the service startup item, boot up.

Second, the script

2.1 GitHub Address
GitHub links
2.2 Script Content

#!/bin/bash#mail:[email protected] #function: Auto Install Memcachedclearecho "###############################                                 ########### "echo" # Auto Install Memcached-1.4 # # "echo" # Press Ctrl + C to cancel # # "echo" # any key to continue # # "echo" ######## ################################## "Read-n 1softdir="/software "memcached_url=" http://www.danga.com/memcached/ Dist/memcached-1.4.0.tar.gz "Libevent_url=" https://github.com/libevent/libevent/releases/download/ Release-2.1.8-stable/libevent-2.1.8-stable.tar.gz "sys_version=$ (rpm-q centos-release|cut-d--f3) Sys_init () {[-F/ Etc/init.d/functions] &&.  /etc/init.d/functions[${sys_version}! = "6"] && echo "Please use centos6.x" && exit 1[$ (id-u)! = "0"] && echo "Error:you must is root to run this script" && exit 1sed-i "s/selinux=enforcing/selinux=disable d/"/etc/selinux/configsetenforce 0yum INstall-y gcc gcc-c++ wget}download_software () {if [!-D ${softdir}];then mkdir ${softdir} && CD ${softdir}el SE cd ${softdir}fifor software_url in ${memcached_url} ${libevent_url}do wget-c ${software_url} If [$?-eq 0]; Then for software in ' ls ' do tar zxf $software-c/tmp done Fidone}install () {cd/tmp/l Ibevent-2.1.8-stable./configure--prefix=/usr/local/libeventmake && Make installrm-rf/tmp/ libevent-2.1.8-stable echo "/usr/local/libevent/lib" >/etc/ld.so.conf.d/libevent.confldconfigcd/tmp/ Memcached-1.4.0./configure--with-libevent=/usr/local/libevent--prefix=/usr/local/memcachedmake && make Installrm-rf/tmp/memcached-1.4.0echo "Export path= $PATH:/usr/local/memcached/bin" >/etc/profile.d/memcached.sh && Source/etc/profile.d/memcached.sh}start_server () {Cat >/etc/init.d/memcached-server<<eof#!/ bin/bash#auth:kaliarch# memcached Startup script for memcached processes## chkconfig:-10# Description:memcache provides fast memory based storage.# processname:memcached. /etc/rc.d/init.d/functionsmemcached= "/usr/local/memcached/bin/memcached" prog= "memcached" port=11211user= nobodymem=20lockfile=\${lockfile-/var/lock/subsys/memcached}pidfile=\${pidfile-/tmp/memcached.pid}getpid=\$ ( Pidof memcached) Start () {action $ "starting \ $prog:"/bin/true # starting memcached with 64MB memory on port 11211    As Deamon and user nobody \ $memcached-D-m \ $mem-p \ $port-u \ $user-P \${pidfile} retval=$? [\ $RETVAL = 0] && touch \${lockfile} return \ $RETVAL}stop () {if test "x\${getpid}"! = x; then ACTI    On $ "stopping \ $prog"/bin/true killall memcached fi retval=\$? [\ $RETVAL = 0] && rm-rf \${lockfile} \${pidfile} return \ $RETVAL}case "\$1" in Start) star        t;;        stop) stop;;            Status) status-p \${pidfile} \${memcached} retval=\$? ;;        restart) stop start;; Condrestart) if test "x\${getpid}"! = x;        Then stop start fi;; *) echo $ "Usage: \$0 {start|status|stop|restart|condrestart}" exit 1esacexit \${retval}eofcd/chmod +x/etc/init.d/memcached-serverchkconfig memcached-server onservice memcached-server start}main () {Sys_initdownload_ Softwareinstallstart_server}main
Third, testing


Memcached installation script (with server self-booting)

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.