伺服器配置如下:
Dell R410 XEON 5506 *2 (8核)/ 16GB memory /300G*4 raid 10
注意:需要根據伺服器實際配置情況更改相關參數.
線上 mysql 主庫配置文檔
- $ cat /etc/my.cnf
- [mysqld]
- port = 3306
- user = mysql
- skip-locking
- skip-innodb
- skip-name-resolve
- key_buffer = 1024M
- max_allowed_packet = 16M
- max_heap_table_size = 1024M
- max_connect_errors = 100
- table_cache = 4096
- sort_buffer_size = 128M
- record_buffer = 4M
- read_buffer_size = 8M
- read_rnd_buffer_size = 8M
- myisam_sort_buffer_size = 16M
- thread_cache_size = 2048
- query_cache_type = 1
- query_cache_size = 1024M
- query_cache_limit = 2M
- flush_time = 384
- back_log = 2048
- tmp_table_size = 2048M
- character_set_server=utf8
- max_connections = 1000
- max_user_connections = 1000
- interactive_timeout =20000
- wait_timeout=20000
- thread_concurrency = 8
- server-id = 1001
- tmpdir = /tmp/
參數說明,來自互聯網!
- 有關請求連接的變數: 有關緩衝區變數: 連接緩衝;
- 有關請求連接的變數:
- max_connections MySql的最大連接數,如果伺服器的併發連接請求量比較大,建議調高此值,以增加并行連接數量
- show variables like '%max_con%';
- -------------------- -------
- | Variable_name | Value |
- -------------------- -------
- | max_connect_errors | 10 |
- | max_connections | 151 |
- -------------------- -------
- 可以通過'conn%'通配符查看當前狀態的連接數量,以定奪該值的大小!
- show status like 'conn%';
- --------------- -------
- | Variable_name | Value |
- --------------- -------
- | Connections | 109 |
- --------------- -------
- back_log 是要求MySQL能有的連接數量.也就是說,如果MySql的連接數據達到max_connections時,新來的請求將會被存在堆棧中,以等待某一連接釋放資源,該堆棧的數量即back_log,如果等待連接的數量超過back_log,將不被授予連接資源
- show variables like '
[火星人 ] 線上 mysql 主庫配置文檔已經有375次圍觀