hostname ip地址 应用服务db1 www.linuxidc.com mgmdb2 192.168.6.160 ndbd,mysqlddb3
hostname ip地址 应用服务
db1 mgm
db2 192.168.6.160 ndbd,mysqld
db3 192.168.6.188 ndbd2, mysqld
db4 192.168.6.191 mysqld一.db1 管理节点 mgm
./configure --prefix=/usr/local/mysql/ --with-charset=utf8 --with-collation=utf8_general_ci --with-client-ldflags=-all-static -with-mysqld-ldflags=-all-static --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-unix-socket-path=/tmp/mysql.sock --sysconfdir=/usr/local/mysql/etc --without-debug --with-mysqld-user=mysql --with-plugin=innobase --with-plugin-ndbcluster --with-plugin-partition
make
make install
cd /usr/local/mysql
mkdir mysql-cluster
cd mysql-cluster
vim config.ini
[ndbd default]
noofreplicas= 2
[mysqld default]
[ndb_mgmd default]
datadir= /usr/local/mysql/mysql-cluster
[ndb_mgmd]
hostname=
[ndbd]
hostname= 192.168.6.160
datadir= /usr/local/mysql/mysql-cluster
[ndbd]
hostname= 192.168.6.188
datadir= /usr/local/mysql/mysql-cluster
[mysqld]
hostname= 192.168.6.160
[mysqld]
hostname= 192.168.6.188
[mysqld]
hostname= 192.168.6.191/usr/local/mysql/libexec/ndb_mgmd -f /usr/local/mysql/mysql-cluster/config.ini/usr/local/mysql/bin/ndb_mgm
-- ndb cluster -- management client --
ndb_mgm> show
connected to management server at: localhost:1186
cluster configuration
---------------------
[ndbd(ndb)] 2 node(s)
id=2 (not connected, accepting connect from 192.168.6.160)
id=3 (not connected, accepting connect from 192.168.6.188)
[ndb_mgmd(mgm)] 1 node(s)
id=1 @ (version: 5.1.45)
[mysqld(api)] 3 node(s)
id=4 (not connected, accepting connect from 192.168.6.160)
id=5 (not connected, accepting connect from 192.168.6.188)
id=6 (not connected, accepting connect from 192.168.6.191)可以看到ndb_mgmd 是 连上的,nbd 和 mysqld 还没有连上~
二.在两个ndbd 节点 db1,db2 安装mysql
./configure --prefix=/usr/local/mysql/ --with-charset=utf8 --with-collation=utf8_general_ci --with-client-ldflags=-all-static -with-mysqld-ldflags=-all-static --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-unix-socket-path=/tmp/mysql.sock --sysconfdir=/usr/local/mysql/etc --without-debug --with-mysqld-user=mysql --with-plugin=innobase --with-plugin-ndbcluster --with-plugin-partition
groupadd mysql
useradd -g mysql mysql
cd /usr/local/mysql
chown root.mysql . -r
/usr/local/mysql/bin/mysql_install_db --user=mysql
vim /usr/local/mysql/etc/my.cnf
[mysqld]
basedir = /usr/local/mysql/
datadir = /usr/local/mysql/var
user = mysql
port = 3306
socket = /tmp/mysql.sock
ndbcluster
ndb-connectstring=www.linuxidc.com
[mysql_cluster]
ndb-connectstring=www.linuxidc.com/usr/local/mysql/libexec/ndbd --initial ### 第一次启动需要 --initial 以后在启动不需要加随后启动两台ndbd 节点上的 mysql 服务
/usr/local/mysql/bin/mysqld_safe --user=mysql &然后在 mgm 服务器上查看
/usr/local/mysql/bin/ndb_mgm
-- ndb cluster -- management client --
ndb_mgm> show
cluster configuration
---------------------
[ndbd(ndb)] 2 node(s)
id=2 @192.168.6.160 (version: 5.1.45, nodegroup: 0)
id=3 @192.168.6.188 (version: 5.1.45, nodegroup: 0, master)
[ndb_mgmd(mgm)] 1 node(s)
id=1 @ (version: 5.1.45)
[mysqld(api)] 3 node(s)
id=4 @192.168.6.160 (version: 5.1.45)
id=5 @192.168.6.188 (version: 5.1.45)
id=6 (not connected, accepting connect from 192.168.6.191)从上面可以看出 两个 ndbd 节点 和 ndbd 上的两个mysql 服务已经连接上了。
三.db4安装mysql节点
./configure --prefix=/usr/local/mysql/ --with-charset=utf8 --with-collation=utf8_general_ci --with-client-ldflags=-all-static -with-mysqld-ldflags=-all-static --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-unix-socket-path=/tmp/mysql.sock --sysconfdir=/usr/local/mysql/etc --without-debug --with-mysqld-user=mysql --with-plugin=innobase --with-plugin-ndbcluster --with-plugin-partition
groupadd mysql
useradd -g mysql mysql
cd /usr/local/mysql
chown root.mysql . -r
/usr/local/mysql/bin/mysql_install_db --user=mysql
vim /usr/local/mysql/etc/my.cnf
[mysqld]
basedir = /usr/local/mysql/
datadir = /usr/local/mysql/var
user = mysql
port = 3306
socket = /tmp/mysql.sock
ndbcluster
ndb-connectstring=www.linuxidc.com
[mysql_cluster]
ndb-connectstring=www.linuxidc.com启动 mysql 服务
/usr/local/mysql/bin/mysqld_safe --user=mysql &回到 mgm 上查看是否正常
db1 $> /usr/local/mysql/bin/ndb_mgm
-- ndb cluster -- management client --
ndb_mgm> show
connected to management server at: localhost:1186
cluster configuration
---------------------
[ndbd(ndb)] 2 node(s)
id=2 @192.168.6.160 (version: 5.1.45, nodegroup: 0)
id=3 @192.168.6.188 (version: 5.1.45, nodegroup: 0, master)
[ndb_mgmd(mgm)] 1 node(s)
id=1 @ (version: 5.1.45)
[mysqld(api)] 3 node(s)
id=4 @192.168.6.160 (version: 5.1.45)
id=5 @192.168.6.188 (version: 5.1.45)
id=6 @192.168.6.191 (version: 5.1.45)好了,一切正常了,现在回到 mysql 节点上 创建和删除数据看是否同步。
那么就登录 db2 的 mysql
db2 $> /usr/local/mysql/bin/mysql -uroot -p
mysql >show databases;
+--------------------+
| database |
+--------------------+
| information_schema |
| mysql |
+--------------------+
2 rows in set (0.00 sec)
mysql > create database eric;
query ok, 1 row affected (0.39 sec)
mysql >show databases;
+--------------------+
| database |
+--------------------+
| information_schema |
| eric |
| mysql |
+--------------------+
3 rows in set (0.01 sec)好了,在看 db3 db4 上是否同步
db3 $> /usr/local/mysql/bin/mysql -uroot -p
mysql $> show databases;
+--------------------+
| database |
+--------------------+
| information_schema |
| eric |
| mysql |
+--------------------+db4 $> /usr/local/mysql/bin/mysql -uroot -p
mysql $> show databases;
+--------------------+
| database |
+--------------------+
| information_schema |
| eric |
| mysql |
+--------------------+
都看到了 eric 数据库·结束
,