【发布时间】:2019-01-28 23:18:12
【问题描述】:
我有两台相同的服务器(A 和 B)通过 Lsyncd 同步。主服务器 A 使用 Magento 1.9.1 CE 配置 apache、Redis 和 RDS,并使用 FPC。我已经使用自定义管理员 url 配置它,使 A 为管理员,B 为前台。我已经同步了除 var 和 app/etc/local.xml 之外的所有目录,因为 B 对 redis 配置进行了轻微修改。
B 连接到 A 的 redis 实例。 Redis 配置用于后端缓存和会话存储。 我测试了在缓存管理中禁用所有缓存类型,它运行良好,但是当我启用它们时,它在 B 中给出了 redis 错误。我禁用了“配置”缓存类型并且错误消失了。
神秘的是,如果我启用“配置”缓存类型,然后在 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 之间共享。
但是,如果在 B 的 local.xml 中我使用单独的数据库,让我们说 2 用于后端缓存,则它没有问题。我想为 A 和 B 使用相同的后端缓存数据库。谁能帮我理解这里发生了什么?
谢谢!
【问题讨论】:
标签: apache redis magento-1.9