Professional Documents
Culture Documents
com
Originally published on
LinuxTechLab.com
Redis is open source database, precisely, its a in-memory data structure store that can
be used as a database, cache & message broker. It does not possess the limits offered
by the relational database & can be used to store a vast amount of data, with support
for a number of data structures like strings, hashes, lists, sets, Sorted sets, bitmaps,
hyperlogs etc.
Typical use cases are session caching, full page cache, message queue applications,
leaderboards and counting among others.
Pre-requisites
Before we can proceed with the installation of redis on our Centos/RHEL servers, we
need to make sure that following packages must be installed on our systems,
1- CentOS/RHEL 7
We need to install the following packages,
$ yum install wget gcc make
2- CentOS/RHEL6
Install the following packages ,
$ yum install tcl wget gcc make
At the time of writing this tutorial, redis 3.2.9 is the latest version. So to download the
redis 3.2.9, open your terminal & execute the following command,
$ wget http://download.redis.io/releases/redis-3.2.9.tar.gz
Next, we will extract the downloaded tar package,
$ tar -xvf redis-3.2.9.tar.gz
Step 2- Compiling & installing redis
Now that we have a extracted, we will compile & install redis. Firstly, open the extracted
folder,
$ cd redis-3.2.9
For this installation we have used all the default settings, but we can modify any settings
as per our need.
Note:-We can also set up a number of redis instances by running this script again &
changing the port number for the new redis instance.
Step 4- Starting the redis service
If you are using more than one redis instance or have changed the port number for
redis instance, then you can replace 6379 with the port number you have chosen to
stop/start the redis service.
To login to redis server & check if redis is working fine, open terminal & run the
command,
$ redis-cli
Once connected, you will get prompt like
127.0.0.1:6379>
We can now issue Ping command & if the redis service is up, we will get PONG as
response,
127.0.0.1:6379> ping
PONG
By default, redis is accessible from localhost but if you wish to access redis server from a
remote location then we need to make some changes in the configuration file. Open the
configuration file for the instance, i.e. /etc/6379.conf,
$ vi /etc/redis/6379.conf
& look for bind 127.0.0.1. We can either replace 127.0.0.1 with 0.0.0.0 or add IP address
of our server to it. It should look like
bind 0.0.0.0
or
bind 127.0.0.1 192.168.1.100
Now exit the file after saving the changes & restart the service for changes to take effect.
$ service redis_6379 restart
Remember if using multiple or different port numbers, changes are to made to all the
configuration files for respective port numbers.
Now to check if we can login to redis from a remote system, login to remote system first
& enter the following command from terminal,
$ redis-cli -h 192.168.1.100 -p 6379
where, 192.168.1.100 is the IP address of the redis server with 6379 as the redis instance
port number.
If you think we have helped you or just want to support us, please consider these :-
Connect to us: Facebook | Twitter | Google Plus
LinuxTechLab.com