Hands-On with REDIS | Part 1

Welcome to this blog. We shall be looking at following topics in this blog :-

  • Installation of Redis-version-7 at local system.
  • Launching Redis-Server.
  • Introduction to Redis.
  • Setting up Redis-replication.
  • Setting up security with Redis-Server, replica & Client.

Question :- Kindly guide the process of setting-up Redis, at our local ?

Answer :- Please take note that redis was made for UNIX based systems. So, it works well with Linux, it works well with Mac. It’s not made for Windows. So for those that want to try it with Windows, it’s going to work with that port but be aware that there’s going to be some issues. Sometimes, it may be unsupported at this point. It’s not the supported version by redis themselves. Just a note. Or you can actually do it on Windows as well, with the help of Docker.

Step #1.) Go to redis.io then go into the download section here so check the downloads page then scroll all the way down to the installation section here.

It will download the files that we need. Then we need to extract those files so do a tar and xzf, which is a special command.

Step #2.) So, let’s go ahead and cd inside of our directory that we just extracted :-

Step #3.) And now, we shall do the command “make”. For those that don’t have the apple developer tools, when you enter “make” and you click “enter” it’s going to ask you to install those tools. When you’re done installing those tools, come back and do the “make” command again. Now, I’m going to do the “make” command. I have the apple developer tools already installed and it’s going to do a whole bunch of stuff.

Question :- Demonstrate the launch of Redis-Server ?

Answer:- Let’s start our redis-server. So, the best way to do this, is to do “src/redis-server” like so. And this is going to start our server. So if you see this, our redis server is actually installed.

Question:- In which language, Redis itself is written ?

Answer:- Redis was written in NCC, which makes it friendly with Unix-based systems like Mac or Linux without any other dependencies. But for Windows, it is a different story, because we need a special port of Redis, which we’ve mentioned.

Question :- Can you now introduce Redis in layman’s language ?

Answer:- Redis is an open-source, in-memory data structure store which supports saving/retrieving variety of data, through Key-Value Pairs. Redis also has high availability, replication, and automatic-partitioning.

Question:- What are Keys and Values in Redis ?


  • Keys in Redis are pretty much like keys that you see in any other labguage i.e. objects with a key-value pair approach.
  • The key is the property name, and then you follow with a value.

Question :- Demonstrate the usage of Key-Value pair through Redis-Client ?

Answer:- Let’s open new terminal :-

  • Launch the Redis-Client as shown below.
  • We have set-up a Key-Value pair into the Redis.
  • The Key here is “userName” and value here is “adityagoel786”. Also, we are fetching the value, based upon Key.

Question :- Which data-structures are supported easily for the Values ?

Answer:- Variety of data-structures are supported, namely :-

  • Strings → Setting value as a string. In above example, we have set the value as a String only.
  • Lists → Lists are exactly what the name implies: a list of strings.
  • Hashes → Hashes are similar to objects where you can set a specific object and then add field-value pair. For example, you can add a user 456 and inside of that user, add first name field with value many.
  • Sets → Sets are basically a list of unordered and unique strings. So basically if you try to add the same value twice, say a Unix user, you won’t be able to add it more than once.
  • Sorted-sets → Sorted sets are exactly the same as sets, except the fact they are ordered by user-defined key for the values. For example, a sorted set could be strings of historical events sorted by the year associated with each event.
  • Bitmaps
  • Hyperloglogs
  • Geospatial-Indexes.

Question:- Let’s now proceed for setup of Replication with Redis ?

Answer:- We setup the replication for high availability of your data.

Step #1.) We’ll make a second copy of the configuration-file. Now, we shall be launching another redis-server on an another port, with this new configuration-file.

  • Note that, our original redis-server runs @ port 6379.
  • And, our replica-redis-server would now be running @ port 6380.

Step #2.) The next thing that, we want to make change in the new-configuration-file is to set this new server as the replica of the original redis-server.

Step #3.) Next, we shall be setting up the AOF fileName with some different name :-

Step #4.) Let’s now start our master-redis-server at port 6379, with the help of original redis configuration file :-

Step #5.) We also start our replica-redis-server at port 6380, with the help of new-redis configuration file :-

  • As you can see here, it says MASTER <-> SLAVE sync started, so we are, this one is the slave, so the process running at port number 6380 is the slave.
  • Eventually, we shall see that, we have both the master & slave processes running successfully and synchronised.

Question:- Let’s now proceed for setting-up security with Redis ?

Answer:- We setup the security with Redis now :-

Step #1.) Let’s now proceed with configuration-file of master-redis-server and set up the password under clause “requirepass” :-

Step #2.) Now, as soon as we take a re-start on the master-redis-server, we would observe the failure in replication-server-side, because even replica now would need the password, in order to connect to the master-redis-server.

Step #3.) Let’s now proceed with configuration-file of replica-redis-server and set up the password with which our replica-server shall connect with master-replica-server, under clause “masterauth” :-

Step #4.) Next, we would restart the replica-redis-server as well now with aforesaid configuration change :-

Step #5.) Now, since we have already taken re-start on the master-redis-server, even our connection through the Redis-CLI would also start failing :-

Step #6.) Let’s now restart our Redis-CLI as well with the password being supplied to it :-

That’s all in this section. If you liked reading this blog, kindly do press on clap button multiple times, to indicate your appreciation. We would see you in next part of this series.

Reference :- https://redis.io




Software Engineer for Big Data distributed systems

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Base seven one hundred forty-seven notation and pronunciation.

BDD Addict Newsletter October 2018

SQL Server — varchar / nvarchar decreased space, increased performace

Environment variables: Unlock the full potential of Kubernetes by storing configuration in the…

Java #4 | OOP Object Oriented Programming (1)


Choosing a Code BootCamp

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
aditya goel

aditya goel

Software Engineer for Big Data distributed systems

More from Medium

Optimistic vs. Pessimistic Database Locking

Hands-On with REDIS | Part 2

How to Use Pub/Sub with NodeJS

Elasticsearch In A Nutshell Part-3