您的位置:首页 > 数据库 > Redis

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

2020-07-14 06:23 3351 查看

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时,需要考虑清楚。

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: