Magento 2如何解锁重新索引过程


65

我正在Magento重新编制索引过程中进行一些测试,并且锁定了股票编制索引过程。

我如何才能解锁此过程?

Design Config Grid index has been rebuilt successfully in 00:00:02
Customer Grid index has been rebuilt successfully in 00:00:03
Category Products index has been rebuilt successfully in 00:00:00
Product Categories index has been rebuilt successfully in 00:00:00
Product Price index has been rebuilt successfully in 00:00:00
Product EAV index has been rebuilt successfully in 00:00:00
Stock index is locked by another reindex process. Skipping.
Catalog Rule Product index has been rebuilt successfully in 00:00:00
Catalog Product Rule index has been rebuilt successfully in 00:00:00
Catalog Search index has been rebuilt successfully in 00:00:06

Answers:


118

您可以通过命令行使用indexer:resetcommand 重置索引器。

这将给出索引列表名称:

php bin/magento indexer:info

输出:

design_config_grid                       Design Config Grid
customer_grid                            Customer Grid
catalog_category_product                 Category Products
catalog_product_category                 Product Categories
catalog_product_price                    Product Price
catalog_product_attribute                Product EAV
catalogsearch_fulltext                   Catalog Search
cataloginventory_stock                   Stock
catalogrule_rule                         Catalog Rule Product
catalogrule_product                      Catalog Product Rule

这将给出索引状态列表:

php bin/magento indexer:status

输出:

Design Config Grid:                                Ready
Customer Grid:                                     Ready
Category Products:                                 Ready
Product Categories:                                Ready
Product Price:                                     Ready
Product EAV:                                       Ready
Catalog Search:                                    Ready
Stock:                                             Processing
Catalog Rule Product:                              Ready
Catalog Product Rule:                              Ready

如果要重置所有索引,可以运行以下命令:

php bin/magento indexer:reset

如果要重置特定的索引(例如cataloginventory_stock),可以运行以下命令:

php bin/magento indexer:reset cataloginventory_stock

1
重置索引会丢失所有等待索引的数据吗?
ol'bob dole

我在magento 2.2.4 enterprise edition使用上述步骤解决了问题时也遇到了同样的问题,但是我的产品没有显示在前面。有什么问题吗?
Chirag Patel

太好了,帮了我很多..
艾米

10

遇到这种情况时,我必须直接在数据库中运行以下SQL查询:

UPDATE indexer_state SET status = 'valid';

我以前找不到索引失败时无法找到任何选项来强制重新索引。


6

在MySQL上运行:

SET SQL_SAFE_UPDATES = 0;
update indexer_state set status = 'invalid' where status != 'valid';

然后在您的终端上运行:

php bin/magento indexer:reindex

当内存限制很少时,通常会发生这种情况,因此请增加 .htaccessNGINX config



0

您还可能会遇到某些表在MySQL中被锁定的状态。在这种情况下,您可以发出unlock tables;sql语句以继续进行。

我遇到了这样的问题:

Category Products indexer process unknown error:
SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction, query was: INSERT INTO

在删除表锁之前无法重新索引的位置。

重置索引会丢失任何等待索引的数据吗?–奥尔伯多尔

索引编制是查看数据集并存储一些键以与适当数据配对的过程。您将在此过程中丢失当前索引,然后重新创建它。除了索引消耗完资源或数据集不准确带来的副作用外,应该没有重新索引的风险。


0

只需运行这些命令

php bin / magento索引器:重置php bin / magento索引器:重置


-2

我通过以下步骤解决了这个问题:

1.-放置表customer_grid_flat

2.-重新创建表:

如果不存在则创建表customer_grid_flatentity_idint UNSIGNED NOT NULL COMMENT'Entity ID', name文本NULL COMMENT'Name', emailvarchar(255)NULL group_idCOMMENT'Email',int NULL COMMENT'Group_id',created_at时间戳NULL默认NULL COMMENT'Created_at ', website_idint NULL COMMENT'Website_id', confirmationvarchar(255)NULL COMMENT'Confirmation', created_in文本NULL COMMENT'Created_in', dob日期NULL COMMENT'Dob', genderint NULL taxvatCOMMENT'Gender',varchar(255)NULL COMMENT'Taxvat', lock_expires时间戳NULL默认NULL COMMENT'Lock_expires',shipping_full文本NULL COMMENT'Shipping_full' , billing_full文本NULL COMMENT' Billing_full', billing_firstnamevarchar(255)NULL COMMENT'Billing_firstname', billing_lastnamevarchar(255)NULL COMMENT'Billing_lastname', billing_telephonevarchar(255)NULL COMMENT'Billing_postlephone', billing_postcodevarchar(255)NULL COMMENT'Billing_postcode', billing_country_idvarchar(255)NULL COMMENT'Billing_country_id', billing_regionvarchar(255)NULL COMMENT'Billing_region' billing_streetvarchar(255)空注释'Billing_street', billing_cityvarchar(255)空注释'Billing_city', billing_faxvarchar(255)空注释'Billing_fax', billing_vat_idvarchar(255)空注释'Billing_vat_id', billing_companyvarchar(255)空注释'Billing_company',主键(entity_id),索引CUSTOMER_GRID_FLAT_GROUP_IDgroup_id),索引CUSTOMER_GRID_FLAT_CREATED_ATcreated_at),索引CUSTOMER_GRID_FLAT_WEBSITE_IDwebsite_id),索引CUSTOMER_GRID_FLAT_CONFIRMATIONconfirmation),INDEX CUSTOMER_GRID_FLAT_DOBdob),INDEXCUSTOMER_GRID_FLAT_GENDERgender),INDEX CUSTOMER_GRID_FLAT_BILLING_COUNTRY_IDbilling_country_id),FULLTEXT FTI_8746F705702DD5F6D45B8C7CE7FE9F2Fnameemailcreated_intaxvatshipping_fullbilling_fullbilling_firstnamebilling_lastnamebilling_telephonebilling_postcodebilling_regionbilling_citybilling_faxbilling_company))COMMENT = 'customer_grid_flat' ENGINE = innodb的字符集= UTF8 COLLATE = utf8_general_ci

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.