简体   繁体   中英

Laradock Redis Exception READONLY You can't write against a read only replica

I am using Laradock to deploy a Laravel application.

Suddenly I get the following error, when hitting the welcome page of the app:

RedisException READONLY You can't write against a read only replica

I have set to true the installation of Redis in the three workspace, php-fpm, and worker containers:

.env

WORKSPACE_INSTALL_PHPREDIS=true
PHP_FPM_INSTALL_PHPREDIS=true
PHP_WORKER_INSTALL_REDIS=true

I also get the exact same error if I test redis in Artisan tinker

➜  www git:(master) ✗ artisan tinker    
Psy Shell v0.11.4 (PHP 8.1.5 — cli) by Justin Hileman
>>> \Cache::store('redis')->put('Laradock', 'Awesome', 10);
RedisException with message 'READONLY You can't write against a read only replica.'

How do I fix this?

I had restart docker container (redis) to fix it

add this to your redis docker compose

​command: redis-server --appendonly yes --replica-read-only no ​

using redis-cli check if config get replica-read-only gives value no .

Sorce: https://laracasts.com/discuss/channels/servers/docker-on-production-error-redisexception-readonly-you-cant-write-against-a-read-only-replica

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM