magento - 负载高 - 后台任务 - cron_schedule
现象:magento2站点,查看系统负载,在4.5左右。
尝试:在top命令详情中,mysqld和php进程占用CPU、内存高。先删除magento的定时任务,再手动退出当前的php任务进程,系统负载明显回落。但将定时任务加回后,负载又升高。最后,将数据库中的cron_schedule清空,即执行 TRUNCATE cron_schedule;
后,基本恢复正常。
现象:magento2站点,查看系统负载,在4.5左右。
尝试:在top命令详情中,mysqld和php进程占用CPU、内存高。先删除magento的定时任务,再手动退出当前的php任务进程,系统负载明显回落。但将定时任务加回后,负载又升高。最后,将数据库中的cron_schedule清空,即执行 TRUNCATE cron_schedule;
后,基本恢复正常。
问题:magento2.4的站点,执行 bin/magento indexer:reindex 后,elastic search 报错。内容如下:
Catalog Search index process error during indexation process:
{"error":{"root_cause":[{"type":"cluster_block_exception","reason":"index [magento2_mazia_243_product_1_v45] blocked by: [TOO_MANY_REQUESTS/12/disk usage exceeded flood-stage watermark, index has read-only-allow-delete block];"}],"type":"cluster_block_exception","reason":"index [magento2_mazia_243_product_1_v45] blocked by: [TOO_MANY_REQUESTS/12/disk usage exceeded flood-stage watermark, index has read-only-allow-delete block];"},"status":429}
尝试:按网上说的,调整elastic search设置后就可以了:
curl -XPUT -H "Content-Type: application/json" http://localhost:9200/_cluster/settings -d '{ "transient": { "cluster.routing.allocation.disk.threshold_enabled": false } }'
curl -XPUT -H "Content-Type: application/json" http://localhost:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}'
参考:https://stackoverflow.com/questions/63689953/magento-2-4-reindex-issue-with-elasticsearch
需求:想将magento2的static和media配置cdn,如aws的cloudfront访问。
尝试:
参考:
现象:通过magento 1.x 自带的导出商品数据功能,再在迁移后的站点里导入,商品丢失价格等部分属性。如果直接通过mysqldump导出及mysql导入整个magento站点数据表,则站点后台无法列出显示商品,“商品管理”为零。
尝试:在phpmyadmin中看到,通过mysql导入数据库内容后的部分数据表,如 catalog_product_entity_int 无数据。尝试通过phpmyadmin导入该表时,提示错误 #1062 - Duplicate entry '204-102-0' for key 'UNQ_CATALOG_PRODUCT_ENTITY_INT_ENTITY_ID_ATTRIBUTE_ID_STORE_ID' 。很可能是因为原数据库的部分数据表有错误,无法成功导出完整的数据。
需求:如果想将wordpress站点的目录移到magento1.x的子目录,通过magento的URL来访问,应该怎么做呢?
尝试:需要修改相应的静态化规则。如nginx的,可参考这个:https://docs.ukfast.co.uk/ecommercestacks/magento/magento1/wpinsubdir.html
location ~ ^/wp/ {
index index.php index.html index.htm;
try_files $uri $uri/ @wphandler;
expires 30d;
location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ {
add_header Cache-Control "public";
add_header X-Frame-Options "SAMEORIGIN";
expires +1y;
try_files $uri $uri/ /get.php?$args;
}
location ~* /(wp-admin/|wp-login\.php) {
try_files $uri $uri/ @wphandler;
index index.html index.htm index.php;
fastcgi_pass replacemebackend;
add_header Cache-Control "no-store";
fastcgi_buffers 1024 4k;
#fastcgi_param HTTPS $my_https; # Uncomment the below for SSL offloading
#fastcgi_param SERVER_PORT $my_port; # Uncomment the below for SSL offloading
fastcgi_read_timeout 600s;
fastcgi_connect_timeout 600s;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~* \.php$ {
try_files $uri $uri/ =404;
fastcgi_pass replacemebackend;
#fastcgi_param HTTPS $my_https; # Uncomment the below for SSL offloading
#fastcgi_param SERVER_PORT $my_port; # Uncomment the below for SSL offloading
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
location @wphandler {
rewrite / /wp/index.php;
}