mysql效能最大化

來源:互聯網
上載者:User

   [client]

  #passwd = your_passwd

  port = 3306

  socket = /data/mysql/mysql.sock

  [mysqld]

  #global settings

  port = 3306

  socket = /data/mysql/mysql.sock

  basedir=/usr/local/mysql

  tmpdir=/data/mysql

  datadir=/data/mysql

  pid-file=/data/mysql/rongzhong.pid

  #跳過外部鎖定 只對MyISAM

  skip-external-locking

  #禁用tcp socket串連,只能使用unix/linux socket串連

  skip_networking

  #禁用DNS解析,提高連線速度

  skip_name_resolve

  #跳過授權表,忘記root密碼時使用

  #skip-grant-tables

  #預設儲存引擎

  #default-storage-engine=MyISAM/INNODB

  #預設字元集

  character_set_server=utf8

  #最大串連數

  max_connections=20480

  #最大單使用者串連數

  max_user_connections=1024

  #伺服器關閉一個互動串連前等待的秒數,預設28800

  interactive_timeout=7200

  #線程緩衝數,直接利用空閑串連來建立新串連,1G —> 8 2G —> 16 3G —> 32 >3G —> 64

  #短串連較多的情況下可以適當增加該值

  thread_cache_size=64

  #單個線程(串連)進行資料排序(eg: order/group by)時的buffer,串連建立時一次性分配,預設2M,當 Sort_merge_passes較大時可增加該值

  sort_buffer_size=2M

  #對沒有索引的表進行join操作時的buffer,預設256K,串連建立時一次性分配

  join_buffer_size=262144

  #指定串連偵聽隊列的大小,該值超過OS的tcp_max_syn_backlog/somaxconn時無效,推薦設定為小於512的整數

  back_log=512

  #table_open_cache中歲多能開啟的表數

  table_open_cache = 256

  #一次訊息傳輸量的最大值,是net_buffer_length的最大值

  max_allowed_packet=8M

  #bin-log

  #開啟二進位日誌

  log-bin=mysql-bin

  log-bin-index=mysql-bin.index

  #日誌格式,可選row/statement/mixed,預設statement,推薦mixed

  binlog_format=mixed

  #一個binlog的最大值

  max_binlog_size=1G

  #對單個串連的binlog緩衝大小,預設1M

  binlog_cache_size=2M

  #binlog cache的總大小

  max_binlog_cache_size=2G

  #sync_binlog may be 0 or 1

  #binlog是否進行磁碟同步,為0時交給OS,為1:事物結束立即同步,IO損耗大

  sync_binlog=0

  #slow-log

  #開啟slow log

  slow-query-log=1

  #指定慢查詢的時間長度

  long-query-time=2

  #路徑

  slow-query-log-file=/data/mysql/slowlog/slow.log

  #未使用索引的查詢也記錄到slow log中

  log_queries_not_using_indexes=1

  #query cache

  #啟用query cache

  query_cache_type=1

  #存放單條query cache的最大值,預設1M

  query_cache_limit=1M

  #存放單條query cache的最小值,預設4K

  query_cache_min_res_unit=4096

  #query的最大值

  query_cache_size=256M

  #MyISAM

  #索引緩衝大小,公式:Key_Size = key_number * (key_length+4)/0.67

  key_buffer_size=128M

  #單個線程進行順序讀取時的緩衝,預設128K

  read_buffer_size=2M

  #單個線程進行隨機讀取時的緩衝,預設256K

  read_rnd_buffer_size = 4M

  #重建索引時允許的最大緩衝大小,預設8M

  myisam_sort_buffer_size = 64M

  #指定索引緩衝中block大小,預設1K

  key_cache_block_size=1024

  #禁止索引的單條重新整理

  delay_key_write=1

  #innodb

  #啟用獨立的資料表空間

  #innodb_file_per_table=1

  #設定innodb記憶體緩衝區大小,在純mysql環境下,推薦設定為伺服器記憶體的60~80%

  innodb_buffer_pool_size =8G

  #設定OS能進入innodb核心的線程數,推薦2*(CPU核心數+磁碟數)

  innodb_thread_concurrency=16

  #設定innodb的io行為,可選值fsync/O_DSYNC/O_DIRECT 推薦O_DIRECT提高隨機寫效率

  innodb_flush_method=O_DIRECT

  #設定mysql主進程每秒鐘向磁碟刷入的髒頁數,預設值200

  #For systems with individual 5400 RPM or 7200 RPM drives, you might lower the value to the former default of 100

  innodb_io_capacity=100

  #設定寫髒頁的線程數

  innodb_write_io_threads = 8

  #設定從磁碟讀檔案塊的線程數

  innodb_read_io_threads = 8

  #設定事物日誌緩衝區大小

  #設定事物日誌緩衝區大小

  innodb_log_buffer_size=8M

  #log thread向磁碟同步處理記錄的方式,可選值為0/1/2

  #0: 每秒鐘重新整理 1:每次事物提交後都重新整理 2:交給OS來同步

  innodb_flush_log_at_trx_commit =0

  #資料庫字典資訊和表結構空間

  innodb_additional_mem_pool_size =16M

  #啟用Double write Buffer地區,保證資料完整性,但消耗IO

  innodb_doublewrite=1

  [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

  [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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.