Comments (1)
So prior to today's endeavour I had been running everything locally, not within docker. It worked for me but would be a hard thing to document with many steps, and it'd be a pain to maintain for most people unless they invested in actually understanding redis and sentinel.
I had luck getting a docker compose file up that spins up two redis instances one as master, one as a slave, and then 2 - 3 sentinel instances.
The compose file is:
version: '2'
networks:
app-tier:
driver: bridge
services:
redis:
image: 'bitnami/redis:latest'
environment:
- REDIS_REPLICATION_MODE=master
- REDIS_PASSWORD=masterpassword123
networks:
- app-tier
ports:
- '6379:6379'
redis-slave:
image: 'bitnami/redis:latest'
environment:
- REDIS_REPLICATION_MODE=slave
- REDIS_MASTER_HOST=redis
- REDIS_MASTER_PASSWORD=masterpassword123
- REDIS_PASSWORD=masterpassword123
ports:
- '6380:6379'
depends_on:
- redis
networks:
- app-tier
redis-sentinel:
image: 'bitnami/redis-sentinel:latest'
links:
- redis
- redis-slave
environment:
- REDIS_SENTINEL_PASSWORD=masterpassword123
- REDIS_MASTER_PASSWORD=masterpassword123
- REDIS_SENTINEL_RESOLVE_HOSTNAMES=yes
- REDIS_SENTINEL_ANNOUNCE_IP=127.0.0.1
depends_on:
- redis
- redis-slave
ports:
- "26379-26381:26379"
networks:
- app-tier
This is then brought up by running:
docker-compose up --scale redis-sentinel=2 -d
There is a problem with it that someone better than I am at docker would still need to solve.
Totara requires that both sentinel and redis be available. The redis nodes get registered with sentinel and then Totara queries sentinel to get the redis services.
Presently, they are exposed via ports. However this isn't enough.
When you ask Sentinel to give you the hosts and ports for redis it returns an IP address associated with the container network, e.g. 172.18.0.3.
To work around this I hacked core code to map from internal IP's to exposed ports on the local machine. But a super hack.
diff --git a/server/lib/classes/redis/sentinel.php b/server/lib/classes/redis/sentinel.php
index f32bfbf71182..5691775842f8 100644
--- a/server/lib/classes/redis/sentinel.php
+++ b/server/lib/classes/redis/sentinel.php
@@ -192,6 +192,20 @@ final class sentinel {
}
$masterhost = $master[0];
$masterport = $master[1];
+
+ switch ($masterhost) {
+ case '172.18.0.3':
+ // Slave
+ $masterhost = '127.0.0.1';
+ $masterport = '6380';
+ break;
+ case '172.18.0.2':
+ // Master
+ $masterhost = '127.0.0.1';
+ $masterport = '6379';
+ break;
+ }
+
try {
$redis = new \Redis();
if (!$redis->connect($masterhost, $masterport, 3)) {
Then to configure Totara:
- Add a new Redis cache store
- Sentinel hosts: 127.0.0.1:26380
- Sentinel master name: mymaster
- Sentinel password: masterpassword123
- Read replica server: 127.0.0.6379
- Database number: 777
- Key prefix: dev
Save that, and check on the next screen the cache store shows as ready.
Finally change you default application mapping to your new redis cache store.
Go!
from totara-docker-dev.
Related Issues (20)
- zshrc command not found: shopt HOT 1
- Build failure for PHP 7.3 - pecl/sqlsrv requires PHP (version >= 7.4.0), installed version is 7.3.33
- Update PHP 8.1 image to latest version (still on beta)
- Integrated docker-dev environment for the machine learning service
- Remote server rewrite rules accidentally blocking valid directories for apache HOT 3
- Apache server drops authorization header when served over https HOT 1
- Config.php default settings have poor performance HOT 3
- Selenium on M1 HOT 4
- Two different default versions of postgres versions HOT 2
- ngrok >=3.0.0 support HOT 6
- Add additional locales to PHP containers
- egrep is deprecated in the 3.8 release of gnu-grep HOT 1
- Expose Machine Learning Service config options to .env file HOT 1
- Mysql 5.7 on M1 HOT 2
- Arm support in Docker images HOT 6
- Restrict access to some directories and files create continues error in SCORM activities HOT 2
- Update selenium & chrome images HOT 1
- Error 'multiarch-support is not installed' during php container build HOT 1
- Outdated database credential docs HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from totara-docker-dev.