vrann/magento-parallel-indexer

CLI 工具,用于并行执行单行重新索引

安装: 4

依赖: 0

建议者: 0

安全: 0

星级: 5

观察者: 3

分支: 2

开放性问题: 0

类型:magento2-module

dev-master 2015-10-09 09:20 UTC

This package is not auto-updated.

Last update: 2024-09-15 02:16:46 UTC


README

这是一个 Magento 2 模块,提供了 CLI 命令来以单行模式运行索引器。这是一种模式,当您更新单个特定实体(而不是所有实体)的重新索引数据时。例如,单个产品的重新索引。

此外,它包含一个 bash 脚本,允许并行运行多个索引器进程。这是为了测试索引器在同时运行在单个实体上时的表现。对于异步重新索引可能很有帮助。

用法

  1. 安装 Magento 2
  2. 确保 composer.json 中的最低稳定性是 "dev"(添加/更新此行 "minimum-stability": "dev")
  3. 执行 > composer require vrann/magento-parallel-indexer
  4. 执行 > bin/magento module:enable Magento_ParallelIndexer
  5. 执行 > bin/magento setup:upgrade

现在 CLI 命令已准备好使用。为了测试它,运行

bin/magento dev:single-row-indexer

使用默认参数,它将在产品、客户、类别和目标规则实体中随机行的所有索引器上运行。它将加载实体集合以获取最大允许的行 ID。这就是为什么这不是最佳方式。为了优化它,请使用参数

bin/magento dev:single-row-indexer
    --indexer=catalogpermissions_product,catalogpermissions_category  //specify indexers to run
    --max-categories=100 //amount of Products. Id will be generated in range from 1 to this number
    --max-products=200 //amount of Categories. Id will be generated in range from 1 to this number
    --max-customers=300 //amount of Customers. Id will be generated in range from 1 to this number
    --max-rules=10 //amount of Rules. Id will be generated in range from 1 to this number
    --reindex-id=1 //avoid generation of random id and use this id for all the entities

此外,还提供了 bash 脚本来并行运行命令。

vendor/bin/./parallel-run.sh 2 2 0

第一个参数是要运行的并行进程数。第二个参数是在并行进程中运行的迭代次数。第三个参数是进程的起始计数器。

之后,为了将参数传递给 dev:single-row-indexer CLI 命令,使用以下顺序:第四个:--indexer 第五个:--reindex-id 第六个:--max-categories 第七个:--max-products 第八个:--max-customers 第九个:--max-rules

vendor/bin/./parallel-run.sh 2 2 0 catalogpermissions_product,catalogpermissions_category 1 100 200 300 10