文章详情

短信预约-IT技能 免费直播动态提醒

请输入下面的图形验证码

提交验证

短信预约提醒成功

mysql双主

2024-04-02 19:55

关注

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

阅读原文内容投诉

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

软考中级精品资料免费领

  • 历年真题答案解析
  • 备考技巧名师总结
  • 高频考点精准押题
  • 2024年上半年信息系统项目管理师第二批次真题及答案解析(完整版)

    难度     807人已做
    查看
  • 【考后总结】2024年5月26日信息系统项目管理师第2批次考情分析

    难度     351人已做
    查看
  • 【考后总结】2024年5月25日信息系统项目管理师第1批次考情分析

    难度     314人已做
    查看
  • 2024年上半年软考高项第一、二批次真题考点汇总(完整版)

    难度     433人已做
    查看
  • 2024年上半年系统架构设计师考试综合知识真题

    难度     221人已做
    查看

相关文章

发现更多好内容

猜你喜欢

AI推送时光机
位置:首页-资讯-数据库
咦!没有更多了?去看看其它编程学习网 内容吧
首页课程
资料下载
问答资讯