#BEGIN CONFIG INFO #DESCR: 4GB RAM, InnoDB only, ACID, fewconnections, heavy queries #TYPE: SYSTEM #END CONFIG INFO
开始配置信息
描述:4GB 内存、只有 InnoDB、ACID、几个连接数、繁重的查询
类型:系统
结束配置信息
# This is a MySQL example config filefor systems with 4GB of memory # running mostly MySQL using InnoDB onlytables and performing complex # queries with few connections.
这是一个针对 4G 内存系统(主要运行只有 InnoDB 表的 MySQL 并使用几个连接数执行复杂的查询)的 MySQL 配置文件例子。
# MySQL programs look for option filesin a set of # locations which depend on thedeployment platform. # You can copy this option file to oneof those # locations. For information about theselocations, see: #http://dev.mysql.com/doc/mysql/en/option-files.html
你可以复制该文件到 /etc/my.cnf 以设置全局的选项,复制到 mysql-data-dir/my.cnf 以设置服务器特有的选项(在本安装中该目录是 C:mysqldata ),复制到 ~/.my.cnf 以设置用户特有的选项。
# In this file, you can use all longoptions that a program supports. # If you want to know which options aprogram supports, run the program # with the "--help" option.
在该文件中,你可以使用一个程序所支持的全部永久选项。
如果你想了解哪些选项是程序支持的,在运行程序时使用“--help”选项。
# More detailed information about theindividual options can also be # found in the manual.
更多有关个别选项的详细信息也可以在手册中找到。
# The following options will be read byMySQL client applications. # Note that only client applicationsshipped by MySQL are guaranteed # to read this section. If you want yourown MySQL client program to # honor these values, you need tospecify it as an option during the # MySQL client library initialization.
下面的选项将被 MySQL 客户端应用程序所读取。
注意,只有 MySQL 标准的客户端应用程序是被保证能读取到该章节的。如果你希望你自己的 MySQL 客户端程序能够承兑这些值,你需要在 MySQL 客户端库初始化中作为一个选项来指定它。
[client] #password = [your_password] port = 3306 socket = /application/mysql-5.5.32/tmp/mysql.sock
# *** Application-specific optionsfollow here ***
*** 应用程序特定的选项在下面 ***
# The MySQL server
MySQL 服务器。
[mysqld]
# generic configuration options port = 3306 socket =/application/mysql-5.5.32/tmp/mysql.sock
通用配置选项
# back_log is the number of connectionsthe operating system can keep in # the listen queue, before the MySQLconnection manager thread has # processed them. If you have a veryhigh connection rate and experience # "connection refused" errors,you might need to increase this value. # Check your OS documentation for themaximum value of this parameter. # Attempting to set back_log higher thanyour operating system limit # will have no effect. back_log = 50
back_log 是指保持在操作系统监听队列中的连接数量,即在 MySQL 连接管理器线程处理它们之前的连接数量。如果你有一个非常高的连接率并见到过“拒绝连接”的错误,你可能需要提高该值。在你的系统文档中检查该参数的最大值。试图将 back_log 设置得高于你操作系统的限制将不会起到任何作用。
# Don't listen on a TCP/IP port at all.This can be a security # enhancement, if all processes thatneed to connect to mysqld run # on the same host. All interaction with mysqld must be made viaUnix # sockets or named pipes. # Note that using this option withoutenabling named pipes on Windows # (via the "enable-named-pipe"option) will render mysqld useless! #skip-networking
根本不用监听一个 TCP/IP 端口。如果运行在相同主机上的所有进程都需要连接到 mysqld,这可能是一个安全增强。所有与 mysqld 的互动都必须通过 Unix sockets(套接字)或命名管道进行。注意,在 Windows 上使用该选项但却不启用命名管道(通过“enable-named-pipe”选项)将使得 mysqld 变得无用。
# The maximum amount of concurrentsessions the MySQL server will # allow. One of these connections willbe reserved for a user with # SUPER privileges to allow theadministrator to login even if the # connection limit has been reached. max_connections = 100
MySQL 允许的并发会话的最大数量。
其中的一个连接将被保留给拥有 SUPER 特权的用户,即使已经到达了连接限制,仍可以允许管理者登录。
# Maximum amount of errors allowed perhost. If this limit is reached, # the host will be blocked fromconnecting to the MySQL server until # "FLUSH HOSTS" has been runor the server was restarted. Invalid # passwords and other errors during theconnect phase result in # increasing this value. See the"Aborted_connects" status variable for # global counter. max_connect_errors = 10
每个主机允许的最大错误数量。
如果已到达该限制,主机将阻止对 MySQL 服务器的连接,直到运行“FLUSH HOSTS”或者服务器被重启。
在连接阶段的无效密码和其它错误将导致该值被提高。
请看全局计数器的“Aborted_connects”状态变量。
# The number of open tables for allthreads. Increasing this value # increases the number of filedescriptors that mysqld requires. # Therefore you have to make sure to setthe amount of open files # allowed to at least 4096 in thevariable "open-files-limit" in # section [mysqld_safe] table_open_cache = 2048
所有线程打开表的数量。
提高该值将提高 mysqld 需要的文件描述符的数量。
因此,你必须确定要设置的打开文件数量,在“mysqld 安全”章节的“open-file-limit”变量中,允许到至少为 4096。
# Enable external file level locking.Enabled file locking will have a # negative impact on performance, soonly use it in case you have # multiple database instances running onthe same files (note some # restrictions still apply!) or if youuse other software relying on # locking MyISAM tables on file level. #external-locking
启用外部文件级锁定。
启用文件锁定将有一个性能上的负面影响,因此,只有在如果你有多个数据库实例运行在相同的文件上(注意,有些限制仍旧被应用)或者如果你使用其它软件依靠在文件级上锁定 MyISAM 表时,才使用
# The maximum size of a query packet theserver can handle as well as # maximum query size server can process(Important when working with # large BLOBs). enlarged dynamically, for each connection. max_allowed_packet = 16M
服务器可以处理的一个查询包的最大容量,以及服务器可以处理的最大查询大小(当工作在大型 BLOB 字段时很重要)。
#动态扩大,对于每一个连接
The size of the cache to hold the SQLstatements for the binary log # during a transaction. If you often usebig, multi-statement # transactions you can increase thisvalue to get more performance. All # statements from transactions arebuffered in the binary log cache and # are being written to the binary log atonce after the COMMIT. If the # transaction is larger than this value,temporary file on disk is used # instead. This buffer is allocated per connection onfirst update # statement in transaction binlog_cache_size = 1M
在一个事务中能够为二进制日志 SQL 语句保持的缓存大小。
如果你经常使用大的、多语句的事务,你可以提高该值以获得更好的性能。
# 来自事务的所有语句被缓冲到二进制日志缓存,并在 COMMIT 之后立即被写入到二进制日志中。
如果事务大于该值,磁盘上的临时文件将被替代使用。
该缓冲在事务中第一个更新语句时分配给每个连接。
# Maximum allowed size for a single HEAP(in memory) table. This option # is a protection against theaccidential creation of a very large HEAP # table which could otherwise use up allmemory resources. max_heap_table_size = 64M
一个单一的 HEAP(在内存中)表的最大允许大小。该选项对偶然创建的一个非常大的 HEAP 表起保护作用,否则它将会使用完所有的内存资源。
# Size of the buffer used for doing fulltable scans. # Allocated per thread, if a full scanis needed. read_buffer_size = 2M
用于进行 MyISAM 表全表扫描的缓冲区大小。
如果全表扫描是需要的,将分配给每个线程。
# When reading rows in sorted orderafter a sort, the rows are read # through this buffer to avoid diskseeks. You can improve ORDER BY # performance a lot, if set this to ahigh value. # Allocated per thread, when needed. read_rnd_buffer_size = 16M
当在一个有序的排序中读取行时,可以通过该缓冲区来读取行,以避免对磁盘的查找。如果将该值设置为一个很高的值,你可以大幅度提高 ORDER BY 的性能。当需要时,分配给每个线程。
# Sort buffer is used to perform sortsfor some ORDER BY and GROUP BY # queries. If sorted data does not fitinto the sort buffer, a disk # based merge sort is used instead - Seethe "Sort_merge_passes" # status variable. Allocated per threadif sort is needed. sort_buffer_size = 8M
排序缓冲被用来执行一些 ORDER BY 和 GROUP BY 查询的排序。
如果已排序的数据没有进入到排序缓冲,一个基于磁盘的合并排序将被替代使用 - 请看“Sort_merge_passes”状态变量。
如果排序是需要的,将分配给每个线程。
# This buffer is used for theoptimization of full JOINs (JOINs without # indexes). Such JOINs are very bad forperformance in most cases # anyway, but setting this variable to alarge value reduces the # performance impact. See the"Select_full_join" status variable for a # count of full JOINs. Allocated perthread if full join is found join_buffer_size = 8M
该缓冲被用来优化 FULL JOIN(没有索引的 JOIN)。
无论如何,该 JOIN 在大多数情况下对性能是非常坏的,但是设置该变量为一个大值将减少对性能的影响。
请看针对一定数量的 FULL JOIN 的“Select_full_join”状态变量。
如果 FULL JOIN 被发现,将分配给每个线程。
# How many threads we should keep in acache for reuse. When a client # disconnects, the client's threads areput in the cache if there aren't # more than thread_cache_size threadsfrom before. This greatly reduces # the amount of thread creations neededif you have a lot of new # connections. (Normally this doesn'tgive a notable performance # improvement if you have a good threadimplementation.) thread_cache_size = 8
我们保持在一个缓存中的可重用的线程有好多。
当一个客户端断开连接时,如果在这之前的线程没有超过 thread_cache_size,客户端的线程将放在缓存中。
如果你有很多新的连接,这将大幅减少创建所需线程的数量。
(如果你有一个很好的线程实现,这通常不会给出一个显著的性能改善。
# This permits the application to givethe threads system a hint for the # desired number of threads that shouldbe run at the same time. This # value only makes sense on systems thatsupport the thread_concurrency() # function call (Sun Solaris, forexample). # You should try [number of CPUs]*(2..4)for thread_concurrency thread_concurrency = 8
这允许应用程序给予线程系统一个针对运行在相同时间的线程所需数量的提示,该值只在支持 thread_concurrency() 函数调用的系统上有意义(例如 Sun Solaris)。你应该对 thread_concurrency 尝试 CPU 数量的 2/4/6/... 倍。
# Query cache is used to cache SELECTresults and later return them # without actual executing the samequery once again. Having the query # cache enabled may result insignificant speed improvements, if your # have a lot of identical queries andrarely changing tables. See the # "Qcache_lowmem_prunes"status variable to check if the current value # is high enough for your load. # Note: In case your tables change veryoften or if your queries are # textually different every time, thequery cache may result in a # slowdown instead of a performanceimprovement. query_cache_size = 64M
# Only cache result sets that aresmaller than this limit. This is to # protect the query cache of a verylarge result set overwriting all # other query results. query_cache_limit = 2M
只有缓存结果集是小于该限制的。
这可以保护一个非常大结果集的查询缓存覆盖所有其它查询结果。
# Minimum word length to be indexed bythe full text search index. # You might wish to decrease it if youneed to search for shorter words. # Note that you need to rebuild yourFULLTEXT index, after you have # modified this value. ft_min_word_len = 4
编制到全文检索索引的最小单词长度。
如果你需要检索更短的单词,你可能希望减小它。
注意,在你修改了该值以后,你需要重建你的 FULLINDEX 索引
# If your system supports the memlock()function call, you might want to # enable this option while running MySQLto keep it locked in memory and # to avoid potential swapping out incase of high memory pressure. Good # for performance. #memlock
如果你的系统支持 memlock() 函数调用,你可能想要启用该选项(运行 MySQL 以保持它锁定到内存,并在出现高内存压力时避免潜在的交换输出)。
这对性能是很有益的。
# Table type which is used by defaultwhen creating new tables, if not # specified differently during theCREATE TABLE statement. default-storage-engine = MYISAM
如果在 CREATE TABLE 语句期间没有指定不同的,当创建一个新表时所使用的默认表类型
# Thread stack size to use. This amountof memory is always reserved at # connection time. MySQL itself usuallyneeds no more than 64K of # memory, while if you use your ownstack hungry UDF functions or your # OS requires more stack for someoperations, you might need to set this # to a higher value. thread_stack = 192K
使用的线程堆栈大小。
该内存量总是在连接时间被保留的。
MySQL 自己通常需要不超过 64K 的内存,然而如果你使用的是你自己的堆栈 UDF 函数或者你的系统针对某些操作需要更多堆栈,你可能需要设置该值为一个更高的值
# Set the default transaction isolationlevel. Levels available are: # READ-UNCOMMITTED, READ-COMMITTED,REPEATABLE-READ, SERIALIZABLE transaction_isolation = REPEATABLE-READ
设置默认的事物级别,可用的级别是
# Maximum size for internal (in-memory)temporary tables. If a table # grows larger than this value, it isautomatically converted to disk # based table This limitation is for asingle table. There can be many # of them. tmp_table_size = 64M
内部临时表最大的容量,如果临时表的容量大于这个设定值时会被自动写入到磁盘基本表中,只限定单表,
# Enable binary logging. This isrequired for acting as a MASTER in a # replication configuration. You alsoneed the binary log if you need # the ability to do point in timerecovery from your latest backup. log-bin=mysql-bin
# binary logging format - mixedrecommended binlog_format=mixed
二进制日志格式,推荐值:mixed
# If you're using replication withchained slaves (A->B->C), you need to # enable this option on server B. Itenables logging of updates done by # the slave thread into the slave'sbinary log. #log_slave_updates
如果是多级备份A--> B --> C进行复制的,那么需要在服务B上启动此项它允许通过服务器线程将日志记录从服务器的二进制日志中来实现日志的更新
# Enable the full query log. Every query(even ones with incorrect # syntax) that the server receives willbe logged. This is useful for # debugging, it is usually disabled inproduction use. #log
# Print warnings to the error logfile. If you have any problem with # MySQL you should enable logging ofwarnings and examine the error log # for possible explanations. #log_warnings
打印警告到错误日志文件。
如果你有任何 MySQL 的问题,你应该启用警告日志并检查错误日志中可能的解释。
# Log slow queries. Slow queries arequeries which take more than the # amount of time defined in"long_query_time" or which do not use # indexes well, if log_short_format isnot enabled. It is normally good idea # to have this turned on if youfrequently add new queries to the # system. slow_query_log
记录慢查询。
慢查询是指消耗时间超过“long_query_time”中定义的总时间的查询,或者如果 log_short_format 没有启用,不使用索引的查询。
如果你频繁地添加新查询到系统中,打开这个通常是一个比较好的主意。
# All queries taking more than thisamount of time (in seconds) will be # trated as slow. Do not use"1" as a value here, as this will result in # even very fast queries being loggedfrom time to time (as MySQL # currently measures time with secondaccuracy only). long_query_time = 2
所有消耗时间超过该总时间的查询都将被视为是缓慢的。不要在这里使用“1”值,因为这会导致甚至非常快的查询都会被不时地被记录(MySQL 当前的度量时间只精确到秒)
# *** Replication related settings
*** 与复制有关的设置
# Unique server identification numberbetween 1 and 2^32-1. This value # is required for both master and slavehosts. It defaults to 1 if # "master-host" is not set,but will MySQL will not function as a master # if it is omitted. server-id = 1
1 到 2^32-1 之间的唯一服务器标识号。
该值对于主服务器和从服务器都是必须的。
如果“master-host”没有设置则默认为 1,但若是忽略,MySQL 将不会作为一个主服务器的功能。
server-id = 1
# Replication Slave (comment out mastersection to use this)
复制从服务器(注释掉主服务器章节以便使用这个)。
# To configure this host as areplication slave, you can choose between # two methods :
要配置该主机为一个复制从服务器,你可以选择以下两种方法:
方法1:
# 1) Use the CHANGE MASTER TO command(fully described in our manual) - # the syntax is:
使用 CHANGE MASTER TO 命令(在我们的手册中有完整的描述) - 其语法是:
# CHANGE MASTER TO MASTER_HOST=<host>, MASTER_PORT=<port>, # MASTER_USER=<user>, MASTER_PASSWORD=<password> ; # # where you replace <host>, <user>, <password> by quotedstrings and # <port> by the master's port number (3306 by default).
使用带引号的字符串替换 〈host〉、〈user〉、〈password〉,并且 〈port〉 是主服务器的端口号(默认为3306)。
例子:
Example: # # CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306, # MASTER_USER='joe', MASTER_PASSWORD='secret'; # # OR
方法2:
# 2) Set the variables below. However,in case you choose this method, then # start replication for the first time (even unsuccessfully, for example # if you mistyped the password in master-password and the slave fails to # connect), the slave will create a master.info file, and any later # changes in this file to the variable values below will be ignored and # overridden by the content of the master.info file, unless you shutdown # the slave server, delete master.info and restart the slaver server. # For that reason, you may want to leave the lines below untouched # (commented) and instead use CHANGE MASTER TO (see above)
2)设置下面的变量。然而,如果你选择了该方法,请在第一时间内启动复制(就算不成功,例如,如果你在 MASTER_PASSWORD 中未键入密码,并且从服务器连接失败),从服务器将创建一个 master.info 文件,稍后在该文件中对下面变量值的任何改变都将被忽略,并被 master.info 文件中的连接所覆盖,除非你关闭从服务器、删除 master.info 并重新启动从服务器。
# 基于这种因素,你可能想要离开下面未接触的行(已注释的)并替代使用 CHANGE MASTER TO(请看上面)
# required unique id between 2 and 2^32- 1 # (and different from the master) # defaults to 2 if master-host is set # but will not function as a slave ifomitted #server-id = 2
需要 2 到 2^32-1 之间的唯一 id(与主服务器不同)。
如果“master-host”已被设置,默认设置为 2。
但若是忽略,将不会作为一个从服务器的功能。
# The replication master for this slave- required #master-host = <hostname>
针对该从服务器的复制主服务器 - 必须的。
# The username the slave will use forauthentication when connecting # to the master - required #master-user = <username>
用户名,当连接到主服务器时,从服务器将用此来进行认证 - 必须的。
# The password the slave willauthenticate with when connecting to # the master - required #master-password = <password>
密码,当连接到主服务器时,从服务器将用此来进行认证 - 必须的。
# The port the master is listening on. # optional - defaults to 3306 #master-port = <port>
端口,主服务器正在监听的。
可选的 - 默认为 3306。
# Make the slave read-only. Only userswith the SUPER privilege and the # replication slave thread will be ableto modify data on it. You can # use this to ensure that noapplications will accidently modify data on # the slave instead of the master #read_only
让从服务器只读。只有拥有 SUPER 特权的用户和复制从服务器线程能够修改它的数据。你可以使用这个来确保不会有应用程序在无意中替代主服务器修改从服务器上的数据。
#*** MyISAM Specific options
*** MyISAM 特有的选项
# Size of the Key Buffer, used to cacheindex blocks for MyISAM tables. # Do not set it larger than 30% of youravailable memory, as some memory # is also required by the OS to cacherows. Even if you're not using # MyISAM tables, you should still set itto 8-64M as it will also be # used for internal temporary disktables. key_buffer_size = 32M
键缓冲区的大小,用来为 MyISAM 表缓存索引块。
不要将它设置为超过你可用内存的 30% 以上,因为操作系统也需要一些内存来缓存行。即使你不使用 MyISAM 表,你仍应该将它设置为 8-64M,因为它也被用于内部的临时磁盘表。
# MyISAM uses special tree-like cache tomake bulk inserts (that is, # INSERT ... SELECT, INSERT ... VALUES(...), (...), ..., and LOAD DATA # INFILE) faster. This variable limitsthe size of the cache tree in # bytes per thread. Setting it to 0 willdisable this optimisation. Do # not set it larger than "key_buffer_size"for optimal performance. # This buffer is allocated when a bulkinsert is detected. bulk_insert_buffer_size = 64M
MyISAM 使用特殊的类似于树的缓存来让大批量插入(亦即 INSERT ... SELECT、INSERT ... VALUES(...) 和 LOAD DATA INFILE)操作变得更快。
该变量限制每个线程的缓存树的字节大小。
将它设置为 0 将禁用该优化。
为了优化性能,不要将它设置得比“key_buffer_size”大。
当检测到大量的插入时,该缓冲区被分配。
# This buffer is allocated when MySQLneeds to rebuild the index in # REPAIR, OPTIMIZE, ALTER tablestatements as well as in LOAD DATA INFILE # into an empty table. It is allocatedper thread so be careful with # large settings. myisam_sort_buffer_size = 128M
当 MySQL 需要通过 REPAIR、OPTIMIZE、ALTER 表语句重建索引,以及 LOAD DATA INFILE 到一个空表时,该缓冲区被分配。它是给每个线程分配的,因此小心比较大的设置。
# The maximum size of the temporary fileMySQL is allowed to use while # recreating the index (during REPAIR,ALTER TABLE or LOAD DATA INFILE. # If the file-size would be bigger thanthis, the index will be created # through the key cache (which isslower). myisam_max_sort_file_size = 10G
当重建索引(在 REPAIR、ALTER TABLE 或 LOAD DATA INFILE 期间)时,MySQL 允许使用的临时文件的最大大小。如果“file-size”比这个值大,索引将通过键缓存(更慢一些)创建。
# If a table has more than one index,MyISAM can use more than one # thread to repair them by sorting inparallel. This makes sense if you # have multiple CPUs and plenty ofmemory. myisam_repair_threads = 1
如果一个表有超过一个的索引,MyISAM 能够在排序时并行地使用超过一个的线程来修复它们。如果你有多个 CPU 和足够的内存,这是很有意义的
# Automatically check and repair notproperly closed MyISAM tables. myisam_recover
自动地检查和修复没有正确关闭的 MyISAM 表。
# *** INNODB Specific options ***
*** INNODB 特定的选项 ***
# Use this option if you have a MySQLserver with InnoDB support enabled # but you do not plan to use it. Thiswill save memory and disk space # and speed up some things. #skip-innodb
如果你有一个支持 InnoDB 启用的 MySQL 服务器,而你却并不计划使用它,请使用该选项。这可以保存一些内存和磁盘空间,并提高速度
# Additional memory pool that is used byInnoDB to store metadata # information. If InnoDB requires more memory for thispurpose it will # start to allocate it from the OS. As this is fast enough on most # recent operating systems, you normallydo not need to change this # value. SHOW INNODB STATUS will displaythe current amount used. innodb_additional_mem_pool_size= 16M
附加的内存池,InnoDB 用来存储元数据信息。
如果 InnoDB 因该目的而需要更多的内存,它将开始从操作系统来分配它。
由于这在大多数最近的操作系统上是足够快的,你通常不需要改变这个值。
SHOW INNODB STATUS 将显示当前使用总量。
# InnoDB, unlike MyISAM, uses a bufferpool to cache both indexes and # row data. The bigger you set this theless disk I/O is needed to # access data in tables. On a dedicateddatabase server you may set this # parameter up to 80% of the machinephysical memory size. Do not set it # too large, though, because competitionof the physical memory may # cause paging in the operatingsystem. Note that on 32bit systems you # might be limited to 2-3.5G of userlevel memory per process, so do not # set it too high. innodb_buffer_pool_size = 2G
#nnoDB,不像 MyISAM,使用一个缓冲池来缓存索引和行数据。你将该值设得越大,在表中访问需要的数据时,磁盘 I/O 就越少。在一个专用的数据库服务器上,你可以设置该参数到机器物理内存大小的 80%。不要把它设置得太大,因为物理内存的竞争可能导致操作系统中的分页。注意,在 32 位的系统上,你可能在每个处理器的用户级内存上被限制在 2-3.5G,因此不要把它设置得太高
# InnoDB stores data in one or more datafiles forming the tablespace. # If you have a single logical drive foryour data, a single # autoextending file would be goodenough. In other cases, a single file # per device is often a good choice. Youcan configure InnoDB to use raw # disk partitions as well - please referto the manual for more info # about this. innodb_data_file_path = ibdata1:10M:autoextend
InnoDB 存储数据到一个或多个数据文件,形成表空间。如果对于你对你的数据有一个单一的物理设备,那么一个单一的自动扩展文件就已经足够了。在其它情况下,每设备一个单一文件是一个非常好的选择。你也可以配置 InnoDB 来使用原始的磁盘分区 - 请参考手册以获取更多有关这个的信息。
Set this option if you would like theInnoDB tablespace files to be # stored in another location. By defaultthis is the MySQL datadir. #innodb_data_home_dir =<directory>
如果你希望 InnoDB 表空间文件存储到其它的地方,设置该选项。默认的是 MySQL 数据目录。
# Number of IO threads to use for asyncIO operations. This value is # hardcoded to 8 on Unix, but on Windowsdisk I/O may benefit from a # larger number. innodb_write_io_threads = 8 innodb_read_io_threads = 8
# If you run into InnoDB tablespacecorruption, setting this to a nonzero # value will likely help you to dumpyour tables. Start from value 1 and # increase it until you're able to dumpthe table successfully. #innodb_force_recovery=1
如果你遇到 InnoDB 表空间腐烂,设置该值为一个非零值,将很容易地帮助你导出你的表。
以值 1 开始并提高它,直到你能够成功地导出表。
# Number of threads allowed inside theInnoDB kernel. The optimal value # depends highly on the application,hardware as well as the OS # scheduler properties. A too high valuemay lead to thread thrashing. innodb_thread_concurrency = 16
InnoDB 内核里面允许的线程数量。
最佳的值高度取决于应用程序、硬件以及操作系统的调度属性。
一个太高的值可能导致线程颠簸
# If set to 1, InnoDB will flush (fsync)the transaction logs to the # disk at each commit, which offers fullACID behavior. If you are # willing to compromise this safety, andyou are running small # transactions, you may set this to 0 or2 to reduce disk I/O to the # logs. Value 0 means that the log isonly written to the log file and # the log file flushed to diskapproximately once per second. Value 2 # means the log is written to the logfile at each commit, but the log # file is only flushed to diskapproximately once per second. innodb_flush_log_at_trx_commit = 1
如果设置为 1,InnoDB 在每次提交(提供完整的 ACID 行为)时刷新事务日志到磁盘。如果你想安全地进行折中,并且你正在运行小事务,你可以为 0 或 2 来减少日志的磁盘 I/O。值 0 表示日志只被写入到日志文件,并且日志文件大约每秒一次刷新到磁盘。值 2 表示日志在每次提交时被写入到日志文件,但是日志文件只是大约每秒一次被刷新到磁盘。
# Speed up InnoDB shutdown. This willdisable InnoDB to do a full purge # and insert buffer merge on shutdown.It may increase shutdown time a # lot, but InnoDB will have to do it onthe next startup instead. #innodb_fast_shutdown
加速 InnoDB 的关闭。
这在关闭时将禁用 InnoDB 做一个完整的清除和插入缓冲合并。
它可能会提高不少关闭的时间,但替代的是 InnoDB 将在下一次启动时来完成它。
# The size of the buffer InnoDB uses forbuffering log data. As soon as # it is full, InnoDB will have to flushit to disk. As it is flushed # once per second anyway, it does notmake sense to have it very large # (even with long transactions). innodb_log_buffer_size = 8M
InnoDB 缓冲日志数据所使用的缓冲区大小。
一旦它满了,InnoDB 将刷新它到磁盘。
因为不管怎么它都是每秒刷新一次,所以没有必要让它变得很大(甚至是很长的事务)。
# Size of each log file in a log group.You should set the combined size # of log files to about 25%-100% of yourbuffer pool size to avoid # unneeded buffer pool flush activity onlog file overwrite. However, # note that a larger logfile size willincrease the time needed for the # recovery process. innodb_log_file_size = 256M
一个日志组中每个日志文件的大小。
你可以设置日志文件的联合大小为你的缓冲池大小的 25%-100%,以避免对日志文件不必要的缓冲池动态刷新重写。
然而,注意,一个更大的日志文件大小将增加恢复处理所需的时间。
# Total number of files in the loggroup. A value of 2-3 is usually good
# enough.
innodb_log_files_in_group = 3
日志组中文件的总数。
通常值为 2-3 就已足够了。
# Location of the InnoDB log files.Default is the MySQL datadir. You # may wish to point it to a dedicatedhard drive or a RAID1 volume for # improved performance #innodb_log_group_home_dir
InnoDB 日志文件的位置。
默认为 MySQL 的数据目录。
你可能希望指定它到一个专用的硬盘或一个 RAID1 卷标来改善性能。
# Maximum allowed percentage of dirtypages in the InnoDB buffer pool. # If it is reached, InnoDB will startflushing them out agressively to # not run out of clean pages at all.This is a soft limit, not # guaranteed to be held. innodb_max_dirty_pages_pct = 90
InnoDB 缓冲池中允许的脏页面的最大百分比。
如果它到达了,InnoDB 将开始积极地清理它们,以避免消耗完所有的干净页面。
这是一个软限制,不保证能够一直保持
# The flush method InnoDB will use forLog. The tablespace always uses # doublewrite flush logic. The defaultvalue is "fdatasync", another # option is "O_DSYNC". #innodb_flush_method=O_DSYNC
InnoDB 对日志使用的刷新方法。
表空间总是使用双写刷新逻辑。
默认值为“fdatasync”,其它选项是“O_DSYNC”。
# How long an InnoDB transaction shouldwait for a lock to be granted # before being rolled back. InnoDBautomatically detects transaction # deadlocks in its own lock table androlls back the transaction. If you # use the LOCK TABLES command, or othertransaction-safe storage engines # than InnoDB in the same transaction,then a deadlock may arise which # InnoDB cannot notice. In cases likethis the timeout is useful to # resolve the situation. innodb_lock_wait_timeout = 120
一个 InnoDB 事务应等待的在回滚之前被授权锁定的时长。
InnoDB 在它自己的锁定表中自动地检测事务死锁,并回滚事务。
如果你在相同的事务中使用 LOCK TABLES 命令,或者其它比 InnoDB 更加事务安全的存储引擎,那么稍后会出现 InnoDB 不能提示的死锁。
如果像这样,超时对于解决问题是很有用的。
[mysqldump] # Do not buffer the whole result set inmemory before writing it to # file. Required for dumping very largetables quick
在写入到文件之前,不要缓冲整个结果集。
导出非常大的表时是必须的。
max_allowed_packet = 16M
[mysql] no-auto-rehash
# Only allow UPDATEs and DELETEs thatuse keys. #safe-updates
只允许 UPDATE 和 DELETE 使用键。
[myisamchk] key_buffer_size = 512M sort_buffer_size = 512M read_buffer = 8M write_buffer = 8M
[mysqlhotcopy] interactive-timeout
[mysqld_safe] # Increase the amount of open filesallowed per process. Warning: Make # sure you have set the global systemlimit high enough! The high value # is required for a large number ofopened tables open-files-limit = 8192
增加每次处理所允许打开的文件数量。
警告:确保你已经设置全局系统限制足够高!
对于一个大数量的打开表,高值是必须的。
参考与my-innodb-heavy-4G.ini 中文版