centos6,mysql 5.5 配置 master \ slave 資料同步備份,centos6slave

來源:互聯網
上載者:User

centos6,mysql 5.5 配置 master \ slave 資料同步備份,centos6slave

資料庫A 做為主服務,資料庫B做為同步庫(註: 兩邊資料庫庫必須要一至,要不然會有不斷的錯誤資訊出來,改啊改,就是不成功)1、配置 master vi /etc/my.cnf   [mysqld]server-id=1log-bin=log pathbinlog-do-db=xxxx //表示只備份xxxx這個庫 ,可以配置多個庫binlog-ignore-db=yyy //表示忽略yyy庫註: 如果binlog-do-db,binlog-ignore-db不加會預設備份全部庫重啟資料庫    service mysqld restart登陸到資料庫  mysql -uroot -p123456建立一個備份帳號,最好具有 slave, reload,super,許可權grant peplication slave,reload,super on *.* to 'backup'@'%'  identfiend by '1234' with grant option;註:with grant option 這個必須有,表示backup 具有可操作許可權flush privileges;show grant for 'backup'@'%'; //查看使用者show master status;如果 ip 地址改變:change master to master_host='xxx',master_user='backup',master_password='1234',master_port='3306',master_log_file='master-log.000001',master_log_pos=4, master_connect_retry=10;2、配置 slave vi /etc/my.cnf server-id=2change master to master_host='xxx',master_user='backup',master_password='1234',master_port='3306',master_log_file='master-log.000001',master_log_pos=4, master_connect_retry=10;註:日誌名稱,使用者名稱,密碼必須與master 一至show slave status\G;查看資訊是否正確slave start;用show slave status\G;只要確定 : slave_io_running=yesslave_sql_running=yes就搞定了。我遇到了2個問題第一個:slave_io_running=connectingslave_sql_running=yeslast_io_error: error connecting master ......找了老半天,原來是使用者名稱密碼整錯了,真是浪費時間第二個:(有點暈了)slave_io_running=noslave_sql_running=yeslast_io_error:   意思是說兩邊的庫和表一至,同步沒有找到相應的庫和表然後 :slave stop;reset slave; // 重新設定slave change master to master_host='xxx',master_user='backup',master_password='1234',master_port='3306',master_log_file='master-log.000001',master_log_pos=4, master_connect_retry=10;再來一遍,沒辦法,最後終於看到 slave_io_running=yesslave_sql_running=yeslast_io_error: 為空白DBA 的活還真是個細心人去玩


相關文章

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.