From 14ee775e39a5a156c83a20e30fa9e81fd7f19445 Mon Sep 17 00:00:00 2001 From: hareku Date: Sun, 17 Feb 2019 00:38:18 +0900 Subject: [PATCH] add: redis-cluster (#1981) --- DOCUMENTATION/content/documentation/index.md | 38 ++++++++++++++++++++ docker-compose.yml | 8 +++++ env-example | 4 +++ redis-cluster/Dockerfile | 3 ++ 4 files changed, 53 insertions(+) create mode 100644 redis-cluster/Dockerfile diff --git a/DOCUMENTATION/content/documentation/index.md b/DOCUMENTATION/content/documentation/index.md index af7f1956..e07b8b3a 100644 --- a/DOCUMENTATION/content/documentation/index.md +++ b/DOCUMENTATION/content/documentation/index.md @@ -708,6 +708,44 @@ composer require predis/predis:^1.0 +
+ +## Use Redis Cluster + +1 - First make sure you run the Redis-Cluster Container (`redis-cluster`) with the `docker-compose up` command. + +```bash +docker-compose up -d redis-cluster +``` + +2 - Open your Laravel's `config/database.php` and set the redis cluster configuration. Below is example configuration with phpredis. + +Read the [Laravel official documentation](https://laravel.com/docs/5.7/redis#configuration) for more details. + +```php +'redis' => [ + 'client' => 'phpredis', + 'options' => [ + 'cluster' => 'redis', + ], + 'clusters' => [ + 'default' => [ + [ + 'host' => 'redis-cluster', + 'password' => null, + 'port' => 7000, + 'database' => 0, + ], + ], + ], +], +``` + + + + + +
## Use Mongo diff --git a/docker-compose.yml b/docker-compose.yml index 25cc19ab..78dc2067 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -456,6 +456,14 @@ services: networks: - backend +### Redis Cluster ########################################## + redis-cluster: + build: ./redis-cluster + ports: + - "${REDIS_CLUSTER_PORT_RANGE}:7000-7005" + networks: + - backend + ### ZooKeeper ######################################### zookeeper: build: ./zookeeper diff --git a/env-example b/env-example index bf45663e..1164af16 100644 --- a/env-example +++ b/env-example @@ -220,6 +220,10 @@ MYSQL_ENTRYPOINT_INITDB=./mysql/docker-entrypoint-initdb.d REDIS_PORT=6379 +### REDIS CLUSTER ######################################### + +REDIS_CLUSTER_PORT_RANGE=7000-7005 + ### ZooKeeper ############################################# ZOOKEEPER_PORT=2181 diff --git a/redis-cluster/Dockerfile b/redis-cluster/Dockerfile new file mode 100644 index 00000000..d610fc43 --- /dev/null +++ b/redis-cluster/Dockerfile @@ -0,0 +1,3 @@ +FROM grokzen/redis-cluster:latest + +LABEL maintainer="hareku "