-
New Feature
-
Resolution: Unresolved
-
Minor
-
None
-
3.9.1
-
None
-
MOODLE_39_STABLE
-
Following up MDL-48468 and using the RedisSentinel available in php-redis 5.2 (https://github.com/phpredis/phpredis/blob/develop/Changelog.md), it is now possible to connect to Redis Sentinel for Redis Clusters.
The idea here is to do minimal changes to the core so to enable this:
- In the session management
- In the cache
The way it has been implemented is strongly linked to the availability of the RedisSentinel function but I guess it can be done though normal redis connector as the protocol for Sentinel is just using normal redis connector.
The only thing that is not supported yet is password/ auth for the sentinel.
Cache
Process for testing cache:
- Install Redis and the Redis PHP extension and configure it (on ubuntu it is redis-sentinel and redis-server, making sure that the bind address is 127.0.0.1).
- Check that redis sentinel and redis server are working (redis-cli for example)
- Restart your web server.
- Browse to Admin > Plugins > Caching > Stores > Redis
- Set a Redis Sentinel test server (127.0.0.1 default port being 26379)
- Check the "Is Test server a Redis Sentinel"
- Browse to Admin > Plugins > Caching > Test performance
- Make sure that Redis is being tested.
- Browse to Admin > Plugins > Caching > Configuration
- Create a Redis instance
- Map it to the string and config caches
- Browse the site and make sure everything is OK.
Now same process as testing redis:
To ensure Redis is working in the testing space
- in config.php, set:
define('TEST_CACHESTORE_REDIS_SENTINEL_TESTSERVERS', '127.0.0.1');
|
define('TEST_CACHESTORE_REDIS_SENTINEL_MASTERNAME', 'mymaster'); define('TEST_CACHESTORE_REDIS_IS_SENTINEL',true);
|
Verify Redis testing is passing by itself with (.)'s and aren't skipped (see redis_sentinel_test.php).
vendor/bin/phpunit cache/stores/redis/tests/redis_sentinel_test.php
|
Add the following to config.php to use redis as the default application store for testing;
define('TEST_CACHE_USING_APPLICATION_STORE' , 'redis');
Run PHPUnit to verify that all the tests pass with a different store set.
vendor/bin/phpunit
|
Session
The session management is slightly different:
- In config.php, set:
$CFG->session_handler_class = '\core\session\redis_sentinel'; |
$CFG->session_redis_sentinel_host = '127.0.0.1'; |
$CFG->session_redis_sentinel_port = 26379; |
$CFG->session_redis_master_name = 'mymaster'; |
$CFG->session_redis_database = 0; // Optional, default is db 0. |
$CFG->session_redis_auth = ''; // Optional, default is don't set one. |
$CFG->session_redis_prefix = 'sess'; // Optional, default is don't set one. |
$CFG->session_redis_acquire_lock_timeout = 120; |
- Check that you can login
Now same process as testing redis sentinel cache:
To ensure Redis is working in the testing space
- in config.php, set:
define('TEST_CACHESTORE_REDIS_SENTINEL_TESTSERVERS','127.0.0.1');
|
define('TEST_CACHESTORE_REDIS_TESTSERVERS','127.0.0.1'); define('TEST_CACHESTORE_REDIS_SENTINEL_MASTERNAME','mymaster');
|
Verify Redis testing is passing by itself with (.)'s and aren't skipped (see redis_sentinel_test.php).
vendor/bin/phpunit lib/tests/session_redis_sentinel_test.php
|
- will help resolve
-
MDL-48468 Add a Redis cache store to Moodle core
-
- Closed
-
- links to