How to deploy redis in linux environment and install it in docker

How to deploy redis in linux environment and install it in docker

Installation Steps

1. Install Redis

Download the redis image through docker search redis和docker pull redis

2. Create a new mount configuration folder

Create two new folders, data and conf, in any location.

mkdir -p /root/docker/redis/data
mkdir -p /root/docker/redis/conf

Note: Because of the default configuration of redis, you will find that you can only connect locally and cannot access remotely. Using Redis Desktop Manager to connect will result in an error, so you need to manually mount the redis configuration file

3. Add the configuration file redis.conf

Create a new file redis.conf in the newly created redis/conf with the following content:

#bind 127.0.0.1 //Allow remote connection protected-mode no appendonly yes //Persistence requirepass 123456 //Password

4. Create and start the redis container

The execution command is as follows:

docker run --name myredis -p 6379:6379 -v /root/docker/redis/data:/data -v /root/docker/redis/conf/redis.conf:/etc/redis/redis.conf -d redis redis-server /etc/redis/redis.conf

The interpretation is as follows:

–name: Give the container a name
-p: port mapping host: container
-v: Mount custom configuration custom configuration: container internal configuration
-d: Run in the background
redis-server --appendonly yes: Execute the redis-server startup command in the container and turn on the redis persistence configuration

5. Startup successful, check the status

Check the startup status through docker ps to see if it is successful

6. Test the connection inside the container

Execute docker exec -it my_redis redis-cli command to enter the terminal.

Log in using auth password .

The completed command is as follows:

[root@*** conf]# docker exec -it myredis redis-cli
127.0.0.1:6379> set name jfaith
(error) NOAUTH Authentication required.
127.0.0.1:6379> auth 123456
OK
127.0.0.1:6379> set name wangcai
OK
127.0.0.1:6379> get name
"jfaith"

Note: If this error occurs: (error) NOAUTH Authentication required.

Explanation: No password was entered for verification. Please enter: auth your password

Summarize

The above is the method of Linux environment deployment and Docker installation of redis introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!
If you find this article helpful, please feel free to reprint it and please indicate the source. Thank you!

You may also be interested in:
  • Detailed explanation of Redis installation tutorial under Linux
  • Redis installation and use tutorial under Linux
  • Installation process of Redis database under Linux system

<<:  MySQL 5.7.22 binary package installation and installation-free version Windows configuration method

>>:  How to use mqtt in uniapp project

Recommend

Implementation of pushing Docker images to Docker Hub

After the image is built successfully, it can be ...

Share 101 MySQL debugging and optimization tips

MySQL is a powerful open source database. With th...

The difference between MySQL count(1), count(*), and count(field)

Table of contents 1. First look at COUNT 2. The d...

HTML+CSS to implement the sample code of the navigation bar drop-down menu

Effect The pictures in the code can be changed by...

MySQL method steps to determine whether it is a subset

Table of contents 1. Problem 2. Solution Option 1...

CSS3 uses scale() and rotate() to achieve zooming and rotation

1. scale() method Zoom refers to "reducing&q...

How to choose between MySQL CHAR and VARCHAR

Table of contents VARCHAR and CHAR Types Conclusi...

Install and configure ssh in CentOS7

1. Install openssh-server yum install -y openssl ...

React internationalization react-intl usage

How to achieve internationalization in React? The...

10 skills that make front-end developers worth millions

The skills that front-end developers need to mast...

JavaScript implements the nine-grid mobile puzzle game

This article shares the specific code for JavaScr...

Interpreting MySQL client and server protocols

Table of contents MySQL Client/Server Protocol If...

Vue3 encapsulates the side navigation text skeleton effect component

Vue3 project encapsulation side navigation text s...

Detailed explanation of several methods of JS array dimensionality reduction

Dimensionality reduction of two-dimensional array...