Use snap to install Redis and configure external network access and access password

Use snap to install Redis and configure external network access and access password

Redis is a popular open source in-memory database for handling data storage and caching. In this article, we will introduce how to use snap to install Redis, and configure external network access and access password through Redis CLI (command line interface).

snap is a package manager for installing software on Linux systems that provides an easy and reliable way to install and manage software. We'll use snap to install Redis and configure it with a few simple commands.

Here are the steps to install and configure Redis:

Step 1: Install Redis

First, make sure snap is installed on your system. If snap is not installed, follow the instructions provided by your Linux distribution to install it.

Open a terminal and execute the following command to install Redis:

$ sudo snap install redis

Wait for the installation to complete.

Step 2: Enter Redis CLI

The snap installation of Redis has no pre-configured files ( redis.conf). Therefore, we need to use Redis's CLI to enter the console and configure it.

Enter the Redis CLI by running the following command in a terminal:

$ redis.cli

You will see a prompt indicating that you have entered the Redis CLI interface.

Step 3: Configure external network access

To configure Redis to allow external network access, use the following command:

config set bind 0.0.0.0

This will bind the Redis server to the 0.0.0.0 IP address, making it externally accessible. Note that this may present some security risks, so proceed with caution.

Step 4: Set Access Password

To set a password for Redis access, use the following command:

config set requirepass mypass

This will set a password named "mypass" as a requirement to access Redis. Be sure to replace "mypass" with a strong password of your choice.

Your configuration changes are now saved, and the Redis server is configured to allow Internet access and access with a password.

Note that if you are using a firewall or network security group, make sure to open the port used by Redis (usually 6379) to allow external access.

Congratulations! You have successfully installed Redis using snap and configured external network access and access password. You can now use Redis to store and process data as needed.

Hope this article can help you get started with Redis quickly. If you have any questions, feel free to leave a comment below. thanks for reading!

other

The following is my redis info information. Different versions of reids may be different, post INFO information for your reference version.

# Server
redis_version:7.0.11
redis_git_sha1:391aa407
redis_git_dirty:0
redis_build_id:4b973c29b1204b90
redis_mode:standalone
os:Linux 5.15.0-73-generic x86_64
arch_bits:64
monotonic_clock:POSIX clock_gettime
multiplexing_api:epoll
atomicvar_api:c11-builtin
gcc_version:9.4.0
process_id:13526
process_supervised:no
run_id:bdf1f0e3f99002a123a9fa123b6dc4c42224e486
tcp_port:6379
server_time_usec:1686034829443208
uptime_in_seconds:3233
uptime_in_days:0
hz:10
configured_hz:10
lru_clock:8313229
executable:/snap/redis/902/usr/bin/redis-server
config_file:
io_threads_active:0

Guess you like

Origin blog.csdn.net/kaka_buka/article/details/131068208
Recommended