Redis Stack搭建

参考
https://redis.io/docs/latest/operate/oss_and_stack/install/archive/install-stack/docker/

  1. 环境查看
    系统环境
# cat /etc/redhat-release 
Rocky Linux release 9.3 (Blue Onyx)
# uname -a
Linux Rocky9Milvus003075 5.14.0-362.18.1.el9_3.0.1.x86_64 #1 SMP PREEMPT_DYNAMIC Sun Feb 11 13:49:23 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

软件环境

# docker version
Client: Docker Engine - Community
 Version:           25.0.3
 API version:       1.44
 Go version:        go1.21.6
 Git commit:        4debf41
 Built:             Tue Feb  6 21:14:42 2024
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          25.0.3
  API version:      1.44 (minimum version 1.24)
  Go version:       go1.21.6
  Git commit:       f417435
  Built:            Tue Feb  6 21:13:06 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.28
  GitCommit:        ae07eda36dd25f8a1b98dfbf587313b99c0190bb
 runc:
  Version:          1.1.12
  GitCommit:        v1.1.12-0-g51d5e94
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
# docker-compose version
Docker Compose version v2.23.3
  1. 设置docker-compose配置文件
# cat docker-compose.yml 
version: "3.8"

services:
  redis-stack:
    image: redis/redis-stack:latest
    container_name: redis-stack
    ports:
      - "6379:6379"   # Redis 服务端口
      - "8001:8001"   # Redis Stack Web UI 端口
    environment:
      # 这里设置 Redis 连接密码
      - REDIS_ARGS=--requirepass qwer1234
    volumes:
      - /root/redis-stack/data:/data            # Redis 数据持久化目录需要使用绝对路径否则不会持久化数据
    restart: always
  1. 启动
# docker-compose up -d
  1. 验证数据是否持久化
# redis-cli -a qwer1234
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
127.0.0.1:6379> set a 1
127.0.0.1:6379> get a 1
127.0.0.1:6379> save

退出终端查看数据目录是否生成数据文件

# ls data/
dump.rdb

重启docker-compose验证

# docker-compose down
# docker-compose up -d

查看数据

# redis-cli -a qwer1234
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
127.0.0.1:6379> get a
"1"
  1. 使用自带webUI查看
    访问地址
http://ip:8001

image
查看值
image

posted @ 2025-10-11 09:39  minseo  阅读(10)  评论(0)    收藏  举报