mysql多实例运行
1.主配置文件
[mysqld_multi]
mysqld = /usr/local/mysql/bin/mysqld_safe
mysqladmin = /usr/local/mysql/bin/mysqladmin
user = dbaroot
password = dbaroot20140312
[mysqld3306] #3306
port = 3306
socket = /data/mysql_3306/var/mysql_3306.sock
datadir = /data/mysql_3306/var
pid-file = /data/mysql_3306/var/mysql3306.pid
event_scheduler=1
server-id = 1
log-bin = /data/mysqllog/binlog_3306/mysql-bin
binlog_format=mixed
log_bin_trust_function_creators = 1
wait_timeout = 300
expire_logs_days = 7
default-character-set = utf8
skip-name-resolve
character-set-server = utf8
back_log = 50
max_connections = 1000
max_connect_errors = 32
max_allowed_packet = 64M
table_cache = 2048
binlog_cache_size = 1M
max_heap_table_size = 64M
tmp_table_size = 64M
key_buffer_size = 32M
read_buffer_size = 2M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 64M
sort_buffer_size = 8M
join_buffer_size = 8M
thread_cache_size = 8
thread_concurrency = 8
thread_stack = 192K
query_cache_size = 64M
query_cache_limit = 2M
tmp_table_size = 64M
ft_min_word_len = 2
default_table_type = INNODB
transaction_isolation = REPEATABLE-READ
slow_query_log
long_query_time = 2
log-short-format
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
#myisam_max_extra_sort_file_size = 10G
myisam_repair_threads = 1
myisam_recover
#skip-bdb
innodb_file_per_table = 1
innodb_additional_mem_pool_size = 16M
innodb_buffer_pool_size = 3G
innodb_data_file_path = ibdata1:1024M:autoextend
innodb_file_io_threads = 4
innodb_thread_concurrency = 16
innodb_flush_log_at_trx_commit = 0
innodb_log_buffer_size = 8M
innodb_log_file_size = 256M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
[mysqld3307] #3307
port = 3307
socket = /data/mysql_3307/var/mysql_3307.sock
datadir = /data/mysql_3307/var
pid-file = /data/mysql_3307/var/mysql3307.pid
event_scheduler=1
server-id = 1
log-bin = /data/mysqllog/binlog_3307/mysql-bin
binlog_format=mixed
log_bin_trust_function_creators = 1
wait_timeout = 300
expire_logs_days = 7
default-character-set = utf8
skip-name-resolve
character-set-server = utf8
back_log = 50
max_connections = 1000
max_connect_errors = 32
max_allowed_packet = 64M
table_cache = 2048
binlog_cache_size = 1M
max_heap_table_size = 64M
tmp_table_size = 64M
key_buffer_size = 32M
read_buffer_size = 2M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 64M
sort_buffer_size = 8M
join_buffer_size = 8M
thread_cache_size = 8
thread_concurrency = 8
thread_stack = 192K
query_cache_size = 64M
query_cache_limit = 2M
tmp_table_size = 64M
key_buffer_size = 32M
read_buffer_size = 2M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 64M
sort_buffer_size = 8M
join_buffer_size = 8M
thread_cache_size = 8
thread_concurrency = 8
thread_stack = 192K
query_cache_size = 64M
query_cache_limit = 2M
tmp_table_size = 64M
ft_min_word_len = 2
default_table_type = INNODB
transaction_isolation = REPEATABLE-READ
slow_query_log
long_query_time = 2
log-short-format
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
#myisam_max_extra_sort_file_size = 10G
myisam_repair_threads = 1
myisam_recover
#skip-bdb
innodb_file_per_table = 1
innodb_additional_mem_pool_size = 16M
innodb_buffer_pool_size = 3G
innodb_data_file_path = ibdata1:1024M:autoextend
innodb_file_io_threads = 4
innodb_thread_concurrency = 16
innodb_flush_log_at_trx_commit = 0
innodb_log_buffer_size = 8M
innodb_log_file_size = 256M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
[mysqldump]
quick
max_allowed_packet = 64M
[mysql]
no-auto-rehash
[isamchk]
key_buffer = 512M
sort_buffer_size = 512M
read_buffer = 8M
write_buffer = 8M
[myisamchk]
key_buffer = 512M
sort_buffer_size = 512M
read_buffer = 8M
write_buffer = 8M
[mysqlhotcopy]
interactive-timeout
[mysqld_safe]
open-files-limit = 8192
2.创建数据目录:
mkdir -p /data/mysql_3306/var
mkdir -p /data/mysql_3307/var
3.属主属组赋权:
chown -R mysql.root /data/mysql_330*
初始化:
/usr/local/mysql/bin/mysql_install_db --datadir=/data/mysql_3307/var/ --user=mysql
启动mysql即可。登陆的时候加上-p 3307/6.