首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Magento管理/前端拆分服务器Redis错误

Magento管理/前端拆分服务器Redis错误
EN

Stack Overflow用户
提问于 2017-10-13 12:02:53
回答 1查看 539关注 0票数 0

我有两个相同的服务器(A和B)通过Lsyncd同步。主服务器A使用Magento 1.9.1CE配置apache、Redis和RDS,并使用FPC。我已经配置它与自定义管理url,使A为管理和B为前端。除了var和app/etc/local.xml之外,我已经同步了所有目录,因为B对redis配置有一些修改。

B连接到A的redis实例。Redis配置为后端缓存和会话存储。我在Cache Management中测试了禁用所有缓存类型,它运行得很好,但是当我启用它们时,它在B中出现了redis错误。我禁用了“配置”缓存类型,然后错误就消失了。

神秘的是,如果我启用'Configuration‘缓存类型,然后在redis中执行'flushall’,并且哪个服务器首先加载并创建后端缓存键,而另一个服务器则有此错误。让我们说,如果A先加载,那么B就有红错误。如果先在红和B负载中进行冲水,则A有红差。

我好像搞不清出了什么问题。这是我的redis配置:

代码语言:javascript
复制
        <session_save>db</session_save>
    <cache>
        <backend>Mage_Cache_Backend_Redis</backend>
        <backend_options>
            <server>127.0.0.1</server>
            <port>6379</port>
            <database>0</database>
            <password>SOME_PASSWORD</password>
            <force_standalone>0</force_standalone>  <!-- 0 for phpredis, 1 for standalone PHP -->
            <connect_retries>3</connect_retries>    <!-- Reduces errors due to random connection failures -->
            <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 -->
            <persistent>1</persistent> <!-- persistence value, 0: not in use, > 0 used as persistence ID -->
        </backend_options>
    </cache>
    <redis_session>                       <!-- All options seen here are the defaults -->
        <host>127.0.0.1</host>
        <port>6379</port>
        <password>SOME_PASSWORD</password>            <!-- Specify if your Redis server requires authentication -->
        <timeout>2.5</timeout>            <!-- This is the Redis connection timeout, not the locking timeout -->
        <persistent></persistent>         <!-- Specify unique string to enable persistent connections. E.g.: sess-db0; bugs with phpredis and php-fpm are known: https://github.com/nicolasff/phpredis/issues/70 -->
        <db>1</db>                        <!-- Redis database number; protection from accidental loss is improved by using a unique DB number for sessions -->
        <compression_threshold>2048</compression_threshold>  <!-- Set to 0 to disable compression (recommended when suhosin.session.encrypt=on); known bug with strings over 64k: https://github.com/colinmollenhour/Cm_Cache_Backend_Redis/issues/18 -->
        <compression_lib>gzip</compression_lib>              <!-- gzip, lzf or snappy -->
        <log_level>4</log_level>               <!-- 0 (emergency: system is unusable), 4 (warning; additional information, recommended), 5 (notice: normal but significant condition), 6 (info: informational messages), 7 (debug: the most information for development/testing) -->
        <max_concurrency>6</max_concurrency>                 <!-- maximum number of processes that can wait for a lock on one session; for large production clusters, set this to at least 10% of the number of PHP processes -->
        <break_after_frontend>5</break_after_frontend>       <!-- seconds to wait for a session lock in the frontend; not as critical as admin -->
        <break_after_adminhtml>30</break_after_adminhtml>
        <bot_lifetime>7200</bot_lifetime>                    <!-- Bots get shorter session lifetimes. 0 to disable -->
    </redis_session>

问题在于后端缓存,即数据库0,它似乎没有在不同的urls之间共享。

Redis错误是:

但是,如果在B的local.xml中,我使用单独的数据库,比如对后端缓存使用2,而不是没有问题。我想为A和B使用相同的后端缓存数据库,有人能帮我理解这里发生了什么吗?

谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-10-27 10:50:44

我找到了一个解决办法,解决方案似乎是有意义的。我在两个服务器上创建了相同的local.xml文件。服务器A中的local.xml文件,我将redis配置为连接到其私有ip,而不是用于缓存和会话的本地ip 127.0.0.1。由于B现在需要连接到A中的redis实例,所以配置是相同的。然后我就冲红了它起了作用。我认为Magento将配置存储在数据库中。因此,在cache管理中启用缓存类型“配置”似乎会导致错误,特别是对于前端服务器B而言,因为当A首先加载时,以前的主机名为127.0.0.1保存在数据库中,这导致服务器B在试图连接到自己而不是远程服务器A时出现了redis连接错误(在B中停止了redis服务)

我做了一些研究,发现确实如此。这篇文章帮助点燃了思维过程。

How can I disable the cache via the database?

本地数据库也是如此。因此,我使用了RDS,但没有意识到这是与主机名不一致的问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46729505

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档