From 0c138c438fa01ad11b316a221121956e72f46fca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E6=9F=922012?= <345849402@qq.com> Date: Tue, 21 Jul 2020 21:22:58 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E6=9E=B6=E6=9E=84=E4=B9=8B=E8=B7=AF/?= =?UTF-8?q?=E7=BC=93=E5=AD=98/Redis=E5=8D=95=E6=9C=BA=E5=AE=89=E8=A3=85?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E8=AF=B4=E6=98=8E.md.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 架构之路/缓存/Redis单机安装配置说明.md | 47 ++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 架构之路/缓存/Redis单机安装配置说明.md diff --git a/架构之路/缓存/Redis单机安装配置说明.md b/架构之路/缓存/Redis单机安装配置说明.md new file mode 100644 index 0000000..85225a5 --- /dev/null +++ b/架构之路/缓存/Redis单机安装配置说明.md @@ -0,0 +1,47 @@ +#### 获取配置文件: + +``` +wget -P /usr/local/redis http://download.redis.io/redis-stable/redis.conf +``` +#### 修改配置文件: + +``` +vi /usr/local/redis/redis.conf +``` + +#### 启动容器: + +``` +docker run -d --name redis -p 6379:6379 -v /usr/local/redis/redis.conf:/etc/redis/redis.conf redis redis-server /etc/redis/redis.conf --appendonly yes --requirepass '123456' +``` + +| 参数 | 说明 | +|---|---| +| -d | 后台运行容器 | +| --name redis | 设置容器名为 redis | +| -p 6379:6379 | 将宿主机 6379 端口映射到容器的 6379 端口 | +| -v /usr/local/redis/redis.conf:/etc/redis/redis.conf | 将宿主机redis.conf映射到容器内 | +| -v /usr/local/redis/data:/data | 将宿主机 /usr/local/redis/data 映射到容器 /data , 方便备份持久数据 | +| redis-server /etc/redis/redis.conf | redis 服务以容器内的 redis.conf 配置启动 | +| --appendonly yes | redis 数据持久化 | +| --requirepass '123456' | 连接密码 | + + +#### 进入容器: + +``` +docker exec -it app_learn /bin/bash +``` + +#### 测试连接: + + +``` +./redis-cli -h 127.0.0.1 -p 6379 +``` + +输入 auth 123456#你刚才设置的密码 + + + +