mysql主從複製

mysql主從複製

  1. 去除原有主從關係mysql

    • 從服務器執行 stop slave便可
  2. 主服務器開啓binlogsql

    • my.cnf 配置
    • log_bin = mysql_bin
    • server-id=x
  3. 主增長用戶服務器

    • create user 'slave'@'192.168.1.%' identified with mysql_native_password by 'slave'; 建立slave用於,密碼爲slave
  4. 給slave用戶受權ide

    • grant replication slave on . to 'slave'@'192.168.1.%';
  5. 從服務器開啓binlog配置server-id,開啓中繼日誌relay_log=/path/to/mysql-relay-bin,中繼日誌索引relay_log-index=/path/to/mysql-relay-index 全部的server-id不能重複
  6. 從服務器配置主服務器信息ui

    • change master to mastr_host='192.168.1.35',master_port=3306,master_user='slave',master_password='slave',master_log_file='mysql-bin.001',master_log_pos=100;
    • 指定開始主從複製時主節點binlog文件,以及開始複製的位置(pos),
    • 主服務器執行show master status能夠查看當前bin log 文件名和position,重啓mysql服務,會發生變化
  7. start slave; 開啓從服務
  8. 從執行show slave statusG 查看狀態
  9. 在數據目錄下有一個auto.cnf文件,記錄了一個uuid 主從的uuid不能重複,不然報錯
相關文章
相關標籤/搜索