How can I configure the anti-spam learning in Warden to use Redis/Valkey for storing bayes data ?

Overview

For high-volume mail servers, migrating the SpamAssassin Bayes storage backend from MySQL to Redis or Valkey significantly improves performance. This configuration stores spam training data and executes lookups in memory, reducing latency and increasing throughput.

Prerequisites:

  • Memory Allocation: Ensure sufficient available RAM on the server. A typical deployment consumes less than 100 MB for Bayes data, while high-traffic servers may require over 1 GB.
  • Network Security: Secure your Redis/Valkey installation before proceeding. Bind the service to the IPv4 loopback interface (127.0.0.1) and ensure port 6379 is not exposed to external networks.

Export Current Bayes Data

Before switching backends, export the existing MySQL-stored Bayes data to a temporary file for later import.

sa-learn -u amavis --backup > /tmp/amavis-bayes.db

Install Redis or Valkey

Select the installation method corresponding to your operating system. Note that Enterprise Linux 10 utilizes Valkey (an open-source fork) due to licensing changes, while older versions utilize Redis.

AlmaLinux/CloudLinux/RHEL 10

yum install valkey
systemctl enable valkey --now

AlmaLinux/CloudLinux/RHEL 9/8

yum install redis
systemctl enable redis --now 

Debian/Ubuntu

apt-get install redis-server
systemctl enable redis-server --now 

Configure Authentication

Edit the redis.conf or valkey.conf file to enforce password authentication. Locate and uncomment the following directive, replacing the placeholder with a strong, secure password:

# requirepass foobared

Enable Redis in Warden

  1. Navigate to Warden > Settings > Learning Settings.
  2. Change the Bayes store module option to Redis.
  3. Enter the configured Redis password in the Bayes SQL DSN field.
  4. Set the Bayes Token TTL (time-to-live for entries):
    • Low-volume servers: 180d (6 months)
    • High-volume servers: 90d (3 months)
  5. Click the Update button to save your settings.

Verify Configuration

If the configuration is successful, the Anti-spam learning dashboard widget will reset to zero. The counter will increment throughout the day as real-time learning, auto-learning, and nightly training processes execute.

Monitor the dashboard to confirm that learning processes are actively updating the Redis backend.

Import Bayes Data

Restore the previously exported Bayes data into the Redis backend by executing the following command:

sa-learn -u amavis --restore /tmp/amavis-bayes.db

Troubleshooting & Common Issues

SpamAssassin 4.0.2 Redis Authentication Bug

SpamAssassin version 4.0.2 contains a known issue that prevents successful connections to password-protected Redis instances. This fix has been backported in RPM packages available via the danami-warden repository. Debian/Ubuntu users may need to apply the patch manually or upgrade their SpamAssassin installation. Refer to the official commit for details: GitHub Commit.

  • redis, learning, bayes, optimize, performance, valkey
  • 2 유용하다고 생각한 사용자 수
이 답변이 도움이 되셨나요?

관련 기사

How can I install or upgrade the extension?

We provide free installation and configuration for all our paid licenses. Open a support ticket...

How can I add stronger Postfix restrictions so that the bulk of spam is rejected at the SMTPD level before it gets processed by Amavis?

Overview Warden enables administrators to enforce stricter Postfix SMTPD restrictions. These...

How can I change the interface language of the extension?

Overview This article provides instructions on how to change the interface language within the...

How can I configure greylisting with Warden Anti-spam and Virus protection?

Overview Greylisting is an email filtering mechanism designed to mitigate spam by temporarily...