CentOS 6.5 installation of Redis and startup script

Source: Internet
Author: User
Tags redis version redis cluster install redis redis server

CentOS 6.5 installation of Redis and startup script

I. Download and install Redis in CentOS 6.5

1. Download the source code, decompress it, and compile the source code.

# Wget http://download.redis.io/releases/redis-2.8.3.tar.gz
# Tar xzf redis-2.8.3.tar.gz
# Cd redis-2.8.3
# Make

2. Go to the src folder in the installation directory and copy the four executable files redis-server, redis-benchmark, redis-cli, and redis. conf to the same directory.

# Mkdir/usr/redis
# Cp redis-server/usr/redis
# Cp redis-benchmark/usr/redis
# Cp redis-cli/usr/redis
# Cp redis. conf/usr/redis
# Cd/usr/redis

3. Start the Redis service.

# Cd/usr/redis
#./Redis-server redis. conf

Startup exception:
Scenario 1:
[17496] 08 Oct 11:48:09. 153 # Server started, Redis version 2.8.17
[17496] 08 Oct 11:48:09. 153 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. to fix this issue add'vm. overcommit_memory = 1' to/etc/sysctl. conf and then reboot or run the command 'sysctl vm. overcommit_memory = 1' for this to take effect.
[17496] 08 Oct 11:48:09. 153 * The server is now ready to accept connections on port 6379

Solution: edit/etc/sysctl. conf and add vm. overcommit_memory = 1. the restart takes effect.

4. Test the client.

Redis 127.0.0.1: 6379> # This line indicates that the installation is successful.

Ii. Set redis startup

Environment: CentOS 6.6 in Linux

1. Write the Startup Script

Note: The default redis. conf file parameter is enabled at the front end. If you change "daemonize no" to "daemonize yes", the system starts at the background.

The script encoding format may not be recognized in Linux on Windows. You can use UltraEdit to convert the format "file --> Conversion --> DOS to UNIX"

#! /Bin/sh
# Chkconfig: 345 86 14
# Description: Startup and shutdown script for Redis
 
PROGDIR =/usr/redis # installation path
PROGNAME = redis-server
DAEMON = $ PROGDIR/$ PROGNAME
CONFIG =/usr/redis. conf
PIDFILE =/var/run/redis. pid
DESC = "redis daemon"
SCRIPTNAME =/etc/rc. d/init. d/redis
 
Start ()
{
If test-x $ DAEMON
Then
Echo-e "Starting $ 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 $1 in
Start)
Start
;;
Stop)
Stop
;;
Restart)
Restart
;;
List)
List
;;
 
*)
Echo "Usage: $ SCRIPTNAME {start | stop | restart | list}"> & 2
Exit 1
;;
Esac
Exit 0

Put the redis script file in the/etc/rc. d/init. d/directory.

2. Add and start the service

# Chmod + x/etc/rc. d/init. d/redis
# Chkconfig -- add redis
# Chkconfig -- level 345 redis on
# Chkconfig -- list redis

3. Restart the test.

You may also like the following articles about Redis. For details, refer:

Install and test Redis in Ubuntu 14.04

Basic configuration of Redis master-slave Replication

Redis cluster details

Install Redis in Ubuntu 12.10 (graphic explanation) + Jedis to connect to Redis

Redis series-installation, deployment, and maintenance

Install Redis in CentOS 6.3

Learning notes on Redis installation and deployment

Redis. conf

Redis details: click here
Redis: click here

This article permanently updates the link address:

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.