Mysql-Replication

ubuntu 12.04 上的 MySQL 5.5 複製設置

  • August 28, 2012

以下master-master配置適用於 MySQL Server 5.1.x(Ubuntu 10.04)。

Master1(192.168.2.80)

##################################
#MySQL Replication
##################################
skip-host-cache
skip-name-resolve
event_scheduler = ON
max_connections = 500
max_connect_errors = 1000

server-id = 10
replicate-same-server-id = 0
auto-increment-increment = 10
auto-increment-offset = 1

master-host = 192.168.2.81
master-user = repli
master-password = secret
master-connect-retry = 60

binlog-format = MIXED
#binlog-ignore-db = information_schema
#binlog-ignore-db = lb1

#max_binlog_size = 500M
log-bin = /var/log/mysql/mysql-bin
log-bin-index = /var/log/mysql/bin-log.index

log-slave-updates
report-host = 192.168.2.80
replicate-ignore-db = information_schema
replicate-ignore-db = lb2
replicate-ignore-db = performance_schema

relay_log_space_limit = 3G
relay-log = /var/log/mysql/relay.log
relay-log-index = /var/log/mysql/relay-log.index
##################################

Master2(192.168.2.81)

##################################
#MySQL Replication
##################################
skip-host-cache
skip-name-resolve
event_scheduler = ON
max_connections = 500
max_connect_errors = 1000

server-id = 20
replicate-same-server-id = 0
auto-increment-increment = 10
auto-increment-offset = 2

master-host = 192.168.2.80
master-user = repli
master-password = secret
master-connect-retry = 60

binlog-format = MIXED
#binlog-ignore-db = information_schema
#binlog-ignore-db = lb2

#max_binlog_size = 500M
log-bin = /var/log/mysql/mysql-bin
log-bin-index = /var/log/mysql/bin-log.index

log-slave-updates
report-host = 192.168.2.81
replicate-ignore-db = information_schema
replicate-ignore-db = lb1
replicate-ignore-db = performance_schema

relay_log_space_limit = 3G
relay-log = /var/log/mysql/relay.log
relay-log-index = /var/log/mysql/relay-log.index
##################################

現在它不適用於 MySQL Server 5.5(ubuntu 12.04)。我的意思是說當我用上面的配置重啟mysql服務時,mysql服務需要很長時間才能啟動,根本不啟動。mysql日誌中沒有任何內容並且是空的。我嘗試殺死 mysql 並再次啟動它,但它仍然沒有啟動,如果我刪除上述複製配置,那麼它通常會啟動。

我用 mysql 5.5 做錯了什麼?我計劃在 Ubuntu 伺服器上設置一個帶有 mysql 複製的四節點集群,用於 HA 和故障轉移。是否推薦用於生產用途Ubuntu 12.04MySQL 5.5

需要你的投入。謝謝!

更新 1

master-*在兩個主伺服器上註釋以下行後,MySQL 正常啟動並且複制工作。

#master-host = 192.168.2.xx
#master-user = repli
#master-password = secret
#master-connect-retry = 60

那麼如何在從屬伺服器上指定主伺服器呢?夠CHANGE MASTER TO MASTER_HOST='192.168.2.xx', MASTER_USER='repli', MASTER_PASSWORD='secret',...了嗎?MySQL 5.5.24 和 ubuntu 12.04 生產準備好了嗎?

我的意思是說當我用上面的配置重啟mysql服務時,mysql服務需要很長時間才能啟動,根本不啟動。mysql日誌中沒有任何內容並且是空的。

您是否指定了log-error選項/etc/my.cnf

master-*在兩個主伺服器上註釋以下行後,MySQL 正常啟動並且複制工作。

#master-host = 192.168.2.xx
#master-user = repli
#master-password = secret
#master-connect-retry = 60

那麼如何在從屬伺服器上指定主伺服器呢?夠CHANGE MASTER TO MASTER_HOST='192.168.2.xx', MASTER_USER='repli', MASTER_PASSWORD='secret',...了嗎?

MySQL 5.5 中刪除了這些master-*選項。當然,CHANGE MASTER TO就足夠了,因為值已保存到master.info文件中。

MySQL 5.5.24 和 ubuntu 12.04 生產準備好了嗎?

是的。但是請查看以獲取更多資訊。

引用自:https://serverfault.com/questions/421687