MySQL主從複製,單台伺服器上實施

來源:互聯網
上載者:User

現在公司向在一台伺服器上做主從複製,現在瞭解到的是需要安裝多個mysql不同的服務,才可以,我現在 在現有單一實例資料庫下,分了不同的連接埠以下所示紅色部分;
[root@mysql ~]# netstat -tunlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address              Foreign Address            State      PID/Program name 
tcp        0      0 0.0.0.0:1001                0.0.0.0:*                  LISTEN      2515/rpc.statd     
tcp        0      0 0.0.0.0:111                0.0.0.0:*                  LISTEN      2483/portmap       
tcp        0      0 127.0.0.1:631              0.0.0.0:*                  LISTEN      2750/cupsd         
tcp        0      0 127.0.0.1:25                0.0.0.0:*                  LISTEN      3056/sendmail: acce
tcp        0      0 :::3306                    :::*                        LISTEN      4025/mysqld       
tcp        0      0 :::3307                    :::*                        LISTEN      17423/mysqld       
tcp        0      0 :::3308                    :::*                        LISTEN      17388/mysqld       
tcp        0      0 :::3309                    :::*                        LISTEN      20371/mysqld     
tcp        0      0 :::22                      :::*                        LISTEN      2741/sshd         
udp        0      0 0.0.0.0:995                0.0.0.0:*                              2515/rpc.statd     
udp        0      0 0.0.0.0:998                0.0.0.0:*                              2515/rpc.statd     
udp        0      0 0.0.0.0:42601              0.0.0.0:*                              3204/avahi-daemon: 
udp        0      0 0.0.0.0:5353                0.0.0.0:*                              3204/avahi-daemon: 
udp        0      0 0.0.0.0:111                0.0.0.0:*                              2483/portmap       
udp        0      0 0.0.0.0:631                0.0.0.0:*                              2750/cupsd         
udp        0      0 :::5353                    :::*                                    3204/avahi-daemon: 
udp        0      0 :::59254                    :::*                                    3204/avahi-daemon: 
[root@mysql mysql]# mysqld_multi --defaults-extra-file=/etc/mysqld_multi.cnf report
Reporting MySQL servers
MySQL server from group: mysqld2 is running
MySQL server from group: mysqld3 is running
MySQL server from group: mysqld4 is running
[root@mysql mysql]# lsof -i:3308
COMMAND  PID  USER  FD  TYPE DEVICE SIZE NODE NAME
mysqld  17388 mysql  11u  IPv6  45429      TCP *:tns-server (LISTEN)
[root@mysql mysql]# lsof -i:3307
COMMAND  PID  USER  FD  TYPE DEVICE SIZE NODE NAME
mysqld  17423 mysql  11u  IPv6  45479      TCP *psession-prxy (LISTEN)
[root@mysql mysql]# lsof -i:3309
COMMAND  PID  USER  FD  TYPE DEVICE SIZE NODE NAME
mysqld  20371 mysql  11u  IPv6  47851      TCP *:tns-adv (LISTEN)
[root@mysql mysql]# lsof -i:3306
COMMAND  PID  USER  FD  TYPE DEVICE SIZE NODE NAME
mysqld  4025 mysql  11u  IPv6  16575      TCP *:mysql (LISTEN)
[root@mysql mysql]#
[root@mysql ~]#

在以上服務都啟動正常的情況下,配置主從,我沒有調整IO的線程,不知道在不同連接埠見做主從複製關係,以下是我配置最後遇到的錯誤,請綠林好漢幫忙看看啊,拍磚。。。
mysql> show slave status\G;
*************************** 1. row ***************************
              Slave_IO_State:
                  Master_Host: 192.168.1.10
                  Master_User: slave001
                  Master_Port: 3308
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000003
          Read_Master_Log_Pos: 1027
              Relay_Log_File: localhost3308-relay-bin.000001
                Relay_Log_Pos: 4
        Relay_Master_Log_File: mysql-bin.000003
            Slave_IO_Running: No
            Slave_SQL_Running: Yes
              Replicate_Do_DB:
          Replicate_Ignore_DB:
          Replicate_Do_Table:
      Replicate_Ignore_Table:
      Replicate_Wild_Do_Table:
  Replicate_Wild_Ignore_Table:
                  Last_Errno: 0
                  Last_Error:
                Skip_Counter: 0
          Exec_Master_Log_Pos: 1027
              Relay_Log_Space: 107
              Until_Condition: None
              Until_Log_File:
                Until_Log_Pos: 0
          Master_SSL_Allowed: No
          Master_SSL_CA_File:
          Master_SSL_CA_Path:
              Master_SSL_Cert:
            Master_SSL_Cipher:
              Master_SSL_Key:
        Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 1593
                Last_IO_Error: Fatal 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).
              Last_SQL_Errno: 0
              Last_SQL_Error:
  Replicate_Ignore_Server_Ids:
            Master_Server_Id: 1
1 row in set (0.00 sec)

ERROR:
No query specified

mysql>

  • 1
  • 2
  • 3
  • 4
  • 下一頁

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.