mysql - Magento MySQL挂了

标签 mysql magento magento-1.9 database-performance entity-attribute-value

我在互联网上的很多地方进行了搜索,以在 Magento 安装的数据库中找到一些问题的答案。

该网站此时不可用(大部分时间持续约 15 分钟并自行解决),不是前端也不是后端。 我尝试了各种 mysql 调整脚本,将索引设置为手动,将数据库移动到专用服务器等。Ubuntu 操作系统的日志或 Magento 日志显示任何异常错误消息。 Fail2Ban 是针对 DDOS 安装的。

mysql 进程或使用 100% 以上或使用 0.0% (!!!) 但整个服务器似乎卡住了。有时甚至我用 Putty/SSH 键入的字符在服务器自行恢复之前也不会显示。

专用数据库服务器有 32Gb RAM,mysql 使用大约 25G。

顶部的顶部: 840 mysql 20 0 25,640g 0,011t 6632 S 26,2 34,2 270:08.31 mysqld

设置 my.cnf:

[mysqld]
key_buffer              = 512M
max_allowed_packet      = 64M
thread_stack            = 512K
thread_cache_size       = 512
sort_buffer_size        = 24M
read_buffer_size        = 8M
read_rnd_buffer_size    = 24M
join_buffer_size        = 128M
max_connections         = 1024
concurrent_insert       = 2
connect_timeout         = 5
table_open_cache        = 12288
tmp_table_size          = 512M
max_heap_table_size     = 512M
bulk_insert_buffer_size = 512M
open-files-limit        = 8192
open-files              = 1024
query_cache_type=1
query_cache_limit       = 4M
query_cache_size        = 512M
slow_query_log_file     = /var/log/mysql/slow.log
slow_query_log          = 0
long_query_time         = 0.2
expire_logs_days        = 10
max_binlog_size         = 1024M
binlog_cache_size       = 32K
innodb_thread_concurrency       = 16
innodb_commit_concurrency       = 2
innodb_buffer_pool_size = 16G
innodb_log_file_size    = 512M
innodb_additional_mem_pool_size = 8M
#innodb_data_file_path   = ibdata1:1024M:autoextend
innodb_file_per_table
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size  = 2G

显示完整进程列表的输出:

| Id    | User            | Host                            | db              | Command | Time | State              | Info                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
++
| 76636 | juwelierwebshop | ...:40316 | juwelierwebshop | Query   |  328 | query end          | INSERT INTO abctools_merkgevuld (sku) VALUES ('JUPA22655')                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| 76638 | juwelierwebshop | ...:40344 | juwelierwebshop | Sleep   |  328 |                    | NULL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| 76642 | juwelierwebshop | ...:40484 | juwelierwebshop | Query   |   54 | query end          | SELECT `main_table`.* FROM `bolconnect_items_be` AS `main_table` WHERE (product_id = '62622')                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| 76695 | juwelierwebshop | ...:54112 | juwelierwebshop | Sleep   |  603 |                    | NULL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| 76696 | juwelierwebshop | ...:54126 | juwelierwebshop | Query   |   54 | update             | INSERT INTO `bolconnect_offerlist` (`ean`, `prijs`, `leverancier`, `sellerid`, `sellerrating`, `avdesc`, `koopbox`, `updated_at`) VALUES ('8718834545421', '619', 'abc', '1121928', '8.8', '5 - 7 dagen', '1', '2018-09-07 12:10:10')                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| 77039 | juwelierwebshop | ...:40290 | juwelierwebshop | Query   |   54 | Sending data       | INSERT INTO `sales_flat_order_grid` (`entity_id`, `status`, `store_id`, `customer_id`, `base_grand_total`, `base_total_paid`, `grand_total`, `total_paid`, `increment_id`, `base_currency_code`, `order_currency_code`, `store_name`, `created_at`, `updated_at`, `billing_name`, `shipping_name`) SELECT `main_table`.`entity_id`, `main_table`.`status`, `main_table`.`store_id`, `main_table`.`customer_id`, `main_table`.`base_grand_total`, `main_table`.`base_total_paid`, `main_table`.`grand_total`, `main_table`.`total_paid`, `main_table`.`increment_id`, `main_table`.`base_currency_code`, `main_table`.`order_currency_code`, `main_table`.`store_name`, `main_table`.`created_at`, `main_table`.`updated_at`, CONCAT(IFNULL(table_billing_name.firstname, ''), ' ', IFNULL(table_billing_name.lastname, '')) AS `billing_name`, CONCAT(IFNULL(table_shipping_name.firstname, ''), ' ', IFNULL(table_shipping_name.lastname, '')) AS `shipping_name` FROM `sales_flat_order` AS `main_table`
 LEFT JOIN `sales_flat_order_address` AS `table_billing_name` ON `main_table`.`billing_address_id`=`table_billing_name`.`entity_id`
 LEFT JOIN `sales_flat_order_address` AS `table_shipping_name` ON `main_table`.`shipping_address_id`=`table_shipping_name`.`entity_id` WHERE (main_table.entity_id IN('27894')) ON DUPLICATE KEY UPDATE `entity_id` = VALUES(`entity_id`), `status` = VALUES(`status`), `store_id` = VALUES(`store_id`), `customer_id` = VALUES(`customer_id`), `base_grand_total` = VALUES(`base_grand_total`), `base_total_paid` = VALUES(`base_total_paid`), `grand_total` = VALUES(`grand_total`), `total_paid` = VALUES(`total_paid`), `increment_id` = VALUES(`increment_id`), `base_currency_code` = VALUES(`base_currency_code`), `order_currency_code` = VALUES(`order_currency_code`), `store_name` = VALUES(`store_name`), `created_at` = VALUES(`created_at`), `updated_at` = VALUES(`updated_at`), `billing_name` = VALUES(`billing_name`), `shipping_name` = VALUES(`shipping_name`) |
| 77041 | juwelierwebshop | ...:40578 | juwelierwebshop | Query   |   54 | statistics         | SELECT `catalog_product_entity`.* FROM `catalog_product_entity` WHERE (entity_id ='45702')                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| 77042 | juwelierwebshop | ...:40766 | juwelierwebshop | Query   |   54 | Sending data       | SELECT COUNT(DISTINCT e.entity_id) FROM `catalog_product_flat_2` AS `e`
 INNER JOIN `report_viewed_product_index` AS `idx_table` ON (idx_table.product_id=e.entity_id) AND (idx_table.visitor_id = '')
 INNER JOIN `catalog_category_product_index` AS `cat_index` ON cat_index.product_id=e.entity_id AND cat_index.store_id=2 AND cat_index.category_id = '2'
 LEFT JOIN `core_store` AS `store_index` ON store_index.store_id = idx_table.store_id
 LEFT JOIN `core_store_group` AS `store_group_index` ON store_index.group_id = store_group_index.group_id
 LEFT JOIN `catalog_category_product_index` AS `store_cat_index` ON store_cat_index.product_id = e.entity_id AND store_cat_index.store_id = idx_table.store_id AND store_cat_index.category_id=store_group_index.root_category_id WHERE (cat_index.visibility IN(3, 2, 4) OR store_cat_index.visibility IN(3, 2, 4))                                                                                                                                                                             |
| 77043 | juwelierwebshop | ...:40930 | juwelierwebshop | Query   |   54 | statistics         | SELECT `catalog_category_entity`.* FROM `catalog_category_entity` WHERE (entity_id ='37')                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| 77047 | juwelierwebshop | ...:42478 | juwelierwebshop | Query   |   53 | Sending data       | SELECT COUNT(DISTINCT e.entity_id) FROM `catalog_product_entity` AS `e`
 INNER JOIN `catalog_product_entity_int` AS `at_status` ON (`at_status`.`entity_id` = `e`.`entity_id`) AND (`at_status`.`attribute_id` = '96') AND (`at_status`.`store_id` = 0)
 INNER JOIN `catalog_product_entity_int` AS `at_visibility` ON (`at_visibility`.`entity_id` = `e`.`entity_id`) AND (`at_visibility`.`attribute_id` = '102') AND (`at_visibility`.`store_id` = 0)
 INNER JOIN `catalog_product_entity_varchar` AS `at_name` ON (`at_name`.`entity_id` = `e`.`entity_id`) AND (`at_name`.`attribute_id` = '71') AND (`at_name`.`store_id` = 0) WHERE (at_name.value LIKE '%BUDDHA TO BUDDHA 811 SIGNIFY CORD BRACELET BROWN%')                                                                                                                                                                                                                                                                                                                                             |
| 77050 | juwelierwebshop | ...:43538 | juwelierwebshop | Query   |   54 | updating           | UPDATE `sales_flat_quote_address` SET `quote_id` = '62660', `created_at` = '2018-09-02 19:38:03', `updated_at` = '2018-09-07 12:10:10', `customer_id` = '22445', `save_in_address_book` = '0', `customer_address_id` = '45277', `address_type` = 'billing', `email` = 'abc@email.nl', `prefix` = NULL, `firstname` = 'Pieter', `middlename` = NULL, `lastname` = 'Slits', `suffix` = NULL, `company` = NULL, `street` = 'Steurgat\n92', `city` = 'Gorinchem', `region` = 'Zuid-Holland', `region_id` = NULL, `postcode` = '4208BL', `country_id` = 'NL', `telephone` = '0621263156', `fax` = NULL, `same_as_billing` = '0', `free_shipping` = '0', `collect_shipping_rates` = '0', `shipping_method` = NULL, `shipping_description` = NULL, `weight` = '0', `subtotal` = '0', `base_subtotal` = '0', `subtotal_with_discount` = '0', `base_subtotal_with_discount` = '0', `tax_amount` = '0', `base_tax_amount` = '0', `shipping_amount` = '0', `base_shipping_amount` = '0', `shipping_tax_amount` = '0', `base_shipping_tax_amount` = '0', `discount_amount` = '0', `base_discount_amount` = '0', `grand_total` = '0', `base_grand_total` = '0', `customer_notes` = NULL, `applied_taxes` = 'a:0:{}', `discount_description` = NULL, `shipping_discount_amount` = NULL, `base_shipping_discount_amount` = NULL, `subtotal_incl_tax` = '0', `base_subtotal_total_incl_tax` = NULL, `hidden_tax_amount` = NULL, `base_hidden_tax_amount` = NULL, `shipping_hidden_tax_amount` = NULL, `base_shipping_hidden_tax_amnt` = NULL, `shipping_incl_tax` = '0', `base_shipping_incl_tax` = '0', `vat_id` = NULL, `vat_is_valid` = NULL, `vat_request_id` = NULL, `vat_request_date` = NULL, `vat_request_success` = NULL, `gift_message_id` = NULL, `kp_id` = NULL, `payment_fee` = '0', `base_payment_fee` = '0', `payment_fee_tax` = '0', `base_payment_fee_tax` = '0' WHERE (address_id='121757') |
| 77052 | juwelierwebshop | ...:43840 | juwelierwebshop | Query   |   54 | init               | commit                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| 77053 | juwelierwebshop | ...:44590 | juwelierwebshop | Query   |  204 | removing tmp table | SELECT `customer_address_entity_varchar`.`entity_id`, `customer_address_entity_varchar`.`attribute_id`, `customer_address_entity_varchar`.`value` FROM `customer_address_entity_varchar` WHERE (entity_type_id =2) AND (entity_id IN (45277)) AND (attribute_id IN ('26', '24', '27', '32', '20', '22', '21', '30', '19', '28', '23', '31', '36', '39', '38')) UNION ALL SELECT `customer_address_entity_int`.`entity_id`, `customer_address_entity_int`.`attribute_id`, `customer_address_entity_int`.`value` FROM `customer_address_entity_int` WHERE (entity_type_id =2) AND (entity_id IN (45277)) AND (attribute_id IN ('29', '37', '40')) UNION ALL SELECT `customer_address_entity_text`.`entity_id`, `customer_address_entity_text`.`attribute_id`, `customer_address_entity_text`.`value` FROM `customer_address_entity_text` WHERE (entity_type_id =2) AND (entity_id IN (45277)) AND (attribute_id IN ('25'))                                                                                                                                         |
| 77055 | juwelierwebshop | ...:44704 | juwelierwebshop | Query   |  203 | Opening tables     | SELECT `customer_address_entity_varchar`.`entity_id`, `customer_address_entity_varchar`.`attribute_id`, `customer_address_entity_varchar`.`value` FROM `customer_address_entity_varchar` WHERE (entity_type_id =2) AND (entity_id IN (45277)) AND (attribute_id IN ('26', '24', '27', '32', '20', '22', '21', '30', '19', '28', '23', '31', '36', '39', '38')) UNION ALL SELECT `customer_address_entity_int`.`entity_id`, `customer_address_entity_int`.`attribute_id`, `customer_address_entity_int`.`value` FROM `customer_address_entity_int` WHERE (entity_type_id =2) AND (entity_id IN (45277)) AND (attribute_id IN ('29', '37', '40')) UNION ALL SELECT `customer_address_entity_text`.`entity_id`, `customer_address_entity_text`.`attribute_id`, `customer_address_entity_text`.`value` FROM `customer_address_entity_text` WHERE (entity_type_id =2) AND (entity_id IN (45277)) AND (attribute_id IN ('25'))                                                                                                                                         |
| 77056 | juwelierwebshop | ...:44950 | juwelierwebshop | Query   |  199 | Opening tables     | SELECT `customer_address_entity_varchar`.`entity_id`, `customer_address_entity_varchar`.`attribute_id`, `customer_address_entity_varchar`.`value` FROM `customer_address_entity_varchar` WHERE (entity_type_id =2) AND (entity_id IN (45277)) AND (attribute_id IN ('26', '24', '27', '32', '20', '22', '21', '30', '19', '28', '23', '31', '36', '39', '38')) UNION ALL SELECT `customer_address_entity_int`.`entity_id`, `customer_address_entity_int`.`attribute_id`, `customer_address_entity_int`.`value` FROM `customer_address_entity_int` WHERE (entity_type_id =2) AND (entity_id IN (45277)) AND (attribute_id IN ('29', '37', '40')) UNION ALL SELECT `customer_address_entity_text`.`entity_id`, `customer_address_entity_text`.`attribute_id`, `customer_address_entity_text`.`value` FROM `customer_address_entity_text` WHERE (entity_type_id =2) AND (entity_id IN (45277)) AND (attribute_id IN ('25'))                                                                                                                                         |
| 77058 | juwelierwebshop | ...:45508 | juwelierwebshop | Query   |   54 | Sending data       | SELECT `catalog_product_website`.`website_id` FROM `catalog_product_website` WHERE (product_id = 16722)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| 77063 | juwelierwebshop | ...:45836 | juwelierwebshop | Query   |   54 | update             | INSERT INTO `sales_flat_quote_address` (`quote_id`, `created_at`, `updated_at`, `customer_id`, `address_type`, `city`, `region`, `region_id`, `postcode`, `country_id`, `same_as_billing`, `collect_shipping_rates`, `shipping_method`, `shipping_description`, `shipping_amount`, `base_shipping_amount`) VALUES ('65679', '2018-09-07 12:10:10', '2018-09-07 12:10:10', NULL, 'shipping', NULL, NULL, '0', NULL, 'NL', '1', '1', 'flatrate_flatrate', NULL, '0', '0')                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| 77067 | juwelierwebshop | ...:46232 | juwelierwebshop | Query   |  229 | update             | INSERT INTO `sales_flat_quote` (`store_id`, `created_at`, `updated_at`, `store_to_base_rate`, `store_to_quote_rate`, `base_currency_code`, `store_currency_code`, `quote_currency_code`, `remote_ip`, `global_currency_code`, `base_to_global_rate`, `base_to_quote_rate`, `is_changed`, `allow_alerts`) VALUES ('2', '2018-09-07 12:07:15', '2018-09-07 12:07:15', '1', '1', 'EUR', 'EUR', 'EUR', '81.169.242.132', 'EUR', '1', '1', '1', '1')                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| 77069 | juwelierwebshop | ...:46678 | juwelierwebshop | Query   |  222 | query end          | SELECT `t_d`.`entity_id`, `t_d`.`attribute_id`, `t_d`.`value` AS `default_value`, `t_s`.`value` AS `store_value`, IF(t_s.value_id IS NULL, t_d.value, t_s.value) AS `value` FROM `catalog_category_entity_varchar` AS `t_d`
 LEFT JOIN `catalog_category_entity_varchar` AS `t_s` ON t_s.attribute_id = t_d.attribute_id AND t_s.entity_id = t_d.entity_id AND t_s.store_id = 2 WHERE (t_d.entity_type_id = 3) AND (t_d.entity_id IN (260)) AND (t_d.attribute_id IN ('41')) AND (t_d.store_id = 0)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| 77074 | juwelierwebshop | ...:46984 | juwelierwebshop | Query   |  216 | query end          | SELECT `e`.*, IF(at_is_active.value_id > 0, at_is_active.value, at_is_active_default.value) AS `is_active` FROM `catalog_category_entity` AS `e`
 INNER JOIN `catalog_category_entity_int` AS `at_is_active_default` ON (`at_is_active_default`.`entity_id` = `e`.`entity_id`) AND (`at_is_active_default`.`attribute_id` = '42') AND `at_is_active_default`.`store_id` = 0
 LEFT JOIN `catalog_category_entity_int` AS `at_is_active` ON (`at_is_active`.`entity_id` = `e`.`entity_id`) AND (`at_is_active`.`attribute_id` = '42') AND (`at_is_active`.`store_id` = 2) WHERE (`e`.`entity_type_id` = '3') AND (`e`.`entity_id` IN('365')) AND (IF(at_is_active.value_id > 0, at_is_active.value, at_is_active_default.value) = '1')                                                                                                                                                                                                                                                                                                                             |
| 77076 | juwelierwebshop | ...:47082 | juwelierwebshop | Query   |  214 | query end          | SELECT `t_d`.`entity_id`, `t_d`.`attribute_id`, `t_d`.`value` AS `default_value`, `t_s`.`value` AS `store_value`, IF(t_s.value_id IS NULL, t_d.value, t_s.value) AS `value` FROM `catalog_category_entity_varchar` AS `t_d`
 LEFT JOIN `catalog_category_entity_varchar` AS `t_s` ON t_s.attribute_id = t_d.attribute_id AND t_s.entity_id = t_d.entity_id AND t_s.store_id = 2 WHERE (t_d.entity_type_id = 3) AND (t_d.entity_id IN (187)) AND (t_d.attribute_id IN ('41')) AND (t_d.store_id = 0) 

..等等

输出 ulimit -a:

core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 1030957
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) 1030957
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

最佳答案

每秒速率=RPS my.cnf [mysqld] 部分要考虑的建议

thread_cache_size=100  # from 512 see refman 5.7 for CAP of 100 suggestions to avoid OOM
innodb_log_buffer_size=512M  # from 2G - BUFFER should NOT be > file size
innodb_log_file_size=2G  # from 512M for a reasonable relationship to BUFFER

以下 4 个是每个 CONNECTION 值,您已经超过了 TOP

sort_buffer_size=4M  # from 24M  default is 2M
read_buffer_size=256K  # from 8M  default is 128K to reduce handler_read_next RPS
read_rnd_buffer_size=512K  # from 24M  default is 256K to reduce handler_read_rnd_next RPS
join_buffer_size=256K  # from 128M default is 128K  for row pointers

请查看我的个人资料、网络个人资料以获取包括我的 Skype ID 在内的联系信息并取得联系。

关于mysql - Magento MySQL挂了,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52362712/

相关文章:

mysql - 获取每组分组 SQL 结果中最大值的记录

Magento 购物车价格规则适用于毛价而不是净价

Magento - 无法在产品管理中删除多个选择值

javascript - 如何应用自定义 CSS 和 Javascript 特定的 CMS 页面 Magento

magento-1.9 - 1.9.0 中的 magento 客户组目录规则错误

magento - 如何在 Magento 中调整类别图像的大小?

PHP Mysql - 创建自己的银行系统

php - 我认为 MySqli select 不起作用?

backup - Magento 的简单自动备份解决方案?

mysql - 使用哪种数据类型来存储分数?