AMP AMP

How To Install And Configure Redis On Linux Mint 20.2

To Install And Configure Redis On Linux Mint 20.2

Introduction:

Redis is an in-memory data structure store, used as a distributed, in-memory key–value database, cache and message broker, with optional durability. Redis supports different kinds of abstract data structures, such as strings, lists, maps, sets, sorted sets, HyperLogLogs, bitmaps, streams, and spatial indices.

Installation Procedure :

Step 1 : Check the OS version by using the below command

root@linuxhelp:~# lsb_release -a
No LSB modules are available.
Distributor ID:	Linuxmint
Description:	Linux Mint 20.2
Release:	20.2
Codename:	uma

Step 2 : Update and download the dependencies by using the below command

root@linuxhelp:~# apt-get install build-essential tcl
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  cpp-9 g++ g++-9 gcc-9 gcc-9-base libasan5 libc-dev-bin libc6-dev libcrypt-dev libgcc-9-dev libstdc++-9-dev libtcl8.6 tcl8.6
Suggested packages:
  gcc-9-locales g++-multilib g++-9-multilib gcc-9-doc gcc-9-multilib glibc-doc libstdc++-9-doc tcl-tclreadline
The following NEW packages will be installed:
  build-essential g++ g++-9 libc-dev-bin libc6-dev libcrypt-dev libstdc++-9-dev libtcl8.6 tcl tcl8.6
The following packages will be upgraded:
  cpp-9 gcc-9 gcc-9-base libasan5 libgcc-9-dev
5 upgraded, 10 newly installed, 0 to remove and 20 not upgraded 

Step 3 : Open the redis.io website and configuring the key’s as shown in the below image

Snap 1

Step 4 : Downlod the redis package as shown in the below image

Step 5 : Update the gpg Key in the particular path by using the below command

root@linuxhelp:~# curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg

Step 6 : Generate the particular permission to access by using the below command

root@linuxhelp:~# echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list
deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb uma main

Step 7 : Download the redios by using the wget command

root@linuxhelp:~# wget https://download.redis.io/releases/redis-6.2.6.tar.gz
--2022-03-10 05:35:36--  https://download.redis.io/releases/redis-6.2.6.tar.gz
Resolving download.redis.io (download.redis.io)... 45.60.125.1
Connecting to download.redis.io (download.redis.io)|45.60.125.1|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2476542 (2.4M) [application/octet-stream]
Saving to: ‘redis-6.2.6.tar.gz’
redis-6.2.6.tar.gz               100%[=======================================================>]   2.36M  5.52MB/s    in 0.4s    
2022-03-10 05:35:37 (5.52 MB/s) - ‘redis-6.2.6.tar.gz’ saved [2476542/2476542]

Step 8 : List the files whether it is installed or not by using the below

root@linuxhelp:~# ls -la
total 76508
drwx------  7 root root     4096 Mar 10 05:35 .
drwxr-xr-x 19 root root     4096 Mar  6 21:46 ..
-rw-------  1 root root     2240 Mar 10 05:29 .bash_history
-rw-r--r--  1 root root     3106 Dec  5  2019 .bashrc
drwx------  3 root root     4096 Jul  3  2021 .cache
drwx------  3 root root     4096 Mar  6 22:29 .dbus
drwxr-xr-x  3 root root     4096 Mar  7 05:17 .local
-rw-r--r--  1 root root      161 Dec  5  2019 .profile
drwxr-xr-x  5 3434 3434     4096 Mar  8 02:03 prometheus-2.33.4.linux-amd64
-rw-r--r--  1 root root 75820407 Feb 22 22:37 prometheus-2.33.4.linux-amd64.tar.gz
-rw-r--r--  1 root root  2476542 Oct  4 16:49 redis-6.2.6.tar.gz
drwxr-xr-x  2 root root     4096 Mar  7 12:49 .rpmdb
-rw-r--r--  1 root root      165 Mar  8 02:01 .wget-hsts

Step 9 : Extract the files by using the tar command

root@linuxhelp:~# tar xzf redis-6.2.6.tar.gz
root@linuxhelp:~# ls -la
total 76512
drwx------  8 root root     4096 Mar 10 05:35 .
drwxr-xr-x 19 root root     4096 Mar  6 21:46 ..
-rw-------  1 root root     2240 Mar 10 05:29 .bash_history
-rw-r--r--  1 root root     3106 Dec  5  2019 .bashrc
drwx------  3 root root     4096 Jul  3  2021 .cache
drwx------  3 root root     4096 Mar  6 22:29 .dbus
drwxr-xr-x  3 root root     4096 Mar  7 05:17 .local
-rw-r--r--  1 root root      161 Dec  5  2019 .profile
drwxr-xr-x  5 3434 3434     4096 Mar  8 02:03 prometheus-2.33.4.linux-amd64
-rw-r--r--  1 root root 75820407 Feb 22 22:37 prometheus-2.33.4.linux-amd64.tar.gz
drwxrwxr-x  7 root root     4096 Oct  4 16:29 redis-6.2.6
-rw-r--r--  1 root root  2476542 Oct  4 16:49 redis-6.2.6.tar.gz
drwxr-xr-x  2 root root     4096 Mar  7 12:49 .rpmdb
-rw-r--r--  1 root root      165 Mar  8 02:01 .wget-hsts

Step 10 : Get into the Redis directory by using the below command

root@linuxhelp:~# cd redis-6.2.6

Step 11 : Run the make command to check the errors by using the below command

root@linuxhelp:~/redis-6.2.6# make
cd src && make all
make[1]: Entering directory '/root/redis-6.2.6/src'
    CC Makefile.dep
rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-rdb redis-check-aof *.o *.gcda *.gcno *.gcov redis.info lcov-html Makefile.dep
rm -f adlist.d quicklist.d ae.d anet.d dict.d server.d sds.d zmalloc.d lzf_c.d lzf_d.d pqsort.d zipmap.d sha1.d ziplist.d release.d networking.d util.d object.d db.d replication.d rdb.d t_string.d t_list.d t_set.d t_zset.d t_hash.d config.d aof.d pubsub.d multi.d debug.d sort.d intset.d syncio.d cluster.d crc16.d endianconv.d slowlog.d scripting.d bio.d rio.d rand.d memtest.d crcspeed.d crc64.d bitops.d sentinel.d notify.d setproctitle.d blocked.d hyperloglog.d latency.d sparkline.d redis-check-rdb.d redis-check-aof.d geo.d lazyfree.d module.d evict.d expire.d geohash.d geohash_helper.d childinf
mpat.c
ar rcs libhiredis.a alloc.o net.o hiredis.o sds.o async.o read.o sockcompat.o
make[3]: Leaving directory '/root/redis-6.2.6/deps/hiredis'
MAKE linenoise
cd linenoise && make
make[3]: Entering directory '/root/redis-6.2.6/deps/linenoise'
cc  -Wall -Os -g  -c linenoise.c
    INSTALL redis-check-rdb
    INSTALL redis-check-aof
Hint: It's a good idea to run 'make test' ;)
make[1]: Leaving directory '/root/redis-6.2.6/src'

Step 12 : Run the make test command to cross verify

root@linuxhelp:~/redis-6.2.6# make test
cd src && make test
make[1]: Entering directory '/root/redis-6.2.6/src'


    CC Makefile.dep
Cleanup: may take some time... OK
Starting test server at port 21079
[ready]: 10266
Testing unit/printver
[ready]: 10267
[ok]: BITCOUNT against test vector #4
[ok]: BITCOUNT against test vector #5
[ok]: BITFIELD signed SET and GET basics
[ok]: BITFIELD unsigned SET and GET basics
[ok]: BITFIELD #<idx> form
[ok]: BITFIELD basic INCRBY form
[ok]: TOUCH alters the last access time of a key
[ok]: BITFIELD chaining of multiple commands
\o/ All tests passed without errors!

Cleanup: may take some time... OK
make[1]: Leaving directory '/root/redis-6.2.6/src'

Step 13 : Run the redis-server file by using the below command

root@linuxhelp:~/redis-6.2.6# src/redis-server 
23326:C 10 Mar 2022 06:26:44.148 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
23326:C 10 Mar 2022 06:26:44.148 # Redis version=6.2.6, bits=64, commit=00000000, modified=0, pid=23326, just started
23326:C 10 Mar 2022 06:26:44.148 # Warning: no config file specified, using the default config. In order to specify a config file use src/redis-server /path/to/redis.conf
23326:M 10 Mar 2022 06:26:44.149 * Increased maximum number of open files to 10032 (it was originally set to 1024).
23326:M 10 Mar 2022 06:26:44.149 * monotonic clock: POSIX clock_gettime

Step 14 : Run the redis -client command in the another tab there by we can successfully log in

root@linuxhelp:~/redis-6.2.6# src/redis-cli
127.0.0.1:6379> set x linuxhelp
OK
127.0.0.1:6379> get x
"linuxhelp"
127.0.0.1:6379> expire x 10
(integer) 1
127.0.0.1:6379> ttl x
(integer) -2
127.0.0.1:6379> get x
(nil)

With this the process of installing and configuring the Redis on Linux Mint 20.2 has come to an end…!!!

FAQ
Q
Can you use Redis with a disk-based database?
A
Yes, a common design pattern involves taking very write-heavy small data in Redis
(and data you need the Redis data structures to model your problem in an efficient way), and big blobs of data into an SQL or eventually consistent on-disk database
Q
Why did you start the Redis project?
A
Originally Redis was started in order to scale LLOOGG. But after I got the basic
server working I liked the idea to share the work with other people, and Redis was turned into an open source
Q
Is Redis on-disk-snapshots atomic?
A
Yes, Redis background saving process is always forked when the server is outside of the execution of a command,
so every command reported to be atomic in RAM is also atomic from the point of view of the disk snapshot.
Q
What happens if Redis runs out of memory?
A
Redis has built-in protections allowing the users to set a max limit on memory usage,
using the maxmemory option in the configuration file to put a limit to the memory Redis can use.
Q
Is there something I can do to lower the Redis memory usage?
A
If you can, use Redis 32 bit instances. Also make good use of small hashes, lists, sorted sets, and sets of integers,
since Redis is able to represent those data types in the special case of a few elements in a much more compact way.