arm64下启动redis官方容器报错处理

arm64下启动redis官方容器报错处理

问题

在飞腾服务器(FT2000+,操作系统centos7.4)上启动redis容器报错:
docker run --rm redis
报错内容
<jemalloc>: Unsupported system page size
经过尝试发现redis:4、redis:5、redis:6-rc镜像均会报以上错误,redis:3启动正常。

分析

redis在新版本中默认使用了jemalloc进行内存管理。
由于jemalloc 在编译时就决定了page size的大小,而这个page size 不会由于kernel的配置而改变,因此jemalloc在某个机器上编译,然后运行在其它机器上时可能会出现问题。
推测可能是由于官方arm镜像的编译环境的page size与当前运行环境的page size不一致导致报错。
参考:
https://github.com/jemalloc/jemalloc/issues/467

解决

在运行环境下,重新编译构建redis镜像,即可解决报错

  1. 取得redis官方镜像的dockerfile
    git clone https://github.com/docker-library/redis.git
  2. 进入对应版本的dockerfile目录
    cd redis
    cd 5.0 #准备构建5.0版本的redis镜像
  3. 构建镜像
    docker build -t redis:5.0 .
  4. 运行redis:5.0镜像
    docker run --rm redis:5.0
    查看控制台输出,确认redis成功启动
    1:C 18 Mar 2020 03:39:21.405 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo 1:C 18 Mar 2020 03:39:21.405 # Redis version=5.0.8, bits=64, commit=00000000, modified=0, pid=1, just started 1:C 18 Mar 2020 03:39:21.405 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf 1:M 18 Mar 2020 03:39:21.407 * Running mode=standalone, port=6379. 1:M 18 Mar 2020 03:39:21.407 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128. 1:M 18 Mar 2020 03:39:21.407 # Server initialized 1:M 18 Mar 2020 03:39:21.407 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect. 1:M 18 Mar 2020 03:39:21.407 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled. 1:M 18 Mar 2020 03:39:21.407 * Ready to accept connections

其它

在arm64环境下,centos的pagesize是64k,ubuntu的pagesize是4k,一般来说64k下编译的镜像是可以在小于或者等于64k的环境下运行的,但如果是在4k下编译的镜像,那么是不能在pagesize大于4k的环境下运行的。这个是jemalloc造成的。如果在编译构建镜像时使用libc就不会有这种问题。
在构建的Dockerfile的RUN make xxxx指令前加上ENV USE_JEMALLOC no即可使得编译redis时不使用jemalloc。
当然,jemalloc在某些场景下性能要优于libc,这个在选择用何种方式编译redis时,需要考虑清楚。

  • 4
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值