docker installation redis7-stand-alone version

Download the redis image

Reference for each version of the redis image: redis image  , here we take redis7.0.5 as an example

docker pull redis:7.0.5

Create mount directory

Just create the corresponding directory according to the mounting path of the mounting directory.

mkdir -p /root/data/redis/conf(自己的挂载路径)
mkdir -p /root/data/redis/data(自己的挂载路径)

Download the redis configuration file 

There is no corresponding redis.conf configuration file in the redis7 version image. You need to manually download the corresponding version of the configuration file.

 Download address reference: github redis download address for each version  , the following takes version 7.0.5 as an example

wget -P /root/software https://github.com/redis/redis/archive/refs/tags/7.0.5.tar.gz

After the download is successful, you can see the corresponding installation package in the corresponding path.

 Unzip the installation package

Remember to change the decompression path to your own download path

tar -zxvf /root/software/7.0.5.tar.gz -C /root/software/

Copy redis.conf to the mount directory

cp /root/software/redis-7.0.5/redis.conf /root/data/redis/conf/

Modify the content of redis.conf in the mount directory

bind 0.0.0.0                # 修改这部分,使redis可以外部访问
protected-mode yes          # 保护模式,默认yes,如果不需要保护模式可以设置为no
port 6379                   # 端口号, 默认是6379,看个人情况修改
logfile /data/redis.log     # 日志文件存放位置
daemonize no                # 用守护线程的方式启动,关闭
dir /data                   # 数据存放目录
requirepass <your password> # 密码
appendonly yes              # redis 开启AOF方式持久化 默认是no
appenddirname "aof"         # aof文件存放的文件夹名称,不能带/,根据个人情况决定是否修改

Start redis

docker run -p 6379:6379 \
--privileged=true \
-v /root/data/redis/data:/data \
-v /root/data/redis/conf:/usr/local/etc/redis \
--name redis \
--restart=always \
-d redis:7.0.5 \
redis-server /usr/local/etc/redis/redis.conf

Link redis client

docker exec -it redis(也可以使用容器id) redis-cli

Use auth to verify password login

auth <your password>

 At this time, you can see that the corresponding file has been generated in the data directory of the mounted volume.

Finish

If you have any questions, please feel free to communicate

Guess you like

Origin blog.csdn.net/LSW_JAVADP/article/details/132274663