2017-10-13 93 views
0

我有两个相同的服务器(A和B)通过Lsyncd同步。主服务器A使用配置了apache,Redis和RDS的Magento 1.9.1 CE并使用FPC。我已经配置了自定义管理员网址,其中A为管理员,B为前台。由于B对redis配置进行了轻微修改,因此我已同步除var和app/etc/local.xml之外的所有目录。Magento管理员/前分割服务器Redis错误

B连接到A的redis实例。 Redis配置为后端缓存和会话存储。 我测试了禁用缓存管理中的所有缓存类型,它运行良好,但是当我启用它们时,它在B中给出了redis错误。我禁用了'配置'缓存类型,错误消失了。

这是神秘的东西;如果我启用'Configuration'缓存类型,然后在redis中执行'flushall';以及哪个服务器A或B先装入并创建后端缓存键,另一个则出现此错误。 可以说,如果A先加载然后B有redis错误。如果在Redis中完成flushall并且B先加载,那么A有redis错误。

我似乎无法弄清楚什么是错的。 这里是我的Redis配置:

 <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 它似乎没有不同的URL之间共享。

Redis的错误是: Redis error

但是,如果B的local.xml中我使用单独的数据库可以说2后端缓存比它没有任何问题。我想为A和B使用相同的后端缓存数据库。谁能帮我理解这里发生了什么?

谢谢!

回答

0

我发现了一个解决方法,解决方案似乎有道理。我在两台服务器上创建了相同的local.xml文件。在服务器A中的local.xml文件中,我配置了redis来连接到它的私有IP,而不是它的本地IP 127.0.0.1,用于缓存和会话。由于B需要连接到A中的redis实例,因此配置相同。然后我做了flushall redis,它工作。 我认为Magento将配置存储在数据库中。因此,在缓存管理中启用缓存类型“配置”似乎会给前端服务器B带来错误,因为当A首先加载之前为127.0.0.1的主机名已保存在导致服务器B出现redis连接错误的数据库中时,因为它试图连接而不是远程服务器A.(redis服务在B中停止)

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

How can I disable the cache via the database?

这与本地数据库中的相同。所以我使用了RDS,但没有意识到这是与主机名不一致的问题。