【问题标题】:Magento Redis Configuration Issue: Cannot find named PHP session module (redis)Magento Redis 配置问题:找不到命名的 PHP 会话模块 (redis)
【发布时间】:2014-01-30 14:57:28
【问题描述】:

我一直在尝试使用 Redis 作为我们性能问题的潜在解决方案,但我在 Magneto Enterprise 1.13.0.2 中配置 Redis 时遇到问题。

我收到以下错误Warning: session_module_name(): Cannot find named PHP session module (redis)

对我来说,这是说它不知道会话处理程序 reddis。

由于 EE 1.13 Redis 应该是开箱即用的,奇怪的是 full_page_cache 可以使用它,而标准的 cachesession_save 不能。

我的 local.xml 配置:

    <session_save><![CDATA[redis]]></session_save>
    <session_save_path><![CDATA[tcp://127.0.0.1:6379?weight=2&timeout=2.5]]></session_save_path>
    <cache>
        <backend>Mage_Cache_Backend_Redis</backend>
        <backend_options>
            <server>127.0.0.1</server> <!-- or absolute path to unix socket -->
            <port>6379</port>
            <persistent></persistent> <!-- Specify a unique string like "cache-db0" to enable persistent connections. -->
            <database>0</database>
            <password></password>
            <force_standalone>0</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 -->
            <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 -->
        </backend_options>
    </cache>
    <full_page_cache>
        <backend>Mage_Cache_Backend_Redis</backend>
        <backend_options>
            <server>127.0.0.1</server> <!-- or absolute path to unix socket -->
            <port>6379</port>
            <persistent></persistent> <!-- Specify a unique string like "cache-db0" to enable persistent connections. -->
            <database>1</database> <!-- Separate database 1 to keep FPC separately -->
            <password></password>
            <force_standalone>0</force_standalone>  <!-- 0 for phpredis, 1 for standalone PHP -->
            <connect_retries>1</connect_retries>    <!-- Reduces errors due to random connection failures -->
            <lifetimelimit>57600</lifetimelimit>    <!-- 16 hours of lifetime for cache record -->
            <compress_data>0</compress_data>        <!-- DISABLE compression for EE FPC since it already uses compression -->
        </backend_options>
    </full_page_cache>
</global>

我很难找到好的文档,我可以回退到https://github.com/colinmollenhour/Cm_Cache_Backend_Redis,但我想使用一个核心包来实现这个功能,它使升级路径更清晰。

http://www.magentocommerce.com/knowledge-base/entry/redis-magento-ce-ee#config-mage https://magento.stackexchange.com/questions/4264/redis-on-magento-enterprise-1-13

【问题讨论】:

    标签: magento redis magento-1.13


    【解决方案1】:

    事实证明这是缺少 PECL redis 扩展的问题,所以安装它,你应该很高兴:

    pecl install redis

    我的印象是我可以通过以下方式使用独立的 PHP:

    <force_standalone>1</force_standalone>  <!-- 0 for phpredis, 1 for standalone PHP -->
    

    我的完整配置最终是:

        <!-- Uses database 0 -->
        <session_save><![CDATA[redis]]></session_save>
        <session_save_path><![CDATA[tcp://127.0.0.1:6379?weight=2&timeout=2.5]]></session_save_path>
        <cache>
            <backend>Mage_Cache_Backend_Redis</backend>
            <backend_options>
                <server>127.0.0.1</server> <!-- or absolute path to unix socket -->
                <port>6379</port>
                <persistent></persistent> <!-- Specify a unique string like "cache-db0" to enable persistent connections. -->
                <database>1</database> <!-- Separate database 2 to keep separate from FPC + Session -->
                <password></password>
                <force_standalone>0</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 -->
                <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 -->
            </backend_options>
        </cache>
        <full_page_cache>
            <backend>Mage_Cache_Backend_Redis</backend>
            <backend_options>
                <server>127.0.0.1</server> <!-- or absolute path to unix socket -->
                <port>6379</port>
                <persistent></persistent> <!-- Specify a unique string like "cache-db0" to enable persistent connections. -->
                <database>2</database> <!-- Separate database 2 to keep FPC separately -->
                <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 -->
                <lifetimelimit>57600</lifetimelimit>    <!-- 16 hours of lifetime for cache record -->
                <compress_data>0</compress_data>        <!-- DISABLE compression for EE FPC since it already uses compression -->
            </backend_options>
        </full_page_cache>
    </global>
    

    【讨论】:

      【解决方案2】:

      我不做很多“dev-ops”类型的东西,

      警告:session_module_name():找不到命名的 PHP 会话模块 (redis)

      是 PHP 错误,而不是 Magento 错误。没有(据我所知)PHP 附带的 redis 后端存储模块。

      根据Cm_RedisSession 模块的GitHub,链接在Magento Wiki Setup 页面中,您不应该设置

      `<session_save>`
      

      local.xml 中的节点。而是

      在 app/etc/local.xml 中将 global/session_save 配置更改为“db”。 “db”值是 MySQL 处理程序,但 Cm_RedisSession 会覆盖它以避免修改核心文件。

      配置看起来像这样

      <session_save>db</session_save>
      <redis_session>                       <!-- All options seen here are the defaults -->
          <host>127.0.0.1</host>            <!-- Specify an absolute path if using a unix socket -->
          <port>6379</port>
          <password></password>             <!-- Specify if your Redis server requires authentication -->
          <timeout>2.5</timeout>          
          <!-- ... more at https://github.com/colinmollenhour/Cm_RedisSession/blob/master/README.md -->
      

      【讨论】:

      • 感谢 Alan 的建议,当像这样配置会话时,它会保存到数据库并且不会触及我的 redis 实例,它们是否通过 Cm_RedisSession 以及后端进行了移植?当将session_save 用作files 并将cache 后端类用作Mage_Cache_Backend_Redis 时,我遇到了同样的问题,很奇怪。
      • @input 我对此并没有深入研究,但是阅读 Cm_RedisSession 文档后,听起来这个扩展将运行时的配置从 db 更改为其他内容。
      猜你喜欢
      • 1970-01-01
      • 2011-03-24
      • 1970-01-01
      • 2014-09-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多