最近在搞乙個報表系統,不是很負責,但是就是資料量比較大,單次寫入上萬條資料,加上在同乙個事務裡面,部署到linux伺服器後,發現特別慢,後面發現mysql安裝後沒有優化配置檔案,導致寫入特別慢。
伺服器mysql版本:
mysql配置檔案預設路徑:vim /etc/my.cnf
配置後重啟:service mysql restart
如果重啟報錯,那麼就是配置檔案裡面加了錯誤配置
shutting down mysql.... success!
starting mysql.... error! the server quit without updating pid file (/data/mysql/dbdata/report.pid).
lower_case_table_names=1
wait_timeout=2880000
interactive_timeout = 2880000
max_allowed_packet = 200m
max_connections = 700
open-files-limit = 10240
################20180607 if error delete this############################
key_buffer_size=256m
back_log = 512
table_open_cache=2048
innodb_file_per_table= 1
innodb_buffer_pool_size = 2048m
innodb_log_file_size = 1024m
innodb_log_buffer_size = 16m
innodb_flush_log_at_trx_commit = 2
innodb_flush_method = 'o_direct'
innodb_max_dirty_pages_pct = 90
使用ulimit -a 或者 ulimit -n 檢視linux當前設定的開啟最大檔案數
centos6.5 要想ulimits 的數值永久生效,必須修改配置檔案/etc/security/limits.conf
在該配置檔案中新增
* soft nofile 65535
* hard nofile 65535
目前只配置這兩個,重啟發現就生效了。
查詢各個引數說明請參考:
下面是網上部落格寫的mysql引數說明
高併發配置
其實,對於 nginx tomcat 等這種 web 伺服器,都提供了 backlog 引數設定入口,當然它們都會有預設值,通常這個預設值都不會太大 包括核心預設的半連線佇列和全連線佇列長度 如果應用併發訪問非常高,只增大應用層 backlog 是沒有意義的,因為可能核心引數關於連線佇列設定的都很小...
nginx高併發配置
nginx配置及說明 worker processes 8 nginx 程序數,建議按照cpu 數目來指定,一般為它的倍數。worker cpu affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000...
nginx高併發配置
nginx配置及說明 worker processes 8 nginx 程序數,建議按照cpu 數目來指定,一般為它的倍數。worker cpu affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000...