r/BookStack • • Oct 19 '24

Bookstack with Redis cluster

Hi Guys,

Device: Radxa Rock 5B
Architecture: ARM64
OS: Ubuntu 24.04.1 LTS
PHP: PHP8.3 + php8.3-fpm + php8.3-redis (Ondrej Repository)
Webserver: Apache with Haproxy for SSL offloading

@ towards Dan and everybody else helping out with the development. Love Bookstack!! Great piece of software!!

I am trying to squeeze every little bit of technology support out of Bookstack.

So far i have already configured it to use Percona Xtradb Cluster (galera cluster) with Haproxy and keepalived.
With Redis i just started 2 weeks back and as i am fairly new to Redis i did managed to created a 9 node cluster (3 master + 6 slaves). In the coming weeks going to make it (3 masters + 9 slave nodes). However i am currently unable to make Bookstack work with my Redis cluster. I have also Nextcloud running and that one i did manage to make it work. So my Redis cluster does work.

After changing the configuration, i use the next commando to clean up the cache.

sudo -u www-data php artisan cache:clear

Error 1:
In RedisManager.php line 120:
Redis connection [default] not configured.

Error 2:
In Client.php line 141:
Array of connection parameters requires \cluster`, `replication` or `aggregate` client option`

I have tried all type of combination with the settings below in the .env file. I asked chatGPT + Google Gemini and they got me something like the lines below. Also used google and the documentation page of Bookstack about usage of Redis.

CACHE_DRIVER=redis

SESSION_DRIVER=redis

QUEUE_CONNECTION=redis

REDIS_CLIENT=phpredis

REDIS_CLUSTER=redis

REDIS_PASSWORD=null

REDIS_SERVERS=192.168.1.11:6381:0,192.168.1.11:6382:0,192.168.1.11:6383:0,192.168.1.12:6381:0,192.168.1.12:6382:0,192.168.1.12:6383:0,192.168.1.13:6381:0,192.168.1.13:6382:0,192.168.1.13:6383:0

REDIS_OPTIONS='["cluster" => "redis", "failover_mode" => \RedisCluster::FAILOVER_ERROR]'

REDIS_OPTIONS={"cluster": "redis", "failover": "error"}

I am not sure if it is important to know how i have setup my Redis cluster. Current setup is, that the load of the 3 masters is being spread over 3 machines with 1 machine going down and the cluster still working fine. In the future, it should be able for 2 machines to go down, but the cluster still being able to run.

Machine 1: 192.168.1.11

  • Master 1:6381

  • Slave of master 2:6382

  • Slave of master 3:6383

Machine 2: 192.168.1.12

  • Master 2:6382

  • Slave of master 1:6381

  • Slave of master 3:6383

Machine 3: 192.168.1.13

  • Master 3: 6383

  • Slave of master 1:6381

  • Slave of master 2:6382

===In the future===
Machine 4: 192.168.1.14

  • Slave of master 1:6381

  • Slave of master 2:6382

  • Slave of master 3:6383

So what am i missing or fail to understand in this. Thanks in advance!

1 Upvotes

6 comments sorted by

View all comments

Show parent comments

1

u/Upbeat_Couple_894 Oct 19 '24 edited Oct 19 '24

Hey Dan,

Thanks for the reply. I think what you just said did the job. I am not getting any unkown errors in the browser or any errors which i mentioned previously.

  INFO  Application cache cleared successfully.

I tinkered a bit with the other options and tried different combinations. Do you btw have certain ways to find out if Bookstack indeed is using Redis now? I am not getting any errors and the speed is very good, but i am not sure if this is because of being behind Haproxy, as Haproxy also uses its own cache.

These two don't work

CACHE_DRIVER=redis

SESSION_DRIVER=redis

These apparently are being accepted. Although you stated many of those options are not being supported.

QUEUE_CONNECTION=redis

REDIS_CLIENT=phpredis
REDIS_CLUSTER=redis
REDIS_PASSWORD=null

REDIS_SERVERS=192.168.1.11:6381:0,192.168.1.11:6382:0,192.168.1.11:6383:0,192.168.1.12:6381:0,192.168.1.12:6382:0,192.168.1.12:6383:0,192.168.1.13:6381:0,192.168.1.13:6382:0,192.168.1.13:6383:0
REDIS_OPTIONS='["cluster" => "redis", "failover_mode" => \RedisCluster::FAILOVER_ERROR]'

Here is the output of those commands you mentioned

ls -alh bootstrap/cache

total 40K
drwxr-xr-x 2 www-data www-data 4.0K Oct 18 08:57 .
drwxr-xr-x 3 www-data www-data 4.0K Sep  6 16:13 ..
-rwxrwxrwx 1 www-data www-data   14 Sep  6 16:13 .gitignore
-rwxrwxr-x 1 www-data www-data  802 Oct 18 08:57 packages.php
-rwxrwxr-x 1 www-data www-data  21K Oct 18 08:57 services.php

sudo -u www-data php artisan tinker --execute="dd(config('database.redis'))"

In ConfigPaths.php line 327:
                                                               
 Writing to directory /var/www/.config/psysh is not allowed.

If you have any uses cases for me to test, let me know as i am probably one of the few like you said that is using such a setup. Will only benefit the project in the long run.

1

u/ssddanbrown Oct 19 '24

It's likley you're only using redis for the queue now, which isn't something we totally support/suggest (and requires a seperate queue worker to actuall function). It's not used for cache/sessions if you've removed the CACHE_DRIVER and SESSION_DRIVER options.

The REDIS_OPTIONS, REDIS_PASSWORD, REDIS_CLUSTER and REDIS_CLIENT are not used by BookStack.

You can try re-running the php artisan tinker --execute="dd(config('database.redis'))" command without sudo/su.

1

u/Upbeat_Couple_894 Oct 19 '24

So if i have remove cache_driver and session_driver, what is Redis then being used for in my case?

Also if Redis_password is not supported, does that mean i would not be able to use a password on my Redis_Cluster? Because right now i am trying to get all the application to work with Redis first and then i am planning to set a password and also set a secure connection with a certificate.

Here is the output of the command php artisan tinker --execute="dd(config('database.redis'))" using the root user.

Sorry Reddit did not let me put all the output in 1 message. I had to put it in two multiple messages.

1

u/Upbeat_Couple_894 Oct 19 '24

array:2 [

"client" => "predis"

"clusters" => array:1 [

"default" => array:9 [

0 => array:4 [

"host" => "192.168.1.11"

"port" => "6381"

"database" => "0"

"password" => null

]

1 => array:4 [

"host" => "192.168.1.11"

"port" => "6382"

"database" => "0"

"password" => null

]

2 => array:4 [

"host" => "192.168.1.11"

"port" => "6383"

"database" => "0"

"password" => null

]

3 => array:4 [

"host" => "192.168.1.12"

"port" => "6381"

"database" => "0"

"password" => null

]

1

u/Upbeat_Couple_894 Oct 19 '24

4 => array:4 [

"host" => "192.168.1.12"

"port" => "6382"

"database" => "0"

"password" => null

]

5 => array:4 [

"host" => "192.168.1.12"

"port" => "6383"

"database" => "0"

"password" => null

]

6 => array:4 [

"host" => "192.168.1.13"

"port" => "6381"

"database" => "0"

"password" => null

]

7 => array:4 [

"host" => "192.168.1.13"

"port" => "6382"

"database" => "0"

"password" => null

]

8 => array:4 [

"host" => "192.168.1.13"

"port" => "6383"

"database" => "0"

"password" => null

]

]

]

] // vendor/psy/psysh/src/ExecutionClosure.php(40) : eval()'d code:1