成都网站建设设计

将想法与焦点和您一起共享

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双主

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


新闻名称:mysql双主-创新互联
标题来源:http://chengdu.cdxwcx.cn/article/cscpdc.html