Magento Redis配置问题:找不到命名的PHP会话模块(redis)

时间:2013-10-09 16:53:12

标签: magento redis magento-1.13

我一直在尝试使用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

2 个答案:

答案 0 :(得分:2)

这已经证明是缺少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>

答案 1 :(得分:1)

我没有做很多“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 -->