Konfigurace master slave Redis klienta (Redisson) s konfigurací pro docker-compose.
redisson.json
{
"masterSlaveServersConfig": {
"idleConnectionTimeout": 10000,
"connectTimeout": 10000,
"timeout": 3000,
"retryAttempts": 3,
"retryInterval": 1500,
"failedSlaveReconnectionInterval": 3000,
"failedSlaveCheckInterval": 60000,
"password": null,
"subscriptionsPerConnection": 5,
"clientName": null,
"subscriptionConnectionMinimumIdleSize": 1,
"subscriptionConnectionPoolSize": 50,
"slaveConnectionMinimumIdleSize": 24,
"slaveConnectionPoolSize": 64,
"masterConnectionMinimumIdleSize": 24,
"masterConnectionPoolSize": 64,
"readMode": "SLAVE",
"subscriptionMode": "SLAVE",
"slaveAddresses": [
"redis://127.0.0.1:32781",
"redis://127.0.0.1:32782",
"redis://127.0.0.1:32783"
],
"masterAddress": "redis://127.0.0.1:32780",
"database": 0
},
"threads": 16,
"nettyThreads": 32,
"transportMode": "NIO"
}
docker-compose.yml
version: '2'services:
redis-master:
image: 'bitnami/redis:latest'
ports:
- '6379'
environment:
- REDIS_REPLICATION_MODE=master
- ALLOW_EMPTY_PASSWORD=yes
volumes:
- '/home/vitfo/Redis/volume' redis-replica:
image: 'bitnami/redis:latest'
ports:
- '6379'
depends_on:
- redis-master
environment:
- REDIS_REPLICATION_MODE=slave
- REDIS_MASTER_HOST=redis-master
- REDIS_MASTER_PORT_NUMBER=6379
- ALLOW_EMPTY_PASSWORD=yes
docker-compose up –scale redis-master=1 –scale redis-replica=3 vytvoří:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
dbb2a6f2bdae bitnami/redis:latest "/opt/bitnami/script…" 13 seconds ago Up 11 seconds 0.0.0.0:32781->6379/tcp redis_redis-replica_3
44adb500c854 bitnami/redis:latest "/opt/bitnami/script…" 13 seconds ago Up 10 seconds 0.0.0.0:32782->6379/tcp redis_redis-replica_2
72e8bdc566b0 bitnami/redis:latest "/opt/bitnami/script…" 13 seconds ago Up 9 seconds 0.0.0.0:32783->6379/tcp redis_redis-replica_1
c4b64430a2ca bitnami/redis:latest "/opt/bitnami/script…" 14 seconds ago Up 12 seconds 0.0.0.0:32780->6379/tcp redis_redis-master_1
Zdroje: