OpenBSD Handbook

    Theme
    • Part I. Install & Configure
      • Introduction to OpenBSD
      • Installing OpenBSD
      • The X Window System
      • Networking on OpenBSD
      • System Configuration
      • OpenBSD Basics
      • Managing Software: Packages and Ports
    • Part II. Daily Operations
      • OpenBSD Desktop Environments
      • Multimedia
      • Printing
      • Linux Compatibility
      • Windows Compatibility
      • Games
    • Part III. System Administration
      • Virtualization
      • Storage and File Systems
      • Updating and Upgrading
      • Localization
      • The OpenBSD Boot Process
      • Security
    • Part IV. Networking & Daemons
      • Services
        • Database
          • MariaDB
          • PostgreSQL
          • Redis
          • memcached
        • Directory
          • YP (NIS)
          • LDAP
        • File
          • NFS
          • Samba
        • FTP Services
          • ftpd
          • ProFTPD
          • vsftpd
          • Pure-FTPd
          • TFTP
        • Mail
          • OpenSMTPD Mail Server
          • Dovecot IMAP and POP3 Server
          • Postfix
          • Exim
          • Rspamd
        • Name
          • Unbound DNS Resolver
          • NSD Authoritative DNS Server
          • BIND DNS Server
        • Networking
          • OpenBGPD
          • rad
          • DHCP on OpenBSD
          • slaacd
        • Web
          • Apache HTTP Server
          • nginx Web Server
          • OpenBSD httpd Web Server
          • relayd Reverse Proxy
        • Logging
          • syslogd
        • Monitoring
          • SNMP
        • Remote Access
          • Audit OpenSSH
          • OpenSSH Server
        • File Synchronization
          • rsync
        • Messaging
          • RabbitMQ Message Broker
        • Time
          • NTP Time Synchronization
        • Load Balancing
          • Build Redundant Load-Balanced Gateways
          • Load Balance Services with NAT or DSR
          • Build an HA HTTPS Load Balancer
      • PF
        • pfctl cheat sheet
        • PF Anchors
        • PF Filter Rules
        • PF Forwarding
        • PF Lists and Macros
        • PF Load Balancing
        • PF Logging
        • PF NAT
        • PF Options
        • PF Policies
        • PF Shortcuts
        • PF Tables
      • Advanced Networking
        • High Availability and State Replication
        • Multi-WAN and Policy-Based Routing
        • VPN and Cryptographic Tunneling
        • Classic and Lightweight Tunnels
        • IPv6 at Scale
        • QoS and Traffic Shaping
        • MPLS and Label Distribution
        • Network Services at Scale
        • Virtualization and Host Networking
        • Large-Scale L2 and L3 Design
        • Telemetry, Logging, and Flow Export
        • Hardening and Operational Safety
        • Reference Architectures
        • Troubleshooting Playbooks
      • Serial Communication
    • Part V. Miscellaneous
      • Virtualization Cheat Sheet
      • OpenBSD Cheatsheet
      • How-to Guides
        • Installation and First Boot
          • Complete the First 30 Minutes After Installation
          • Check Hardware Compatibility Before Installing
          • Bootstrap Wi-Fi Firmware Without Ethernet
          • Run OpenBSD as a Virtual Machine Guest
          • Install OpenBSD on a VPS or Cloud Server
          • Install OpenBSD with Full-Disk Encryption
          • Dual-Boot OpenBSD on a UEFI System
          • Automate OpenBSD Installation with Autoinstall and PXE
        • Desktops and Laptops
          • Set Up OpenBSD as a Laptop or Workstation
          • Configure Laptop Power Management
          • Troubleshoot Web Browsers on OpenBSD
          • Use Plan 9 Tools on OpenBSD
          • Build a Minimal Desktop with suckless Tools
          • Install Z shell (zsh)
        • Networking and Remote Access
          • Create an Administrator Account with doas and SSH Keys
          • Configure Secure Remote Access with OpenSSH
          • Use FIDO Security Keys with OpenSSH
          • Configure Wi-Fi Roaming and Wired Failover
          • Troubleshoot PF, NAT, and Routing
          • Route Multiple VLANs with PF
          • Configure a Road-Warrior WireGuard VPN
          • Route IPv6 Networks without NAT
          • Test OpenBGPD with Two Providers
          • Unlock an Internal Service with an SSH Key
          • Build a Simple Router and Firewall
        • Servers and Services
          • Set Up WordPress on OpenBSD
          • Build a Mail Server with OpenSMTPD, Dovecot, and Rspamd
        • Security, Maintenance and Recovery
          • Establish a Conservative Security Baseline
          • Recover Access and Reset the Root Password
          • Collect OpenBSD Diagnostic Evidence
          • Troubleshoot Package Installation and Update Failures
          • Schedule Recurring Maintenance
          • Monitor an OpenBSD System
          • Back Up and Restore an OpenBSD System
          • Configure softraid RAID1
          • Recover an OpenBSD System That Does Not Boot
        • Building, Automation and Virtual Machines
          • Manage OpenBSD with Ansible
          • Build Third-Party Software from Ports
          • Build OpenBSD from Source
          • Plan a Docker Workload Migration to OpenBSD
      • OpenBSD for Linux Users
      • OpenBSD for FreeBSD Users
      • OpenBSD for macOS Users
    • OpenBSD FAQ
    • OpenBSD Architectures
      • OpenBSD Package Search
        • Synopsis
        • Installation
        • Configuration
        • Enabling the Service
        • Basic Usage
        • Persistence
        • Remote Access and Security
        • Service Management

        Redis

        Synopsis #

        Redis stores key-value data in memory, including strings, hashes, sets, sorted sets, and streams. It also supports saving data to disk, replication, and Lua scripting.

        Redis is commonly used for caching, messaging, job queues, and ephemeral data storage.

        Redis is not included in the OpenBSD base system, but is available via packages. The Redis server runs as a daemon (redis-server) and is managed with rcctl(8).

        Installation #

        Install the Redis package:

        doas pkg_add redis
        

        This installs:

        • redis-server: the main daemon
        • redis-cli: command-line interface client
        • Default configuration at /etc/redis/redis.conf

        Configuration #

        The main configuration file is:

        /etc/redis/redis.conf
        

        A minimal configuration example:

        bind 127.0.0.1
        port 6379
        
        daemonize yes
        pidfile /var/run/redis/redis.pid
        logfile ""
        syslog-enabled yes
        syslog-facility daemon
        
        dir /var/redis
        dbfilename dump.rdb
        

        Key options:

        • bind: restricts listening to loopback
        • port: default is 6379
        • daemonize: yes for the packaged rc service
        • dir: working directory for data persistence
        • logfile: optional file logging; syslog requires syslog-enabled yes

        Create the data directory if not present:

        doas mkdir -p /var/redis
        doas chown _redis:_redis /var/redis
        

        Enabling the Service #

        Enable and start Redis:

        doas rcctl enable redis
        doas rcctl start redis
        

        Check status:

        doas rcctl check redis
        

        View logs:

        doas tail -f /var/log/daemon
        

        Basic Usage #

        Connect using the Redis client:

        $ redis-cli
        127.0.0.1:6379> SET keyname "hello"
        OK
        127.0.0.1:6379> GET keyname
        "hello"
        

        Exit the client with CTRL+D or QUIT.

        Persistence #

        Redis can save the dataset to disk in two ways:

        1. RDB (snapshotting) — default method using dump.rdb
        2. AOF (append-only file) — logs each write operation

        To enable AOF persistence in /etc/redis/redis.conf:

        appendonly yes
        appendfilename "appendonly.aof"
        

        Restart Redis to apply:

        doas rcctl restart redis
        

        For a backup, stop Redis cleanly, copy its configured persistence files, then restart it. Test restoration in a separate instance. For backups without downtime, use a completed RDB snapshot or follow the documented AOF backup procedure; copying files during an AOF rewrite may produce an incomplete backup.

        Remote Access and Security #

        By default, Redis binds to 127.0.0.1 only.

        To allow access from remote hosts (not recommended unless protected):

        1. Change bind address in /etc/redis/redis.conf:
        bind 127.0.0.1 192.0.2.1
        
        1. (Optional) Set a password:
        requirepass "strongsecret"
        
        1. Use pf(4) to restrict port 6379:
        pass in on $int_if proto tcp from 192.0.2.0/24 to port 6379
        
        1. Restart Redis:
        doas rcctl restart redis
        

        Accessing with authentication:

        redis-cli -a strongsecret
        

        The OpenBSD 8.0 Redis ports build TLS support. Configure Redis TLS certificates and listeners following the installed configuration documentation; the plain TCP example above does not encrypt traffic.

        Service Management #

        Standard service commands:

        doas rcctl enable redis
        doas rcctl start redis
        doas rcctl restart redis
        doas rcctl check redis
        
        Report a bug
        • Synopsis
        • Installation
        • Configuration
        • Enabling the Service
        • Basic Usage
        • Persistence
        • Remote Access and Security
        • Service Management