
Redis® is an in-memory NoSQL database used as a key-value store, document database, or vector database. It supports fast read and write operations with common data structures such as Strings, Hash, List, Set, Stream, and Bitmap. Redis® is a versatile data store used with different types of storage applications such as caching, streaming, and messaging.
This article explains how to install Redis® on a FreeBSD 14.0 server.
Before you begin:
Redis® is available in the default package repositories on FreeBSD 14.0. Follow the steps below to install the latest available package on your server.
Update the server's package index.
Search for all available Redis® packages.
Output:
Install the latest available package. For example, Redis® 7.2.5.
Enable the Redis® service to automatically start at system boot.
Start the Redis® service on your server.
Output:
View the Redis® system service status and verify that it's running.
Output:
Redis® uses the /usr/local/etc/redis.conf file to run on your server with specific configurations. Follow the steps below to modify the configuration file and enable Redis® to listen for incoming connection requests.
Open the Redis® configuration file /usr/local/etc/redis.conf using a text editor such as vi.
Set the timeout configuration directive to close the connection when a client is idle.
Set the daemonze directive to yes to run Redis® as a daemon.
Set the server's verbosity level.
Set the maximum number of databases to run on the server. By default 16.
Set the save configuration directive to periodically take a snapshot of available databases to disk.
Set the maximum number of clients that can connect at the same time.
Set the maximum memory usage limit.
Enable threading when using a multi-core server.
Enable the Append Only File (AOF) option as an alternative persistence mode to avoid database write failures.
Enable the Redis® instance as a cluster node.
Log queries that exceed the specified execution time (microseconds).
Save and close the configuration file.
Restart the Redis® service to apply the configuration changes.
Output:
Follow the steps below to secure Redis®.
Open the main configuration file /usr/local/etc/redis.conf.
Enable protected mode to allow only local connection requests and require password authentication for all users.
Set the default user password.
Bind Redis® to a specific network address on your server such as 127.0.0.1.
Set the following configuration directive to block insecure commands.
Remove sensitive privileges from regular user accounts.
Save and close the configuration file.
Restart Redis® to apply the configuration changes.
Follow the steps below to test access to the Redis® shell.
Access the Redis® CLI.
Authenticate the default user using the password you set earlier.
Output:
Send a PING request to the server and verify that it's accepted.
Output:
Select a database such as 1
Output:
View all secure database user profiles.
Output:
Create a new key in the database with the value Greetings from Vultr.
Output:
View the key value.
Output:
Exit the Redis CLI.
You have installed Redis® on FreeBSD 14.0 and secured the server to enable authentication for all database users. You can integrate Redis® databases with dynamic applications to enable caching and improve your server performance. For more information, visit the Redis® documentation.
0 Comments
Be the first to comment and share your perspective with the community.