docker安装redis及避坑:‘locale-collate ““‘ Bad directive or wrong number of arguments

一、步骤

拉取redis镜像

docker pull redis

创建挂载目录

mkdir /mydata/redis/data

进入挂载目录/mydata/redis,下载redis.conf文件

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

在这里插入图片描述

授权

chmod 777 redis.conf

修改默认配置信息

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

docker启动redis

docker run -d --name=redis01  \
-p 6379:6379 \
-v /mydata/redis/redis.conf:/etc/redis/redis.conf \
-v /mydata/redis/data:/data \
--restart=always \
redis:latest redis-server /etc/redis/redis.conf

二、踩坑

完成以上步骤,发现redis容器启动报错,查看日志:

*** FATAL CONFIG FILE ERROR (Redis 6.2.6) ***
Reading the configuration file, at line 416
>>> 'locale-collate ""'
Bad directive or wrong number of arguments

*** FATAL CONFIG FILE ERROR (Redis 6.2.6) ***
Reading the configuration file, at line 416
>>> 'locale-collate ""'
Bad directive or wrong number of arguments

*** FATAL CONFIG FILE ERROR (Redis 6.2.6) ***
Reading the configuration file, at line 416
>>> 'locale-collate ""'
Bad directive or wrong number of arguments

*** FATAL CONFIG FILE ERROR (Redis 6.2.6) ***
Reading the configuration file, at line 416
>>> 'locale-collate ""'
Bad directive or wrong number of arguments

*** FATAL CONFIG FILE ERROR (Redis 6.2.6) ***
Reading the configuration file, at line 416
>>> 'locale-collate ""'
Bad directive or wrong number of arguments

*** FATAL CONFIG FILE ERROR (Redis 6.2.6) ***
Reading the configuration file, at line 416
>>> 'locale-collate ""'
Bad directive or wrong number of arguments

三、解决

问题原因:不同的redis版本需要不同的配置文件,根据报错日志可知当前redis的版本为6.2.6,所以需要去redis官网下载对应版本的配置文件
redis配置文件下载地址
在这里插入图片描述
下载后把之前的redis.conf替换掉,然后按照之前的方法修改配置信息,完成后再次启动redis

docker run -d --name=redis01  \
-p 6379:6379 \
-v /mydata/redis/redis.conf:/etc/redis/redis.conf \
-v /mydata/redis/data:/data \
--restart=always \
redis:latest redis-server /etc/redis/redis.conf

这下成功启动:
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值