gaocc
V2EX  ›  问与答

mysql 读写分离配置问题,求教!

  •  1
     
  •   gaocc · Apr 13, 2018 · 1355 views
    This topic created in 2968 days ago, the information mentioned may be changed or developed.

    想在 win7 系统也试试读写分离,然后就一个笔记本电脑,我的做法是复制出第二个 mysql,加到服务里,修改 my.ini 如下: 主:

    server-id = 1

    binlog-do-db=community_ms

    log-bin=mysql-bin

    从:
    server-id = 10
    replicate-do-db= community_ms
    log-bin=mysql-bin

    然后配了用户:

    create user 'forslave'@'127.0.0.1' identified by '123456';

    GRANT REPLICATION SLAVE ON . TO 'forslave'@'127.0.0.1';

    添加用户:

    change master to master_host='127.0.0.1',

    master_port=3306,

    master_user='forslave',

    master_password='123456',

    master_log_file='mysql-bin.xxx',

    master_log_pos=xxx;

    启动 slave start;

    然后查看: show slave status;

    结果 slave_io_running 一直是 NO

    查日志报错如下:

    [ERROR] The slave I/O thread stops because master and slave have equal MySQL server ids; these ids must be different for replication to work (or the --replicate-same-server-id option must be used on slave but this does not always make sense; please check the manual before using it).

    就是说 id 重复了,可配置文件里明明不一样,然后用:

    show variables like 'server_id';

    看了下也是一个 1,一个 10.

    然后,各种百度,折腾半天没弄出问题在哪儿,求教啊!

    3 replies    2018-04-14 08:15:07 +08:00
    gaocc
        1
    gaocc  
    OP
       Apr 13, 2018
    求问题出在哪儿,查出来是 1 和 10,但启动就是报重复
    有说是其它配置覆盖了,可 win7 系统我也没找见哪个文件会覆盖的 my.ini
    msg7086
        2
    msg7086  
       Apr 14, 2018
    master_host='127.0.0.1'

    你连自己干什么?
    msg7086
        3
    msg7086  
       Apr 14, 2018
    你要是同一台机器下开两台 mysql,你给第二台换端口了吗?要不然连 127.0.0.1 不是连他自己玩了?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1101 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 17:58 · PVG 01:58 · LAX 10:58 · JFK 13:58
    ♥ Do have faith in what you're doing.