Skip to content
OroPlatform package, enables Redis storage support for application cache.
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Configuration BAP-16691: Fix deprecations in redis-config package for symfony3.0 up… Mar 12, 2018
Connection/Aggregate CS-3918: Implement cluster support for oro/redis-config-bundle Feb 7, 2018
DependencyInjection
Resources/config
Service BAP-18080: Error using DatesAwareTrait with a non-configurable entity… Jan 28, 2019
Tests Merge remote-tracking branch 'origin/master' into ticket/BB-15098 Oct 1, 2018
.gitignore CS-3901: Multi-node cache storage setup in HA mode documentation Feb 9, 2018
LICENSE BAP-17728: Fix various typos Oct 15, 2018
OroRedisConfigBundle.php Merge remote-tracking branch 'origin/master' into ticket/BB-15098 Oct 1, 2018
README.md DOC-783: Add or fix descriptions for bundles of the commerce-enterpri… Apr 16, 2018
composer.json [master] - BB-14614: Release preparation activities (#19347) Jul 25, 2018
phpunit.xml.dist CS-3918: Implement cluster support for oro/redis-config-bundle Feb 8, 2018

README.md

OroRedisConfigBundle

OroRedisConfigBundle provides configuration enhancements for Oro applications to enable usage of Redis for caching.

The bundle enables developers to set Redis parameters in the application configuration YAML files and after that automatically enables and configures Redis caching services for different types of application caches (Doctrine cache, file cache, wsse_nonces cache, etc.) based on these parameters.

Configure Redis Servers

Oro architecture require a least two instances of redis server. First instance will be used as fast persistent storage for sessions and second as LRU Cache storage.

Ubuntu Xenial or later

Install redis-server via apt

sudo apt install redis-server

Configure second instance as lru memory cache

Create folders for redis-cache server

sudo mkdir -p /var/lib/redis-cache /var/log/redis-cache /var/run/redis-cache
sudo chown redis:redis /var/lib/redis-cache /var/log/redis-cache /var/run/redis-cache

Create tmpfiles config

echo "d /run/redis-cache 2775 redis redis -" | sudo tee /usr/lib/tmpfiles.d/redis-cache-server.conf

Copy original configs for second server

sudo cp -rp /etc/redis /etc/redis-cache

Replace all content in /etc/redis-cache/redis.conf with:

daemonize yes
pidfile /var/run/redis-cache/redis-server.pid
port 6380
tcp-backlog 511
bind 127.0.0.1
timeout 0
tcp-keepalive 0
loglevel notice
logfile /var/log/redis-cache/redis-server.log
databases 16
maxmemory 256mb
maxmemory-policy allkeys-lru
stop-writes-on-bgsave-error no
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir /var/lib/redis-cache
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
slave-priority 100
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-entries 512
list-max-ziplist-value 64
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes

Create systemd unit /lib/systemd/system/redis-cache-server.service for redis-cache with following contents:

[Unit]
Description=Redis-Cache
After=network.target

[Service]
Type=forking
ExecStart=/usr/bin/redis-server /etc/redis-cache/redis.conf
PIDFile=/var/run/redis-cache/redis-server.pid
TimeoutStopSec=0
Restart=always
User=redis
Group=redis

ExecStartPre=-/bin/run-parts --verbose /etc/redis-cache/redis-server.pre-up.d
ExecStartPost=-/bin/run-parts --verbose /etc/redis-cache/redis-server.post-up.d
ExecStop=-/bin/run-parts --verbose /etc/redis-cache/redis-server.pre-down.d
ExecStop=/bin/kill -s TERM $MAINPID
ExecStopPost=-/bin/run-parts --verbose /etc/redis-cache/redis-server.post-down.d

PrivateTmp=yes
PrivateDevices=yes
ProtectHome=yes
ReadOnlyDirectories=/
ReadWriteDirectories=-/var/lib/redis-cache
ReadWriteDirectories=-/var/log/redis-cache
ReadWriteDirectories=-/var/run/redis-cache
CapabilityBoundingSet=~CAP_SYS_PTRACE

ProtectSystem=true
ReadWriteDirectories=-/etc/redis-cache

[Install]
WantedBy=multi-user.target
Alias=redis-cache.service

Enable and start systemd unit

systemctl enable redis-cache-server.service
systemctl start redis-cache

Verify status of new service

systemctl status redis-cache

Install Package

Require package via composer

composer require oro/redis-config 

Configuration for standalone redis setup

Update parameters.yml with the following:

session_handler:    'snc_redis.session.handler'
redis_dsn_session:  'redis://127.0.0.1:6379/0'
redis_dsn_cache:    'redis://127.0.0.1:6380/0'
redis_dsn_doctrine: 'redis://127.0.0.1:6380/1'
redis_setup: 'standalone' #optional, current configuration is applied if it's not set

Configuration for redis cluster setup

Update parameters.yml with the following:

session_handler:    'snc_redis.session.handler'
redis_dsn_session:  ['redis://127.0.0.1:6379/0?alias=master','redis://127.0.0.1:6380/0']
redis_dsn_cache:    ['redis://127.0.0.1:6381/0?alias=master','redis://127.0.0.1:6382/0']
redis_dsn_doctrine: ['redis://127.0.0.1:6381/1?alias=master','redis://127.0.0.1:6382/0']
redis_setup: 'cluster'

Configuration for sentinel redis setup

Update parameters.yml with the following:

session_handler:    'snc_redis.session.handler'
redis_dsn_session:  ['redis://127.0.0.1:26379/0','redis://127.0.0.1:26379/0']
redis_dsn_cache:    ['redis://127.0.0.1:26379/1','redis://127.0.0.1:26379/1']
redis_dsn_doctrine: ['redis://127.0.0.1:26379/2','redis://127.0.0.1:26379/2']
redis_setup: 'sentinel'
redis_sentinel_master_name: 'mymaster'
redis_sentinel_prefer_slave: '127.0.0.1'

In this case it is required to provide redis-sentinel endpoints with db numbers for redis_dsn_session,redis_dsn_cache,redis_dsn_doctrine. In parameter redis_sentinel_master_name master service name, which configured in sentinel.conf, needs to be provided

sentinel monitor mymaster 127.0.0.1 2

Parameter redis_sentinel_prefer_slave is responsible for selection preferable slave node via IP address in case if cluster has a few slaves and it needs to connect to specific one. Also, please pay attention, you have to set up at least 2 sentinel endpoints, otherwise integration will not work.

Related links

You can’t perform that action at this time.