MySQL Cluster Replication With MySQL Cluster and non-NDB
- 環境介紹
因為筆電的空間和RAM有限,僅能在3台VM上來建置所有的場景VM配置:
(3台環境資源配置均相同就不分開寫了)
hostname-> IP Address
ol65-> 192.168.56.101
ol65-cluster1-> 192.168.56.103
ol65-cluster2->192.168.56.104:
OS: Oracle Linux 6.5
RAM: 4G
mysql-5.6.19-ndb-7.3.6-cluster-commercial-advanced
mysql-5.6.21-enterprise-commercial-advanced (這只有在192.168.56.101)
第一座MySQL cluster:
mgm_node: 192.168.56.101:1186
data_node_1: 192.168.56.103:50501
data_node_2: 192.168.56.104:50502
sql_node_1: 192.168.56.103:3306
sql_node_2: 192.168.56.104:3306
sql_node_2: 192.168.56.104:3306
第二座MySQL cluster:
slave_mgm: 192.168.56.101:1188
Table schema:
slave_mgm: 192.168.56.101:1188
slave_data_1: 192.168.56.103:50503
slave_data_2: 192.168.56.104:50504
slave_sql_1: 192.168.56.103:3306
slave_sql_2: 192.168.56.104:3306
MySQL Server
slave: 192.168.56.101:3306
slave_sql_2: 192.168.56.104:3306
MySQL Server
slave: 192.168.56.101:3306
- 架構
MySQL Cluster Replication with MySQL Cluster |
MySQL Cluster Replication with non-NDB |
- 前置設定
Table schema:
在Slave的mysql資料庫中新建此表,這個表是用來記錄已經從Master寫到Slave中的操作,所以之後的failover可以從這個表中找到線索
CREATE TABLE `ndb_apply_status` (
`server_id` INT(10) UNSIGNED NOT NULL,
`epoch` BIGINT(20) UNSIGNED NOT NULL,
`log_name` VARCHAR(255) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL,
`start_pos` BIGINT(20) UNSIGNED NOT NULL,
`end_pos` BIGINT(20) UNSIGNED NOT NULL,
PRIMARY KEY (`server_id`) USING HASH
) ENGINE=NDBCLUSTER DEFAULT CHARSET=latin1;
這張表的storage engine如果是NDBCLUSTER的話只適用於cluster架構中,若不是可以改成MyISAM`server_id` INT(10) UNSIGNED NOT NULL,
`epoch` BIGINT(20) UNSIGNED NOT NULL,
`log_name` VARCHAR(255) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL,
`start_pos` BIGINT(20) UNSIGNED NOT NULL,
`end_pos` BIGINT(20) UNSIGNED NOT NULL,
PRIMARY KEY (`server_id`) USING HASH
) ENGINE=NDBCLUSTER DEFAULT CHARSET=latin1;
Config file:
my.cnf (master_1:192.168.56.103:3306)
server_id = 1
log-bin
binlog_format = ROW
expire_logs_days = 7 #清理過期多少天的bin log
ndb-log-update-as-write=0
my.cnf (master_2:192.168.56.104:3306)
server_id = 2
log-bin
binlog_format = ROW
expire_logs_days = 7 #清理過期多少天的bin log
ndb-log-update-as-write=0
my.cnf (slave_1:192.168.56.103:3307)
server_id = 3
slave-exec-mode = IDEMPOTENT
skip-slave-start #(可設可不設)
slave-skip-errors = ddl_exist_errors
my.cnf (slave_2:192.168.56.104:3307)
server_id = 4
slave-exec-mode = IDEMPOTENT
skip-slave-start #(可設可不設)
slave-skip-errors = ddl_exist_errors
留言
張貼留言