MySQL主主主从从从配置文件
Posted 小木目心
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MySQL主主主从从从配置文件相关的知识,希望对你有一定的参考价值。
主配置文件:
[[email protected] ~]# more /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
?
log-bin=mysqlbin
server-id = 1 #主机标示,整数
read-only =0 #主机,读写都可以
binlog-do-db =testdb01 #需要备份数据,多个写多行
binlog-ignore-db =mysql #不需要备份的数据库,多个写多行
?
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
?
?
从配置文件:
[[email protected] ~]# more /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
?
log-bin=mysqlbin
?
server-id = 2
log_slave_updates=1
master-host = 10.0.0.8
master-user = mysqlbak
master-pass = abc123!
master-port = 3306
master-connect-retry=60 #如果从服务器发现主服务器断掉,重新连接的时>间差(秒)
replicate-do-db =testdb01 #只复制某个库
replicate-ignore-db=mysql #不复制某个库
?
?
?
?
?
?
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
?
从从配置文件:
[[email protected] ~]$ more /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
?
log-bin=mysqlbin
?
server-id = 3
master-host = 10.0.0.9
master-user = mysqlbak02
master-pass = abc123!
master-port = 3306
master-connect-retry=60 #如果从服务器发现主服务器断掉,重新连接的时>间差(秒)
replicate-do-db =testdb01 #只复制某个库
replicate-ignore-db=mysql #不复制某个库
?
?
?
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
以上是关于MySQL主主主从从从配置文件的主要内容,如果未能解决你的问题,请参考以下文章