Redis Centos 7 Installation & Configure by below command
sudo yum install redis -y
sudo systemctl start redis.service
sudo systemctl enable redis
sudo systemctl status redis.service
Redis Ubuntu Installation & Configure by below command
sudo apt-get install redis
sudo systemctl start redis.service
sudo systemctl enable redis
sudo systemctl status redis.service
Once Redis installation done, need to configure in Magento 2
Redis Magento 2 Configure by below methods
There are two ways to include Redis code inside env.php
Step-1: By using CLI Command
php bin/magento setup:config:set –session-save=redis –session-save-redis-host=127.0.0.1 –session-save-redis-log-level=4 –session-save-redis-db=2
php bin/magento setup:config:set –cache-backend=redis –cache-backend-redis-server=127.0.0.1 –cache-backend-redis-db=0
Step-2: By using direct put code in env.php
Download below file & copy redis code in env.php file
https://mage2db.com/Redis_Cache_Code_In_ENVdotphp.pdf
As Redis working fine, need to run below following command redis monitor, session storage value, redis flush cache
[1] redis-cli redirects in Host with Port as below
Here also checking as cache store value properly as well as get properly as below.
ubuntu@ip-172-31-43-109:/var/www/html/magento234$ redis-cli
127.0.0.1:6379> set test “Hello”
OK
[1.1] 127.0.0.1:6379>
[1.2] 127.0.0.1:6379> set test “Hello”
OK
127.0.0.1:6379> get test
“Hello”
[1.3] 127.0.0.1:6379> exit
[1.4] Restart Redis
sudo systemctl restart redis-server
[2] Type command redis-cli monitor
and refresh your front website or press F5, you will see an output on your screen.
It Means, Magento 2 Redis working fine , if display like after command
[3] Type redis-cli ping
and you’ll get a reply PONG which means everything is looking good.
[4] Type php -m | grep redis
by which you’ll see redis in reply, which confirms that the PHP Redis Extension is ready to go.
[5] Type redis-cli FLUSHALL
if you need to clear Redis cache, simply type redis-cli FLUSHALL and an OK reply will confirm that your cache has been cleared successfully.
[6] To check Redis Version Type redis-server -v
[7] Default Port used by Redis 6379
[8] Other Important Redis command as below
redis-cli info–Complete info about the redis-instance
redis-cli info server–Server Information, cersions, configs, binary
redis-cli info clients–Connected clients
redis-cli info memory–Statistics about memory usage and limits
redis-cli info persistence–Info about RDB and AOF
redis-cli info stats–Connection, network, keyspace statistics
redis-cli info replication–Replication settings and status