How to install and configure Redis 6 on FreeBSD 13

Pinterest LinkedIn Tumblr

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.

In this tutorial we are going to learn how to install Redis 6 on FreeBSD 13.

Related Content


To follow along, ensure that you have:

  • An updated FreeBSD 13 server
  • Access to the Internet
  • Root access to the server or user with sudo access

Table of Content

  1. Update FreeBSD 13 Server
  2. Installing Redis
  3. Configuring Redis
  4. Connecting and performing basic operations in Redis
  5. Performing Redis Benchmark

1. Update Fedora 34 Server

Before proceeding, ensure that the server is updated using this command (as a root user):

pkg update
pkg upgrade 

Let us also ensure vim is installed using this command since we will use it later:

pkg install -y vim

2. Installing redis

Redis is available in the default FreeBSD repositories. To install it, use this command:

pkg install -y redis

This is the output on my server

# pkg install -y redis
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
The following 1 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
	redis: 6.2.6

Number of packages to be installed: 1

The process will require 6 MiB more space.
729 KiB to be downloaded.
[1/1] Fetching redis-6.2.6.pkg: 100%  729 KiB 746.3kB/s    00:01
Checking integrity... done (0 conflicting)
[1/1] Installing redis-6.2.6...
===> Creating groups.
Creating group 'redis' with gid '535'.
===> Creating users
Creating user 'redis' with uid '535'.
[1/1] Extracting redis-6.2.6: 100%
Message from redis-6.2.6:

To setup "redis" you need to edit the configuration file:

      To run redis from startup, add redis_enable="YES"
      in your /etc/rc.conf.

Use this command to confirm the redis package installed:

# pkg info redis
Name           : redis
Version        : 6.2.6
Installed on   : Fri Nov 19 10:01:00 2021 UTC
Origin         : databases/redis
Architecture   : FreeBSD:13:amd64
Prefix         : /usr/local
Categories     : databases
Licenses       : BSD3CLAUSE
Maintainer     : [email protected]
WWW            :
Comment        : Persistent key-value database with built-in net interface
Options        :
	JEMALLOC       : off
	LUA            : off
	LUAJIT         : off
	LUAJITOR       : off
	TESTS          : off
	TLS            : off
	TRIB           : off
Annotations    :
	FreeBSD_version: 1300139
	repo_type      : binary
	repository     : FreeBSD
Flat size      : 6.10MiB
Description    :
Redis is an open source, advanced key-value store.  It is often referred
to as a data structure server since keys can contain strings, hashes,
lists, sets and sorted sets.

You can run atomic operations on these types, like appending to a string;
incrementing the value in a hash; pushing to a list; computing set
intersection, union and difference; or getting the member with highest
ranking in a sorted set.

In order to achieve its outstanding performance, Redis works with an
in-memory dataset.  Depending on your use case, you can persist it either
by dumping the dataset to disk every once in a while, or by appending each
command to a log.

Redis also supports trivial-to-setup master-slave replication, with very
fast non-blocking first synchronization, auto-reconnection on net split
and so forth.


Now that the service has been installed, let’s start it with this command:

# service redis onestart
Starting redis.

Enable the service so it starts on boot:

# sysrc redis_enable="YES"
redis_enable:  -> YES

After the service starts, use this command to check the status of the service:

# service redis status
redis is running as pid 33056.

The above indicates that the service has been started successfully.

3. Configuring Redis

The redis configuration file is located in this path /usr/local/etc/redis.conf. In this section, we are going to update the redis configuration file to allow remote access, to set an authentication password, to add a pid file and to Set Persistent Store for Recovery.

Edit redis config file using this:

vim /usr/local/etc/redis.conf

To allow remote access to the redis instance, bind redis to using this line:

bind * -::*

To set password in redis, use this:

requirepass j2GfJuLFR8

To add a pid file to redis:

pidfile /var/run/redis/

Set Persistent Store for Recovery by changing the appendonlyvalue to yes

appendonly yes
appendfilename "appendonly.aof"

Restart redis service to apply changes:

# service redis restart
Stopping redis.
Waiting for PIDS: 33056.
Starting redis.

4. Connecting and performing basic operations in Redis

Connecting to redis locally:

# redis-cli

To authenticate:> auth j2GfJuLFR8

You should receive OK in the output. If you input a wrong password, Authentication should fail.

Check redis information.> INFO

This will output a long list of data. You can limit the output by passing Section as an argument. E.g.> INFO Server
# Server
os:FreeBSD 13.0-RELEASE-p4 amd64

5. Performing Redis Benchmarking

Run the benchmark with 15 parallel connections, for a total of 10k requests, against local redis to test its performance.

# redis-benchmark -h -p 6379 -n 10000 -c 15 -a j2GfJuLFR8
====== PING_INLINE ======
  10000 requests completed in 0.23 seconds
  15 parallel clients
  3 bytes payload
  keep alive: 1
  host configuration "save": 3600 1 300 100 60 10000
  host configuration "appendonly": no
  multi-thread: no

Latency by percentile distribution:
0.000% <= 0.031 milliseconds (cumulative count 1)
50.000% <= 0.095 milliseconds (cumulative count 6342)
75.000% <= 0.103 milliseconds (cumulative count 7740)


Cumulative distribution of latencies:
29.540% <= 0.103 milliseconds (cumulative count 2954)
99.810% <= 0.207 milliseconds (cumulative count 9981)
99.990% <= 0.303 milliseconds (cumulative count 9999)
100.000% <= 0.407 milliseconds (cumulative count 10000)

  throughput summary: 91743.12 requests per second
  latency summary (msec):
          avg       min       p50       p95       p99       max
        0.121     0.032     0.127     0.167     0.183     0.319

For more options and examples, use:

$ redis-benchmark --help


In this guide, we have managed to install and configure Redis 6 in FreeBSD 13.

I am a Devops Engineer, but I would describe myself as a Tech Enthusiast who is a fan of Open Source, Linux, Automations, Cloud and Virtualization. I love learning and exploring new things so I blog in my free time about Devops related stuff, Linux, Automations and Open Source software. I can also code in Python and Golang.

Write A Comment