Skip to main content

多主

my.ini配置文件里要比双主多一个配置

log-slave-updates = true

从服务器不会将从主服务器接收到的任何更新记录到自己的二进制日志中。此选项告诉从服务器将其SQL线程执行的更新记录到自己的二进制日志中。

log-slave-updates是一个全局非动态选项,其值为布尔型,即TRUE和FALSE。缺省为FALSE,修改该参数需要重启实例。

    Normally, a slave does not log to its own binary log any updates that are received from a master server. This option tells the slave to log the updates performed by its SQL thread to its own binary log. For this option to have any effect, the slave must also be started with the --log-bin [2039] option to enable binary logging. Prior to MySQL 5.5, the server would not start when using the --log-slave-updates [2004] option without also starting the server with the --log-bin [2039] option, and would fail with an error; in MySQL 5.6, only a warning is generated. (Bug #44663) --log-slave-updates [2004] is used when you want to chain replication servers. For example, you might want to set up replication servers using this arrangement:

    A -> B -> C

    Here, A serves as the master for the slave B, and B serves as the master for the slave C. For this to work, B must be both a master and a slave. You must start both A and B with --log-bin [2039] to enable binary logging, and B with the --log-slave-updates [2004] option so that updates received from A are logged by B to its binary log.

show master status;

| master-log.000007 | 646 |

change master to master_host='192.168.111.220',master_user='will',master_password='asdasd',master_log_file='master-log.000007' ,master_log_pos= 646 ;

| master-log.000005 | 446

change master to master_host='192.168.111.221',master_user='will',master_password='asdasd',master_log_file='master-log.000005' ,master_log_pos= 446 ;

| master-log.000004 | 1445 |

change master to master_host='192.168.111.222',master_user='will',master_password='asdasd',master_log_file='master-log.000004' ,master_log_pos= 1445 ;

slave start;

show slave status \G;