MySQL5.5.32生產環境大內存優化配置實例

[client]
port    = 3306
socket    = /tmp/mysql.sock
default-character-set = utf8 #設置客戶端的字符編碼
[mysqld]
# generic configuration options
port    = 3306
socket    = /tmp/mysql.sock
#*** char set ***
character-set-server = utf8 #設置服務器端的字符編碼
             
#*** network ***
back_log = 512
#skip-networking #默認沒有開啓
max_connections = 3000
max_connect_errors = 30
table_open_cache = 4096
#external-locking #默認沒有開啓
max_allowed_packet = 32M
max_heap_table_size = 128M
             
# *** global cache ***
read_buffer_size = 8M
read_rnd_buffer_size = 64M
sort_buffer_size = 16M
join_buffer_size = 16M
             
# *** thread ***
thread_cache_size = 16
thread_concurrency = 8
thread_stack = 512K
             
# *** query cache ***
query_cache_size = 128M
query_cache_limit = 4M
             
# *** index ***
ft_min_word_len = 8
             
#memlock #默認沒有開啓
default-storage-engine = INNODB
transaction_isolation = REPEATABLE-READ
             
# *** tmp table ***
tmp_table_size = 64M
             
# *** bin log ***
log-bin=mysql-bin
binlog_cache_size = 4M
binlog_format=mixed
#log_slave_updates #默認沒有開啓
#log #默認沒有開啓,此處是查詢日誌,開啓會影響服務器性能
log_warnings #開啓警告日誌
             
# *** slow query log ***
slow_query_log
long_query_time = 10
# *** Replication related settings
server-id = 1
#server-id = 2
#master-host = <hostname>
#master-user = <username>
#master-password = <password>
#master-port = <port>
#read_only
#*** MyISAM Specific options
key_buffer_size = 128M
bulk_insert_buffer_size = 256M
myisam_sort_buffer_size = 256M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
myisam_recover
             
# *** INNODB Specific options ***
#skip-innodb #默認沒有開啓
innodb_additional_mem_pool_size = 64M
innodb_buffer_pool_size = 6G #注意在32位系統上你每個進程可能被限制在 2-3.5G 用戶層面內存限制, 所以不要設置的太高.
innodb_data_file_path = ibdata1:10M:autoextend
#innodb_data_home_dir = <directory>
innodb_write_io_threads = 8
innodb_read_io_threads = 8
#innodb_force_recovery=1
innodb_thread_concurrency = 16
innodb_flush_log_at_trx_commit = 2
#說明:innodb_flush_log_at_trx_commit = 2 如果是遊戲服務器,建議此值設置爲2;如果是對數據安全要求極高的應用,建議設置爲1;設置爲0性能最高,但如果發生故障,數據可能會有丟失的危險!默認值1的意思是每一次事務提交或事務外的指令都需要把日誌寫入(flush)硬盤,這是很費時的。特別是使用電池供電緩存(Battery backed up cache)時。設成2對於很多運用,特別是從MyISAM錶轉過來的是可以的,它的意思是不寫入硬盤而是寫入系統緩存。日誌仍然會每秒flush到硬盤,所以你一般不會丟失超過1-2秒的更新。設成0會更快一點,但安全方面比較差,即使MySQL掛了也可能會丟失事務的數據。而值2只會在整個操作系統掛了時纔可能丟數據。
#innodb_fast_shutdown
innodb_log_buffer_size = 16M
innodb_log_file_size = 512M
innodb_log_files_in_group = 3
#innodb_log_group_home_dir
innodb_max_dirty_pages_pct = 90
#innodb_flush_method=O_DSYNC
innodb_lock_wait_timeout = 120
[mysqldump]
quick
max_allowed_packet = 32M
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 2048M
sort_buffer_size = 2048M
read_buffer = 32M
write_buffer = 32M
[mysqlhotcopy]
interactive-timeout
[mysqld_safe]
open-files-limit = 10240
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章