300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > mysql主从复制 读写分离集群/etc/my.cnf配置文件

mysql主从复制 读写分离集群/etc/my.cnf配置文件

时间:2022-03-18 04:48:01

相关推荐

mysql主从复制 读写分离集群/etc/my.cnf配置文件

master1和master2做主高可用

node1和master1组成主从复制,读写分离

node2和master2组成主从复制,读写分离

下面给出配置文件

1. master1: /etc/f

# For advice on how to change settings please see# /doc/refman/8.0/en/server-configuration-defaults.html[mysqld]## Remove leading # and set to the amount of RAM for the most important data# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.# innodb_buffer_pool_size = 128M## Remove the leading "# " to disable binary logging# Binary logging captures changes between backups and is enabled by# default. It's default setting is log_bin=binlog# disable_log_bin## Remove leading # to set options mainly useful for reporting servers.# The server defaults are faster for transactions and fast SELECTs.# Adjust sizes as needed, experiment to find the optimal values.# join_buffer_size = 128M# sort_buffer_size = 2M# read_rnd_buffer_size = 2M## Remove leading # to revert to previous value for default_authentication_plugin,# this will increase compatibility with older clients. For background, see:# /doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugindefault-authentication-plugin=mysql_native_passwordcharacter-set-server=utf8datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.socklog-error=/var/log/mysqld.logpid-file=/var/run/mysqld/mysqld.pidvalidate_password.check_user_name=OFFvalidate_password.length=4validate_password.mixed_case_count=0validate_password.number_count=0validate_password.policy=0validate_password.special_char_count=0#主从复制-主机21配置# 主服务器唯一IDserver-id=21# 启用二进制日志log-bin=mysql-bin# 设置不要复制的数据库(可设置多个)binlog-ignore-db=sysbinlog-ignore-db=mysqlbinlog-ignore-db=information_schemabinlog-ignore-db=performance_schema# 设置需要复制的数据库(可设置多个)binlog-do-db=testdbbinlog-do-db=testdb2binlog-do-db=testdb3binlog-do-db=testdb4# 设置logbin格式binlog_format=STATEMENT# 写入操作更新二进制日志文件log-slave-updateswait_timeout=31536000interactive_timeout=31536000

2. node1: /etc/f

# For advice on how to change settings please see# /doc/refman/8.0/en/server-configuration-defaults.html[mysqld]## Remove leading # and set to the amount of RAM for the most important data# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.# innodb_buffer_pool_size = 128M## Remove the leading "# " to disable binary logging# Binary logging captures changes between backups and is enabled by# default. It's default setting is log_bin=binlog# disable_log_bin## Remove leading # to set options mainly useful for reporting servers.# The server defaults are faster for transactions and fast SELECTs.# Adjust sizes as needed, experiment to find the optimal values.# join_buffer_size = 128M# sort_buffer_size = 2M# read_rnd_buffer_size = 2M## Remove leading # to revert to previous value for default_authentication_plugin,# this will increase compatibility with older clients. For background, see:# /doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugindefault-authentication-plugin=mysql_native_passwordcharacter-set-server=utf8datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.socklog-error=/var/log/mysqld.logpid-file=/var/run/mysqld/mysqld.pidvalidate_password.check_user_name=OFFvalidate_password.length=4validate_password.mixed_case_count=0validate_password.number_count=0validate_password.policy=0validate_password.special_char_count=0# 主从复制-从机26配置# 从服务器唯一IDserver-id=26# 启用中继日志relay-log=mysql-relaywait_timeout=31536000interactive_timeout=31536000

3. master2: /etc/f

# For advice on how to change settings please see# /doc/refman/8.0/en/server-configuration-defaults.html[mysqld]## Remove leading # and set to the amount of RAM for the most important data# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.# innodb_buffer_pool_size = 128M## Remove the leading "# " to disable binary logging# Binary logging captures changes between backups and is enabled by# default. It's default setting is log_bin=binlog# disable_log_bin## Remove leading # to set options mainly useful for reporting servers.# The server defaults are faster for transactions and fast SELECTs.# Adjust sizes as needed, experiment to find the optimal values.# join_buffer_size = 128M# sort_buffer_size = 2M# read_rnd_buffer_size = 2M## Remove leading # to revert to previous value for default_authentication_plugin,# this will increase compatibility with older clients. For background, see:# /doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugindefault-authentication-plugin=mysql_native_passworddatadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.socklog-error=/var/log/mysqld.logpid-file=/var/run/mysqld/mysqld.pidcharacter-set-server=utf8validate_password.check_user_name=OFFvalidate_password.length=4validate_password.mixed_case_count=0validate_password.number_count=0validate_password.policy=0validate_password.special_char_count=0#主从复制-主机22配置# 主服务器唯一IDserver-id=22# 启用二进制日志log-bin=mysql-bin# 设置不要复制的数据库(可设置多个)binlog-ignore-db=sysbinlog-ignore-db=mysqlbinlog-ignore-db=information_schemabinlog-ignore-db=performance_schema# 设置需要复制的数据库(可设置多个)binlog-do-db=testdbbinlog-do-db=testdb2binlog-do-db=testdb3binlog-do-db=testdb4# 设置logbin格式binlog_format=STATEMENT# 写入操作更新二进制日志文件log-slave-updateswait_timeout=31536000interactive_timeout=31536000

4. node2: /etc/f

# For advice on how to change settings please see# /doc/refman/8.0/en/server-configuration-defaults.html[mysqld]## Remove leading # and set to the amount of RAM for the most important data# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.# innodb_buffer_pool_size = 128M## Remove the leading "# " to disable binary logging# Binary logging captures changes between backups and is enabled by# default. It's default setting is log_bin=binlog# disable_log_bin## Remove leading # to set options mainly useful for reporting servers.# The server defaults are faster for transactions and fast SELECTs.# Adjust sizes as needed, experiment to find the optimal values.# join_buffer_size = 128M# sort_buffer_size = 2M# read_rnd_buffer_size = 2M## Remove leading # to revert to previous value for default_authentication_plugin,# this will increase compatibility with older clients. For background, see:# /doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugindefault-authentication-plugin=mysql_native_passwordcharacter-set-server=utf8datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.socklog-error=/var/log/mysqld.logpid-file=/var/run/mysqld/mysqld.pidvalidate_password.check_user_name=OFFvalidate_password.length=4validate_password.mixed_case_count=0validate_password.number_count=0validate_password.policy=0validate_password.special_char_count=0# 主从复制-从机27配置# 从服务器唯一IDserver-id=27# 启用中继日志relay-log=mysql-relaywait_timeout=31536000interactive_timeout=31536000

总结

底层走的是binlog进行复制的。

从库需要给从库账号和密码让其访问。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。