1. 先了解一下你是否应该用mysql集群。
减少数据中心结点压力和大数据量处理,采用把mysql分布,一个或多个application对应一个mysql数据库。把几个mysql数据库公用的数据做出共享数据,例如购物车,用户对象等等,存在数据结点里面。其他不共享的数据还维持在各自分布的mysql数据库本身中。
2. 集群mysql中名称概念.(如上图)
1)sql结点(sql node--上图对应为mysqld):分布式数据库。包括自身数据和查询中心结点数据.
2)数据结点(data node -- ndbd):集群共享数据(内存中).
3)管理服务器(management server – ndb_mgmd):集群管理sql node,data node.
3.配置
mysql-max版本,当然现在mysql集群系统windonws平台上面不被支持.
安装mysql就不多说了,网上一大堆,简明扼要。
a:192.168.1.251 – data node和management server.
b:192.168.1.254 – sql node.
当然,你也可以让一个机器同时为3者。
a,b my.inf加上:
mysqld] ndbcluster # run ndb engine ndb-connectstring=192.168.1.251 # location of mgm node # options for ndbd process: [mysql_cluster] ndb-connectstring=192.168.1.251 # location of mgm node a: /var/lib/mysql-cluster/config.ini [ndbd default] noofreplicas=1 # 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. # tcp/ip options: [tcp default] portnumber=2202 # this the default; however, you can use any # port that is free for all the hosts in cluster # note: it is recommended beginning with mysql 5.0 that # you do not specify the portnumber at all and simply allow # the default value to be used instead # management process options: [ndb_mgmd] hostname=192.168.1.251 # hostname or ip address of mgm node datadir=/var/lib/mysql-cluster # directory for mgm node logfiles # options for data node a: [ndbd] # (one [ndbd] section per data node) hostname=192.168.1.251 # hostname or ip address datadir=/usr/local/mysql/data # directory for this data node's datafiles # sql node options: [mysqld] hostname=192.168.1.254 #[mysqld] #这个相当于192.168.1.251
