How to install Redis on OpenSuse Tumbleweed

How To Install Redis On OpenSUSE Tumbleweed

In this short article we will learn how to install Redis on OpenSuse Tumbelweed operating system.

Introduction

Redis, short for Remote Dictionary Server, has emerged as a powerful and versatile open-source, in-memory data structure store. Originally developed by Salvatore Sanfilippo, Redis has gained widespread adoption due to its speed, simplicity, and flexibility. In this article, we’ll delve into the world of Redis, exploring its key features, use cases, and best practices.

Key Features of Redis

  • In-Memory Storage: Redis stores data in RAM, enabling lightning-fast data access.
  • Data Structures: Redis supports various data types such as strings, hashes, lists, sets, and sorted sets, making it versatile for different use cases.
  • Persistence: While primarily an in-memory store, Redis allows data persistence to disk, providing durability in case of system reboots.
  • Replication and High Availability: Redis supports master-slave replication, ensuring data availability even in the event of node failures.
  • Pub/Sub Messaging: Redis includes a publish/subscribe mechanism, allowing for real-time communication between different parts of an application.

Common Use Cases

  • Caching: Redis excels as a caching mechanism due to its fast read and write capabilities, reducing database load and improving overall application performance.
  • Session Storage: Storing session data in Redis ensures quick retrieval and enhances scalability in web applications.
  • Real-time Analytics: Its ability to handle high-throughput, real-time data makes Redis suitable for scenarios like analytics dashboards.
  • Leaderboards and Counting: Sorted sets in Redis make it easy to implement leaderboards and count-related functionalities in applications.

How To Install Redis On OpenSuse Tumbleweed

In this section we will deeply learn how to install Redis on OpenSuse operating system. Here are the steps to install Redis on OpenSUSE Tumbleweed :

  • Update OpenSuse Tumbleweed Sytem Repository
  • Adding Redis Repository
  • Install Redis
  • Configure Redis
  • Connecting and performing basic operations in Redis
  • Performing Redis Benchmark

1. Update OpenSuse Tumbleweed Sytem Repository

Before installing Redis on the system, it’s a good practice to update our system’s package repository information to ensure if wet the latest available packages. For this purpse we will run the following command:

$ sudo zypper refresh

Output :

ramansah@bckinfobckinfo:~> sudo zypper refresh
[sudo] password for root: 
Repository 'Main Repository (NON-OSS)' is up to date.                                                                       
Repository 'Main Repository (OSS)' is up to date.                                                                           
Repository 'Main Update Repository' is up to date.                                                                          
Repository 'openSUSE-20240131-0' is up to date.                                                                             
Repository 'Open H.264 Codec (openSUSE Tumbleweed)' is up to date.                                                          
Repository 'Databases (openSUSE_Tumbleweed)' is up to date.                                                                 
Repository 'snappy' is up to date.                                                                                          
All repositories have been refreshed.
ramansah@bckinfobckinfo:~> sudo zypper update
Loading repository data...
Reading installed packages...

2. Adding Redis Repository

By default, Redis 6 has been available in the default OpenSUSE Tumbleweed. But if we need the latest version of Redis, then we have to add Redis repository to the system. To get the latest version, we will add Redis repository to the system by using command:

$ sudo curl -L -o /etc/zypp/repos.d/server-database.repo https://download.opensuse.org/repositories/server:/database/openSUSE_Tumbleweed/server:database.repo

The output will be as follow :

ramansah@bckinfobckinfo:~> sudo curl -L -o /etc/zypp/repos.d/server-database.repo https://download.opensuse.org/repositories/server:/database/openSUSE_Tumbleweed/server:database.repo
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   288  100   288    0     0    269      0  0:00:01  0:00:01 --:--:--   269

Then we will verify if the Redis repository has already added to the system. By using command line :

$ vi /etc/zypp/repos.d/server-database.repo

Output :

ramansah@bckinfobckinfo:~> vi /etc/zypp/repos.d/server-database.repo

[server_database]
name=Databases (openSUSE_Tumbleweed)
type=rpm-md
baseurl=https://download.opensuse.org/repositories/server:/database/openSUSE_Tumbleweed/
gpgcheck=1
gpgkey=https://download.opensuse.org/repositories/server:/database/openSUSE_Tumbleweed/repodata/repomd.xml.key
enabled=1
~                                                                                                                           
~                                       

Based on repository file above, then we have known if Redis repo has already added to the system. Then we need to refresh the system by submitting command line :

 $ sudo zypper ref

Output :

ramansah@bckinfobckinfo:~> sudo zypper ref
Repository 'Main Repository (NON-OSS)' is up to date.                                                                       
Repository 'Main Repository (OSS)' is up to date.                                                                           
Repository 'Main Update Repository' is up to date.                                                                          
Repository 'openSUSE-20240131-0' is up to date.                                                                             
Repository 'Open H.264 Codec (openSUSE Tumbleweed)' is up to date.                                                          
Repository 'Databases (openSUSE_Tumbleweed)' is up to date.                                                                 
Repository 'snappy' is up to date.                                                                                          
All repositories have been refreshed.

3. Install Redis On OpenSuse Tumbleweed

In this section we have updated our system repo. To install Redis on OpenSuse we just submit following command .

$ sudo zypper in redis

Output :

ramansah@bckinfobckinfo:~> sudo zypper in redis
Loading repository data...
Reading installed packages...
Resolving package dependencies...

The following NEW package is going to be installed:
  redis

1 new package to install.
Overall download size: 1.6 MiB. Already cached: 0 B. After the operation, additional 5.8 MiB will be used.
Continue? [y/n/v/...? shows all options] (y): 
Retrieving: redis-7.2.4-229.11.x86_64 (Databases (openSUSE_Tumbleweed))                                      (1/1),   1.6 MiB    
Retrieving: redis-7.2.4-229.11.x86_64.rpm ...................................................................[done (744.0 KiB/s)]

Checking for file conflicts: ..............................................................................................[done]
/usr/bin/systemd-sysusers -
See /usr/share/doc/packages/redis/README.SUSE to continue
(1/1) Installing: redis-7.2.4-229.11.x86_64 ...............................................................................[done]
Running post-transaction scripts ..........................................................................................[done]

Then wen will verify, if Redis has already installed on the system. To verify Redis version we will submit following command line :

$ zypper info redis

Output :

ramansah@bckinfobckinfo:~>  zypper info redis
Loading repository data...
Reading installed packages...


Information for package redis:
------------------------------
Repository     : Databases (openSUSE_Tumbleweed)
Name           : redis
Version        : 7.2.4-229.11
Arch           : x86_64
Vendor         : obs://build.opensuse.org/server:database
Installed Size : 5.8 MiB
Installed      : Yes
Status         : up-to-date
Source package : redis-7.2.4-229.11.src
Upstream URL   : https://redis.io
Summary        : Persistent key-value database
Description    : 
    redis is an advanced key-value store. It is similar to memcached but the dataset
    is not volatile, and values can be strings, exactly like in memcached,
    but also lists, sets, and ordered sets. All this data types can be manipulated
    with atomic operations to push/pop elements, add/remove elements, perform server
    side union, intersection, difference between sets, and so forth. Redis supports
    different kind of sorting abilities.

4. Creating Systemd File

To manage Redis service which, we will create systemd file. We will use vi text editor for this persin.

$ sudo vi /etc/systemd/system/redis.service

[Unit]
Description=Redis In-Memory Data Store
After=network.target

[Service]
User=redis
Group=redis
ExecStart=/usr/sbin/redis-server /etc/redis/redis.conf
LimitNOFILE=10240
ExecStop=/usr/bin/redis-cli shutdown
Restart=always

[Install]
WantedBy=multi-user.target
~ 

By default, the configuration file has already bundled as pre built file. We only need to change its file and add executbale privilage for this file.

ramansah@bckinfobckinfo:~> sudo cp /etc/redis/default.conf.example /etc/redis/redis.conf
ramansah@bckinfobckinfo:~> sudo chown redis:redis /etc/redis/redis.conf

5. Starting Redis Service

The next step in installing Redis on OpenSuse is to start Redis service and enabled it. For this purpose we will do following command lines :

$ sudo systemctl start redis
$ sudo systemctl status redis
$ sudo systemctl enable redis

Output :

ramansah@bckinfobckinfo:~> sudo systemctl start redis
ramansah@bckinfobckinfo:~> sudo systemctl status redis
● redis.service - Redis In-Memory Data Store
     Loaded: loaded (/etc/systemd/system/redis.service; disabled; preset: disabled)
     Active: active (running) since Fri 2024-02-16 23:43:10 WIB; 4s ago
   Main PID: 46605 (redis-server)
      Tasks: 5 (limit: 2241)
        CPU: 21ms
     CGroup: /system.slice/redis.service
             └─46605 "/usr/sbin/redis-server 127.0.0.1:6379"

Feb 16 23:43:10 bckinfobckinfo.com systemd[1]: Started Redis In-Memory Data Store.
ramansah@bckinfobckinfo:~> sudo systemctl enable redis
Created symlink /etc/systemd/system/multi-user.target.wants/redis.service → /etc/systemd/system/redis.service.
Redis Service

6. Configuring Redis

In this section we will configure Redis. By configuring Redis we could allow remote access, setting authentication password, add a pid file and to Set Persistent Store for Recovery. The configuration file is located at /etc/redis/redis.conf file.

We will uncomment file :

 Examples:
#
# bind 192.168.1.100 10.0.0.1     # listens on two specific IPv4 addresses
# bind 127.0.0.1 ::1              # listens on loopback IPv4 and IPv6
 bind * -::*                      # like the default, all available interfaces
#
# ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the
# internet, binding to all the interfaces is dangerous and will expose the

# command, these will cause requirepass to be ignored.
#
 requirepass pastest202401       

# AOF and RDB persistence can be enabled at the same time without problems.
# If the AOF is enabled on startup Redis will load the AOF, that is the file
# with the better durability guarantees.
#
# Please check https://redis.io/topics/persistence for more information.

appendonly yes

# The base name of the append only file.
# - appendonly.aof.1.incr.aof, appendonly.aof.2.incr.aof as incremental files.
# - appendonly.aof.manifest as a manifest file.

appendfilename "appendonly.aof"

After updating Redis configuration file, then we will restart Redis service by submitting command line :

$ sudo systemctl restart redis

If our server is using Firewall, then we need to allow the connection from external entity. For this purpose we will use command lines :

ramansah@bckinfobckinfo:~> sudo firewall-cmd --add-port=6379/tcp --permanent
success
ramansah@bckinfobckinfo:~> sudo firewall-cmd --reload
success

7. Testing Redis

In this section we will try to login and and do basic operation in Redis.

$ redis-cli

Output :

ramansah@bckinfobckinfo:~> redis-cli
127.0.0.1:6379> auth pastest202401
OK
127.0.0.1:6379> info server
# Server
redis_version:7.2.4
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:7e5fceed731af78a
redis_mode:standalone
os:Linux 6.7.2-1-default x86_64
arch_bits:64
monotonic_clock:POSIX clock_gettime
multiplexing_api:epoll
atomicvar_api:c11-builtin
gcc_version:13.2.1
process_id:2168
process_supervised:no
run_id:4affe2729ce2a250d130614e8ef697c2403f9ae6
tcp_port:6379
server_time_usec:1709083053687855
uptime_in_seconds:179
uptime_in_days:0
hz:10
configured_hz:10
lru_clock:14584237
executable:/usr/sbin/redis-server
config_file:/etc/redis/redis.conf
io_threads_active:0
listener0:name=tcp,bind=127.0.0.1,bind=-::1,port=6379
Redis Testing

Conclusion

Redis stands out as a robust and versatile solution for in-memory data storage, offering unparalleled speed and flexibility. As technology continues to evolve, Redis is likely to remain a key player in the realm of data management, providing developers with a reliable tool to address various application challenges.

(Visited 151 times, 1 visits today)

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *