优化Mysql参数的具体步骤-创新互联
不知道大家之前对类似优化Mysql参数的具体步骤的文章有无了解,今天我在这里给大家再简单的讲讲。感兴趣的话就一起来看看正文部分吧,相信看完优化Mysql参数的具体步骤你一定会有所收获的。
站在用户的角度思考问题,与客户深入沟通,找到高坪网站设计与高坪网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:成都网站设计、做网站、企业官网、英文网站、手机端网站、网站推广、域名与空间、网站空间、企业邮箱。业务覆盖高坪地区。一、优化的配置文件
[client] port=3306 socket=/tmp/mysql.sock [mysqld] # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. innodb_buffer_pool_size = 3G # Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. # log_bin # These are commonly set, remove the # and set as required. user = mysql basedir = /app/mysql datadir = /app/mysql/data port=3307 server-id = 1 socket=/tmp/mysql.sock #允许创建函数 log_bin_trust_function_creators = 1 character-set-server = utf8 #log-error = /var/log/mysql/error.log #pid-file = /var/log/mysql/mysql.pid general_log = 1 skip-name-resolve #skip-networking back_log = 300 max_connections = 1000 max_connect_errors = 6000 open_files_limit = 65535 table_open_cache = 4096 max_allowed_packet = 100M binlog_cache_size = 10M max_heap_table_size = 32M tmp_table_size = 64M read_buffer_size = 8M read_rnd_buffer_size = 8M sort_buffer_size = 8M join_buffer_size = 128M key_buffer_size = 8M thread_cache_size = 64 query_cache_type = 1 query_cache_size = 128M query_cache_limit = 2M ft_min_word_len = 4 log_bin = mysql-bin binlog_format = mixed expire_logs_days = 30 performance_schema = 0 explicit_defaults_for_timestamp lower_case_table_names = 1 myisam_sort_buffer_size = 8M myisam_repair_threads = 1 interactive_timeout = 28800 wait_timeout = 28800 # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size = 128M # sort_buffer_size = 2M # read_rnd_buffer_size = 2M # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 # Recommended in standard MySQL setup sql_mode=NO_ENGINE_SUBSTITUTION,NO_AUTO_CREATE_USER,STRICT_TRANS_TABLES [mysqldump] quick max_allowed_packet = 16M
二、参数解释查看
max_connections = 1000 #客户端连接数 max_connect_errors = 6000 #错误连接数 ----- mysql> show variables like '%conn%'; +-----------------------------------------------+-----------------+ | Variable_name | Value | +-----------------------------------------------+-----------------+ | character_set_connection | utf8 | | collation_connection | utf8_general_ci | | connect_timeout | 10 | | disconnect_on_expired_password | ON | | init_connect | | | max_connect_errors | 6000 | | max_connections | 1000 | | max_user_connections | 0 | | performance_schema_session_connect_attrs_size | 0 | +-----------------------------------------------+-----------------+ 9 rows in set (0.01 sec) ----- 查看系统当前连接数 mysql> show status like 'Threads%'; +-------------------+-------+ | Variable_name | Value | +-------------------+-------+ | Threads_cached | 9 | | Threads_connected | 3 | #连接数 | Threads_created | 12 | | Threads_running | 2 | +-------------------+-------+ 4 rows in set (0.01 sec) ---------------------------------------------------------------------------------------------------- table_open_cache=4096 #通常此值需要大于Opened_tables值 查看当前Opened_tables值 mysql> show status like '%Opened%'; +--------------------------+-------+ | Variable_name | Value | +--------------------------+-------+ | Opened_files | 2979 | | Opened_table_definitions | 1 | | Opened_tables | 1 | #对比 +--------------------------+-------+ 3 rows in set (0.00 sec) ---------------------------------------------------------------------------------------------------- max_heap_table_size = 32M tmp_table_size = 64M #参考文档:https://www.jb51.net/article/85341.htm mysql> show status like '%created_tmp%'; #查看当前情况 +-------------------------+-------+ | Variable_name | Value | +-------------------------+-------+ | Created_tmp_disk_tables | 2921 | | Created_tmp_files | 11 | | Created_tmp_tables | 8476 | +-------------------------+-------+ 3 rows in set (0.00 sec) ---------------------------------------------------------------------------------------------------- read_buffer_size = 8M read_rnd_buffer_size = 8M sort_buffer_size = 8M join_buffer_size = 128M key_buffer_size = 8M 参考文档:https://www.jb51.net/article/84170.htm ---------------------------------------------------------------------------------------------------- innodb_buffer_pool_size = 3G #大建议值为内存的75% --------------------------------------------------------------------------------------------------- thread_cache_size = 64 系统参数: mysql> show global status like 'Threads_%'; +-------------------+-------+ | Variable_name | Value | +-------------------+-------+ | Threads_cached | 9 | #这就是thread_cache_size | Threads_connected | 3 | | Threads_created | 12 | | Threads_running | 2 | +-------------------+-------+ 4 rows in set (0.00 sec) 参考文档:https://www.jianshu.com/p/47adb747652d --------------------------------------------------------------------------------------------------- query_cache_type = 1 query_cache_size = 128M query_cache_limit = 2M mysql> SHOW VARIABLES LIKE 'have_query_cache'; +------------------+-------+ | Variable_name | Value | +------------------+-------+ | have_query_cache | YES | +------------------+-------+ 1 row in set (0.00 sec) mysql> SHOW STATUS LIKE 'Qcache%'; +-------------------------+-----------+ | Variable_name | Value | +-------------------------+-----------+ | Qcache_free_blocks | 1 | | Qcache_free_memory | 134200384 | | Qcache_hits | 0 | | Qcache_inserts | 0 | | Qcache_lowmem_prunes | 0 | | Qcache_not_cached | 6 | | Qcache_queries_in_cache | 0 | | Qcache_total_blocks | 1 | +-------------------------+-----------+ 8 rows in set (0.00 sec)
看完优化Mysql参数的具体步骤这篇文章,大家觉得怎么样?如果想要了解更多相关,可以继续关注我们的行业资讯板块。
另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
分享文章:优化Mysql参数的具体步骤-创新互联
转载源于:http://ybzwz.com/article/dpjcjp.html