Jump to content

How to Install & Configure Redis-Server on Centos/Fedora Server


Recommended Posts

  • Superior Administrator
Posted

‘Redis’ is an Open source key-value data store, shared by multiple processes, multiple applications, or multiple Servers. Key values are more complex types like Hashes, Lists, Sets or Sorted Sets.

 

Let’s have a quick look on the installation steps of “Redis

 

Here we go…

 

Step – 1

 

First of all we need to switch to superuser & install dependencies:

 

[iCODE]

su

yum install make gcc wget tcl

[/iCODE]

 

Step-2

Download Redis Packages & Unzip. This guide is based on installing Redis 2.8.3:

 

wget http://download.redis.io/releases/redis-2.8.3.tar.gz
tar xzvf redis-2.8.3.tar.gz

 

Step-3

Compiling and Installing Redis from the source:

 

cd redis-2.8.3
make
make install

 

Step- 4

 

Starting Redis server by executing the following command without any argument:

 

redis-server

 

Step-5

 

Check if Redis is working. To check, send a PING command using redis-cli. This will return ‘PONG’ if everything is fine.

 

redis-cli ping
PONG

 

Step-6

 

Add Redis-server to init script. Create a directory to store your Redis config files & data:

 

mkdir -p /etc/redis
mkdir -p /var/redis

 

Also we need to create a directory inside “/var/redis” that works as data & a working directory for this Redis instance.

 

mkdir /var/redis/redis

 

Step-7

 

Copy the template configuration file you’ll find in the root directory of Redis distribution into /etc/redis/

 

cp redis.conf /etc/redis/redis.conf

 

Edit the configuration file, make sure to perform the following changes:

 

  • Set daemonize to yes (by default it’s set to ‘No’).
  • Set the pidfile to /var/run/redis.pid
  • Set your preferred loglevel
  • Set the logfile to /var/log/redis.log
  • Set the dir to /var/redis/redis
  • Save and exit from the editor

Step-8

Add the Redis init script.

 

vi /etc/init.d/redis

 

And paste the following codes to it

 

#!/bin/sh
#
# chkconfig: 345 20 80
# description: Redis is an open source (BSD licensed), in-memory data structure store, used as database, cache and message broker.

# Source function library.
. /etc/init.d/functions

REDISPORT=6379
EXEC=/usr/local/bin/redis-server
CLIEXEC=/usr/local/bin/redis-cli

PIDFILE=/var/run/redis.pid
CONF="/etc/redis/redis.conf"

case "$1" in
   start)
       if [ -f $PIDFILE ]
       then
           echo "$PIDFILE exists, process is already running or crashed"
       else
           echo "Starting Redis server..."
           $EXEC $CONF
       fi
       ;;
   stop)
       if [ ! -f $PIDFILE ]
       then
           echo "$PIDFILE does not exist, process is not running"
       else
           PID=$(cat $PIDFILE)
           echo "Stopping ..."
           $CLIEXEC -p $REDISPORT shutdown
           while [ -x /proc/${PID} ]
           do
               echo "Waiting for Redis to shutdown ..."
               sleep 1
           done
           echo "Redis stopped"
       fi
       ;;
   restart)
       stop
       start
       ;;
   *)
       echo "Please use start or stop as first argument"
       ;;
esac
exit 0

 

Save the file and exit from the editor.

 

Step-9

Give appropriate permission to the init script

 

chmod u+x /etc/init.d/redis

 

Step-10

To run the Redis server at startup we need to add it to the chkconfig list

 

chkconfig --add redis
chkconfig --level 345 redis on

 

Step-11

Finally we are ready to start the Redis Server.

 

/etc/init.d/redis start

 

The redis server will start automatically on system boot.

 

Conclusion:

 

‘Redis’ also supports datatypes such as Transitions, Publish and Subscribe. ‘Redis’ is considered more powerful than ‘Memcache’. It would be smart to bring ‘Redis’ into practice and put ‘Memcache’ down for a while.

 

We provide one-stop solution by utilizing Redis server with Rails , PHP applications and deploy in cloud services such as AWS to make sure that the application is fully scalable.

 

You can also check the compression of Memcached vs Redis, to know more information on which one to pick for Large web apps?

 

Source:

 

This is the hidden content, please

  • Like 1
  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

  • Superior Administrator
Posted

Errors and Fixes:

 

WARNING: /proc/sys/net/core/somaxconn is set to the lower value of 128

 

To fix this warning you have to set a new config to /etc/rc.local so that the setting will persist upon reboot

 

$~: sudo nano /etc/rc.local

Add this:

 

sysctl -w net.core.somaxconn=65535

When you reboot the next time, the new setting will be to allow 65535 connections instead of 128 as before

  • Like 1
  • Superior Administrator
Posted

WARNING you have Transparent Huge Pages (THP) support enabled

 

On Linux I solved this running those on HOST:

 

echo never > /sys/kernel/mm/transparent_hugepage/enabled

echo never > /sys/kernel/mm/transparent_hugepage/defrag

  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...
×
GloTorrents Community Forum
Home
Activities
Sign In
Search
More
×