当前位置:Gxlcms > 数据库问题 > mysql-cluster集群原理介绍和搭建步骤(四个data/sql节点) (转)

mysql-cluster集群原理介绍和搭建步骤(四个data/sql节点) (转)

时间:2021-07-01 10:21:17 帮助过:3人阅读

/a datadir=/data/ndb" /etc/my.cnf


shell> /usr/local/mysql/scripts/mysql_install_db --user=root --basedir=/usr/local/mysql --datadir=/data/ndb


shell> chown mysql:mysql -R /data/ndb






//data/sql节点配置---(154/155/156/157)


shell> cd /usr/local/mysql/bin/


shell> cp ndb_mgm* /usr/local/bin/






shell> vim /etc/my.cnf


-------------------------


[mysql_cluster]


ndb-connectstring=10.10.54.154


[mysqld]


datadir=/data/ndb


ndbcluster


ndb-connectstring=10.10.54.154


-------------------------






//管理节点154配置


shell> mkdir -p /etc/ndb/config.ini


shell> vim /etc/ndb/config.ini


--------------------------------------


[NDBD DEFAULT]


NoOfReplicas=2


DataMemory=128M


IndexMemory=64M






[TCP DEFAULT]


portnumber=2202






[NDB_MGMD]


NodeId=1


hostname=10.10.54.154


datadir=/var/lib/mysql-cluster






[NDBD]


NodeId=2


hostname=10.10.54.154


datadir=/data/ndb


BackupDataDir=/data/backup






[NDBD]


NodeId=3


hostname=10.10.54.155


datadir=/data/ndb


BackupDataDir=/data/backup






[NDBD]


NodeId=4


hostname=10.10.54.156


datadir=/data/ndb


BackupDataDir=/data/backup






[NDBD]


NodeId=5


hostname=10.10.54.157


datadir=/data/ndb


BackupDataDir=/data/backup






[MYSQLD]


NodeId=7


hostname=10.10.54.154






[MYSQLD]


NodeId=8


hostname=10.10.54.155






[MYSQLD]


NodeId=9


hostname=10.10.54.156






[MYSQLD]


NodeId=10


hostname=10.10.54.157






[MYSQLD]


NodeId=11






[MYSQLD]


NodeId=12






[MYSQLD]


NodeId=13






[MYSQLD]


NodeId=14


------------------------------------

 

 

//启动mysql-cluster


---启动顺序management node--data node---sql node





#启动管理节点


shell> ndb_mgmd -f /var/lib/mysql-cluster/config.ini --initial


 ##--initial参数第一次启动时加上


#启动数据节点


shell> ndbd       #--initial ##初始化数据库,用在备份,恢复时


2014-02-27 18:14:23 [ndbd] INFO     -- Angel connected to ‘10.10.54.154:1186‘


2014-02-27 18:14:23 [ndbd] INFO     -- Angel allocated nodeid: 2





#启动sql节点


shell> /etc/init.d/mysqld start









//查看mysql集群状态


shell> ndb_mgm


ndb_mgm> show


Cluster Configuration


---------------------


[ndbd(NDB)] 4 node(s)


id=2 @10.10.54.154  (mysql-5.5.35 ndb-7.2.15, Nodegroup: 0, *)


id=3 @10.10.54.155  (mysql-5.5.35 ndb-7.2.15, Nodegroup: 0)


id=4 @10.10.54.156  (mysql-5.5.35 ndb-7.2.15, Nodegroup: 1)


id=5 @10.10.54.157  (mysql-5.5.35 ndb-7.2.15, Nodegroup: 1)





[ndb_mgmd(MGM)] 1 node(s)


id=1 @10.10.54.154  (mysql-5.5.35 ndb-7.2.15)






[mysqld(API)] 8 node(s)


id=7 @10.10.54.154  (mysql-5.5.35 ndb-7.2.15)


id=9 @10.10.54.155  (mysql-5.5.35 ndb-7.2.15)


id=10 @10.10.54.156  (mysql-5.5.35 ndb-7.2.15)


id=11 @10.10.54.157  (mysql-5.5.35 ndb-7.2.15)


id=12 (not connected, accepting connect from any host)


id=13 (not connected, accepting connect from any host)


id=14 (not connected, accepting connect from any host)


id=15 (not connected, accepting connect from any host)





//测试mysql-cluster


1.管理机上创建表


mysql> create database d1;


mysql> use d1;


mysql> CREATE TABLE `t_e` (


  `emp_no` int(11) NOT NULL,


  `birth_date` date NOT NULL,


  `first_name` varchar(14) NOT NULL,


  `last_name` varchar(16) NOT NULL,


  `gender` enum(‘M‘,‘F‘) NOT NULL,


  `hire_date` date NOT NULL,


  PRIMARY KEY (`emp_no`)


) ENGINE=ndbcluster DEFAULT CHARSET=utf8





2.mysql> insert into t_e select * from employees.employees;


##插入出错


ERROR 1297 (HY000): Got temporary error 233 ‘Out of operation records in transaction coordinator (increase MaxNoOfConcurrentOperations)‘ from NDBCLUSTER


#原因时插入数据量太大




mysql> insert into t_e select * from employees.employees limit 10000;


#插入成功



3.data节点上查看,数据已同步





//关闭mysql-cluster


1.先关闭sql节点


/etc/init.d/mysqld stop


2.在管理机上


shell> ndb_mgm


ndb_mgm> shutdown #关闭所有cluster进程

mysql-cluster集群原理介绍和搭建步骤(四个data/sql节点) (转)

标签:

人气教程排行