Hi Friends,
From last few days, I have done much research on Redis, like how to install it on different Linux Distro, how it is working, how to set up Redis cluster and troubleshooting issue related to Redis. So I will share all my experience for Redis in this post and my upcoming post one by one.
In this post, we will discuss what is Redis and how to install it on Ubuntu machine.
What is Redis?
Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache and message broker. It supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperlog, geospatial indexes with radius queries and streams. Redis has built-in replication, Lua scripting, LRU eviction, transactions and different levels of on-disk persistence and provides high availability via Redis Sentinel and automatic partitioning with Redis Cluster. To know more about it, refer to the Official site of Redis.
Installation of Redis:
There are many ways to install Redis on a machine. But here, we will install the Redis from its source. T compile it from the source, we need build-essentials package. So first of all, we will install build-essentials package on our machine.
Build-essentials: The build-essentials is a reference for all the packages needed to compile a debian package. It generally includes the gcc/g++ compilers an libraries and some other utils.
To install it, run the below command:
sudo apt-get install build-essential
Redis installation steps:
Download the stable Redis, you can download it from here
If you want to download a specific version of Redis, you can get it from here:
Here we will install Redis version: redis-4.0.10
So create a folder with any name and download the Redis package in it.
wget http://download.redis.io/releases/redis-4.0.10.tar.gz
Since the downloaded file is in the compressed format, we need to extract it. Use the below command to extract it.
tar -zxf redis-4.0.10.tar.gz
Now go to the extracted directory and you will see lots of files/folders under it.
Now compile the Redis binaries. Use the below command:
make
This process will take some time to complete. Once it is complete, you will get the below output at the end:
CC rax.o
LINK redis-server
INSTALL redis-sentinel
CC redis-cli.o
LINK redis-cli
CC redis-benchmark.o
LINK redis-benchmark
INSTALL redis-check-rdb
INSTALL redis-check-aof
Hint: It’s a good idea to run ‘make test’ 😉
make[1]: Leaving directory ‘/home/ubuntu/redis-download/redis-4.0.10/src’
Now run the test suite to verify that everything builds correctly.
make test
This is an optional step. We are executing this to check you are good to install the Redis from the source package. Also, note that to run the test, ‘tcl’ util must be present on your system. If it is not present, you will get an error message like below.
Since tcl util is not present in the above server, it is throwing the error. We will not first install tcl util and then we will again try to run the test suite.
sudo apt-get install tcl
Now run the test suite, you will be able to execute it.
make test
Please note that this process will also take some time to complete. Once it is completed, you will get the below message:
~~
\o/ All tests passed without errors!
~~
If there is no error, that means we are good to proceed with the Redis installation.
Now make Redis executable by running the below command:
make install
Note: You might get permission issue, so use ‘sudo’ with the command.
Without sudo, you might get the below error:
With sudo, you will be able to make it.
Now it is time to complete the Redis installation. So execute the below command to complete the installation.
sudo utils/install_server.sh
This will look like this:
As you can see above, the installation is asking option to set the details according to our requirements. If you do not want to change anything and want to use the default settings, simply press “Enter” for each step. Once you are happy with the settings, press ENTER to complete, or if you think you want to change some settings before installing Redis, you can press Ctrl-C and start again with “sudo utils/install_server.sh“.
Now check, if the Redis server is running on your machine or not:
ps aux | grep redis
Now connect to redis-cli to access Redis server. Execute the below command to go to redis command line.
redis-cli
I hope you enjoyed this post. In the next Redis post, I will discuss how to secure your Redis installation.
Note: Since this installation is just for test purpose, I have not shared how to secure it.
If you face any issue in installing in, feel free to leave your comment in the comment section. I will be more than happy to assist you.
Thank you. 🙂
My name is Shashank Shekhar. I am a DevOps Engineer, currently working in one of the best companies in India. I am having around 5 years of experience in Linux Server Administration and DevOps tools.
I love to work in Linux environment & love learning new things.
Powered by Facebook Comments
Leave a Reply