A simple solution to the problem of excessive resource occupation by mysql

Source: Internet
Author: User

In linux, it is often the case that VBB is used in a forum system such as slow, mysql is suspended, and there are too many sleep processes. As a result, the system was completed for dozens of users.
In fact, this is the problem of mysql configuration, the default linux, mysql configuration is the my-large.cnf configuration, the configuration is suitable for large servers. High memory, such as 2G, 4G memory, is suitable for use, but generally M memory will not work. It will occupy MB of memory to save the mysql processes of the system. These processes are not released for a long time, resulting in slow system. So, change the configuration to a my-small.cnf, small configuration is enough. Its configuration is as follows:
# Example mysql config file for small systems.
#
# This is for a system with little memory (<= 64 M) where MySQL is only used
# From time to time and its important that the mysqld deamon
# Doesnt use much resources.
#
# You can copy this file
#/Etc/my. cnf to set global options,
# Mysql-data-dir/my. cnf to set server-specific options (in this
# Installation this directory is/var/lib/mysql) or
#~ /. My. cnf to set user-specific options.
#
# One can in this file use all long options that the program supports.
# If you want to know which options a program support, run the program
# With -- help option.
# The following options will be passed to all MySQL clients
[Client]
# Password = your password
Port = 3306
Socket =/tmp/mysql. sock
# Here follows entries for some specific programs
# The MySQL server
[Mysqld]
Port = 3306
Socket =/tmp/mysql. sock
Skip-locking
Set-variable = key_buffer = 16 K
Set-variable = max_allowed_packet = 1 M
Set-variable = thread_stack = 64 K
Set-variable = table_cache = 4
Set-variable = sort_buffer = 64 K
Set-variable = net_buffer_length = 2 K
Server-id = 1
# Uncomment the following if you want to log updates
# Log-bin
# Uncomment the following if you are NOT using BDB tables
# Skip-bdb
# Uncomment the following if you are using InnoDB tables
# Innodb_data_home_dir =/var/lib/mysql/
# Innodb_data_file_path = ibdata1: 10 M: autoextend
# Innodb_log_group_home_dir =/var/lib/mysql/
# Innodb_log_arch_dir =/var/lib/mysql/
# You can set .. _ buffer_pool_size up to 50-80%
# Of RAM but beware of setting memory usage too high
# Set-variable = innodb_buffer_pool_size = 16 M
# Set-variable = innodb_additional_mem_pool_size = 2 M
# Set .. _ log_file_size to 25% of buffer pool size
# Set-variable = innodb_log_file_size = 5 M
# Set-variable = innodb_log_buffer_size = 8 M
# Innodb_flush_log_at_trx_commit = 1
# Set-variable = innodb_lock_wait_timeout = 50
[Mysqldump]
Quick
Set-variable = max_allowed_packet = 16 M
[Mysql]
No-auto-rehash
# Remove the next comment character if you are not familiar with SQL
# Safe-updates
[Isamchk]
Set-variable = key_buffer = 8 M
Set-variable = sort_buffer = 8 M
[Myisamchk]
Set-variable = key_buffer = 8 M
Set-variable = sort_buffer = 8 M
[Mysqlhotcopy]
Interactive-timeout
The above configuration is enough for your system to run mysql at high speed. The sleep process will soon be recycled without occupying resources, which is very suitable for small servers. Generally, personal hosted servers are also suitable.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.