Meg*_*Wis 5 redis docker docker-compose redis-cluster
我正在尝试使用 docker image 配置 Redis 集群bitnami/redis-cluster。
以下是docker-compose.yml:
version: \'3.8\'\n\nservices:\n redis-node-0:\n image: bitnami/redis-cluster:6.2.7\n volumes:\n - redis-node-data-0:/bitnami/redis/data\n environment:\n - ALLOW_EMPTY_PASSWORD=yes\n - REDIS_NODES=redis-node-0 redis-node-1 redis-node-2\n\n redis-node-1:\n image: bitnami/redis-cluster:6.2.7\n volumes:\n - redis-node-data-1:/bitnami/redis/data\n environment:\n - ALLOW_EMPTY_PASSWORD=yes\n - REDIS_NODES=redis-node-0 redis-node-1 redis-node-2\n\n redis-node-2:\n image: bitnami/redis-cluster:6.2.7\n volumes:\n - redis-node-data-2:/bitnami/redis/data\n ports:\n - 6379:6379\n depends_on:\n - redis-node-0\n - redis-node-1\n environment:\n - ALLOW_EMPTY_PASSWORD=yes\n - REDIS_NODES=redis-node-0 redis-node-1 redis-node-2\n - REDIS_CLUSTER_REPLICAS=1\n - REDIS_CLUSTER_CREATOR=yes\n\nvolumes:\n redis-node-data-0:\n driver: local\n redis-node-data-1:\n driver: local\n redis-node-data-2:\n driver: local\nnetworks:\n default:\n name: local_network\n\nRun Code Online (Sandbox Code Playgroud)\nDocker 容器正在完美运行:\n输出docker ps:
| 集装箱编号 | 图像 | 命令 | 已创建 | 地位 | 端口 | 名称 |
|---|---|---|---|---|---|---|
| bea9a7c52eba | bitnami/redis 集群:6.2.7 | “/opt/bitnami/script\xe2\x80\xa6” | 12 分钟前 | 12 分钟前 | 0.0.0.0:6379->6379/tcp | 本地-redis-节点-2-1 |
| 63c08f1330e0 | bitnami/redis 集群:6.2.7 | “/opt/bitnami/script\xe2\x80\xa6” | 12 分钟前 | 12 分钟前 | 6379/TCP | 本地-redis-node-1-1 |
| e1b163d75254 | bitnami/redis 集群:6.2.7 | “/opt/bitnami/script\xe2\x80\xa6” | 12 分钟前 | 12 分钟前 | 6379/TCP | 本地-redis-节点-0-1 |
正如我所设置的local-redis-node-2-1那样REDIS_CLUSTER_CREATOR,现在它负责初始化集群。因此,我正在使用该节点执行以下所有命令。
进入容器内部:docker exec -it local-redis-node-2-1 redis-cli
然后,尝试将数据保存在 redis 中set a 1,出现错误:(error) CLUSTERDOWN Hash slot not serve
输出cluster slots:(empty array)
我试过docker exec -it local-redis-node-2-1 redis-cli --cluster fix localhost:6379。但它只分配6379 slots out of 16383给local-redis-node-2-1其他节点,剩余的插槽不会分配给其他节点。下面是输出cluster slots:
127.0.0.1:6379> cluster slots\n1) 1) (integer) 0\n 2) (integer) 16383\n 3) 1) "172.18.0.9"\n 2) (integer) 6379\n 3) "819770cf8b39793517efa10b9751083c854e15d7"\nRun Code Online (Sandbox Code Playgroud)\n我做错事了。我也很想知道手动解决方案,但更感兴趣的是了解通过 docker-compose 设置集群插槽的解决方案。
\n有人可以帮助我通过 docker-compose.yml 自动设置集群插槽吗?
\n只读副本是否可以与此 docker-compose.yml 一起使用,或者我是否错过了某些内容?
\n另外,有人可以确认在解决集群插槽后集群是否可以正常工作吗?
\n日志local-redis-node-2-1如下:
redis-cluster 00:47:45.70 \nredis-cluster 00:47:45.73 Welcome to the Bitnami redis-cluster container\nredis-cluster 00:47:45.76 Subscribe to project updates by watching https://github.com/bitnami/containers\nredis-cluster 00:47:45.78 Submit issues and feature requests at https://github.com/bitnami/containers/issues\nredis-cluster 00:47:45.80 \nredis-cluster 00:47:45.83 INFO ==> ** Starting Redis setup **\nredis-cluster 00:47:46.00 WARN ==> You set the environment variable ALLOW_EMPTY_PASSWORD=yes. For safety reasons, do not use this flag in a production environment.\nredis-cluster 00:47:46.05 INFO ==> Initializing Redis\nredis-cluster 00:47:46.29 INFO ==> Setting Redis config file\nChanging old IP 172.18.0.8 by the new one 172.18.0.8\nChanging old IP 172.18.0.6 by the new one 172.18.0.6\nChanging old IP 172.18.0.9 by the new one 172.18.0.9\nredis-cluster 00:47:47.30 INFO ==> ** Redis setup finished! **\n\n1:C 10 Dec 2022 00:47:47.579 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo\n1:C 10 Dec 2022 00:47:47.580 # Redis version=6.2.7, bits=64, commit=00000000, modified=0, pid=1, just started\n1:C 10 Dec 2022 00:47:47.580 # Configuration loaded\n1:M 10 Dec 2022 00:47:47.584 * monotonic clock: POSIX clock_gettime\n1:M 10 Dec 2022 00:47:47.588 * Node configuration loaded, I\'m 819770cf8b39793517efa10b9751083c854e15d7\n1:M 10 Dec 2022 00:47:47.595 # A key \'__redis__compare_helper\' was added to Lua globals which is not on the globals allow list nor listed on the deny list.\n1:M 10 Dec 2022 00:47:47.598 * Running mode=cluster, port=6379.\n1:M 10 Dec 2022 00:47:47.599 # Server initialized\n1:M 10 Dec 2022 00:47:47.612 * Ready to accept connections\n1:M 10 Dec 2022 00:47:49.673 # Cluster state changed: ok\nRun Code Online (Sandbox Code Playgroud)\n日志local-redis-node-1-1如下:
redis-cluster 00:47:45.43 \nredis-cluster 00:47:45.46 Welcome to the Bitnami redis-cluster container\nredis-cluster 00:47:45.48 Subscribe to project updates by watching https://github.com/bitnami/containers\nredis-cluster 00:47:45.51 Submit issues and feature requests at https://github.com/bitnami/containers/issues\nredis-cluster 00:47:45.54 \nredis-cluster 00:47:45.56 INFO ==> ** Starting Redis setup **\nredis-cluster 00:47:45.73 WARN ==> You set the environment variable ALLOW_EMPTY_PASSWORD=yes. For safety reasons, do not use this flag in a production environment.\nredis-cluster 00:47:45.79 INFO ==> Initializing Redis\nredis-cluster 00:47:46.00 INFO ==> Setting Redis config file\nChanging old IP 172.18.0.8 by the new one 172.18.0.8\nChanging old IP 172.18.0.6 by the new one 172.18.0.6\nChanging old IP 172.18.0.9 by the new one 172.18.0.9\nredis-cluster 00:47:47.10 INFO ==> ** Redis setup finished! **\n\n1:C 10 Dec 2022 00:47:47.387 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo\n1:C 10 Dec 2022 00:47:47.388 # Redis version=6.2.7, bits=64, commit=00000000, modified=0, pid=1, just started\n1:C 10 Dec 2022 00:47:47.388 # Configuration loaded\n1:M 10 Dec 2022 00:47:47.392 * monotonic clock: POSIX clock_gettime\n1:M 10 Dec 2022 00:47:47.395 * Node configuration loaded, I\'m 2ab0b8db952cc101f7873cdcf8cf691f8f6bae7b\n1:M 10 Dec 2022 00:47:47.403 # A key \'__redis__compare_helper\' was added to Lua globals which is not on the globals allow list nor listed on the deny list.\n1:M 10 Dec 2022 00:47:47.406 * Running mode=cluster, port=6379.\n1:M 10 Dec 2022 00:47:47.407 # Server initialized\n1:M 10 Dec 2022 00:47:47.418 * Ready to accept connections\n1:M 10 Dec 2022 00:56:02.716 # New configEpoch set to 1\n1:M 10 Dec 2022 00:56:41.943 # Cluster state changed: ok\nRun Code Online (Sandbox Code Playgroud)\n日志local-redis-node-0-1如下:
redis-cluster 00:47:45.43 \nredis-cluster 00:47:45.46 Welcome to the Bitnami redis-cluster container\nredis-cluster 00:47:45.49 Subscribe to project updates by watching https://github.com/bitnami/containers\nredis-cluster 00:47:45.51 Submit issues and feature requests at https://github.com/bitnami/containers/issues\nredis-cluster 00:47:45.54 \nredis-cluster 00:47:45.56 INFO ==> ** Starting Redis setup **\nredis-cluster 00:47:45.73 WARN ==> You set the environment variable ALLOW_EMPTY_PASSWORD=yes. For safety reasons, do not use this flag in a production environment.\nredis-cluster 00:47:45.79 INFO ==> Initializing Redis\nredis-cluster 00:47:46.00 INFO ==> Setting Redis config file\nChanging old IP 172.18.0.8 by the new one 172.18.0.8\nChanging old IP 172.18.0.6 by the new one 172.18.0.6\nChanging old IP 172.18.0.9 by the new one 172.18.0.9\nredis-cluster 00:47:47.11 INFO ==> ** Redis setup finished! **\n\n1:C 10 Dec 2022 00:47:47.387 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo\n1:C 10 Dec 2022 00:47:47.388 # Redis version=6.2.7, bits=64, commit=00000000, modified=0, pid=1, just started\n1:C 10 Dec 2022 00:47:47.388 # Configuration loaded\n1:M 10 Dec 2022 00:47:47.391 * monotonic clock: POSIX clock_gettime\n1:M 10 Dec 2022 00:47:47.395 * Node configuration loaded, I\'m 5ffeca48faa750a5f47c76639598fdb9b7b8b720\n1:M 10 Dec 2022 00:47:47.402 # A key \'__redis__compare_helper\' was added to Lua globals which is not on the globals allow list nor listed on the deny list.\n1:M 10 Dec 2022 00:47:47.405 * Running mode=cluster, port=6379.\n1:M 10 Dec 2022 00:47:47.405 # Server initialized\n1:M 10 Dec 2022 00:47:47.415 * Ready to accept connections\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
1378 次 |
| 最近记录: |