【问题标题】:Reindex for Multiple magento roots in a single server using Shell script使用 Shell 脚本为单个服务器中的多个 magento 根重建索引
【发布时间】:2023-01-29 23:00:39
【问题描述】:

我正在尝试为 Reindex 实现一个 shell 脚本。

关心:

我在一台服务器上有五个站点。 (html-abc、html-cdf、html-xyz 等,位于 /var/www/)。我想使用 shell 脚本为每个站点运行重新索引,并且应该在 reindex.log 文件中记录带有时间戳的日志。

目前我正在使用 cron 为每个站点执行重建索引,但我无法在日志文件中看到时间戳。任何人都可以帮忙吗?

样本计划 */30 * * * * /usr/bin/php7.4 /var/www/html-abc/bin/magento indexer:reindex 2>&1 | grep -v “按计划运行作业” >> /var/log/magento_index.log

我得到的结果

test@testaz:~/scripts$ tail -n 50 /var/log/magento_index.log Design Config Grid index has been rebuilt successfully in 00:00:00 Customer Grid index has been rebuilt successfully in 00:00:00 process error during indexation process: Product Flat Data index is locked by another reindex process. Skipping. Category Products index has been rebuilt successfully in 00:00:01 Product Categories index has been rebuilt successfully in 00:00:00 Catalog Rule Product index has been rebuilt successfully in 00:00:00 Product EAV index has been rebuilt successfully in 00:00:02 Stock index has been rebuilt successfully in 00:00:01 Inventory index has been rebuilt successfully in 00:00:00 Catalog Product Rule index has been rebuilt successfully in 00:00:00 Product Price index has been rebuilt successfully in 00:00:09 Catalog Search index has been rebuilt successfully in 00:00:03 Design Config Grid index has been rebuilt successfully in 00:00:00 Customer Grid index has been rebuilt successfully in 00:00:01 process error during indexation process: Product Flat Data index is locked by another reindex process. Skipping. Category Products index has been rebuilt successfully in 00:00:01 Product Categories index has been rebuilt successfully in 00:00:00 Catalog Rule Product index has been rebuilt successfully in 00:00:00 Product EAV index has been rebuilt successfully in 00:00:01 Stock index has been rebuilt successfully in 00:00:00 Inventory index has been rebuilt successfully in 00:00:00 Catalog Product Rule index has been rebuilt successfully in 00:00:00 Product Price index has been rebuilt successfully in 00:00:02 Catalog Search index has been rebuilt successfully in 00:00:02

样本计划 */30 * * * * /usr/bin/php7.4 /var/www/html-abc/bin/magento indexer:reindex 2>&1 | grep -v “按计划运行作业” >> /var/log/magento_index.log

我得到的结果

test@testaz:~/scripts$ tail -n 50 /var/log/magento_index.log Design Config Grid index has been rebuilt successfully in 00:00:00 Customer Grid index has been rebuilt successfully in 00:00:00 process error during indexation process: Product Flat Data index is locked by another reindex process. Skipping. Category Products index has been rebuilt successfully in 00:00:01 Product Categories index has been rebuilt successfully in 00:00:00 Catalog Rule Product index has been rebuilt successfully in 00:00:00 Product EAV index has been rebuilt successfully in 00:00:02 Stock index has been rebuilt successfully in 00:00:01 Inventory index has been rebuilt successfully in 00:00:00 Catalog Product Rule index has been rebuilt successfully in 00:00:00 Product Price index has been rebuilt successfully in 00:00:09 Catalog Search index has been rebuilt successfully in 00:00:03 Design Config Grid index has been rebuilt successfully in 00:00:00 Customer Grid index has been rebuilt successfully in 00:00:01 process error during indexation process: Product Flat Data index is locked by another reindex process. Skipping. Category Products index has been rebuilt successfully in 00:00:01 Product Categories index has been rebuilt successfully in 00:00:00 Catalog Rule Product index has been rebuilt successfully in 00:00:00 Product EAV index has been rebuilt successfully in 00:00:01 Stock index has been rebuilt successfully in 00:00:00 Inventory index has been rebuilt successfully in 00:00:00 Catalog Product Rule index has been rebuilt successfully in 00:00:00 Product Price index has been rebuilt successfully in 00:00:02 Catalog Search index has been rebuilt successfully in 00:00:02

【问题讨论】:

    标签: magento cron devops reindex


    【解决方案1】:

    以下是您可以尝试解决此问题的一些方法:

    1. 检查 Magento 管理面板以查看当前是否有另一个重建索引进程正在运行。如果是这样,请等待它完成,然后再尝试重新索引。

    2. 检查您的服务器资源,如果内存或 CPU 使用率低,可能会导致重建索引进程被锁定。在这种情况下,您可以尝试增加服务器的资源或等到资源再次可用时重新编制索引。

    3. 清除缓存并再次尝试重建索引。

    4. 如果问题仍然存在,您可以尝试通过截断数据库中的 index_event、index_process 和 indexer_state 表来手动解锁索引。但是,这样做应该谨慎,因为它会导致数据不一致,强烈建议在继续之前备份数据库。

    5. 如果上述步骤未能解决问题,请检查 Magento 和服务器日志以获取有关问题原因的更多信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-06-20
      • 1970-01-01
      • 1970-01-01
      • 2019-01-20
      • 2012-11-05
      • 1970-01-01
      • 2018-03-07
      • 2013-07-06
      相关资源
      最近更新 更多