Linux · Redis

Install Redis 3.0 on CentOS7 Minimal

Install prerequisite for Redis

Make and GCC packages are used for compiling the source package. Whereas, we are installing wget for downloading the redis source package.

yum install make gcc wget

Download Redis 3 stable Source package

Use wget command to download the stable release Redis 3.0.2 . We recommend you to always install stable release, which you can search in Redis Download URL

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

Untar downloaded Redis Tar ball

Use the tar command to extract out the Redis from the downloaded tarball file.

tar -xvzf redis-3.0.2.tar.gz

Compiling of Redis from source

Once you extract the Redis Package from tarball, you will get the Redis directory.
In our case, we got directory with name called redis-3.0.2 .

Change to extracted out redis directory. Now you will do most of the command activity inside redis package directory ( i.e redis-3.0.2)

cd redis-3.0.2

Now compiling the dependencies of Redis , available inside extracted out redis directory.

cd deps
make hiredis lua jemalloc linenoise

Once the dependencies are compiled, now start compiling the redis. For this you have to change to one level back. Means go back to Redis installation directory.

cd ..
make
make install

The redis server is installed only with binaries in your system. In next section we will install init script.

Install init script

In this section we will install init script to manage the process of Redis.
You can use this method in CentOS 7/ RHEL 7 / Ubuntu 14.04 .

I hope you are still inside the Redis installation Directory. Inside the directory you will see utils directory . We have to change to utils directory and run the install_server.sh script.

cd utils
./install_server.sh

Now you script will ask some question. When you hit only ENTER, the system will take default value or answer.

Given below is reference from our server.

[root@localhost redis-3.0.2]# cd utils/
[root@localhost utils]# ./install_server.sh
Welcome to the redis service installer
This script will help you easily set up a running redis server

Please select the redis port for this instance: [6379] 
Selecting default: 6379
Please select the redis config file name [/etc/redis/6379.conf] 
Selected default - /etc/redis/6379.conf
Please select the redis log file name [/var/log/redis_6379.log] 
Selected default - /var/log/redis_6379.log
Please select the data directory for this instance [/var/lib/redis/6379] 
Selected default - /var/lib/redis/6379
Please select the redis executable path [/usr/local/bin/redis-server] 
Selected config:
Port           : 6379
Config file    : /etc/redis/6379.conf
Log file       : /var/log/redis_6379.log
Data dir       : /var/lib/redis/6379
Executable     : /usr/local/bin/redis-server
Cli Executable : /usr/local/bin/redis-cli
Is this ok? Then press ENTER to go on or Ctrl-C to abort.
Copied /tmp/6379.conf => /etc/init.d/redis_6379
Installing service...
Successfully added to chkconfig!
Successfully added to runlevels 345!
Starting Redis server...
Installation successful!
[root@localhost utils]#

Redis start/stop/restart/status

Once the all above steps are done, we can start/stop/restart the Redis Server and also check its status.

In CentOS 7 / RHEL 7

## To check status of Redis Server
systemctl status redis_6379

## To start Redis Server
systemctl start redis_6379

## To stop Redis Server
systemctl stop redis_6379

## To restart the Redis Server
systemctl restart redis_6379

Login into Redis Server

To login into redis server is quite easy. The command is applicable in CentOS 7/RHEL 7/ Ubuntu (as per this post, we only only selected these 3 Operating system)

Use below given command to login into redis server from localhost .

redis-cli

See below given reference.

[root@localhost ~]# redis-cli 
127.0.0.1:6379> 
127.0.0.1:6379> 
127.0.0.1:6379> exit
[root@localhost ~]#

To check help of redis-cli command.

redis-cli --help

Check listening ports by redis

Use ss command to find the listening port.

ss -tanp|grep 6379

Given below is reference,

[root@localhost ~]# ss -tanp|grep 6379
LISTEN     0      128                       *:6379                     *:*      users:(("redis-server",8032,5))
LISTEN     0      128                      :::6379                    :::*      users:(("redis-server",8032,4))
[root@localhost ~]#
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s