mysqld_multi 启动 mysql 多实例
@import url(http://www.blogjava.net/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);
因为连接数的问题,我不得不在一台机器上多启 mysql instance
1. 建立两个 mysql 数据库实例
mysql_install_db --datadir=xxx
2. 配置 /etc/my.cnf
[client]
#password
= your_password
#port
= 3306
#socket
= /var/lib/mysql/mysql.sock
# Here follows entries for some specific programs
[mysqld_multi]
mysqld = /usr/bin/mysqld_safe
mysqladmin = /usr/bin/mysqladmin
user = mysql
password = mysql
[mysqld1]
datadir = /home/intple/mysql/data1
max_connections = 800
long_query_time = 0.1
#log-queries-not-using-indexes
slow_query_log = 1
slow_query_log_file = /var/log/mysql-slow.log
port
= 3306
socket
= /home/intple/mysql/data1/mysql.sock
skip-locking
key_buffer_size = 384M
max_allowed_packet = 1M
table_open_cache = 512
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M
thread_cache_size = 32
query_cache_size = 512M
# Try number of CPU's*2 for thread_concurrency
thread_concurrency = 32
log-bin=mysql-bin
server-id = 1
binlog_format=mixed
innodb_buffer_pool_size = 20G
innodb_additional_mem_pool_size = 32M
innodb_thread_concurrency = 32
# Set .._log_file_size to 25 % of buffer pool size
innodb_log_file_size = 256M
innodb_log_buffer_size = 32M
innodb_flush_log_at_trx_commit = 1
innodb_autoextend_increment = 64M
innodb_lock_wait_timeout = 200
[mysqld2]
datadir = /home/intple/mysql/data2
max_connections = 800
long_query_time = 0.1
#log-queries-not-using-indexes
slow_query_log = 1
slow_query_log_file = /var/log/mysql2-slow.log
port
= 3307
socket
= /home/intple/mysql/data2/mysql2.sock
skip-locking
key_buffer_size = 384M
max_allowed_packet = 1M
table_open_cache = 512
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M
thread_cache_size = 32
query_cache_size = 512M
# Try number of CPU's*2 for thread_concurrency
thread_concurrency = 32
log-bin=mysql-bin
server-id
= 1
binlog_format=mixed
innodb_buffer_pool_size = 20G
innodb_additional_mem_pool_size = 32M
innodb_thread_concurrency = 32
# Set .._log_file_size to 25 % of buffer pool size
innodb_log_file_size = 256M
innodb_log_buffer_size = 32M
innodb_flush_log_at_trx_commit = 1
innodb_autoextend_increment = 64M
innodb_lock_wait_timeout = 200
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates
[myisamchk]
key_buffer_size = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
3. 启动
mysqld_multi start 1 &
mysqld_multi start 2 &