mysql 常用配置

來源:互聯網
上載者:User

標籤:

innodb_buffer_pool_size 緩衝區的大小,一般為記憶體的70%-80%之間, 用來緩衝表及索引資料,鎖等級資料的最主要緩衝空間。

通過查看 show status like ‘innodb_buffer_pool_%‘;

innodb_log_file_size 記錄檔大小,越大越好,可以減少 buffer pool checkpoint的頻率不能超過4G,

可以設定了多個組,如3組,每組大小 300M

innodb_log_buffer_size 設定 log buffer大小,預設為1M,主要作用就是緩衝Log資料,

提高 Log 的IO效能,一般8M可以勝任 show status like ‘innodb_log%‘; 如果 Innodb_log_waits 為 0 ,

不用等待,緩衝夠大, 如果大於0,就是緩衝不夠大,可以適當增大innodb_file_per_table =1

可以每個表有單獨的資料和索引檔案資料

innodb_data_file_path 不僅指定所有 innodb資料檔案的路徑,

還指定初始大小分配,以下是兩個硬碟

innodb_data_file_path = /disk1/local/mysql/innodb1:1000M:autoextend:8M:max:1G;

innodb_data_file_path = /disk2/local/mysql/innodb2:2000M:autoextend

如果沒有指定innodb_data_home_dir的話,不然就直接用 innodb_data_home_dir的值

如果指定 innodb_data_home_dir,則: innodb_data_home_dir=/usr/local/mysql innodb_data_file_path=ibdata1:2G;ibdata2:2G;ibdata3:2G:autoextend:max:3G

則表示在/usr/local/mysql下有 ibdata1,ibdata2,ibdata3三個存放資料的檔案,

最後一個可以自動擴充,就是當ibdata3大於2G時,會自動增加,增加到 最大為3G

============================

[mysqld]

#general

datadir   = /usr/local/mysql socket   = /usr/local/mysql/mysql.sock (應該與編譯安裝目錄不在同一位置)

pid_file  =/usr/local/mysql/mysql.pid (應該與編譯安裝目錄不在同一位置)

user   = mysql

port   =3306

default_storage_engine =innodb

expire_logs_days = 15

#innodb

innodb_buffer_pool_size = 70-80%記憶體值

innodb_log_file_size = 至少要有幾百M

innodb_log_buffer_size = 1-8M/32-128M

innodb_file_per_table = 1

#innodb與檔案系統相互作用,設定為 0_DIRECT時,需要開啟 innodb_file_per_table

#預設為 fdatasync innodb_flush_method = 0_DIRECT (類unix特有,繞過作業系統的緩衝)

#MYISAM

#金鑰快取,預設只有一個,但可以設定多個,只緩衝索引,資料緩衝則靠系統

#查看總大小,應該比這個值小一點點,單位為 B

# select sum(index_length) from information_schema.tables where engine=‘myisam‘;

key_buffer_size  = 32M

#設定多個時

key_buffer_1.key_buffer_size = value

key_buffer_2.key_buffer_size = value

#用key_buffer_1來緩衝t1,t2表的、索引

cache index t1,t2 in key_buffer_1;

########

#LOGGING

log_error  = /usr/local/mysql/mysql-error.log

slow_query_log  = /usr/local/mysql/mysql-slow.log

#OTHER

tmp_table_size  = 32M/或更大

max_heap_table_size = 32M

query_cache_type = 0

query_cache_size = 0

max_connections  = 10000(預設為100)

open_file_limit  = 65535 (開啟最大檔案數目,越大會越好點)

[client]

socket   = /usr/local/mysql/mysql.sock

port   = 3306

 

mysql 常用配置

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.