参考贺老师书里的内容加上自己的注释
# MySQL configuration for 72G memory [client] port = 3306 socket = /tmp/mysql.sock #The MySQL server #########Basic########### [mysqld] server-id = 22 port = 3306 user = mysql basedir = /usr/local/mysql datadir = /mysqlData/data tmpdir = /mysqlData/tmp socket = /tmp/mysql.sock skip-external-locking --(This is OFF if mysqld uses external locking (system locking) External locking affects only MyISAM table access) skip-name-resolve --(Do not resolve host names when checking client connections. Use only IP addresses. If you use this option, all Host column values in the grant tables must be IP addresses or localhost) default-storage-engine = INNODB character-set-server = utf8 wait_timeout = 100 --(The number of seconds the server waits for activity on a noninteractive connection before closing it) connect_timeout = 20 --(The number of seconds that the mysqld server waits for a connect packet before responding with Bad handshake. The default value is 10 seconds) interactive_timeout = 100 --(The number of seconds the server waits for activity on an interactive connection before closing it.) back_log = 500 --( The number of outstanding connection requests MySQL can have 指定MySQL可能的连接数量。当MySQL主线程在很短的时间内得到非常多的连接请求,该参数就起作用,之后主线程花些时间(尽管很短)检查连接并且启动一个新线程 ) myisam_recover --(Set the MyISAM storage engine recovery mode) event_scheduler = ON --(This variable indicates the status of the Event Scheduler) ########binlog############ log-bin = /mysqlLog/logs/mysql-bin binlog_format = row max_binlog_size = 128M binlog_cache_size = 2M expire-logs-days = 5 ########replication########## slave-net-timeout = 10 --(The number of seconds to wait for more data from the master before the slave considers the connection broken, aborts the read, and tries to reconnect) rpl_semi_sync_master_enabled = 1 --(Controls whether semisynchronous replication is enabled on the master.) rpl_semi_sync_master_wait_no_slave = 1 --(With semisynchronous replication, for each transaction, the master waits until timeout for acknowledgment of receipt from some semisynchronous slave 默认打开,表示当备库起来后,并跟上主库时,自动切换到同步模式,如果关闭,即使备库起来并跟上了,也不会启用半同步) rpl_semi_sync_master_timeout = 1000 --(A value in milliseconds that controls how long the master waits on a commit for acknowledgment from a slave before timing out and reverting to asynchronous replication) rpl_semi_sync_slave_enabled = 1 --(Controls whether semisynchronous replication is enabled on the slave) skip-slave-start --(Tells the slave server not to start the slave threads when the server starts) log_slave_updates = 1 --(Whether updates received by a slave server from a master server should be logged to the slave's own binary log. Binary logging must be enabled on the slave for this variable to have any effect.) relay_log_recovery = 1 --(Enables automatic relay log recovery immediately following server startup) ########slow log############ slow_query_log = 1 slow_query_log_file = /mysqlLog/logs/mysql.slow long_query_time = 2 --(If a query takes longer than this many seconds, the server increments the Slow_queries status variable) ########error log############ log-error = /mysqlLog/logs/error.log ########per_thread_buffers###### max_connections = 1024 --(The maximum permitted number of simultaneous client connections 是指整个mysql服务器的最大连接数) max_user_connections = 1000 --(The maximum number of simultaneous connections permitted to any given MySQL user account. A value of 0 (the default) means “no limit.” 是指每个数据库用户的最大连接数) max_connect_errors = 10000 --(If more than this many successive connection requests from a host are interrupted without a successful connection, the server blocks that host from further connections.是一个MySQL中与安全有关的计数器值,它负责阻止过多尝试失败的客户端以防止暴力破解密码的情况) key_buffer_size = 64M --(Index blocks for MyISAM tables are buffered and are shared by all threads. key_buffer_size is the size of the buffer used for index blocks. The key buffer is also known as the key cache.) max_allowed_packet = 128M --(The maximum size of one packet or any generated/intermediate string, or any parameter sent by the mysql_stmt_send_long_data() C API function Server接受的数据包大小,避免大数据写入或者更新失败) table_cache = 3096 --(5.1.13之前的版本) table_open_cache = 6144 --(The number of open tables for all threads.) table_definition_cache= 4096 --(The number of table definitions (from .frm files) that can be stored in the definition cache) sort_buffer_size = 512K read_buffer_size - 512K read_rnd_buffer_size = 512K --(This variable is used for reads from MyISAM tables, and, for any storage engine, for Multi-Range Read optimization.) join_buffer_size = 512K --(The minimum size of the buffer that is used for plain index scans, range index scans, and joins that do not use indexes and thus perform full table scans) tmp_table_size = 64M --(The maximum size of internal in-memory temporary tables. This variable does not apply to user-created MEMORY tables.) max_heap_table_size = 64M --(This variable sets the maximum size to which user-created MEMORY tables are permitted to grow 它规定了内部内存临时表的最大值,每个线程都要分配。(实际起限制作用的是tmp_table_size和max_heap_table_size的最小值。)如果内存临时表超出了限制,MySQL就会自动地把它转化为基于磁盘的MyISAM表,存储在指定的tmpdir目录下) query_cache_type = 0 --(Set the query cache type. Setting the GLOBAL value sets the type for all clients that connect thereafter.不缓存查询结果) query_cache_size = 0 --(The amount of memory allocated for caching query results) bulk_insert_buffer_size = 32M --(MyISAM uses a special tree-like cache to make bulk inserts faster for INSERT ... SELECT, INSERT ... VALUES (...), (...), ..., and LOAD DATA INFILE when adding data to nonempty tables.) thread_cache_size = 64 --(How many threads the server should cache for reuse.) #thread_concurrency = 32 --(This variable is specific to Solaris 8 and earlier systems, for which mysqld invokes the thr_setconcurrency() function with the variable value, This variable is deprecated as of MySQL 5.6.1 and is removed in MySQL 5.7) thread_stack = 256K (The stack size for each thread.) ########InnoDB############### innodb_data_home_dir = /mysqlData/data innodb_log_group_home_dir = /mysqlLog/logs innodb_data_file_path = ibdata1:2G:autoextend innodb_buffer_pool_size = 50G innodb_buffer_pool_instances = 8 innodb_additional_mem_pool_size = 16M --(The size in bytes of a memory pool InnoDB uses to store data dictionary information and other internal data structures.As of MySQL 5.6.3, innodb_additional_mem_pool_size is deprecated and will be removed in a future MySQL release.) innodb_log_file_size = 1024M innodb_log_buffer_size = 64M innodb_log_files_in_group = 3 innodb_flush_log_at_trx_commit = 2 --(Controls the balance between strict ACID compliance for commit operations, and higher performance that is possible when commit-related I/O operations are rearranged and done in batches.) innodb_lock_wait_timeout = 10 --(The length of time in seconds an InnoDB transaction waits for a row lock before giving up) innodb_sync_spin_loops = 40 --(The number of times a thread waits for an InnoDB mutex to be freed before the thread is suspended.) innodb_max_dirty_pages_pct = 90 --(InnoDB tries to flush data from the buffer pool so that the percentage of dirty pages does not exceed this value.) innodb_support_xa = 1 --(Enables InnoDB support for two-phase commit in XA transactions, causing an extra disk flush for transaction preparation.) innodb_thread_concurrency = 0 --(InnoDB tries to keep the number of operating system threads concurrently inside InnoDB less than or equal to the limit given by this variable (InnoDB uses operating system threads to process user transactions).跟cpu有关) innodb_thread_sleep_delay = 500 --(How long InnoDB threads sleep before joining the InnoDB queue, in microseconds.) innodb_file_io_threads = 4 --(在innodb plugin中,不在使用innodb_file_io_threads参数,而使用innodb_read_io_threads and innodb_write_io_threads 两个值代替) innodb_concurrency_tickets = 1000 --(Determines the number of threads that can enter InnoDB concurrently) c = 1 --(跟创建函数相关的操作) innodb_flush_method = O_DIRECT --(Defines the method used to flush data to the InnoDB data files and log files, which can affect I/O throughput,O_DIRECT: InnoDB uses O_DIRECT (or directio() on Solaris) to open the data files, and uses fsync() to flush both the data and log files. This option is available on some GNU/Linux versions, FreeBSD, and Solaris.) innodb_file_per_table innodb_read_io_threads = 16 --(The number of I/O threads for read operations in InnoDB.) innodb_write_io_threads = 16 --(The number of I/O threads for write operations in InnoDB.) innodb_io_capacity = 2000 --(The innodb_io_capacity parameter sets an upper limit on the I/O activity performed by the InnoDB background tasks, such as flushing pages from the buffer pool and merging data from the change buffer.在MySQL中一次刷新的脏页的数量有一个 innodb_io_capacity的参数进行控制, innodb_io_capacity越大,一次刷新的脏页的数量也就越大) innodb_file_format = Barracuda --(The file format to use for new InnoDB tables. Currently, Antelope and Barracuda are supported.) innodb_purge_threads = 1 --(The number of background threads devoted to the InnoDB purge operation) innodb_purge_batch_size = 32 --(The granularity of changes, expressed in units of redo log records, that trigger a purge operation, flushing the changed buffer pool blocks to disk. 表示一次完成多少个undolog page 但这个值有一个有趣的副作用是会影响到undolog的释放,因为总是在128轮purge后释放undolog page,在5.5及之后版本,开始支持128个回滚段) innodb_old_blocks_pct = 75 --(Specifies the approximate percentage of the InnoDB buffer pool used for the old block sublist.) innodb_change_buffering = all --(Whether InnoDB performs change buffering, an optimization that delays write operations to secondary indexes so that the I/O operations can be performed sequentially. 当更新/插入的非聚集索引的数据所对应的页不在内存中时(对非聚集索引的更新操作通常会带来随机IO),会将其放到一个insert buffer中,当随后页面被读到内存中时,会将这些变化的记录merge到页中。当服务器比较空闲时,后台线程也会做merge操作) transaction_isolation = READ-COMMITTED [mysqldump] quick max_allowed_packet = 128M myisam_max_sort_file_size = 10G [mysql] no-auto-rehash [myisamchk] key_buffer_size = 64M sort_buffer_size = 256K read_buffer = 2M write_buffer = 2M [mysqlhotcopy] interactive-timeout [mysqld_safe] open-files-limit = 28192