时间:2021-07-01 10:21:17 帮助过:2人阅读
五、mysql-master 和 mysql-slave 配置文件
mysql-master 配置档:
#!/bin/bash
[mysqld_multi]
mysqld = /usr/local/mysql/bin/mysqld_safe
mysqladmin = /usr/local/mysql/bin/mysqladmin
user = root
password = yunjee0515ueopro1234
[mysqld1]
basedir = /usr/local/mysql
character-set-server = utf8
port = 3306
socket = /tmp/mysql_3306.sock
datadir = /usr/local/mysql/data/dbdata_3306
pid-file = /usr/local/mysql/data/dbdata_3306/mysql.pid
log-error = /usr/local/mysql/data/dbdata_3306/mysql.err
server-id = 1
skip-character-set-client-handshake #忽略应用程序想要设置的其他字符集
init-connect=‘SET NAMES utf8‘ #连接时执行的SQL
character-set-server=utf8 #服务端默认字符集
wait_timeout=1800 #请求的最大连接时间
interactive_timeout=1800 #和上一参数同时修改才会生效
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES #sql模式
log-bin = mysql-bin #打开二进制功能,MASTER主服务器必须打开此项
relay-log = mysql-bin #文件名格式
relay-log-index = mysql-bin.index #index文件名
##MySQL 5.6.10版本提供了更方便的基于GTID的复制功能,MySQL可以通过GTID自动识别上次同步的点,极大地方便了运维人员,减少出错的几率。
binlog-format=ROW #binlog格式
log-slave-updates=true #表示如果一个MASTER挂掉的话,另外一个马上接管
gtid-mode=on #用于启动GTID及满足附属的其它需求
enforce-gtid-consistency=true #
#report-port=port #从属服务器的端口
#report-host=host #从属服务器的主机名
master-info-repository=TABLE #启用此两项,可用于实现在崩溃时保证二进制及从服务器安全的功能
relay-log-info-repository=TABLE #
sync-master-info=1 #启用之可确保无信息丢失
slave-parallel-workers=2 #设定从服务器的SQL线程数;0表示关闭多线程复制功能
binlog-checksum=CRC32 #
master-verify-checksum=1 #
slave-sql-verify-checksum=1 #启用复制有关的所有校验功能
binlog-rows-query-log_events=1 ###MySQL 5.6.10版本提供了更方便的基于GTID的复制功能,MySQL可以通过GTID自动识别上次同步的点,极大地方便了运维人员,减少出错的几率。
expire_logs_day=5 #超过5天的binlog删除
max_binlog_size=104857600
#replicate-ignore-db = mysql #忽略不同步主从的数据库
#replicate-ignore-db = information_schema
#replicate-ignore-db = performance_schema
#replicate-ignore-db = test
#replicate-ignore-db = zabbix
#replicate-ignore-db = sysbench
#replicate-ignore-db = db_3306
##slave-skip-errors=0 #主从忽略错误数
##注释掉,使用默认设置
#skip-external-locking
##innodb_force_recovery = 1
key_buffer_size = 256M
max_allowed_packet = 100M
#table_open_cache = 1024
#sort_buffer_size = 128M
#net_buffer_length = 8K
#read_buffer_size = 128M
#read_rnd_buffer_size = 256M
#myisam_sort_buffer_size = 32M
#character-set-server = utf8
skip-name-resolve
max_connections = 10000
##慢查询设置
slow-query-log=on
long_query_time = 2
#log-queries-not-using-indexes
##注释掉,使用默认设置
## For InnoDB
innodb_buffer_pool_size = 1G
#innodb_additional_mem_pool_size = 128M
## Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 128M
#innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 50
#innodb_file_per_table=1
[mysqld2]
basedir = /usr/local/mysql
character-set-server = utf8
port = 3307
socket = /tmp/mysql_3307.sock
datadir = /usr/local/mysql/data/dbdata_3307
pid-file = /usr/local/mysql/data/dbdata_3307/mysql.pid
log-error = /usr/local/mysql/data/dbdata_3307/mysql.err
server-id = 1
skip-character-set-client-handshake #忽略应用程序想要设置的其他字符集
init-connect=‘SET NAMES utf8‘ #连接时执行的SQL
character-set-server=utf8 #服务端默认字符集
wait_timeout=1800 #请求的最大连接时间
interactive_timeout=1800 #和上一参数同时修改才会生效
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES #sql模式
log-bin = mysql-bin #打开二进制功能,MASTER主服务器必须打开此项
relay-log = mysql-bin #文件名格式
relay-log-index = mysql-bin.index #index文件名
#MySQL 5.6.10版本提供了更方便的基于GTID的复制功能,MySQL可以通过GTID自动识别上次同步的点,极大地方便了运维人员,减少出错的几率。
binlog-format=ROW #binlog格式
log-slave-updates=true #表示如果一个MASTER挂掉的话,另外一个马上接管
gtid-mode=on #用于启动GTID及满足附属的其它需求
enforce-gtid-consistency=true #
#report-port=port #从属服务器的端口
#report-host=host #从属服务器的主机名
master-info-repository=TABLE #启用此两项,可用于实现在崩溃时保证二进制及从服务器安全的功能
relay-log-info-repository=TABLE #
sync-master-info=1 #启用之可确保无信息丢失
slave-parallel-workers=2 #设定从服务器的SQL线程数;0表示关闭多线程复制功能
binlog-checksum=CRC32 #
master-verify-checksum=1 #
slave-sql-verify-checksum=1 #启用复制有关的所有校验功能
binlog-rows-query-log_events=1 ###MySQL 5.6.10版本提供了更方便的基于GTID的复制功能,MySQL可以通过GTID自动识别上次同步的点,极大地方便了运维人员,减少出错的几率。
expire_logs_day=5 #超过5天的binlog删除
max_binlog_size=104857600
#replicate-ignore-db = mysql #忽略不同步主从的数据库
#replicate-ignore-db = information_schema
#replicate-ignore-db = performance_schema
#replicate-ignore-db = test
#replicate-ignore-db = zabbix
#replicate-ignore-db = sysbench
#replicate-ignore-db = db_3307
##slave-skip-errors=0 #主从忽略错误数
##注释掉,使用默认设置
#skip-external-locking
##innodb_force_recovery = 1
key_buffer_size = 256M
max_allowed_packet = 100M
#table_open_cache = 1024
#sort_buffer_size = 128M
#net_buffer_length = 8K
#read_buffer_size = 128M
#read_rnd_buffer_size = 256M
#myisam_sort_buffer_size = 32M
#character-set-server = utf8
skip-name-resolve
max_connections = 10000
##慢查询设置
slow-query-log=on
long_query_time = 2
#log-queries-not-using-indexes
##注释掉,使用默认设置
## For InnoDB
innodb_buffer_pool_size = 1G
#innodb_additional_mem_pool_size = 128M
## Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 128M
#innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 50
#innodb_file_per_table=1
[mysqld3]
basedir = /usr/local/mysql
character-set-server = utf8
port = 3308
socket = /tmp/mysql_3308.sock
datadir = /usr/local/mysql/data/dbdata_3308
pid-file = /usr/local/mysql/data/dbdata_3308/mysql.pid
log-error = /usr/local/mysql/data/dbdata_3308/mysql.err
server-id = 1
skip-character-set-client-handshake #忽略应用程序想要设置的其他字符集
init-connect=‘SET NAMES utf8‘ #连接时执行的SQL
character-set-server=utf8 #服务端默认字符集
wait_timeout=1800 #请求的最大连接时间
interactive_timeout=1800 #和上一参数同时修改才会生效
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES #sql模式
log-bin = mysql-bin #打开二进制功能,MASTER主服务器必须打开此项
relay-log = mysql-bin #文件名格式
relay-log-index = mysql-bin.index #index文件名
#MySQL 5.6.10版本提供了更方便的基于GTID的复制功能,MySQL可以通过GTID自动识别上次同步的点,极大地方便了运维人员,减少出错的几率。
binlog-format=ROW #binlog格式
log-slave-updates=true #表示如果一个MASTER挂掉的话,另外一个马上接管
gtid-mode=on #用于启动GTID及满足附属的其它需求
enforce-gtid-consistency=true #
#report-port=port #从属服务器的端口
#report-host=host #从属服务器的主机名
master-info-repository=TABLE #启用此两项,可用于实现在崩溃时保证二进制及从服务器安全的功能
relay-log-info-repository=TABLE #
sync-master-info=1 #启用之可确保无信息丢失
slave-parallel-workers=2 #设定从服务器的SQL线程数;0表示关闭多线程复制功能
binlog-checksum=CRC32 #
master-verify-checksum=1 #
slave-sql-verify-checksum=1 #启用复制有关的所有校验功能
binlog-rows-query-log_events=1 ###MySQL 5.6.10版本提供了更方便的基于GTID的复制功能,MySQL可以通过GTID自动识别上次同步的点,极大地方便了运维人员,减少出错的几率。
expire_logs_day=5 #超过5天的binlog删除
max_binlog_size=104857600
#replicate-ignore-db = mysql #忽略不同步主从的数据库
#replicate-ignore-db = information_schema
#replicate-ignore-db = performance_schema
#replicate-ignore-db = test
#replicate-ignore-db = zabbix
#replicate-ignore-db = sysbench
#replicate-ignore-db = db_3308
##slave-skip-errors=0 #主从忽略错误数
##注释掉,使用默认设置
#skip-external-locking
##innodb_force_recovery = 1
key_buffer_size = 256M
max_allowed_packet = 100M
#table_open_cache = 1024
#sort_buffer_size = 128M
#net_buffer_length = 8K
#read_buffer_size = 128M
#read_rnd_buffer_size = 256M
#myisam_sort_buffer_size = 32M
#character-set-server = utf8
skip-name-resolve
max_connections = 10000
##慢查询设置
slow-query-log=on
long_query_time = 2
#log-queries-not-using-indexes
##注释掉,使用默认设置
## For InnoDB
innodb_buffer_pool_size = 1G
#innodb_additional_mem_pool_size = 128M
## Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 128M
#innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 50
#innodb_file_per_table=1
[mysqldump]
quick
max_allowed_packet = 256M
[mysql]
no-auto-rehash
prompt=\\u@\\d \\R:\\m>
# Remove the next comment character if you are not familiar with SQL
#safe-updates
[myisamchk]
key_buffer_size = 512M
sort_buffer_size = 512M
read_buffer = 8M
write_buffer = 8M
[mysqlhotcopy]
interactive-timeout
mysql-slave 配置档:
#!/bin/bash
[mysqld_multi]
mysqld = /usr/local/mysql/bin/mysqld_safe
mysqladmin = /usr/local/mysql/bin/mysqladmin
user = root
password = yunjee0515ueopro1234
[mysqld1]
basedir = /usr/local/mysql
character-set-server = utf8
port = 3306
socket = /tmp/mysql_3306.sock
datadir = /usr/local/mysql/data/dbdata_3306
pid-file = /usr/local/mysql/data/dbdata_3306/mysql.pid
log-error = /usr/local/mysql/data/dbdata_3306/mysql.err
server-id = 2
skip-character-set-client-handshake #忽略应用程序想要设置的其他字符集
init-connect=‘SET NAMES utf8‘ #连接时执行的SQL
character-set-server=utf8 #服务端默认字符集
wait_timeout=1800 #请求的最大连接时间
interactive_timeout=1800 #和上一参数同时修改才会生效
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES #sql模式
log-bin = mysql-bin #打开二进制功能,MASTER主服务器必须打开此项
relay-log = mysql-bin #文件名格式
relay-log-index = mysql-bin.index #index文件名
##MySQL 5.6.10版本提供了更方便的基于GTID的复制功能,MySQL可以通过GTID自动识别上次同步的点,极大地方便了运维人员,减少出错的几率。
binlog-format=ROW #binlog格式
log-slave-updates=true #表示如果一个MASTER挂掉的话,另外一个马上接管
gtid-mode=on #用于启动GTID及满足附属的其它需求
enforce-gtid-consistency=true #
report-port=3306 #从属服务器的端口
report-host=10.1.0.60 #从属服务器的主机名
master-info-repository=TABLE #启用此两项,可用于实现在崩溃时保证二进制及从服务器安全的功能
relay-log-info-repository=TABLE #
sync-master-info=1 #启用之可确保无信息丢失
slave-parallel-workers=2 #设定从服务器的SQL线程数;0表示关闭多线程复制功能
binlog-checksum=CRC32 #
master-verify-checksum=1 #
slave-sql-verify-checksum=1 #启用复制有关的所有校验功能
binlog-rows-query-log_events=1 ###MySQL 5.6.10版本提供了更方便的基于GTID的复制功能,MySQL可以通过GTID自动识别上次同步的点,极大地方便了运维人员,减少出错的几率。
expire_logs_day=5 #超过5天的binlog删除
max_binlog_size=104857600
#replicate-ignore-db = mysql #忽略不同步主从的数据库
#replicate-ignore-db = information_schema
#replicate-ignore-db = performance_schema
#replicate-ignore-db = test
#replicate-ignore-db = zabbix
#replicate-ignore-db = sysbench
#replicate-ignore-db = db_3306
##slave-skip-errors=0 #主从忽略错误数
##注释掉,使用默认设置
#skip-external-locking
##innodb_force_recovery = 1
key_buffer_size = 256M
max_allowed_packet = 100M
#table_open_cache = 1024
#sort_buffer_size = 128M
#net_buffer_length = 8K
#read_buffer_size = 128M
#read_rnd_buffer_size = 256M
#myisam_sort_buffer_size = 32M
#character-set-server = utf8
skip-name-resolve
max_connections = 10000
##慢查询设置
slow-query-log=on
long_query_time = 2
#log-queries-not-using-indexes
##注释掉,使用默认设置
## For InnoDB
innodb_buffer_pool_size = 1G
#innodb_additional_mem_pool_size = 128M
## Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 128M
#innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 50
#innodb_file_per_table=1
[mysqld2]
basedir = /usr/local/mysql
character-set-server = utf8
port = 3307
socket = /tmp/mysql_3307.sock
datadir = /usr/local/mysql/data/dbdata_3307
pid-file = /usr/local/mysql/data/dbdata_3307/mysql.pid
log-error = /usr/local/mysql/data/dbdata_3307/mysql.err
server-id = 2
skip-character-set-client-handshake #忽略应用程序想要设置的其他字符集
init-connect=‘SET NAMES utf8‘ #连接时执行的SQL
character-set-server=utf8 #服务端默认字符集
wait_timeout=1800 #请求的最大连接时间
interactive_timeout=1800 #和上一参数同时修改才会生效
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES #sql模式
log-bin = mysql-bin #打开二进制功能,MASTER主服务器必须打开此项
relay-log = mysql-bin #文件名格式
relay-log-index = mysql-bin.index #index文件名
#MySQL 5.6.10版本提供了更方便的基于GTID的复制功能,MySQL可以通过GTID自动识别上次同步的点,极大地方便了运维人员,减少出错的几率。
binlog-format=ROW #binlog格式
log-slave-updates=true #表示如果一个MASTER挂掉的话,另外一个马上接管
gtid-mode=on #用于启动GTID及满足附属的其它需求
enforce-gtid-consistency=true #
report-port=3307 #从属服务器的端口
report-host=10.1.0.60 #从属服务器的主机名
master-info-repository=TABLE #启用此两项,可用于实现在崩溃时保证二进制及从服务器安全的功能
relay-log-info-repository=TABLE #
sync-master-info=1 #启用之可确保无信息丢失
slave-parallel-workers=2 #设定从服务器的SQL线程数;0表示关闭多线程复制功能
binlog-checksum=CRC32 #
master-verify-checksum=1 #
slave-sql-verify-checksum=1 #启用复制有关的所有校验功能
binlog-rows-query-log_events=1 ###MySQL 5.6.10版本提供了更方便的基于GTID的复制功能,MySQL可以通过GTID自动识别上次同步的点,极大地方便了运维人员,减少出错的几率。
expire_logs_day=5 #超过5天的binlog删除
max_binlog_size=104857600
#replicate-ignore-db = mysql #忽略不同步主从的数据库
#replicate-ignore-db = information_schema
#replicate-ignore-db = performance_schema
#replicate-ignore-db = test
#replicate-ignore-db = zabbix
#replicate-ignore-db = sysbench
#replicate-ignore-db = db_3307
##slave-skip-errors=0 #主从忽略错误数
##注释掉,使用默认设置
#skip-external-locking
##innodb_force_recovery = 1
key_buffer_size = 256M
max_allowed_packet = 100M
#table_open_cache = 1024
#sort_buffer_size = 128M
#net_buffer_length = 8K
#read_buffer_size = 128M
#read_rnd_buffer_size = 256M
#myisam_sort_buffer_size = 32M
#character-set-server = utf8
skip-name-resolve
max_connections = 10000
##慢查询设置
slow-query-log=on
long_query_time = 2
#log-queries-not-using-indexes
##注释掉,使用默认设置
## For InnoDB
innodb_buffer_pool_size = 1G
#innodb_additional_mem_pool_size = 128M
## Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 128M
#innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 50
#innodb_file_per_table=1
[mysqld3]
basedir = /usr/local/mysql
character-set-server = utf8
port = 3308
socket = /tmp/mysql_3308.sock
datadir = /usr/local/mysql/data/dbdata_3308
pid-file = /usr/local/mysql/data/dbdata_3308/mysql.pid
log-error = /usr/local/mysql/data/dbdata_3308/mysql.err
server-id = 2
skip-character-set-client-handshake #忽略应用程序想要设置的其他字符集
init-connect=‘SET NAMES utf8‘ #连接时执行的SQL
character-set-server=utf8 #服务端默认字符集
wait_timeout=1800 #请求的最大连接时间
interactive_timeout=1800 #和上一参数同时修改才会生效
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES #sql模式
log-bin = mysql-bin #打开二进制功能,MASTER主服务器必须打开此项
relay-log = mysql-bin #文件名格式
relay-log-index = mysql-bin.index #index文件名
#MySQL 5.6.10版本提供了更方便的基于GTID的复制功能,MySQL可以通过GTID自动识别上次同步的点,极大地方便了运维人员,减少出错的几率。
binlog-format=ROW #binlog格式
log-slave-updates=true #表示如果一个MASTER挂掉的话,另外一个马上接管
gtid-mode=on #用于启动GTID及满足附属的其它需求
enforce-gtid-consistency=true #
report-port=3308 #从属服务器的端口
report-host=10.1.0.60 #从属服务器的主机名
master-info-repository=TABLE #启用此两项,可用于实现在崩溃时保证二进制及从服务器安全的功能
relay-log-info-repository=TABLE #
sync-master-info=1 #启用之可确保无信息丢失
slave-parallel-workers=2 #设定从服务器的SQL线程数;0表示关闭多线程复制功能
binlog-checksum=CRC32 #
master-verify-checksum=1 #
slave-sql-verify-checksum=1 #启用复制有关的所有校验功能
binlog-rows-query-log_events=1 ###MySQL 5.6.10版本提供了更方便的基于GTID的复制功能,MySQL可以通过GTID自动识别上次同步的点,极大地方便了运维人员,减少出错的几率。
expire_logs_day=5 #超过5天的binlog删除
max_binlog_size=104857600
#replicate-ignore-db = mysql #忽略不同步主从的数据库
#replicate-ignore-db = information_schema
#replicate-ignore-db = performance_schema
#replicate-ignore-db = test
#replicate-ignore-db = zabbix
#replicate-ignore-db = sysbench
#replicate-ignore-db = db_3308
##slave-skip-errors=0 #主从忽略错误数
##注释掉,使用默认设置
#skip-external-locking
##innodb_force_recovery = 1
key_buffer_size = 256M
max_allowed_packet = 100M
#table_open_cache = 1024
#sort_buffer_size = 128M
#net_buffer_length = 8K
#read_buffer_size = 128M
#read_rnd_buffer_size = 256M
#myisam_sort_buffer_size = 32M
#character-set-server = utf8
skip-name-resolve
max_connections = 10000
##慢查询设置
slow-query-log=on
long_query_time = 2
#log-queries-not-using-indexes
##注释掉,使用默认设置
## For InnoDB
innodb_buffer_pool_size = 1G
#innodb_additional_mem_pool_size = 128M
## Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 128M
#innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 50
#innodb_file_per_table=1
[mysqldump]
quick
max_allowed_packet = 256M
[mysql]
no-auto-rehash
prompt=\\u@\\d \\R:\\m>
# Remove the next comment character if you are not familiar with SQL
#safe-updates
[myisamchk]
key_buffer_size = 512M
sort_buffer_size = 512M
read_buffer = 8M
write_buffer = 8M
[mysqlhotcopy]
interactive-timeout
Innobackup mysql 多实例环境搭建主从同步
标签: