Magento Admin/Front 拆分服务器 Redis 错误
Magento Admin/Front Split server Redis error
我有两个相同的服务器(A 和 B)通过 Lsyncd 同步。主服务器A使用配置了apache、Redis和RDS的Magento 1.9.1 CE,并使用FPC。我已经用自定义管理员配置它 url 使 A 为管理员,B 为前台。我已经同步了除 var 和 app/etc/local.xml 之外的所有目录,因为 B 对 redis 配置略有修改。
B 连接到 A 的 redis 实例。
Redis 配置用于后端缓存和会话存储。
我测试了在缓存管理中禁用所有缓存类型并且它运行良好但是当我启用它们时它在 B 中出现了 redis 错误。我禁用了 'Configuration' 缓存类型并且错误消失了。
神秘的是,如果我启用 '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错误是:
但是,如果在 B 的 local.xml 中我使用单独的数据库,假设 2 用于后端缓存,那么它没有问题。我想为 A 和 B 使用相同的后端缓存数据库。谁能帮助我了解这里发生了什么?
谢谢!
我找到了一个解决方法,这个解决方案似乎很有意义。我在两台服务器上制作了相同的 local.xml 文件。服务器A中的local.xml文件,我配置redis连接到它的私有ip而不是它的本地ip 127.0.0.1用于缓存和会话。由于 B 需要连接到 A 中的 redis 实例,因此配置相同。然后我做了 flushall redis 并且它起作用了。
我认为 Magento 将配置存储在数据库中。因此,在缓存管理中启用缓存类型 "Configuration" 似乎会产生错误,尤其是对于前端服务器 B,因为当 A 首先加载时,先前为 127.0.0.1 的主机名保存在数据库中,这导致服务器 B 在尝试时出现 redis 连接错误连接到自身而不是远程服务器 A。(redis 服务在 B 中停止)
我做了一些研究,发现确实如此。这 post 有助于激发思考过程。
How can I disable the cache via the database?
这与本地数据库相同。所以我使用了 RDS 但没有意识到这是与主机名不一致有关的问题。
我有两个相同的服务器(A 和 B)通过 Lsyncd 同步。主服务器A使用配置了apache、Redis和RDS的Magento 1.9.1 CE,并使用FPC。我已经用自定义管理员配置它 url 使 A 为管理员,B 为前台。我已经同步了除 var 和 app/etc/local.xml 之外的所有目录,因为 B 对 redis 配置略有修改。
B 连接到 A 的 redis 实例。 Redis 配置用于后端缓存和会话存储。 我测试了在缓存管理中禁用所有缓存类型并且它运行良好但是当我启用它们时它在 B 中出现了 redis 错误。我禁用了 'Configuration' 缓存类型并且错误消失了。
神秘的是,如果我启用 '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错误是:
但是,如果在 B 的 local.xml 中我使用单独的数据库,假设 2 用于后端缓存,那么它没有问题。我想为 A 和 B 使用相同的后端缓存数据库。谁能帮助我了解这里发生了什么?
谢谢!
我找到了一个解决方法,这个解决方案似乎很有意义。我在两台服务器上制作了相同的 local.xml 文件。服务器A中的local.xml文件,我配置redis连接到它的私有ip而不是它的本地ip 127.0.0.1用于缓存和会话。由于 B 需要连接到 A 中的 redis 实例,因此配置相同。然后我做了 flushall redis 并且它起作用了。 我认为 Magento 将配置存储在数据库中。因此,在缓存管理中启用缓存类型 "Configuration" 似乎会产生错误,尤其是对于前端服务器 B,因为当 A 首先加载时,先前为 127.0.0.1 的主机名保存在数据库中,这导致服务器 B 在尝试时出现 redis 连接错误连接到自身而不是远程服务器 A。(redis 服务在 B 中停止)
我做了一些研究,发现确实如此。这 post 有助于激发思考过程。
How can I disable the cache via the database?
这与本地数据库相同。所以我使用了 RDS 但没有意识到这是与主机名不一致有关的问题。