GordonLesti / Lesti_Fpc

Simple Magento Fullpagecache
https://gordonlesti.com/lesti-fpc-documentationversion-1-4-5/
Other
358 stars 159 forks source link

Issue with redis backend cache and Lesti #297

Closed vhanahrni closed 7 years ago

vhanahrni commented 7 years ago

I get this error :

 Connection to Redis failed after 2 failures

I have 2 redis instances , configured following this post

system – redis port 6379 fpc – redis port 6381

I have no issue when backend cache is running only,

but when Lesti is active I get this error in frontend.

While trying to refresh the cache from magento admin panel, I get the same error, and in error log i have

AH01797: client denied by server configuration: /var/www/vhosts/domain.com/httpdocs/magento_folder/app/etc/local.xml

What do you think ?

local.xml and fpc.xml are configured like this :

local.xml :

    <cache>
        <backend>Cm_Cache_Backend_Redis</backend>
        <backend_options>
            <server>127.0.0.1</server> <!-- or absolute path to unix socket for better performance -->
            <port>6379</port>
            <persistent></persistent>
            <database>0</database>
            <password></password>
            <force_standalone>1</force_standalone>  <!-- 0 for phpredis, 1 for standalone PHP -->
            <connect_retries>1</connect_retries>    <!-- Reduces errors due to random connection failures -->
            <read_timeout>10</read_timeout>         <!-- Set read timeout duration; phpredis does not currently support setting read timeouts -->
            <automatic_cleaning_factor>0</automatic_cleaning_factor> <!-- Disabled by default -->
            <compress_data>1</compress_data>  <!-- 0-9 for compression level, recommended: 0 or 1 -->
            <compress_tags>1</compress_tags>  <!-- 0-9 for compression level, recommended: 0 or 1 -->
            <compress_threshold>20480</compress_threshold>  <!-- Strings below this size will not be compressed -->
            <compression_lib>gzip</compression_lib> <!-- Supports gzip, lzf and snappy -->
            <use_lua>0</use_lua>
            <!--persistent>1</persistent--> <!-- persistence value, 0: not in use, > 0 used as persistence ID -->
        </backend_options>
    </cache>

fpc.xml :

        <lifetime>86400</lifetime>
        <backend>Cm_Cache_Backend_Redis</backend>
        <backend_options>
            <server>127.0.0.1</server>
            <port>6381</port>
            <persistent>cache-fpc</persistent>
            <database>1</database>
            <password></password>
            <force_standalone>1</force_standalone>
            <connect_retries>1</connect_retries>
            <lifetimelimit>86400</lifetimelimit>
            <read_timeout>10</read_timeout>
            <compress_data>1</compress_data>
            <compress_tags>1</compress_tags>
            <compress_data>gzip</compress_data>
        </backend_options>
GordonLesti commented 7 years ago

Hello @vhanahrni I am no expert on this topic, but the error of your logs is a Apache error and I am not sure if that is really the reason of your problem. Maybe related I would say. What does telnet localhost 6381 as mentioned in Magento REDIS : system, session and full page cache management solution say?

vhanahrni commented 7 years ago

Hello, and thanks for your quick comment.

For an attempt to load the home page I get :

 telnet localhost 6381
 1495541409.120914 [0 127.0.0.1:55506] "HGET" "zc:k:1ad_CORE_CACHE_OPTIONS" "d"
 1495541409.121133 [0 127.0.0.1:55506] "HGET" "zc:k:1ad_CONFIG_GLOBAL_LOCK" "d"
 1495541409.121261 [0 127.0.0.1:55506] "HGET" "zc:k:1ad_CONFIG_GLOBAL" "d"
 1495541409.140634 [0 127.0.0.1:55506] "HGET" "zc:k:1ad_APP_23731870E7D82E5184839697A2C56287" "d"
 1495541409.140896 [0 127.0.0.1:55506] "HGET" "zc:k:1ad_STORE_ADMIN_CONFIG_CACHE" "d"
 1495541409.141114 [0 127.0.0.1:55506] "HGET" "zc:k:1ad_APP_EECB6F171DB7FEEEC351EB5AE943461D" "d"
 1495541409.141359 [0 127.0.0.1:55506] "HGET" "zc:k:1ad_APP_D575253B02D0CC74B6626E7632D51AC3" "d"
 1495541409.141518 [0 127.0.0.1:55506] "HGET" "zc:k:1ad_STORE_DEFAULT_CONFIG_CACHE" "d"
 1495541409.142736 [0 127.0.0.1:55506] "HGET" "zc:k:1ad_CONFIG_GLOBAL_STORES_DEFAULT" "d"
 1495541409.150351 [0 127.0.0.1:55506] "HGET" "zc:k:1ad_CONFIG_GLOBAL_ADMIN" "d"
 1495541409.158213 [0 127.0.0.1:55507] "HINCRBY" "sess_unfoq365vri5ui0funql5776ul" "lock" "1"
 1495541409.158402 [0 127.0.0.1:55507] "HMSET" "sess_unfoq365vri5ui0funql5776ul" "pid" "domain.com|13241" "lock" "1"
 1495541409.158424 [0 127.0.0.1:55507] "EXPIRE" "sess_unfoq365vri5ui0funql5776ul" "3600"
 1495541409.158495 [0 127.0.0.1:55507] "HGET" "sess_unfoq365vri5ui0funql5776ul" "data"
 1495541409.159478 [0 127.0.0.1:55506] "HGET" "zc:k:1ad_config_theme" "d"
 1495541409.161585 [0 127.0.0.1:55506] "HGET" "zc:k:1ad_TRANSLATE_EN_US_FRONTEND_1_RWD_DEFAULT" "d"
 1495541409.161703 [0 127.0.0.1:55506] "HGET" "zc:k:1ad_TRANSLATE_EN_US_FRONTEND_1_RWD_DEFAULT" "t"
 1495541409.161803 [0 127.0.0.1:55506] "DEL" "zc:k:1ad_TRANSLATE_EN_US_FRONTEND_1_RWD_DEFAULT"
 1495541409.161815 [0 127.0.0.1:55506] "SREM" "zc:ti:" "1ad_TRANSLATE_EN_US_FRONTEND_1_RWD_DEFAULT"
 1495541409.214519 [0 127.0.0.1:55506] "HGET" "zc:k:1ad_TRANSLATE_EN_US_FRONTEND_1_RWD_DEFAULT" "t"
 1495541409.214744 [0 127.0.0.1:55506] "SADD" "zc:tags" "1ad_TRANSLATE" "1ad_MAGE"
 1495541409.214753 [0 127.0.0.1:55506] "SADD" "zc:ti:1ad_TRANSLATE" "1ad_TRANSLATE_EN_US_FRONTEND_1_RWD_DEFAULT"
 1495541409.214764 [0 127.0.0.1:55506] "SADD" "zc:ti:1ad_MAGE" "1ad_TRANSLATE_EN_US_FRONTEND_1_RWD_DEFAULT"
 1495541409.214840 [0 127.0.0.1:55506] "HGET" "zc:k:1ad_TRANSLATE_EN_US_FRONTEND_1_RWD_DEFAULT" "d"
 1495541409.217177 [0 127.0.0.1:55506] "HGET" "zc:k:1ad_DB_PDO_MYSQL_DDL_mgto_log_visitor_info_1" "d"
 1495541409.220219 [0 127.0.0.1:55507] "HGET" "sess_unfoq365vri5ui0funql5776ul" "pid"
 1495541409.220338 [0 127.0.0.1:55507] "SELECT" "0"
 1495541409.220347 [0 127.0.0.1:55507] "HMSET" "sess_unfoq365vri5ui0funql5776ul" "data" "core|a:2:{s:23:\"_session_validator_data\";a:4:{s:11:\"remote_addr\";s:13:\"XX.XX.XX.XX\";s:8:\"http_via\";s:0:\"\";s:20:\"http_x_forwarded_for\";s:0:\"\";s:15:\"http_user_agent\";s:119:\...\";}s:13:\"session_hosts\";a:1:{s:27:\"domain.com\";b:1;}}" "lock" "0"
 1495541409.220396 [0 127.0.0.1:55507] "HINCRBY" "sess_unfoq365vri5ui0funql5776ul" "writes" "1"
 1495541409.220407 [0 127.0.0.1:55507] "EXPIRE" "sess_unfoq365vri5ui0funql5776ul" "3600"
GordonLesti commented 7 years ago

I have no clue what all that stuff is, but that looks like session stuff. Pretty similar to Monitor Magento redis session cache.

vhanahrni commented 7 years ago

The trace are :

There has been an error processing your request

Connection to Redis failed after 2 failures.

Trace:
#0 /var/www/vhosts/domain.com/httpdocs/magento/lib/Credis/Client.php(362): Credis_Client->connect()
#1 /var/www/vhosts/domain.com/httpdocs/magento/lib/Credis/Client.php(447): Credis_Client->connect()
#2 /var/www/vhosts/domain.com/httpdocs/magento/lib/Credis/Client.php(440): Credis_Client->__call('select', Array)
#3 /var/www/vhosts/domain.com/httpdocs/magento/app/code/local/Cm/Cache/Backend/Redis.php(359): Credis_Client->select(1)
#4 /var/www/vhosts/domain.com/httpdocs/magento/app/code/local/Cm/Cache/Backend/Redis.php(238): Cm_Cache_Backend_Redis->_applyClientOptions(Object(Credis_Client))
#5 /var/www/vhosts/domain.com/httpdocs/magento/lib/Zend/Cache.php(153): Cm_Cache_Backend_Redis->__construct(Array)
#6 /var/www/vhosts/domain.com/httpdocs/magento/lib/Zend/Cache.php(94): Zend_Cache::_makeBackend('Cm_Cache_Backen...', Array, true, true)
#7 /var/www/vhosts/domain.com/httpdocs/magento/app/code/core/Mage/Core/Model/Cache.php(136): Zend_Cache::factory('Varien_Cache_Co...', 'Cm_Cache_Backen...', Array, Array, true, true, true)
#8 /var/www/vhosts/domain.com/httpdocs/magento/app/code/community/Lesti/Fpc/Model/Fpc.php(60): Mage_Core_Model_Cache->__construct(Array)
#9 /var/www/vhosts/domain.com/httpdocs/magento/app/code/core/Mage/Core/Model/Config.php(1354): Lesti_Fpc_Model_Fpc->__construct(Array)
#10 /var/www/vhosts/domain.com/httpdocs/magento/app/Mage.php(463): Mage_Core_Model_Config->getModelInstance('fpc/fpc', Array)
#11 /var/www/vhosts/domain.com/httpdocs/magento/app/Mage.php(477): Mage::getModel('fpc/fpc', Array)
#12 /var/www/vhosts/domain.com/httpdocs/magento/app/code/community/Lesti/Fpc/Model/Observer/Save.php(135): Mage::getSingleton('fpc/fpc')
#13 /var/www/vhosts/domain.com/httpdocs/magento/app/code/community/Lesti/Fpc/Model/Observer/Save.php(80): Lesti_Fpc_Model_Observer_Save->_getFpc()
#14 /var/www/vhosts/domain.com/httpdocs/magento/app/code/core/Mage/Core/Model/App.php(1339): Lesti_Fpc_Model_Observer_Save->modelSaveAfter(Object(Varien_Event_Observer))
#15 /var/www/vhosts/domain.com/httpdocs/magento/app/code/core/Mage/Core/Model/App.php(1318): Mage_Core_Model_App->_callObserverMethod(Object(Lesti_Fpc_Model_Observer_Save), 'modelSaveAfter', Object(Varien_Event_Observer))
#16 /var/www/vhosts/domain.com/httpdocs/magento/app/Mage.php(448): Mage_Core_Model_App->dispatchEvent('model_save_afte...', Array)
#17 /var/www/vhosts/domain.com/httpdocs/magento/app/code/core/Mage/Core/Model/Abstract.php(465): Mage::dispatchEvent('model_save_afte...', Array)
#18 /var/www/vhosts/domain.com/httpdocs/magento/app/code/core/Mage/Core/Model/Abstract.php(319): Mage_Core_Model_Abstract->_afterSave()
#19 /var/www/vhosts/domain.com/httpdocs/magento/app/code/core/Mage/Log/Model/Visitor.php(168): Mage_Core_Model_Abstract->save()
#20 /var/www/vhosts/domain.com/httpdocs/magento/app/code/core/Mage/Core/Model/App.php(1339): Mage_Log_Model_Visitor->initByRequest(Object(Varien_Event_Observer))
#21 /var/www/vhosts/domain.com/httpdocs/magento/app/code/core/Mage/Core/Model/App.php(1318): Mage_Core_Model_App->_callObserverMethod(Object(Mage_Log_Model_Visitor), 'initByRequest', Object(Varien_Event_Observer))
#22 /var/www/vhosts/domain.com/httpdocs/magento/app/Mage.php(448): Mage_Core_Model_App->dispatchEvent('controller_acti...', Array)
#23 /var/www/vhosts/domain.com/httpdocs/magento/app/code/core/Mage/Core/Controller/Varien/Action.php(527): Mage::dispatchEvent('controller_acti...', Array)
#24 /var/www/vhosts/domain.com/httpdocs/magento/app/code/core/Mage/Core/Controller/Front/Action.php(64): Mage_Core_Controller_Varien_Action->preDispatch()
#25 /var/www/vhosts/domain.com/httpdocs/magento/app/code/core/Mage/Core/Controller/Varien/Action.php(407): Mage_Core_Controller_Front_Action->preDispatch()
#26 /var/www/vhosts/domain.com/httpdocs/magento/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(254): Mage_Core_Controller_Varien_Action->dispatch('index')
#27 /var/www/vhosts/domain.com/httpdocs/magento/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#28 /var/www/vhosts/domain.com/httpdocs/magento/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#29 /var/www/vhosts/domain.com/httpdocs/magento/app/Mage.php(683): Mage_Core_Model_App->run(Array)
#30 /var/www/vhosts/domain.com/httpdocs/magento/index.php(87): Mage::run('', 'store')
#31 {main}
GordonLesti commented 7 years ago

Have you tried something like Magento-Redismanager?

rafaelpatro commented 7 years ago

I hope it helps! Lesti_Fpc and Redis working with me:

        <cache>
            <backend>Cm_Cache_Backend_Redis</backend>
            <backend_options>
                <server>/var/run/redis/redis.sock</server>
                <port>0</port>
                <database>1</database>
                <password></password>
                <force_standalone>0</force_standalone>
                <connect_retries>1</connect_retries>
                <automatic_cleaning_factor>0</automatic_cleaning_factor>
                <compress_data>1</compress_data>
                <compress_tags>1</compress_tags>
                <compress_threshold>80960</compress_threshold>
                <compression_lib>gzip</compression_lib>
                <persistent>0</persistent>
            </backend_options>
        </cache>

Redis 3.06 PHP 7.0.8 Apache 2.4 Magento 1.9.3.0

vhanahrni commented 7 years ago

Hello, thanks for your comment.

What configuration do you have in fpc.xml ?

rafaelpatro commented 7 years ago
<?xml version="1.0"?>
<config>
    <global>
        <fpc>
            <lifetime>604800</lifetime>
            <!-- example for redis -->
            <!-- please read https://github.com/colinmollenhour/Cm_Cache_Backend_Redis for more informations -->
            <backend>Cm_Cache_Backend_Redis</backend>
            <backend_options>
                <server>/var/run/redis/redis.sock</server>
                <port>0</port>
                <persistent>0</persistent>
                <database>1</database>
                <password></password>
                <force_standalone>0</force_standalone>
                <connect_retries>1</connect_retries>
                <lifetimelimit>604800</lifetimelimit>
                <read_timeout>10</read_timeout>
                <compress_data>1</compress_data>
                <compress_tags>1</compress_tags>
                <compression_lib>gzip</compression_lib>
            </backend_options>
        </fpc>
    </global>
</config>
vhanahrni commented 7 years ago

I removed the multiple instances conf to go back to only one on 6379. Then enable lesti whith no issue. does your socket handle multiple port ?

rafaelpatro commented 7 years ago

No. I don't know whether ports are used or not when connected by socket. But I use multiple databases through socket connection with no issues.

vhanahrni commented 7 years ago

ok thanks. we can close.