mysql 单机多实例配置

Posted yinguohai

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql 单机多实例配置相关的知识,希望对你有一定的参考价值。

如果你想在一台机器上进行主从配置实验,本篇可以帮助你实现愿望

[client]
#password   = your_password
port        = 3306
socket      = /tmp/mysql.sock

[mysqld]
port        = 3306
socket      = /tmp/mysql.sock
datadir = /data/mysqldata
skip-external-locking
key_buffer_size = 64M
max_allowed_packet = 1M
table_open_cache = 256
sort_buffer_size = 1M
net_buffer_length = 8K
read_buffer_size = 1M
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 16M
thread_cache_size = 32
query_cache_size = 32M
tmp_table_size = 64M
performance_schema_max_table_instances = 500
sql_mode ='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'

auto-increment-increment = 2
auto-increment-offset = 1

explicit_defaults_for_timestamp = true
#skip-networking
max_connections = 500
max_connect_errors = 100
open_files_limit = 65535

log-bin=mysql-bin
binlog_format=mixed
server-id   = 1
replicate-wild-do-table = jhstore.jh_store
replicate-wild-do-table = jhstore.jh_store_goods
replicate-wild-do-table = jhstore.jh_goods 
replicate-wild-do-table = jhstore.jh_goods_property
replicate-wild-do-table = jhstore.jh_order
replicate-wild-do-table = jhstore.jh_order_goods
replicate-wild-do-table = jhstore.jh_depart
replicate-wild-do-table = jhstore.jh_monetary
replicate-wild-do-table = jhstore.jh_black_list
replicate-wild-do-table = jhstore.jh_adrate
replicate-wild-do-table = jhstore.jh_team
replicate-wild-do-table = jhstore.jh_email
replicate-do-db=jhstore
replicate-ignore-db=mysql
expire_logs_days = 10
early-plugin-load = ""

#loose-innodb-trx=0
#loose-innodb-locks=0
#loose-innodb-lock-waits=0
#loose-innodb-cmp=0
#loose-innodb-cmp-per-index=0
#loose-innodb-cmp-per-index-reset=0
#loose-innodb-cmp-reset=0
#loose-innodb-cmpmem=0
#loose-innodb-cmpmem-reset=0
#loose-innodb-buffer-page=0
#loose-innodb-buffer-page-lru=0
#loose-innodb-buffer-pool-stats=0
#loose-innodb-metrics=0
#loose-innodb-ft-default-stopword=0
#loose-innodb-ft-inserted=0
#loose-innodb-ft-deleted=0
#loose-innodb-ft-being-deleted=0
#loose-innodb-ft-config=0
#loose-innodb-ft-index-cache=0
#loose-innodb-ft-index-table=0
#loose-innodb-sys-tables=0
#loose-innodb-sys-tablestats=0
#loose-innodb-sys-indexes=0
#loose-innodb-sys-columns=0
#loose-innodb-sys-fields=0
#loose-innodb-sys-foreign=0
#loose-innodb-sys-foreign-cols=0

default_storage_engine = InnoDB
innodb_file_per_table = 1
innodb_data_home_dir = /data/mysqldata
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /data/mysqldata
innodb_buffer_pool_size = 256M
innodb_log_file_size = 64M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50


[mysqld_multi]
mysqld = /usr/local/mysql/bin/mysqld_safe
mysqladmin = /usr/local/mysql/bin/mysqladmin
log =/var/log/mysqld_multi.log



[mysqld2]
port        = 3307
socket      = /tmp/mysql2.sock
datadir = /data/mysqldata2
pid-file = /data/mysqldata2/iZj6cesnhdn0muxuf1zeliZ.pid

skip-external-locking
key_buffer_size = 64M
max_allowed_packet = 1M
table_open_cache = 256
sort_buffer_size = 1M
net_buffer_length = 8K
read_buffer_size = 1M
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 16M
thread_cache_size = 32
query_cache_size = 32M
tmp_table_size = 64M
performance_schema_max_table_instances = 500
sql_mode ='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'


auto-increment-increment = 2
auto-increment-offset = 2


explicit_defaults_for_timestamp = true
#skip-networking
max_connections = 500
max_connect_errors = 100
open_files_limit = 65535

log-bin=mysql-bin
binlog_format=mixed
server-id   = 2
replicate-wild-do-table = jhstore.jh_store
replicate-wild-do-table = jhstore.jh_store_goods
replicate-wild-do-table = jhstore.jh_goods 
replicate-wild-do-table = jhstore.jh_goods_property
replicate-wild-do-table = jhstore.jh_order
replicate-wild-do-table = jhstore.jh_order_goods
replicate-wild-do-table = jhstore.jh_depart
replicate-wild-do-table = jhstore.jh_monetary
replicate-wild-do-table = jhstore.jh_black_list
replicate-wild-do-table = jhstore.jh_adrate
replicate-wild-do-table = jhstore.jh_team
replicate-wild-do-table = jhstore.jh_email
replicate-do-db=jhstore
replicate-ignore-db=mysql
expire_logs_days = 10
early-plugin-load = ""

#loose-innodb-trx=0
#loose-innodb-locks=0
#loose-innodb-lock-waits=0
#loose-innodb-cmp=0
#loose-innodb-cmp-per-index=0
#loose-innodb-cmp-per-index-reset=0
#loose-innodb-cmp-reset=0
#loose-innodb-cmpmem=0
#loose-innodb-cmpmem-reset=0
#loose-innodb-buffer-page=0
#loose-innodb-buffer-page-lru=0
#loose-innodb-buffer-pool-stats=0
#loose-innodb-metrics=0
#loose-innodb-ft-default-stopword=0
#loose-innodb-ft-inserted=0
#loose-innodb-ft-deleted=0
#loose-innodb-ft-being-deleted=0
#loose-innodb-ft-config=0
#loose-innodb-ft-index-cache=0
#loose-innodb-ft-index-table=0
#loose-innodb-sys-tables=0
#loose-innodb-sys-tablestats=0
#loose-innodb-sys-indexes=0
#loose-innodb-sys-columns=0
#loose-innodb-sys-fields=0
#loose-innodb-sys-foreign=0
#loose-innodb-sys-foreign-cols=0

default_storage_engine = InnoDB
innodb_file_per_table = 1
innodb_data_home_dir = /data/mysqldata2
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /data/mysqldata2
innodb_buffer_pool_size = 256M
innodb_log_file_size = 64M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50



[mysqld3]
port        = 3308
socket      = /tmp/mysql3.sock
datadir = /data/mysqldata3
pid-file = /data/mysqldata3/iZj6cesnhdn0muxuf1zeliZ.pid

skip-external-locking
key_buffer_size = 64M
max_allowed_packet = 1M
table_open_cache = 256
sort_buffer_size = 1M
net_buffer_length = 8K
read_buffer_size = 1M
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 16M
thread_cache_size = 32
query_cache_size = 32M
tmp_table_size = 64M
performance_schema_max_table_instances = 500
sql_mode ='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'

master-info-repository=TABLE
relay-log-info-repository=TABLE


explicit_defaults_for_timestamp = true
#skip-networking
max_connections = 500
max_connect_errors = 100
open_files_limit = 65535

log-bin=mysql-bin
binlog_format=mixed
server-id   = 3
replicate-wild-do-table = jhstore.jh_admin
replicate-wild-do-table = jhstore.jh_admin_log
replicate-wild-do-table = jhstore.jh_adrate
replicate-wild-do-table = jhstore.jh_article
replicate-wild-do-table = jhstore.jh_attachment
replicate-wild-do-table = jhstore.jh_auth_group
replicate-wild-do-table = jhstore.jh_auth_group_access
replicate-wild-do-table = jhstore.jh_auth_group_down
replicate-wild-do-table = jhstore.jh_auth_rule
replicate-wild-do-table = jhstore.jh_black_list
replicate-wild-do-table = jhstore.jh_category
replicate-wild-do-table = jhstore.jh_config
replicate-wild-do-table = jhstore.jh_configvalue
replicate-wild-do-table = jhstore.jh_depart
replicate-wild-do-table = jhstore.jh_email_backip
replicate-wild-do-table = jhstore.jh_goods
replicate-wild-do-table = jhstore.jh_goods_property
replicate-wild-do-table = jhstore.jh_image
replicate-wild-do-table = jhstore.jh_image_folder
replicate-wild-do-table = jhstore.jh_mac
replicate-wild-do-table = jhstore.jh_monetary
replicate-wild-do-table = jhstore.jh_order
replicate-wild-do-table = jhstore.jh_order_goods
replicate-wild-do-table = jhstore.jh_order_history
replicate-wild-do-table = jhstore.jh_role
replicate-wild-do-table = jhstore.jh_send_email
replicate-wild-do-table = jhstore.jh_store
replicate-wild-do-table = jhstore.jh_store_goods
replicate-wild-do-table = jhstore.jh_team
replicate-wild-do-table = jhstore.jh_email
replicate-do-db=jhstore
replicate-ignore-db=mysql
expire_logs_days = 10
early-plugin-load = ""

#loose-innodb-trx=0
#loose-innodb-locks=0
#loose-innodb-lock-waits=0
#loose-innodb-cmp=0
#loose-innodb-cmp-per-index=0
#loose-innodb-cmp-per-index-reset=0
#loose-innodb-cmp-reset=0
#loose-innodb-cmpmem=0
#loose-innodb-cmpmem-reset=0
#loose-innodb-buffer-page=0
#loose-innodb-buffer-page-lru=0
#loose-innodb-buffer-pool-stats=0
#loose-innodb-metrics=0
#loose-innodb-ft-default-stopword=0
#loose-innodb-ft-inserted=0
#loose-innodb-ft-deleted=0
#loose-innodb-ft-being-deleted=0
#loose-innodb-ft-config=0
#loose-innodb-ft-index-cache=0
#loose-innodb-ft-index-table=0
#loose-innodb-sys-tables=0
#loose-innodb-sys-tablestats=0
#loose-innodb-sys-indexes=0
#loose-innodb-sys-columns=0
#loose-innodb-sys-fields=0
#loose-innodb-sys-foreign=0
#loose-innodb-sys-foreign-cols=0

default_storage_engine = MyISAM
innodb_file_per_table = 1
innodb_data_home_dir = /data/mysqldata3
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /data/mysqldata3
innodb_buffer_pool_size = 256M
innodb_log_file_size = 64M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50



[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash

[myisamchk]
key_buffer_size = 64M
sort_buffer_size = 1M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout

以上是关于mysql 单机多实例配置的主要内容,如果未能解决你的问题,请参考以下文章

MySQL单机多实例部署详解

MYSQL的单机多实例部署

centos7mysql5.6.30单机多实例配置主主复制

centos7下mysql5.6.30配置单机多实例主从半同步复制

单机MySQL多实例主从同步

mysql单机多实例