Microsoft Azure部署MYSQL-MMM(2)配置主主複製

來源:互聯網
上載者:User

標籤:style   color   microsoft   black   

(2)配置Master-Master複製


在db1(master1)、db2(master2)、db3(slave)上編譯my.conf

#vi /etc/my.cnf


[mysqld]

datadir=/var/lib/mysql

socket=/var/lib/mysql/mysql.sock

user=mysql


#下面為新添加的內容

default-storage-engine = innodb  


replicate-ignore-db = mysql  

binlog-ignore-db    = mysql  


server-id           = 1  #每台伺服器不能相同

log-bin             = /var/log/mysql/mysql-bin.log  

log_bin_index       = /var/log/mysql/mysql-bin.log.index  

relay_log           = /var/log/mysql/mysql-bin.relay  

relay_log_index     = /var/log/mysql/mysql-bin.relay.index  

expire_logs_days    = 10  

max_binlog_size     = 100M  

log_slave_updates   = 1


650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/5D/13/wKioL1UhbUiiaC7EAAL4J-0uxqQ003.jpg" />


注意:

      1)server-id在每台伺服器上的值都是不一樣,在這裡依次為1、2、3、4。

      2)因為在這裡把log檔案配置到了/var/log/mysql下,而mysql預設的目錄是在/var/lib/mysql,所以首先要建立mysql檔案夾,Mkdir /var/log/mysql,然後用chown -R mysql.mysql /var/log/mysql mysql命令將mysql的所有者修改為使用者mysql。其次要保證,mysql檔案夾的許可權755(即-rwxr-xr-x)。

如果沒有修改許可權和所有者,重啟服務時就會在錯誤記錄檔中出現找不到mysql-bin.log或者mysql-bin.log.index的錯誤(/usr/libexec/mysqld: File ‘/var/log/mysql/mysql-bin.log.index‘ not found (Errcode: 13))。


完成編譯後重啟MYSQL服務

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/5D/18/wKiom1UhbATgzYLDAACQy2-5Rv4890.jpg" />


檢查複製狀態,如:

show master status;

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/5D/13/wKioL1UhbUmw0KSFAAGQCnk4uEc591.jpg" />


檢查日誌是否產生道新目錄,如下

# ls /var/log/mysql

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/5D/18/wKiom1UhbAXgd1ySAADUTA2KhMI476.jpg" />


使用mysql-mmm時一共需要三個使用者: replication、mmm_agent和mmm_monitor(管理伺服器上用來監控cluster狀態的使用者,所以可以限定只能從管理伺服器登入)。使用下面三條命令建立這三個使用者並分配相應的許可權

GRANT REPLICATION CLIENT ON *.* TO ‘mmm_monitor‘@‘10.0.0.%‘ IDENTIFIED BY ‘monitor‘;  

GRANT SUPER, REPLICATION CLIENT, PROCESS ON *.* TO ‘mmm_agent‘@‘10.0.0.%‘   IDENTIFIED BY ‘agent‘;  

GRANT REPLICATION SLAVE ON *.* TO ‘replication‘@‘10.0.0.%‘ IDENTIFIED BY ‘replication‘;


接下來再db1和db2分別執行下面命令修改複製賬戶和密碼。並啟動SLAVE進程。

change master to master_host=‘10.0.0.4‘, master_port=3306, master_user=‘replication‘, master_password=‘replication‘;start slave;

change master to master_host=‘10.0.0.5‘, master_port=3306, master_user=‘replication‘, master_password=‘replication‘;start slave;

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M01/5D/13/wKioL1UhbUmgwm9IAACfJHErtFA903.jpg" />


檢查複製狀態,如:

show slave status\G

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/5D/13/wKioL1UhbUuATwJ2AASZ4uZR5uQ137.jpg" />

本文出自 “李珣部落格-微軟技術與雲” 部落格,請務必保留此出處http://lixun.blog.51cto.com/4198640/1629178

Microsoft Azure部署MYSQL-MMM(2)配置主主複製

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.