MySQL配置文件参数的一些说明(二)

2014-11-24 17:46:44 · 作者: · 浏览: 4
的执行时长,因此,负载较重的服务器上更容易产生慢查询。其最小值为0,
默认值为10,单位是秒钟。它也支持毫秒级的解析度。作用范围为全局或会话级别,可用于配置文件,属动态变量。
--slow-query-log
#Log slow queries to a table or log file. Defaults logging to a file hostname-slow.log or a table mysql.slow_log if --log-output=TABLE is used. Must be enabled
to activate other slow log options
--slow-query-log-file=name
#Log slow queries to given log file. Defaults logging to hostname-slow.log. Must be enabled to activate other slow log options
--long-query-time=#
#Log all queries that have taken more than long_query_time seconds to execute to file. The argument will be treated as a decimal value with microsecond
precision
innodb_flush_log_at_trx_commit:
0:the log buffer is written out to the log file once per second and the flush to disk operation is performed on the log file, but nothing is done at a
transaction commit;
1:(the default) the log buffer is written out to the log file at each transaction commit and the flush to disk operation is performed on the log file;
2: the log buffer is written out to the file at each commit, but the flush to disk operation is not performed on it.;
For the greatest possible durability and consistency in a replication setup using InnoDB with transactions, use innodb_flush_log_at_trx_commit=1 and
sync_binlog=1 in your master server my.cnf file.
Caution
Many operating systems and some disk hardware fool the flush-to-disk operation. They may tell mysqld that the flush has taken place, even though it has not.
Then the durability of transactions is not guaranteed even with the setting 1, and in the worst case a power outage can even corrupt the InnoDB database. Using a
battery-backed disk cache in the SCSI disk controller or in the disk itself speeds up file flushes, and makes the operation safer. You can also try using the Unix
command hdparm to disable the caching of disk writes in hardware caches, or use some other command specific to the hardware vendor.
innodb_additional_mem_pool_size
The size in bytes of a memory pool InnoDB uses to store data dictionary information and other internal data structures。The more tables you have in your
application, the more memory you need to allocate here. If InnoDB runs out of memory in this pool, it starts to allocate memory from the operating system and writes
warning messages to the MySQL error log. The default value is 8MB.
innodb_buffer_pool_size
The size in bytes of the memory buffer InnoDB uses to cache data and indexes of its tables. mysql5.5上缺省值128M.如果是专用的DB服务器,且以InnoDB引擎为主的场景
,通常可设置物理内存的
50%如果是非专用DB服务器,可以先尝试设置成内存的1/4,如果有问题再调整重要配置参数和变量:
sql_log_bin
在恢复备份的数据(逻辑备份)时,需要关闭二进制日志记录,以免将恢复过程也记录进日志。
innodb_file_per_table = 1
启用InnoDB表每表一文件,默认所有库使用一个表空间,这个在单表备份和恢复中是必须的,而且也便于管理,建议开启


大部分配置文件的参数可在服务器启动时作为选项提供。因此可以使用mysqld --help --verbose查看配置参数的解。并且服务器启动后可以通过该命令输出的末尾查看当前服务器使


用的变量参数值。


关于配置文件中各参数,更全面、详细的请参考http://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html


请将版本号5.5改成你所使用的版本。


推荐阅读: