mysql双主
master01
月湖网站建设公司创新互联建站,月湖网站设计制作,有大型网站制作公司丰富经验。已为月湖上千余家提供企业网站建设服务。企业网站搭建\成都外贸网站制作要多少钱,请找那个售后服务好的月湖做网站的公司定做!
[client]
port = 3306
socket = /home/MySQL/socket/mysql.sock
#default-character-set=utf8
[mysqld]
port = 3306
#character_set_server=utf8
#skip-grant-tables = 1
character_set_server = utf8
socket = /home/mysql/socket/mysql.sock
datadir = /home/mysql/data
pid-file = /home/mysql/pid/mysql.pid
user = mysql
bind-address = 0.0.0.0
server-id = 1 #此处注意
skip-name-resolve
back_log = 600
max_connections = 1000
max_connect_errors = 6000
open_files_limit = 65535
table_open_cache = 128
max_allowed_packet = 4M
binlog_cache_size = 1M
max_heap_table_size = 8M
tmp_table_size = 16M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
sort_buffer_size = 8M
join_buffer_size = 8M
key_buffer_size = 4M
thread_cache_size = 8
query_cache_size = 8M
query_cache_limit = 2M
ft_min_word_len = 4
log_bin = mysql-bin
binlog_format = mixed
expire_logs_days = 30
log_error = /home/mysql/error/mysql-error.log
slow_query_log = 1
long_query_time = 1
slow_query_log_file = /home/mysql/slow/mysql-slow.log
performance_schema = 0
explicit_defaults_for_timestamp
skip-external-locking
default_storage_engine = InnoDB
innodb_file_per_table = 1
innodb_open_files = 500
innodb_buffer_pool_size = 64M
innodb_write_io_threads = 4
innodb_read_io_threads = 4
innodb_thread_concurrency = 0
innodb_purge_threads = 1
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 2M
innodb_log_file_size = 32M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
bulk_insert_buffer_size = 8M
myisam_sort_buffer_size = 8M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
interactive_timeout = 28800
wait_timeout = 28800
innodb_file_per_table = ON
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
validate-password = OFF
log_bin_trust_function_creators = ON
lower_case_table_names=1
#binlog-ignore-db=mysql
#myql start bantongbu
rpl_semi_sync_master_enabled=1
#mysql_binlog_size = 500M
max_binlog_size=1024M
expire_logs_days=7
replicate-wild-ignore-table=mysql.% #此处加上
replicate-wild-ignore-table=information_schema.% #此处加上
replicate-wild-ignore-table=performance_schema.% #此处加上
replicate-wild-ignore-table=test.%
##########MM#####
auto_increment_offset = 1 #此处加上
auto_increment_increment = 2 #此处加上 奇数和偶数
[mysqldump]
quick
max_allowed_packet = 16M
[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M
read_buffer = 4M
write_buffer = 4M
##################################################
master02的配置
[client]
port = 3306
socket = /home/mysql/socket/mysql.sock
#default-character-set=utf8
[mysqld]
port = 3306
#character_set_server=utf8
#skip-grant-tables = 1
character_set_server = utf8
socket = /home/mysql/socket/mysql.sock
datadir = /home/mysql/data
pid-file = /home/mysql/pid/mysql.pid
user = mysql
bind-address = 0.0.0.0
server-id = 3 #此处不一样
skip-name-resolve
back_log = 600
max_connections = 1000
max_connect_errors = 6000
open_files_limit = 65535
table_open_cache = 128
max_allowed_packet = 4M
binlog_cache_size = 1M
max_heap_table_size = 8M
tmp_table_size = 16M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
sort_buffer_size = 8M
join_buffer_size = 8M
key_buffer_size = 4M
thread_cache_size = 8
query_cache_size = 8M
query_cache_limit = 2M
ft_min_word_len = 4
log_bin = mysql-bin
binlog_format = mixed
expire_logs_days = 30
log_error = /home/mysql/error/mysql-error.log
slow_query_log = 1
long_query_time = 1
slow_query_log_file = /home/mysql/slow/mysql-slow.log
performance_schema = 0
explicit_defaults_for_timestamp
skip-external-locking
default_storage_engine = InnoDB
innodb_file_per_table = 1
innodb_open_files = 500
innodb_buffer_pool_size = 64M
innodb_write_io_threads = 4
innodb_read_io_threads = 4
innodb_thread_concurrency = 0
innodb_purge_threads = 1
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 2M
innodb_log_file_size = 32M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
bulk_insert_buffer_size = 8M
myisam_sort_buffer_size = 8M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
interactive_timeout = 28800
wait_timeout = 28800
innodb_file_per_table = ON
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
validate-password = OFF
log_bin_trust_function_creators = ON
lower_case_table_names=1
#binlog-ignore-db=mysql
#myql start bantongbu
rpl_semi_sync_master_enabled=1
#mysql_binlog_size = 500M
max_binlog_size=1024M
expire_logs_days=7
replicate-wild-ignore-table=mysql.%
replicate-wild-ignore-table=information_schema.%
replicate-wild-ignore-table=performance_schema.%
replicate-wild-ignore-table=test.%
##########MM#####
auto_increment_offset = 2 #此处不一样
auto_increment_increment = 2 #此处不一样
[mysqldump]
quick
max_allowed_packet = 16M
[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M
read_buffer = 4M
write_buffer = 4M
##################################
master01
grant replication slave on . to 'repl_user'@'1922.168.56.11' identified by 'repl_passwd';
show master status
master02
change master to
master_host='192.168.56.10',
master_user='repl_user',
master_password='repl_passwd',
master_log_file='mysql-bin.000046',
master_log_pos=154;
start slave
###############################
master02
grant replication slave on . to 'repl_user'@'1922.168.56.10' identified by 'repl_passwd';
show master status
master01
change master to
master_host='192.168.56.11',
master_user='repl_user',
master_password='repl_passwd',
master_log_file='mysql-bin.000046',
master_log_pos=154;
start slave
##########################################
至此双主搭建完毕 宕机一台插入测试 宕机另外一台在插入测试,可以看出主键不冲突
网页题目:mysql双主
标题网址:http://pwwzsj.com/article/ijsjej.html