隨著互聯(lián)網(wǎng)的不斷發(fā)展,數(shù)據(jù)庫的高并發(fā)性能越來越成為熱門話題,mysql數(shù)據(jù)庫的高并發(fā)性能也受到越來越多的關(guān)注。
那么,如何提高mysql數(shù)據(jù)庫的高并發(fā)性能呢?下面我們從以下幾個(gè)方面進(jìn)行探討。
一、數(shù)據(jù)庫的連接數(shù)
innodb_buffer_pool_size = 1G
innodb_log_file_size = 256M
innodb_log_buffer_size = 32M
innodb_flush_log_at_trx_commit = 2
innodb_read_io_threads = 8
innodb_write_io_threads = 8
innodb_io_capacity = 5000
innodb_io_capacity_max = 10000
innodb_flush_neighbors = 0
innodb_thread_concurrency = 64
innodb_concurrency_tickets = 2000
innodb_purge_threads = 4
innodb_adaptive_flushing_lwm = 10
innodb_adaptive_flushing = on
innodb_flush_method = O_DIRECT
二、sql語句的優(yōu)化
CREATE INDEX idx_order_paytime ON orders(pay_time);
CREATE INDEX idx_order_delivery ON orders(delivery_id);
CREATE INDEX idx_order_status ON orders(status);
CREATE INDEX idx_order_uid_goodsid ON orders(uid,goods_id);
三、mysql的集群
my.cnf:
[mysqld]
port = 3306
pid-file = /usr/local/mysql/var/mysql.pid
socket = /usr/local/mysql/var/mysql.sock
datadir = /usr/local/mysql/data
log_error = /usr/local/mysql/data/mysql_error.log
character_set_server = utf8mb4
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
default-character-set = utf8mb4
[client]
default-character-set = utf8mb4
port = 3306
socket = /usr/local/mysql/var/mysql.sock
use-remote-mysql = true
mysql_access_cache = off
ndbd.ccnf
[ndbd default]
exclude_ips=118.17.1.1,118.17.1.2
connectstring=118.17.1.1,118.17.1.2
DataDir=/usr/local/mysql/mysql-cluster
ServerPort=2203
[ndb_mgmd]
hostname=118.17.1.1
datadir=/usr/local/mysql/mysql-cluster
[ndbd]
hostname=118.17.1.1
datadir=/usr/local/mysql/mysql-cluster
[ndbd]
hostname=118.17.1.2
datadir=/usr/local/mysql/mysql-cluster
[mysqld]
hostname=118.17.1.1
[mysqld]
hostname=118.17.1.2
以上就是mysql數(shù)據(jù)庫高并發(fā)性能的一些優(yōu)化方法,希望可以對(duì)大家有所幫助。