What's new

Welcome to GloTorrents Community

Join us now to get access to all our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, and so, so much more. It's also quick and totally free, so what are you waiting for?

Ask question

Ask Questions and Get Answers from Our Community

Answer

Answer Questions and Become an Expert on Your Topic

Contact Staff

Our Experts are Ready to Answer your Questions

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

_.:=iTake=:._

Administrator
Staff member
ZeuS
Super Moderator
+Lifetime VIP+
Registered
Joined
Oct 20, 2018
Messages
1,370
Reaction score
1,435
Points
113
Credits
14,854
‘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:


su
yum install make gcc wget tcl


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

Code:
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:

Code:
cd redis-2.8.3
make
make install

Step- 4

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

Code:
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.

Code:
redis-cli ping
PONG

Step-6

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

Code:
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.

Code:
mkdir /var/redis/redis

Step-7

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

Code:
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.

Code:
vi /etc/init.d/redis

And paste the following codes to it

Code:
#!/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

Code:
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

Code:
chkconfig --add redis
chkconfig --level 345 redis on

Step-11
Finally we are ready to start the Redis Server.

Code:
/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:

http://blog.andolasoft.com/2013/07/...gure-redis-server-on-centosfedora-server.html
 

_.:=iTake=:._

Administrator
Staff member
ZeuS
Super Moderator
+Lifetime VIP+
Registered
Joined
Oct 20, 2018
Messages
1,370
Reaction score
1,435
Points
113
Credits
14,854
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
 

_.:=iTake=:._

Administrator
Staff member
ZeuS
Super Moderator
+Lifetime VIP+
Registered
Joined
Oct 20, 2018
Messages
1,370
Reaction score
1,435
Points
113
Credits
14,854
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​
 

Prom3th3uS

Administrator
Staff member
Junior Administrator
Super Moderator
+Lifetime VIP+
Contributor
Registered
Joined
Oct 21, 2018
Messages
836
Reaction score
321
Points
63
Location
Unknown
Credits
12,458
Superb Tutorial, thanks for publishing it here :)
 
shape1
shape2
shape3
shape4
shape7
shape8
Top