Manual Installation and Optimization of Redis 7 from Source on Ubuntu 24.04 VPS

Introduction

At ByteHosting, we understand the importance of having a reliable and high-performance database system like Redis for your applications. While Redis is available through many package managers, sometimes you need the latest version or want to customize your build for optimal performance. In this guide, we will walk you through the manual installation and optimization of Redis 7 from source on Ubuntu 24.04 VPS. Whether you're running a small-scale project or a resource-constrained environment, our step-by-step instructions will help you get Redis up and running efficiently.

Prerequisites: VPS Setup and Required Packages

Before we begin, ensure your Ubuntu 24.04 VPS is properly set up. We recommend a clean installation with root or sudo privileges. Our affordable KVM-based VPS plans in Frankfurt am Main provide a solid foundation for deploying Redis and other services.

Next, install the essential packages needed for building Redis from source:

sudo apt update
sudo apt install build-essential tcl git -y

This command installs the compiler, make tools, TCL (used for testing), and Git (if you want to clone the source code directly).

Downloading Redis 7 Source Code

Redis 7 source code is available on the official Redis GitHub repository. You can clone the latest stable release directly:

git clone --branch 7.0.0 https://github.com/redis/redis.git

Alternatively, you can download a specific release tarball from the Redis website or GitHub releases page. Cloning the repository allows you to stay updated with the latest commits and patches.

Compiling and Installing Redis from Source

Once the source code is downloaded, navigate into the directory:

cd redis

Build Redis using the provided makefile:

make -j$(nproc)

This command compiles Redis utilizing all available CPU cores, speeding up the build process. After compilation, run the test suite to ensure everything works correctly:

make test

Note: Running tests can take some time, especially on low-resource VPS. If you prefer to skip tests, you can proceed with:

sudo make install

Finally, install Redis binaries system-wide:

sudo make install

This installs the Redis server and CLI tools into /usr/local/bin.

Configuring Redis for Optimal Performance on Low RAM

After installation, the next step is configuring Redis for your environment. The main configuration file is located at /etc/redis/redis.conf. For low-resource VPS, consider the following optimizations:

  • Memory management: Set maxmemory to limit Redis memory usage:
maxmemory 512mb
  • Eviction policy: Choose an eviction policy suitable for your workload, e.g., allkeys-lru:
maxmemory-policy allkeys-lru
  • Persistence: Disable or reduce persistence if not needed, to save I/O and memory:
save 900 1
save 300 10
save 60 10000
# Comment out or remove these lines for no persistence

Adjust other settings like tcp-keepalive and timeout to optimize network performance. After editing, restart Redis:

sudo systemctl restart redis.service

Verifying Redis Installation and Basic Operation

To verify Redis is running correctly, connect using the Redis CLI:

redis-cli ping

If Redis is operational, it will respond with PONG. You can also check the service status:

sudo systemctl status redis

Test basic commands like setting and getting keys:

redis-cli
127.0.0.1:6379> set testkey "Hello Redis"
OK
127.0.0.1:6379> get testkey
"Hello Redis"

Troubleshooting Common Installation and Configuration Issues

If Redis fails to start or respond, check the logs:

sudo journalctl -u redis

Ensure your configuration file has correct syntax and paths. For low-resource environments, monitor memory usage and adjust maxmemory accordingly. If you encounter compilation errors, verify that all dependencies are installed and that your system is up to date.

Conclusion

Manually installing Redis 7 from source on Ubuntu 24.04 gives you control over the build and configuration, allowing for tailored performance tuning especially on low-resource VPS environments. At ByteHosting, we provide reliable, affordable VPS hosting in Frankfurt am Main, making it easy to deploy Redis and other critical services. Follow our step-by-step guide to ensure a smooth installation process and optimize Redis for your specific needs. If you need a cost-effective VPS to run Redis or other applications, explore our plans and get started today!

Read more