mysql配置文件-my-innodb-heavy-4G.cnf中文註釋

#BEGIN CONFIG INFO
#DESCR: 4GB RAM, InnoDB only, ACID, few connections, heavy queries
#TYPE: SYSTEM
#END CONFIG INFO
#
# This is a MySQL example config file for systems with 4GB of memory
# running mostly MySQL using InnoDB only tables and performing complex
# queries with few connections.
# 
這是一個mysql配置文件的示例:要求系統內存4G,
運行的mysql大多用的是InnoDB數據庫引擎,僅僅少量連接的表和複雜查詢
# MySQL programs look for option files in a set of
# locations which depend on the deployment platform.
# You can copy this option file to one of those
# locations. For information about these locations, see:
# http://dev.mysql.com/doc/mysql/en/option-files.html
#
mysql程序在查詢選項文件,依賴於發佈平臺,選項如--no-defaults,--help這樣
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.
#
在這個文件裏,你可以用所有程序支持的長選項
如果你想知道程序支持哪些選項,運行命令帶--help
# More detailed information about the individual options can also be
# found in the manual.
#
更多關於個別選項的詳細信息也可以在手冊中找到
#
# The following options will be read by MySQL client applications.
# Note that only client applications shipped by MySQL are guaranteed
# to read this section. If you want your own MySQL client program to
# honor these values, you need to specify it as an option during the
# MySQL client library initialization.
#
下面的選項將會被mysql客戶端應用程序讀到
注意:只有被mysql裝載的mysql客戶端程序才能保證堵到這部分內容
如果你想要你自己的mysql客戶端擁有這些值,
你需要在mysql客戶端初始化的時候,把它作爲一個選項指定
[client]
#password    = [your_password]
port        = 3306
socket        = /application/mysql-5.5.57/tmp/mysql.sock
# *** Application-specific options follow here ***
#
# The MySQL server
#
[mysqld]
# generic configuration options
#一般配置
port        = 3306
socket        = /application/mysql-5.5.57/tmp/mysql.sock
# back_log is the number of connections the operating system can keep in
# the listen queue, before the MySQL connection manager thread has
# processed them. If you have a very high connection rate and experience
# "connection refused" errors, you might need to increase this value.
# Check your OS documentation for the maximum value of this parameter.
# Attempting to set back_log higher than your operating system limit
# will have no effect.
back_log 是操作系統在MySQL連接管理器線程處理他們之前,
在監聽隊列裏可以保持的連接數。
如果你有很高的連接率和“連接拒絕”錯誤的體驗,那就需要加大這個值。
查詢你的操作系統文檔,看看這個參數的最大值。
試圖把back_log設置來大於你的操作系統限制是沒有用的。
back_log = 50
# Don't listen on a TCP/IP port at all. This can be a security
# enhancement, if all processes that need to connect to mysqld run
# on the same host.  All interaction with mysqld must be made via Unix
# sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (via the "enable-named-pipe" option) will render mysqld useless!
#skip-networking
不要去監聽一個TCP/IP端口。
如果所有的需要連接到mysqld的進程都跑在相同的主機上,這能夠增加安全。
所有和mysqld的交互,必須經由unix套接字或者命名管道。
注意:在windows上用這個選項,如果沒有可用的命名管道,
(選項enable-named-pipe)將會導致mysqld無效
# The maximum amount of concurrent sessions the MySQL server will
# allow. One of these connections will be reserved for a user with
# SUPER privileges to allow the administrator to login even if the
# connection limit has been reached.
mysql允許的最大併發回話數。他們中的那個有超級權限的用戶連接,
即使已經到了連接限制的時候,也可以被保留來允許管理員登錄。
max_connections = 100
# Maximum amount of errors allowed per host. If this limit is reached,
# the host will be blocked from connecting to the MySQL server until
# "FLUSH HOSTS" has been run or the server was restarted. Invalid
# passwords and other errors during the connect phase result in
# increasing this value. See the "Aborted_connects" status variable for
# global counter.
每個主機被允許的最大錯誤數。如果這個到了這個限制,這個主機連接mysql服務器
將會被阻塞,直到運行了“刷新主機”或者服務器重啓。無效的密碼或者其他錯誤在
連接階段導致這個值的增長。查看“Aborted_connects”狀態可以得到變量全局計數器
max_connect_errors = 10
# The number of open tables for all threads. Increasing this value
# increases the number of file descriptors that mysqld requires.
# Therefore you have to make sure to set the amount of open files
# allowed to at least 4096 in the variable "open-files-limit" in
# section [mysqld_safe]
所有進程打開的表的數量。這個值的增長是mysqld要求的文件描述數量的增長。
因此,你必須確保設置打開文件數,即在【myqld_safe】部分的變量
”open-files-limit“至少要允許4096,
table_open_cache = 2048
# Enable external file level locking. Enabled file locking will have a
# negative impact on performance, so only use it in case you have
# multiple database instances running on the same files (note some
# restrictions still apply!) or if you use other software relying on
# locking MyISAM tables on file level.
啓用外部文件級別鎖定。啓用文件鎖定將對性能產生負面影響,所以你只需要
在同一文件上運行的多個數據庫實例的時候用它。(注意一些限制任然適用)
或者如果你用了其他軟件依賴在文件級別鎖定MyISAM表
#external-locking
# The maximum size of a query packet the server 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
# The size of the cache to hold the SQL statements for the binary log
# during a transaction. If you often use big, multi-statement
# transactions you can increase this value to get more performance. All
# statements from transactions are buffered in the binary log cache and
# are being written to the binary log at once after the COMMIT.  If the
# transaction is larger than this value, temporary file on disk is used
# instead.  This buffer is allocated per connection on first update
# statement in transaction
在事物中二進制日誌的SQL查詢語句的緩存能夠支持的大小。
如果你經常使用大的多實例的查詢事物你可以增加這個值來獲取更好的性能。
所有來自事物的查詢都被緩衝在二進制日誌緩存中,並且是當提交的時候立刻
被寫在二進制日誌中。如果這個事物大於這個值,就使用硬盤的臨時文件。
此緩衝區在第一次更新時分配給每個連接。
binlog_cache_size = 1M
# Maximum allowed size for a single HEAP (in memory) table. This option
# is a protection against the accidential creation of a very large HEAP
# table which could otherwise use up all memory resources.
單堆(內存中)表的最大值。
這個選項是一個意外創建的保護,因爲一個大的單堆表可能會耗盡所有內存資源
max_heap_table_size = 64M
# Size of the buffer used for doing full table scans.
# Allocated per thread, if a full scan is needed.
用於做全表掃描的緩衝區大小。
如果全表掃描需要,爲每一個線程分配。
read_buffer_size = 2M
# When reading rows in sorted order after a sort, the rows are read
# through this buffer to avoid disk seeks. You can improve ORDER BY
# performance a lot, if set this to a high value.
# Allocated per thread, when needed.
排序後,讀取排序中的行,通過緩衝區讀行避免磁盤尋求。
如果把這個值設的比較大,你可以增加“ORDER BY”的性能。
當需要時爲每個線程分配。
read_rnd_buffer_size = 16M
# Sort buffer is used to perform sorts for some ORDER BY and GROUP BY
# queries. If sorted data does not fit into the sort buffer, a disk
# based merge sort is used instead - See the "Sort_merge_passes"
# status variable. Allocated per thread if sort is needed.
排序緩衝用於“ORDER BY and GROUP BY”查詢執行排序。
如果排序的數據沒有納入排序緩衝,磁盤的合併排序將會被用來替代,
看這個狀態變量:"Sort_merge_passes",當需要時爲每個線程分配。
sort_buffer_size = 8M
# This buffer is used for the optimization of full JOINs (JOINs without
# indexes). Such JOINs are very bad for performance in most cases
# anyway, but setting this variable to a large value reduces the
# performance impact. See the "Select_full_join" status variable for a
# count of full JOINs. Allocated per thread if full join is found
這個緩衝是用於連接(無索引的連接)的優化。
在大多數情況下這樣的連接不利於性能,但是把這個值設的很大又會減少
性能影響。請看狀態變量“Select_full_join”,一個全連接的計數。
當全連接的時候爲每個線程分配。
join_buffer_size = 8M
# How many threads we should keep in a cache for reuse. When a client
# disconnects, the client's threads are put in the cache if there aren't
# more than thread_cache_size threads from before.  This greatly reduces
# the amount of thread creations needed if you have a lot of new
# connections. (Normally this doesn't give a notable performance
# improvement if you have a good thread implementation.)
爲了重用,我們應該保存多少個線程。
當一個客戶端斷開鏈接,如果沒有比以前的thread_cache_size線程多,
這個客戶端線程被放到緩存。如果你有許多新的連接,
這大大減少了創建需要的線程數量。這並沒有顯著的表現
如果你有一個好的線程實現,那就改進。
thread_cache_size = 8
# This permits the application to give the threads system a hint for the
# desired number of threads that should be run at the same time.  This
# value only makes sense on systems that support the thread_concurrency()
# function call (Sun Solaris, for example).
# You should try [number of CPUs]*(2..4) for thread_concurrency
這個允許應用程序,爲這個可以在相同時間運行的,想要的線程數,給線程系統一個提示。
這個值僅僅在系統上是有意義的,它提供一個方法叫做thread_concurrency(),(比如工程師)
你可以試試爲thread_concurrency設置【cpu數量】*(2..4)
thread_concurrency = 8
# Query cache is used to cache SELECT results and later return them
# without actual executing the same query once again. Having the query
# cache enabled may result in significant speed improvements, if your
# have a lot of identical queries and rarely 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 very often or if your queries are
# textually different every time, the query cache may result in a
# slowdown instead of a performance improvement.
查詢緩存用於緩存查詢結果,並且隨後返回他們,在沒有再一次真實執行相同的查詢。
如果你有很多相同的查詢並且很少改變表,
有這個緩存查詢,使得許多結果有顯著的速度提升。
狀態變量“Qcache_lowmem_prunes”檢查是否這個當前值足夠高。
注意:萬一你的表經常變,或者如果你的查詢每一次都不同,這個查詢緩存將會導致降速
而不是性能改進。
query_cache_size = 64M
# Only cache result sets that are smaller than this limit. This is to
# protect the query cache of a very large result set overwriting all
# other query results.
只有小於此限制的緩存結果集。
保護一個非常大的結果集覆蓋所有的查詢緩存其他查詢結果。
query_cache_limit = 2M
# Minimum word length to be indexed by the full text search index.
# You might wish to decrease it if you need to search for shorter words.
# Note that you need to rebuild your FULLTEXT index, after you have
# modified this value.
最小單詞長度被全文搜索索引索引。
如果你想要查詢更短的單詞,你可以減小它。
注意,你修改了這個值,你需要重新編譯你的全文搜索索引。
ft_min_word_len = 4
# If your system supports the memlock() function call, you might want to
# enable this option while running MySQL to keep it locked in memory and
# to avoid potential swapping out in case of high memory pressure. Good
# for performance.
#memlock
如果您的系統支持memlock()函數調用,你會想要讓着選項可用,
在運行MySQL時,把它鎖在內存中,爲了避免在高內存壓力下進行潛在的交換。
對性能有好處。
# Table type which is used by default when creating new tables, if not
# specified differently during the CREATE TABLE statement.
當創建新表的時候,如果沒有在創建表的時候特別指定,
表類型使用的是默認的。
default-storage-engine = MYISAM
# Thread stack size to use. This amount of memory is always reserved at
# connection time. MySQL itself usually needs no more than 64K of
# memory, while if you use your own stack hungry UDF functions or your
# OS requires more stack for some operations, you might need to set this
# to a higher value.
線程堆棧大小。在連接的時間,這段內存總是被保留的。
mysql自身通常需要不大於64k的內存,當如果你用你自己的堆棧渴望UDF功能,
或者你的系統爲了更多的操作需要更多的堆棧,你就可以把這個值設大一點。
thread_stack = 192K
# Set the default transaction isolation level. 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 is automatically converted to disk
# based table This limitation is for a single table. There can be many
# of them.
臨時表最大內存大小。如果一個表大於這個值了,它會自動轉換爲磁盤
基於表這個限制是針對一個表的。
tmp_table_size = 64M
# Enable binary logging. This is required for acting as a MASTER in a
# replication configuration. You also need the binary log if you need
# the ability to do point in time recovery from your latest backup.
啓用二進制日誌記錄。
在複製配置中這是作爲master需要的。
如果你需要從最新的備份中及時恢復的能力,那麼你需要二進制日誌記錄
log-bin=mysql-bin
# binary logging format - mixed recommended
二進制日誌格式-推薦mixed
binlog_format=mixed
# If you're using replication with chained slaves (A->B->C), you need to
# enable this option on server B. It enables logging of updates done by
# the slave thread into the slave's binary log.
如果你使用的是被鏈接的從複製(A-B-C),你需要在B服務器上啓用這個選項。
它支持通過從從屬線程進入到從屬的二進制日誌中的日誌記錄更新
#log_slave_updates
# Enable the full query log. Every query (even ones with incorrect
# syntax) that the server receives will be logged. This is useful for
# debugging, it is usually disabled in production use.
啓用完整查詢日誌。
服務器接收到的每個查詢(甚至有錯誤語法的)都會被記錄。
這對調試很有用,但是在生產環境中不用。
#log
# Print warnings to the error log file.  If you have any problem with
# MySQL you should enable logging of warnings and examine the error log
# for possible explanations. 
打印警告道錯誤日誌文件中。
如果你對MYSQL有任何問題,你最好啓用警告日誌,並且檢查錯誤日誌可能的解釋
#log_warnings
# Log slow queries. Slow queries are queries which take more than the
# amount of time defined in "long_query_time" or which do not use
# indexes well, if log_short_format is not enabled. It is normally good idea
# to have this turned on if you frequently add new queries to the
# system.
慢查詢。
慢查詢是在log_short_format沒啓用的情況下,查詢那些超過在“long_query_time”中
定義的時間的,或者是沒有很好的用索引的。
slow_query_log
# All queries taking more than this amount 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 logged from time to time (as MySQL
# currently measures time with second accuracy only).
所有查詢的時間超過這個時間(以秒爲單位)就說明是慢的。這裏的值不要用“1”,
因爲這會導致甚至快查詢有時也被記錄到(因爲MYSQL 當前記錄時間是以秒爲精度的)
long_query_time = 2
# ***  Replication related settings 
複製相關的設置
# Unique server identification number between 1 and 2^32-1. This value
# is required for both master and slave hosts. It defaults to 1 if
# "master-host" is not set, but will MySQL will not function as a master
# if it is omitted.
獨一無二的服務器識別數字,1~2^32-1。
在master和slave主機都需要這個值。如果沒有設置“mater-host”它就是默認爲1,
但是如果省略了MySQL將不能作爲一個主。
server-id = 1
# Replication Slave (comment out master section to use this)
複製slave(請註釋掉主部分來使用這個)
#
# To configure this host as a replication slave, you can choose between
# two methods :
爲了配置這個主機爲從庫,你可以選擇這兩個方法:
#
# 1) Use the CHANGE MASTER TO command (fully described in our manual) -
#    the syntax is:
1)使用命令: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 quoted strings and
#    <port> by the master's port number (3306 by default).
這裏你需要用引用字符串來代替 <host>, <user>, <password> ,且<port> 是用master
的端口號(默認3306)
#
#    Example:
#
#    CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,
#    MASTER_USER='joe', MASTER_PASSWORD='secret';
#
# OR
#
# 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)
#
設置下面的變量。可是,萬一你改變方法,就會從第一次開始複製(
甚至不成功,比如你的密碼拼寫錯誤,從庫就會連接失敗)
# 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 if omitted
要求獨一無二的id在2~2^32-1之間(且與master不同)
如果msater-host設置了,這個值默認是2,
但是如果忽略了就沒有salve的功能
#server-id = 2
#
# The replication master for this slave - required
被從庫複製的主庫 必填
#master-host = <hostname>
#
# The username the slave will use for authentication when connecting
# to the master - required
用於身份驗證的連接到msater的從庫的用戶名-必填
#master-user = <username>
#
# The password the slave will authenticate with when connecting to
# the master - required
用於身份驗證的連接到master的從庫的密碼
#master-password = <password>
#
# The port the master is listening on.
# optional - defaults to 3306
master監聽的端口
可選的-默認是3306
#master-port = <port>
# Make the slave read-only. Only users with the SUPER privilege and the
# replication slave thread will be able to modify data on it. You can
# use this to ensure that no applications will accidently modify data on
# the slave instead of the master
使slave 只讀。只有用戶有超級權限並且複製slave進程能夠修改數據。
用這個來確保,在slave上而不是master上,沒有應用將會突然修改數據。
#read_only
#*** MyISAM Specific options
MyISAM引擎詳細選項
# Size of the Key Buffer, used to cache index blocks for MyISAM tables.
# Do not set it larger than 30% of your available memory, as some memory
# is also required by the OS to cache rows. Even if you're not using
# MyISAM tables, you should still set it to 8-64M as it will also be
# used for internal temporary disk tables.
索引緩衝區的大小,用於緩存MyISAM表的索引塊。
不要設置來大於你可用內存的30%,因爲一些內存也被系統用來緩存行。
甚至如果你不用MyISAM引擎表,你也需要設置它爲8-64M,因爲它也將被用於
內部的臨時磁盤表。
key_buffer_size = 32M
# MyISAM uses special tree-like cache to make bulk inserts (that is,
# INSERT ... SELECT, INSERT ... VALUES (...), (...), ..., and LOAD DATA
# INFILE) faster. This variable limits the size of the cache tree in
# bytes per thread. Setting it to 0 will disable this optimisation.  Do
# not set it larger than "key_buffer_size" for optimal performance.
# This buffer is allocated when a bulk insert is detected.
MyISAM引擎用特殊的樹狀緩存來使得批量插入(即:insert...select,
insert ... values(...),(...),..., and load data infile)更快。
這個變量限制了樹狀緩存每個線程字節的大小。將其設置爲0將禁用此優化。
爲了最佳性能不要設置它大於“key_buffer_size”。
當檢測到批量插入時,將分配此緩衝區。
bulk_insert_buffer_size = 64M
# This buffer is allocated when MySQL needs to rebuild the index in
# REPAIR, OPTIMIZE, ALTER table statements as well as in LOAD DATA INFILE
# into an empty table. It is allocated per thread so be careful with
# large settings.
 當MySQL需要重建索引,在修補,優化,更改表狀態的時候,和重載數據文件到空表一樣,
 這個緩衝將會被分配。它爲每個進程分配所以設置成大的值小心。
myisam_sort_buffer_size = 128M
# The maximum size of the temporary file MySQL is allowed to use while
# recreating the index (during REPAIR, ALTER TABLE or LOAD DATA INFILE.
# If the file-size would be bigger than this, the index will be created
# through the key cache (which is slower).
當重新創建索引(即:在修補,優化,更改表狀態的時候)的時候,
MySQL被允許的最大臨時文件大小。
如果“file-size”大於這值,索引將會通過鍵緩存創建(這樣比較慢)
myisam_max_sort_file_size = 10G
# If a table has more than one index, MyISAM can use more than one
# thread to repair them by sorting in parallel. This makes sense if you
# have multiple CPUs and plenty of memory.
如果表有不止一個索引,MyISAM則可以用不止一個進程並行排序來修補他們。
如果你有多CPU何足夠的內存,這很好理解。
myisam_repair_threads = 1
# Automatically check and repair not properly closed MyISAM tables.
自動檢查和修復不適當關閉MyISAM表
myisam_recover
# *** INNODB Specific options ***
INNODB特定選項
# Use this option if you have a MySQL server with InnoDB support enabled
# but you do not plan to use it. This will save memory and disk space
# and speed up some things.
如果你的MySQL服務支持InnoDB但是你又不想用它,就可以用這個選項。
這可以節省內存和磁盤空間並且加快速度
#skip-innodb
# Additional memory pool that is used by InnoDB to store metadata
# information.  If InnoDB requires more memory for this purpose it will
# start to allocate it from the OS.  As this is fast enough on most
# recent operating systems, you normally do not need to change this
# value. SHOW INNODB STATUS will display the current amount used.
InnoDB使用存儲元數據信息的額外內存池。
如果InnoDB需要更多的內存,OS將會分配給它。因爲在大多最近的操作系統中這個足夠快,
你一般不需要改變這值。SHOW INNODB STATUS可以展示目前的用量。
innodb_additional_mem_pool_size = 16M
# InnoDB, unlike MyISAM, uses a buffer pool to cache both indexes and
# row data. The bigger you set this the less disk I/O is needed to
# access data in tables. On a dedicated database server you may set this
# parameter up to 80% of the machine physical memory size. Do not set it
# too large, though, because competition of the physical memory may
# cause paging in the operating system.  Note that on 32bit systems you
# might be limited to 2-3.5G of user level memory per process, so do not
# set it too high.
InnoDB,不像MyISAM,它用緩衝池來緩存索引和行數據。
你把這值設的越大,就更少的用到磁盤I/O訪問數據表。
在專用數據庫服務器上,你可以設置這個參數爲機器物理內存的80%。不要再設大了,
因爲物理內存的競爭將會導致操作系統分頁。
innodb_buffer_pool_size = 2G
# InnoDB stores data in one or more data files forming the tablespace.
# If you have a single logical drive for your data, a single
# autoextending file would be good enough. In other cases, a single file
# per device is often a good choice. You can configure InnoDB to use raw
# disk partitions as well - please refer to the manual for more info
# about this.
InnoDB以表空間的形式在一個或多個數據文件中存儲數據。
如果您的數據有一個單一的邏輯驅動器,一個單一的自擴充文件將會足夠好。
在其他情況下,一個設備一個文件常常是一個好的選擇。
你可以配置InnoDB來使用磁盤分區-可以參照手冊獲取更多的信息
innodb_data_file_path = ibdata1:10M:autoextend
# Set this option if you would like the InnoDB tablespace files to be
# stored in another location. By default this is the MySQL datadir.
這個選項是你可以讓InnoDB表空間文件儲存在其他地址。默認在MYSQL的數據目錄
#innodb_data_home_dir = <directory>
# Number of IO threads to use for async IO operations. This value is
# hardcoded to 8 on Unix, but on Windows disk I/O may benefit from a
# larger number.
異步操作的IO線程數。在Unix系統這個值寫死爲8的,但是windows系統這
個數比較大一點的話磁盤I/O性能會比較好。
innodb_write_io_threads = 8
innodb_read_io_threads = 8
# If you run into InnoDB tablespace corruption, setting this to a nonzero
# value will likely help you to dump your tables. Start from value 1 and
# increase it until you're able to dump the table successfully.
如果您遇到InnoDB表空間損壞,設置這個值爲非0的將會幫你清理表。
值從1開始增長到直到你可以成功的清理表。
#innodb_force_recovery=1
# Number of threads allowed inside the InnoDB kernel. The optimal value
# depends highly on the application, hardware as well as the OS
# scheduler properties. A too high value may lead to thread thrashing.
InnoDB內核允許的線程數。其最優值高度依賴應用程序,硬件和操作系統
。調度程序屬性。太大的值會導致線程超負荷。
innodb_thread_concurrency = 16
# If set to 1, InnoDB will flush (fsync) the transaction logs to the
# disk at each commit, which offers full ACID behavior. If you are
# willing to compromise this safety, and you are running small
# transactions, you may set this to 0 or 2 to reduce disk I/O to the
# logs. Value 0 means that the log is only written to the log file and
# the log file flushed to disk approximately once per second. Value 2
# means the log is written to the log file at each commit, but the log
# file is only flushed to disk approximately once per second.
如果設爲1,每次ACID提交的時候,InnoDB將會同步刷新事物日誌到硬盤。
如果你想妥協這安全,你就跑少一些事物,你可以設這個值爲0或者2來縮小磁盤
I/O寫日誌。
值爲0表示日誌僅僅是寫到日誌文件,並且日誌文件大約每秒刷新一次磁盤。
值爲2表示每次提交都會把日誌寫到日誌文件,並且日誌文件大約每秒刷新一次磁盤。
innodb_flush_log_at_trx_commit = 1
# Speed up InnoDB shutdown. This will disable 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 on the next startup instead.
加快InnoDB關閉。這將禁止InnoDB完全清除並在關機時插入緩衝區合併。
它將花費更多的關閉時間,但是InnoDB將必須在下次開始的時候做這個事情。
#innodb_fast_shutdown
# The size of the buffer InnoDB uses for buffering log data. As soon as
# it is full, InnoDB will have to flush it to disk. As it is flushed
# once per second anyway, it does not make sense to have it very large
# (even with long transactions). 
緩衝區InnoDB用於緩衝日誌數據的大小。
一旦它滿了,InnoDB將會把它刷新到磁盤。以爲它是一秒刷新一次,
所以不要把它設置的很大(即便是在長事物中)
innodb_log_buffer_size = 8M
# Size of each log file in a log group. You should set the combined size
# of log files to about 25%-100% of your buffer pool size to avoid
# unneeded buffer pool flush activity on log file overwrite. However,
# note that a larger logfile size will increase the time needed for the
# recovery process.
日誌組中每個日誌文件的大小。你可以設置合併的日誌文件大小爲你的緩衝池大小的
25%-100%,以避免無用的在日誌文件重寫的時候的緩衝池刷新活動。
但是,注意,一個大的日誌文件將會增加恢復程序需要的時間。
innodb_log_file_size = 256M
# Total number of files in the log group. A value of 2-3 is usually good
# enough.
日誌組裏面的文件總數。2-3就足夠了。
innodb_log_files_in_group = 3
# Location of the InnoDB log files. Default is the MySQL datadir. You
# may wish to point it to a dedicated hard drive or a RAID1 volume for
# improved performance
InnoDB日誌文件的位置。默認是mysql數據目錄。
你可以指定一個專門的硬盤或者RAID1捲來提高性能
#innodb_log_group_home_dir
# Maximum allowed percentage of dirty pages in the InnoDB buffer pool.
# If it is reached, InnoDB will start flushing them out agressively to
# not run out of clean pages at all. This is a soft limit, not
# guaranteed to be held.
InnoDB緩衝池中髒頁面允許的最大百分比。如果它滿了,InnoDB將會把它衝洗出來
而根本不是把它清理乾淨。
這是一個軟限制,不是一定要保留的。
innodb_max_dirty_pages_pct = 90
# The flush method InnoDB will use for Log. The tablespace always uses
# doublewrite flush logic. The default value is "fdatasync", another
# option is "O_DSYNC".
InnoDB刷新日誌的方法。表空間常常用的是雙寫刷新邏輯。
默認是“fdatasync”,其他選項是“O_DSYNC”。
#innodb_flush_method=O_DSYNC
# How long an InnoDB transaction should wait for a lock to be granted
# before being rolled back. InnoDB automatically detects transaction
# deadlocks in its own lock table and rolls back the transaction. If you
# use the LOCK TABLES command, or other transaction-safe storage engines
# than InnoDB in the same transaction, then a deadlock may arise which
# InnoDB cannot notice. In cases like this the timeout is useful to
# resolve the situation.
InnoDB事物在回滾之前可以等待的多長時間。InnoDB在他自己的鎖表中自動檢測事物死鎖,
並且回滾這個事物。在相同的事物中,如果你用命令:LOCK TABLES,
或者其他transaction-safe儲存引擎,而不是InnoDB,那麼就會發生InnoDB不能通知的死鎖。
因此這個超時就會對解決這個處境很有用。
innodb_lock_wait_timeout = 120
[mysqldump]
# Do not buffer the whole result set in memory before writing it to
# file. Required for dumping very large tables
在寫到文件以前,不緩衝整個結果集的內存。對於大表示必須的
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
# Only allow UPDATEs and DELETEs that use keys.
#safe-updates
[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 files allowed per process. Warning: Make
# sure you have set the global system limit high enough! The high value
# is required for a large number of opened tables
每個進程允許增加打開文件的數量。
警告:確保你設置的全局系統限制大於這個值!
對於有大量打開表這個要求大的值。
open-files-limit = 8192


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章