Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

服务部署--redis #6

Open
bitjian opened this issue Jan 25, 2024 · 0 comments
Open

服务部署--redis #6

bitjian opened this issue Jan 25, 2024 · 0 comments
Labels
docker linux linux常用命令

Comments

@bitjian
Copy link
Owner

bitjian commented Jan 25, 2024

服务部署--redis

安装redis镜像

docker pull redis

创建挂载目录

分别挂载redis配置文件 和 数据目录

mkdir -p ~/docker/redis/conf ~/docker/redis/data
cd ~/docker/redis/conf 

获取官方redis配置文件

wget http://download.redis.io/redis-stable/redis.conf

配置权限

chmod 777 redis.conf

修改默认配置文件 最好用编辑器打开查询并修改对应配置项

vi ~/docker/redis/conf/redis.conf

bind 127.0.0.1 # 这行要注释掉,解除本地连接限制
protected-mode no # 默认yes,如果设置为yes,则只允许在本机的回环连接,其他机器无法连接。
daemonize no # 默认no 为不守护进程模式,docker部署不需要改为yes,docker run -d本身就是后台启动,不然会冲突
requirepass 123456 # 设置密码
appendonly yes # 持久化

启动redis容器

docker run --name redis \
-p 6379:6379 \
-v ~/docker/redis/conf/redis.conf:/etc/redis/redis.conf \
-v ~/docker/redis/data:/data \
--privileged=true \
-d redis redis-server /etc/redis/redis.conf --appendonly yes

说明:
-p 6379:6379:端口映射,前面是宿主机,后面是容器。
–name redis:指定该容器名称。
-v 挂载文件或目录:前面是宿主机,后面是容器。
--privileged=true 设置权限
-d redis redis-server /etc/redis/redis.conf:表示后台启动redis,以配置文件启动redis,加载容器内的conf文件。
appendonly yes:开启redis 持久化。

@bitjian bitjian added linux linux常用命令 docker labels Jan 25, 2024
@bitjian bitjian changed the title 服务部署--nginx 服务部署--redis Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docker linux linux常用命令
Projects
None yet
Development

No branches or pull requests

1 participant