02redis
# 1.Redis的优势-能干什么
- 1.性能极高 – Redis能读的速度是110000次/秒,写的速度是81000次/秒
- 2.数据类型丰富,不仅仅支持简单的key-value类型的数据,同时还提供list,set,zset,hash等数据结构
- 3.Redis支持数据的持久化,可以将内存中的数据保持在磁盘中,重启的时候可以再次加载进行使用
- 4.Redis支持数据的备份,即master-slave模式的数据备份
# 2.Redis的安装
# 2.1 官网地址
https://redis.io/ (opens new window)
中文:
- http://www.redis.cn/ (opens new window)
- https://www.redis.com.cn/documentation.html (opens new window)
# 2.2 下载安装
docker 安装
version: '3'
services:
redis:
image: registry.cn-hangzhou.aliyuncs.com/zhengqing/redis:7.0.5 # 镜像'redis:7.0.5'
container_name: redis # 容器名为'redis'
# restart: unless-stopped # 指定容器退出后的重启策略为始终重启,但是不考虑在Docker守护进程启动时就已经停止了的容器
command: redis-server --requirepass 123456 --appendonly yes # 启动redis服务并添加密码为:123456,并开启redis持久化配置
environment: # 设置环境变量,相当于docker run命令中的-e
TZ: Asia/Shanghai
LANG: en_US.UTF-8
volumes: # 数据卷挂载路径设置,将本机目录映射到容器目录
- "./redis/data:/data"
- "./redis/config/redis.conf:/etc/redis/redis.conf" # `redis.conf`文件内容`http://download.redis.io/redis-stable/redis.conf`
ports: # 映射端口
- "6379:6379"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
进入redis命令行
chmod -R 777 ./redis
# 运行 -- 单机模式
docker-compose -f docker-compose-redis.yml -p redis up -d
docker exec -it redis redis-cli -a 123456
1
2
3
4
5
2
3
4
5
# 2.3 文档资料
源码地址 https://github.com/redis/redis (opens new window)
编辑 (opens new window)
上次更新: 2024/07/30, 22:54:54