【问题标题】:Magento How to disable Redis Caching at run time if REDIS server failover如果 REDIS 服务器故障转移,Magento 如何在运行时禁用 Redis 缓存
【发布时间】:2017-11-02 19:49:59
【问题描述】:

我们遇到了 Redis 停机: Can't save in background: fork: Cannot allocate memory 我们的网络有一段时间无法使用。 如果 Redis 不可用,我想正确设置 Magento 以回退到磁盘文件缓存中。最好的选择是什么? 我们正在运行 Magento 1.9.3.2 和 Redis 3.2.10,我们的 app/etc/local.xml 缓存和会话设置是:

<cache>
  <backend>Cm_Cache_Backend_Redis</backend>
  <backend_options>
  <server>127.0.0.1</server>
  <port>6379</port>
  <persistent></persistent>
  <database>12</database>
  <password></password>
  <force_standalone>0</force_standalone>
  <connect_retries>1</connect_retries>
  <read_timeout>10</read_timeout>
  <automatic_cleaning_factor>0</automatic_cleaning_factor>
  <compress_data>1</compress_data>
  <compress_tags>1</compress_tags>
  <compress_threshold>20480</compress_threshold>
  <compression_lib>gzip</compression_lib>
  <use_lua>0</use_lua>
  </backend_options>
</cache>

<session_save>db</session_save>
<redis_session>
  <host>127.0.0.1</host>
  <port>6379</port>
  <password></password>
  <timeout>2.5</timeout>
  <persistent></persistent>
  <db>13</db>
  <compression_threshold>2048</compression_threshold>
  <compression_lib>gzip</compression_lib>
  <log_level>1</log_level>
  <max_concurrency>6</max_concurrency>
  <break_after_frontend>5</break_after_frontend>
  <break_after_adminhtml>30</break_after_adminhtml>
  <first_lifetime>600</first_lifetime>
  <bot_first_lifetime>60</bot_first_lifetime>
  <bot_lifetime>7200</bot_lifetime>
  <disable_locking>0</disable_locking>
  <min_lifetime>60</min_lifetime>
  <max_lifetime>2592000</max_lifetime>
</redis_session>

欢迎所有建议。

【问题讨论】:

    标签: magento redis


    【解决方案1】:

    要以正确的方式修复它,您应该考虑为 redis 分配更多内存。还将您的缓存和会话拆分为在不同端口上运行的两个不同的 redis 进程。 Magento 缓存不需要持久缓存,但所有键都需要大量内存。还要查看你的 redis 配置中的驱逐策略。 https://redis.io/topics/lru-cache

    如果你仍然对肮脏的后备感兴趣,你可以修补 Mage_Core_Model_App

    app/code/core/Mage/Core/Model/App.php

     $this->_cache = Mage::getModel('core/cache', $options);
    
    +        if ($this->_cache) {
    +                try {
    +                        $this->_cache->load('somekey');
    +                } catch (Exception $e) {
    +                        Mage::getConfig()->setNode('global/cache/backend', 'file');
    +                        return $this->getCache();
    +                }
    +        }
    

    在方法_initCache中

    【讨论】:

      猜你喜欢
      • 2015-05-14
      • 1970-01-01
      • 2016-03-12
      • 2021-02-27
      • 1970-01-01
      • 2023-04-05
      • 1970-01-01
      • 2014-10-05
      • 2023-03-14
      相关资源
      最近更新 更多