gpt4 book ai didi

amazon-web-services - aws codebuild/使用本地 redis(ubuntu 镜像)

转载 作者:行者123 更新时间:2023-12-03 06:42:23 26 4
gpt4 key购买 nike

进入代码构建;目前希望在本地 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到 buildspec 我发现 Redis 无法绑定(bind):

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

关于amazon-web-services - aws codebuild/使用本地 redis(ubuntu 镜像),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62772318/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com