moneyslow.com

小内存vps内mysql的优化

linux shell学习

linux shell学习

本文操作的vps是美国的buyvm.net购买的,特点就是不限带宽,不限流量,要干啥你可以猜到,购买链接

只有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

内存优化
Exit mobile version