海阔中文网

57 views
8月 10 2021

小内存vps内mysql的优化

只有1G内存的vps的情况下,还要启动mysql,默认的参数会占用大量的内存,需要优化缩减:

默认情况下的配置:
mysql> show variables like '%performance_schema_max_table_instances%';
+----------------------------------------+-------+
| Variable_name | Value |
+----------------------------------------+-------+
| performance_schema_max_table_instances | -1 |
+----------------------------------------+-------+
1 row in set (0.04 sec)

mysql> show variables like '%table_definition_cache%';
+------------------------+-------+
| Variable_name | Value |
+------------------------+-------+
| table_definition_cache | 1400 |
+------------------------+-------+
1 row in set (0.01 sec)

mysql> show variables like '%table_open_cache%';
+----------------------------+-------+
| Variable_name | Value |
+----------------------------+-------+
| table_open_cache | 2000 |
| table_open_cache_instances | 16 |
+----------------------------+-------+
2 rows in set (0.00 sec)

修改my.cnf参数重的配置:

innodb_buffer_pool_size = 10M
performance_schema_max_table_instances = 200
table_definition_cache = 100
table_open_cache = 100

重启mysql
systemctl restart mysql

小内存vps内mysql的优化
内存优化

Written by 海阔中文网

海阔中文网真棒!


京ICP备11047313号-20