aws codebuild / 使用本地 redis(ubuntu 图片)

aws codebuild / using local redis (ubuntu image)

开始代码构建;目前希望在本地 ubuntu 图像上使用 redis;
使用以下脚本:

version: 0.2
phases:
  install:
    commands:
      - apt update
      - apt install -y redis-server wget 
  pre_build:
    commands:
      - wget https://raw.githubusercontent.com/Hronom/wait-for-redis/master/wait-for-redis.sh
      - chmod +x ./wait-for-redis.sh
      - service redis-server start
      - ./wait-for-redis.sh localhost:6379
  build:
    commands:
      - redis-cli info
      - redis-cli info server

目前看来 docker-compose 并不是最终必需的,我们将首先考虑以这种方式使用它 - 期待标准的 ubuntu 行为。

我们正在使用类似的方法安装 postgres,它确实可以正常启动并且完全可用。

这里我们无法正常启动redis,wait-for-redis不断重试(不断报错Could not connect to Redis at localhost:6379: Connection refused

使用 ec2 linux 图像(基于 yum),我们没有这样的问题

在 ubuntu 上下文中启动 redis 的正确方法是什么?

刚 运行 遇到同样的问题。

当我向构建规范添加 cat /var/log/redis/*.log 时,我发现 Redis 无法绑定:

Creating Server TCP listening socket ::1:6379: bind: Cannot assign requested address

进一步的研究表明这是一个已知问题:https://github.com/redis/redis/issues/3241

... 可以通过将这些行添加到构建规范(在使用 redis 之前)来修复:

- sed -i '/^bind/s/bind.*/bind 127.0.0.1/' /etc/redis/redis.conf
- service redis-server restart