首页 > 代码库 > mysql cluster
mysql cluster
A B C 三台机器做mysql cluster
manage 10.251.124.38
sql node 10.251.128.56
data node 10.251.128.20
mysql-cluster-gpl-7.3.6-linux-glibc2.5-x86_64.tar.gz 软件版本
管理节点配置:
[root@VM_124_38_centos ~]# cat /var/lib/mysql-cluster/config.ini
# Options affecting ndbd processes on all data nodes:
[ndbd default]
NoOfReplicas=2 # Number of replicas
DataMemory=80M # How much memory to allocate for data storage
IndexMemory=18M # How much memory to allocate for index storage
# For DataMemory and IndexMemory, we have used the
# default values. Since the "world" database takes up
# only about 500KB, this should be more than enough for
# this example Cluster setup.
# Management process options:
[ndb_mgmd]
Id=1
Hostname=10.251.124.38 # Hostname or IP address of management node
Datadir=/usr/local/mysql/logs # Directory for management node log files
# Options for data node "A":
[ndbd]
Id=2
Hostname=10.251.128.20 # Hostname or IP address
Datadir=/usr/local/mysql/ndbdata # Directory for this data node‘s data files
# Options for data node "B":
[ndbd]
Id=3
Hostname=10.251.128.56 # Hostname or IP address
Datadir=/usr/local/mysql/ndbdata # Directory for this data node‘s data files
[MYSQLD]
NodeId=10
Hostname=10.251.128.56
[MYSQLD]
NodeId=11
Hostname=10.251.128.20
# SQL node options:
#[mysqld]
#Id=6
第一次初始化/usr/local/mysql/bin/ndb_mgmd -f /var/lib/mysql-cluster/config.ini --initial
以后启动 /usr/local/mysql/bin/ndb_mgmd -f /var/lib/mysql-cluster/config.ini
data节点配置:
[root@VM_128_56_centos ~]# cat /etc/my.cnf
[mysqld]
ndbcluster # run NDB storage engine
ndb-connectstring=10.251.124.38 # location of management server
# Options for ndbd process:
[mysql_cluster]
ndb-connectstring=10.251.124.38 # location of management server
[root@VM_128_56_centos ~]# cat /var/lib/mysql-cluster/config.ini
# Options for mysqld process:
[mysqld]
ndbcluster # run NDB storage engine
ndb-connectstring=10.251.124.38 # location of management server
# Options for ndbd process:
[mysql_cluster]
ndb-connectstring=10.251.124.38 # location of management server
第一次启动初始化/usr/local/mysql/bin/ndbd --initial
以后启动/usr/local/mysql/bin/ndbd
安装配置mysqld并启动
[root@VM_128_56_centos ~]# /usr/local/mysql/bin/ndbd
Unable to connect with connect string: nodeid=0,10.251.124.38:1186
Retrying every 5 seconds. Attempts left: 12 11 10 9 8 7 6
2014-10-27 12:01:05 [ndbd] INFO -- Angel connected to ‘10.251.124.38:1186‘
2014-10-27 12:01:05 [ndbd] INFO -- Angel allocated nodeid: 3
sql节点配置
[root@VM_128_20_centos ~]# cat /etc/my.cnf
[mysqld]
ndbcluster # run NDB storage engine
ndb-connectstring=10.251.124.38 # location of management server
# Options for ndbd process:
[mysql_cluster]
ndb-connectstring=10.251.124.38 # location of management server
安装配置mysqld并启动
第一次启动初始化/usr/local/mysql/bin/ndbd --initial
以后启动/usr/local/mysql/bin/ndbd
[root@VM_128_20_centos ~]# /usr/local/mysql/bin/ndbd
Unable to connect with connect string: nodeid=0,10.251.124.38:1186
Retrying every 5 seconds. Attempts left: 12 11 10 9 8 7 6 5
2014-10-27 12:01:06 [ndbd] INFO -- Angel connected to ‘10.251.124.38:1186‘
2014-10-27 12:01:07 [ndbd] INFO -- Angel allocated nodeid: 2
管理节点操作:
ndb_mgm> show
Connected to Management Server at: localhost:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=2 @10.251.128.20 (mysql-5.6.19 ndb-7.3.6, Nodegroup: 0, *)
id=3 @10.251.128.56 (mysql-5.6.19 ndb-7.3.6, Nodegroup: 0)
[ndb_mgmd(MGM)] 1 node(s)
id=1 @10.251.124.38 (mysql-5.6.19 ndb-7.3.6)
[mysqld(API)] 2 node(s)
id=4 @10.251.128.56 (mysql-5.6.19 ndb-7.3.6)
id=5 @10.251.128.20 (mysql-5.6.19 ndb-7.3.6)
注意事项:引擎必须是NDB 才能数据同步。
可以配置多个管理节点,数据全部内存缓存,掉电瞬间的数据会丢失。需要基于lvs做方案才能完美
其他参考:http://blog.csdn.net/chengfei112233/article/details/7703812
mysql cluster