CentOS 6.6 Installation Redis and custom startup scripts

Source: Internet
Author: User
Tags redis centos iptables install redis redis server

First, installation

1. Official: http://www.redis.cn/download.html

2. Download, unzip, compile

wget http://download.redis.io/releases/redis-2.8.18.tar.gz  
tar xzf redis-2.8.18.tar.gz   
CD redis-2.8.18 Make  
  

(Note: An error that may occur when you perform make: 1. GCC is not installed, please: Yum intsall gcc;2. Install the error error:jemalloc/jemalloc.h:no such file or directory; solution: Change = = "Make MALLOC = libc)


3. configuration file specified to custom/use/local/redis

Mkdir/usr/local/redis  
cp src/redis-server  /usr/local/redis  
CP Src/redis-benchmark/usr/local/redis  
CP src/redis-cli  /usr/local/redis  
cp redis.conf  /usr/local/redis  

4. Test and launch

Cd/usr/local/redis  



Second, through the custom script, sets up the boot

1. Startup script

Note: The default redis.conf file parameter is started by the foreground, and modifying Daemonize No to daemonize Yes is started in the background.

Vi/etc/init.d/redis
Copy the script to the/etc/init.d/redis

#!/bin/sh #chkconfig: 2345 #description: Startup and Shutdown script for Redis Progdir=/usr/local/redis #安装路径 Progn Ame=redis-server daemon= $PROGDIR/$PROGNAME config=/usr/local/redis/redis.conf pidfile=/var/run/redis.pid DESC= " Redis Daemon "Scriptname=/etc/init.d/redis start () {if test-x $DAEMON then Echo-e" Startin 
                   G $DESC: $PROGNAME "If $DAEMON $CONFIG then echo-e" OK "
                   Else Echo-e "Failed" fi else
                   Echo-e "couldn ' t find Redis Server ($DAEMON)" fi} Stop () {if test-e $PIDFILE then
                            Echo-e "Stopping $DESC: $PROGNAME" if Kill ' cat $PIDFILE ' then
                   Echo-e "OK" Else Echo-e "failed"
               Fi Else    Echo-e "No Redis Server ($DAEMON) running" fi} restart () {ECHO-E "restarting $DESC: $PROGNAME"
        Stop start} list () {PS aux | grep $PROGNAME} case ' in Start ' Start
         ;;
         stop) stop;;
         restart) restart;;
 
         list) list;;
*) echo "Usage: $SCRIPTNAME {start|stop|restart|list}" >&2 exit 1;; ESAC Exit 0
2. Add service and set boot up

chmod +x/etc/init.d/redis  
chkconfig--add redis chkconfig--level 345 on  
  

3. Test

Ps-ef |grep Redis//Whether there is already a Redis instance
service Redis Stop
service Redis start

4. Open 6379 ports for remote connection

Vi/etc/sysconfig/iptables//Open 6379

Service iptables restart//reboot

5. Remote connection: Two ways

A. Installation:

sudo apt-get install Redis-tools

B. Direct Telnet



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.