memcached-1.4.13 + repcached Automatic installation script

Source: Internet
Author: User

#!/bin/bash# author:jian# date:2017-11-16# version:0.1# description:  Automatically installs the memcached-1.4.13 and automatically hits the corresponding version of the repcached-1.4.13 patch, applies to CentOS64 bit system, passes test url1= "http://memcached.org/" on CENTOS6/7 Files/old/memcached-1.4.13.tar.gz "url2=" http://mdounin.ru/files/repcached-2.3.1-1.4.13.patch.gz "url3=" https:// Github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz "String= ' cat  /etc/redhat-release ' vers= ' echo ${string##*release}|sed  ' s/^[[:space:]]*//g ' |awk -F '. "   ' {print $1} ' Download_dir=/usr/local/src/export path=/usr/local/sbin:/usr/local/bin:/usr/sbin :/usr/bin:/root/bin:/bin:/sbin:/usr/local/memcached/binif which memcached &>/dev/null  ; then   echo -e  "\033[31myou have installed memcached  on your system,please uninstall it first!\033[0m "   exit  1ficheck_user ()  {if [  $UID  -ne 0 ] ;then   echo -e  "\033[31myou must be root  to run this script!\033[0m " 1>&2   exit 1fi}install_progs ()  {for prog in  ' echo [email protected] ' doif ! which  $prog   &>/dev/null; then   echo  "installing  $prog &nbsp ..."      yum install  $prog  -y &>/dev/null    if [ $?  -eq 0 ];then      echo  "install  $prog  ok"      else      echo  "download  $prog  failed,exit"        exit 2   fifidone}download ()  {    cd  $download _dir   for url in  ' echo [email protected] '    do       if [ ! -e ${download_dir}${url##*/} ];then          echo  "downloading ${url##*/}&nbsp ..."           if wget -q -t 8 -c -T 3  $url   ;then             echo  "Download ${ Url##*/} ok. "           else             echo -e  "\033[31mdownload ${url##*/} failed.\033[0m"           fi      else           echo  "File ${download_dir}${url##*/} exists."       fi   done}# libevent-2.1.8-stable.tar.gzinstall_ Libevent ()  {   cd  $download _dir   if [ -f /usr/local/libevent/lib/ libevent-2.1.so.6 ];then      echo  "Libevent has installed  on your system "   else       echo " Installing libevent ... "      tar xf ${url3##*/} &>/ dev/null      cd $ (echo  "${url3##*/}"  |sed  ' s/\.tar\.gz//g ')       ./configure --prefix=/usr/local/libevent       make && make install      echo  "/usr/ Local/libevent/lib " > /etc/ld.so.conf.d/libevent.conf      ldconfig    fi}install_memcached ()  {cd  $download _dirtar xf ${url1##*/} & >/dev/nullgzip -d -c ${download_dir}${url2##*/} > ${download_dir}repcached-2.3.1-1.4.13.patchcd $ (echo  "${ url1##*/} " |sed  ' s/\.tar\.gz//g ') patch -p1 < /repcached-2.3.1-1.4.13.patch./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/ libevent --enable-replication --enable-64bitmake && make installecho  ' Export path=/usr/local/memcached/bin: $PATH '  > /etc/profile.d/memcached.shsource /etc/ profile.d/memcached.sh}check_userinstall_progs wget gccdownload  $url 1  $url 2  $url 3if  [ -f ${download_dir}${url1##*/} ] && [ -f ${download_dir}${ url2##*/} ] && [ -f ${download_dir}${url3##*/} ];then    install_libevent   install_memcachedelse    echo  "There is a  lack of necessary installation packageS,please check. "    echo  "You can download the package manually and put  the package into: /usr/local/src "   exit 1fiif [ -f / usr/local/memcached/bin/memcached ];then   echo -e  "\033[32mCongratulations,you  have successfuly installed memcached!\033[0m "    cd  $download _ dir   rm -rf ${download_dir}$ (echo  "${url1##*/}"  |sed  ' s/\.tar\.gz//g ' )    rm -rf ${download_dir}$ (echo  "${url3##*/}"  |sed  ' s/\.tar\.gz//g ') else   echo -e  "\033[31minstalled memcached failed,please check!\033[ 0m "fi echo  ' port=" 11211 "'  > /etc/sysconfig/memcachedecho  ' user=" Nobody "'  > > /etc/sysconfig/memcachedecho  ' maxconn= ' " >> /etc/sysconfig/memcachedec"ho  ' cachesize= '  >> /etc/sysconfig/memcachedecho  ' options= ' '  >>  /etc/sysconfig/memcached##############################################################################     Below is a service script provided by CentOS6, CentOS7                                     ################################################################################# CENTOS6 The service script, writes it to the/etc/rc.d/init.d/memcached file ####!/bin/bash## init file for memcached##  chkconfig: - 86 14# description: Distributed memory caching  daemon## processname: memcached# config: /etc/sysconfig/memcached. /etc/rc.d/init.d/ Functions. /etc/sysconfig/memcached## default variablesretval=0prog= "/usr/local/memcached/bin/ Memcached "desc=" DISTRIBUTED&NBsp;memory caching "lockfile="/var/lock/subsys/memcached "Start ()  {         echo -n $ "starting  $desc   (memcached): "          daemon  $prog  -d -p  $PORT  -u  $USER  -c  $MAXCONN  -m  $CACHESIZE   $OPTIONS         RETVAL=$?         [  $RETVAL  -eq 0 ] && success  && touch  $lockfile  | |  failure        echo         return  $RETVAL}stop ()  {        echo -n $ " shutting down  $desc   (memcached):  "        killproc   $prog         retval=$?        [  $RETVAL &NBSP;-EQ&NBSP;0&NBSP;]&NBSP;&AMP;&AMP;&NBSP;SUCCESS&NBSP;&AMP;&AMP;&NBSP;RM  -f  $lockfile  | |  failure        echo         return  $RETVAL}restart ()  {        stop         start}reload ()  {        echo  -n $ "reloading  $desc   ($prog): "          killproc  $prog  -HUP        RETVAL=$?         [  $RETVAL  -eq 0 ] && success | |  failure        echo         return  $RETVAL}case  "$"  in  start)          start        ;;   stop)         stop         ;;   restart)         restart         ;;   condrestart)         [ -e  $lockfile  ]  && restart        RETVAL=$?         ;;          reload)          reload        ;;   status)         status  $prog          RETVAL=$?        ;;    *)         echo $ "Usage: $0 {start|stoP|restart|condrestart|status} "        RETVAL=1esacexit  $RETVAL # # # Centos7 The service script, writes it to the/usr/lib/systemd/system/memcached.service file ###[unit]description=memcachedbefore= httpd.serviceafter=network.target[service]type=simpleenvironmentfile=-/etc/sysconfig/memcachedexecstart=/usr/ local/memcached/bin/memcached -u  $USER  -p  $PORT  -m  $CACHESIZE  -c $ maxconn  $OPTIONS [Install]wantedby=multi-user.target


This article is from the "11819889" blog, please be sure to keep this source http://11829889.blog.51cto.com/11819889/1982597

memcached-1.4.13 + repcached Automatic installation script

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.