加入收藏 | 设为首页 | 会员中心 | 我要投稿 宁德站长网 (https://www.0593zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MySql教程 > 正文

企业情况下MySQL5.5调优

发布时间:2022-04-12 13:21:30 所属栏目:MySql教程 来源:互联网
导读:参照 腾讯云 和ucloud my.cnf 以及网上找的资料 整理出来的 my.cnf , 以后修改任何参数都会继续更新 也是在测试阶段 物理机 : ubuntu14.04 配置 8core 32G mysql : 5.5.62 调优配置 [client] port = 3306 socket = /var/run/mysqld/mysqld.sock default-
        
       参照 腾讯云 和ucloud my.cnf 以及网上找的资料
       整理出来的 my.cnf , 以后修改任何参数都会继续更新
      也是在测试阶段
      物理机 : ubuntu14.04 配置 8core 32G
       mysql : 5.5.62
 
调优配置
[client]
port            = 3306
socket          = /var/run/mysqld/mysqld.sock
default-character-set = utf8
[mysqld_safe]
socket          = /var/run/mysqld/mysqld.sock
[mysqld]
user            = mysql
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
port            = 3306
basedir         = /usr
datadir         = /var/lib/mysql
tmpdir          = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
key_buffer             = 256M
max_allowed_packet     = 1073741824
thread_stack           = 512K
thread_cache_size      = 50
max_connections        = 5000
max_connect_errors     = 1000000
table_cache            = 4096
max_heap_table_size    = 128M
open_files_limit       = 102400
back_log               = 2000
thread_concurrency     = 20
sort_buffer_size       = 524288
ft_min_word_len        = 4
query_cache_size       = 0
log_error                          = /var/log/mysql/error.log
log_slow_queries                   = /var/log/mysql/mysql-slow.log
long_query_time                    = 3
server-id                          = 1
log_bin                            = /var/log/mysql/mysql-bin.log
expire_logs_days                   = 2
tmp_table_size                     = 4294967295
#default_table_type                = InnoDB
#loose-skip-bdb
default-storage-engine             =InnoDB
innodb_file_format=barracuda
#ROW_FORMAT=COMPRESSED
innodb_additional_mem_pool_size    = 64M
innodb_buffer_pool_size            = 6G
innodb_data_file_path              = ibdata1:128M:autoextend
innodb_read_io_threads             = 8
innodb_write_io_threads            = 8
innodb_thread_concurrency          = 20
innodb_flush_log_at_trx_commit     = 2
innodb_log_buffer_size             = 8388608
innodb_log_file_size               = 512M
innodb_log_files_in_group          = 3
innodb_max_dirty_pages_pct         = 90
innodb_lock_wait_timeout           = 120
[mysqldump]
quick
quote-names
max_allowed_packet                 = 1073741824
[mysql]
default-character-set              = utf8
[isamchk]
key_buffer                         = 256M
!includedir /etc/mysql/conf.d/
附一些参数的简单解释
 
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
[client]
port        = 3306
socket      = /var/run/mysqld/mysqld.sock
# Here is entries for some specific programs
# The following values assume you have at least 32M ram
# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[mysqld_safe]
socket      = /var/run/mysqld/mysqld.sock
nice        = 0
open-files-limit = 8192   #增加每个进程的可打开文件数量
[mysqld]
#
# * Basic Settings
#
user        = mysql
pid-file    = /var/run/mysqld/mysqld.pid
socket      = /var/run/mysqld/mysqld.sock
port        = 3306
basedir     = /usr
datadir     = /var/lib/mysql
tmpdir      = /tmp          #记录msyql临时文件
#back_log        = 300   
lc-messages-dir = /usr/share/mysql
skip-external-locking    #允许外部文件级别的锁. 打开文件锁会对性能造成负面影响
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#bind-address       = 0.0.0.0   #控制可连接数据库的 客户端
#
# * Fine Tuning
 
# * IMPORTANT: Additional settings that can override those from this file!
#   The files must end with '.cnf', otherwise they'll be ignored.
#
[myisamchk]
key_buffer             = 2048M
sort_buffer_size       = 2048M
read_buffer            = 32M
write_buffer           = 32M
[mysqlhotcopy]
interactive-timeout
!includedir /etc/mysql/conf.d/

(编辑:宁德站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读