如何在同一台主机配置MySQL Cluster
发表于:2025-01-22 作者:千家信息网编辑
千家信息网最后更新 2025年01月22日,这篇文章主要为大家展示了"如何在同一台主机配置MySQL Cluster",内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下"如何在同一台主机配置MySQL Cl
千家信息网最后更新 2025年01月22日如何在同一台主机配置MySQL Cluster
这篇文章主要为大家展示了"如何在同一台主机配置MySQL Cluster",内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下"如何在同一台主机配置MySQL Cluster"这篇文章吧。
MySQL cluster是share nothing的集群,采用ndb存储引擎,和Oracle的RAC采用集中存储不同,是一种分布式的架构,所以可以很轻松的实现在同一台主机上配置MySQL Cluster,相对RAC来说要简单得多。
在MySQL Cluster中,有三种不同的节点:
管理节点:守护进程为ndb_mgmd,用于管理cluster。
数据节点: 守护进程为ndbd,用于存放数据
SQL节点:守护进程为mysqld,就是一个MySQL实例,对外供客户端连接访问数据。
本文将在一台64位linux主机上同时配置上述三种节点。在实际生产环境中,根据需要,可以在相同或者不同的机器部署节点。本次实例中共包含以下节点:
一个管理节点
两个数据节点
三个SQL节点
下载Mysql cluster,当前版本7.0.6,http://dev.mysql.com/downloads/cluster/7.0.html
解压,并复制到安装目录
tar zxvf mysql-cluster-gpl-7.0.6-linux-x86_64-glibc23.tar.gzcp mysql-cluster-gpl-7.0.6-linux-x86_64-glibc23 /u01/mysql-clustercd /u01/mysql-cluster
创建三个MySQL实例的数据目录
mkdir data/data1mkdir data/data2mkdir data/data3mkdir data/data1/mysqlmkdir data/data1/testmkdir data/data2/mysqlmkdir data/data2/testmkdir data/data3/mysqlmkdir data/data3/test
Cluster配置文件如下
$ more conf/config.ini[ndbd default]noofreplicas=2[ndbd]hostname=localhostid=2[ndbd]hostname=localhostid=3[ndb_mgmd]id = 1hostname=localhost[mysqld]id=4hostname=localhost[mysqld]id=5hostname=localhost[mysqld]id=6hostname=localhost
三个MySQL实例配置文件如下
$ more conf/my1.cnf[mysqld]ndb-nodeid=4ndbcluster=truedatadir=/u01/mysql-cluster/data/data1basedir=/u01/mysql-clusterport=9306server-id=1log-bin$ more conf/my2.cnf[mysqld]ndb-nodeid=5ndbcluster=truedatadir=/u01/mysql-cluster/data/data2basedir=/u01/mysql-clusterport=9307server-id=2log-bin$ more conf/my3.cnf[mysqld]ndb-nodeid=6ndbcluster=truedatadir=/u01/mysql-cluster/data/data3basedir=/u01/mysql-clusterport=9308server-id=3log-bin
初始化三个MySQL实例
script/mysql_install_db --basedir=/u01/mysql-cluster --datadir=/u01/mysql-cluster/data/data1script/mysql_install_db --basedir=/u01/mysql-cluster --datadir=/u01/mysql-cluster/data/data2script/mysql_install_db --basedir=/u01/mysql-cluster --datadir=/u01/mysql-cluster/data/data3
初始化管理节点
bin/ndb_mgmd --initial -f conf/config.ini --configdir=/u01/mysql-cluster
进入管理节点查看配置
$ bin/ndb_mgm-- NDB Cluster -- Management Client --ndb_mgm> help--------------------------------------------------------------------------- NDB Cluster -- Management Client -- Help---------------------------------------------------------------------------HELP Print help textHELP COMMAND Print detailed help for COMMAND(e.g. SHOW)SHOW Print information about clusterCREATE NODEGROUP,... Add a Nodegroup containing nodesDROP NODEGROUPDrop nodegroup with id NGSTART BACKUP [NOWAIT | WAIT STARTED | WAIT COMPLETED]START BACKUP [] [NOWAIT | WAIT STARTED | WAIT COMPLETED]START BACKUP [] [SNAPSHOTSTART | SNAPSHOTEND] [NOWAIT | WAIT STARTED | WAIT COMPLETED] Start backup (default WAIT COMPLETED,SNAPSHOTEND)ABORT BACKUPAbort backupSHUTDOWN Shutdown all processes in clusterCLUSTERLOG ON [] ... Enable Clus= ALERT | CRITICAL | ERROR | WARNING | INFO | DEBUG= STARTUP | SHUTDOWN | STATISTICS | CHECKPOINT | NODERESTART | CONNECTION| INFO | ERROR | CONGESTION | DEBUG | BACKUP= 0 - 15= ALL | Any database node idFor detailed help on COMMAND, use HELP COMMAND.ndb_mgm> showConnected to Management Server at: localhost:1186Cluster Configuration---------------------[ndbd(NDB)] 2 node(s)id=2 (not connected, accepting connect from localhost)id=3 (not connected, accepting connect from localhost)[ndb_mgmd(MGM)] 1 node(s)id=1 @localhost (mysql-5.1.34 ndb-7.0.6)[mysqld(API)] 3 node(s)id=4 (not connected, accepting connect from localhost)id=5 (not connected, accepting connect from localhost)id=6 (not connected, accepting connect from localhost)
初始化数据节点
bin/ndbd --initial -c localhost:11862009-06-21 23:13:19 [ndbd] INFO -- Configuration fetched from 'localhost:1186', generation: 1bin/ndbd --initial -c localhost:11862009-06-21 23:13:50 [ndbd] INFO -- Configuration fetched from 'localhost:1186', generation: 1
启动SQL节点
bin/mysqld --defaults-file=conf/my1.cnf&[1] 17843 090621 23:14:36 [Warning] No argument was provided to --log-bin,and --log-bin-index was not used; so replication may break when this MySQL server acts as a masterand has his hostname changed!! Please use '--log-bin=test-bin' to avoid this problem.InnoDB: The first specified data file ./ibdata1 did not exist:InnoDB: a new database to be created!090621 23:14:36 InnoDB: Setting file ./ibdata1 size to 10 MBInnoDB: Database physically writes the file full: wait...090621 23:14:36 InnoDB: Log file ./ib_logfile0 did not exist: new to be createdInnoDB: Setting log file ./ib_logfile0 size to 5 MBInnoDB: Database physically writes the file full: wait...090621 23:14:36 InnoDB: Log file ./ib_logfile1 did not exist: new to be createdInnoDB: Setting log file ./ib_logfile1 size to 5 MBInnoDB: Database physically writes the file full: wait...InnoDB: Doublewrite buffer not found: creating newInnoDB: Doublewrite buffer createdInnoDB: Creating foreign key constraint system tablesInnoDB: Foreign key constraint system tables created090621 23:14:36 InnoDB: Started; log sequence number 0 0090621 23:14:36 [Note] NDB: NodeID is 4, management server 'localhost:1186'090621 23:14:37 [Note] NDB[0]: NodeID: 4, all storage nodes connected090621 23:14:37 [Note] Starting Cluster Binlog Thread090621 23:14:37 [Note] Event Scheduler: Loaded 0 events090621 23:14:37 [Note] bin/mysqld: ready for connections.Version: '5.1.34-ndb-7.0.6-cluster-gpl-log' socket: '/tmp/mysql.sock'port: 9306 MySQL Cluster Server (GPL)090621 23:14:38 [Note] NDB Binlog: Ndb tables initially read only.090621 23:14:38 [Note] NDB: Creating mysql.ndb_schema090621 23:14:38 [Note] NDB Binlog: CREATE TABLE Event: REPL$mysql/ndb_schema090621 23:14:38 [Note] NDB Binlog: logging ./mysql/ndb_schema (UPDATED,USE_WRITE)090621 23:14:38 [Note] NDB: Creating mysql.ndb_apply_status090621 23:14:39 [Note] NDB Binlog: CREATE TABLE Event: REPL$mysql/ndb_apply_status090621 23:14:39 [Note] NDB Binlog: logging ./mysql/ndb_apply_status (UPDATED,USE_WRITE)2009-06-21 23:14:39 [NdbApi] INFO -- Flushing incomplete GCI:s < 20/32009-06-21 23:14:39 [NdbApi] INFO -- Flushing incomplete GCI:s < 20/3090621 23:14:39 [Note] NDB Binlog: starting log at epoch 20/3090621 23:14:39 [Note] NDB Binlog: ndb tables writable
bin/mysqld --defaults-file=conf/my2.cnf&bin/mysqld --defaults-file=conf/my3.cnf&
查看cluster
bin/ndb_mgm-- NDB Cluster -- Management Client --ndb_mgm> showConnected to Management Server at: localhost:1186Cluster Configuration---------------------[ndbd(NDB)] 2 node(s)id=2 @127.0.0.1 (mysql-5.1.34 ndb-7.0.6, Nodegroup: 0, Master)id=3 @127.0.0.1 (mysql-5.1.34 ndb-7.0.6, Nodegroup: 0)[ndb_mgmd(MGM)] 1 node(s)id=1 @127.0.0.1 (mysql-5.1.34 ndb-7.0.6)[mysqld(API)] 3 node(s)id=4 @127.0.0.1 (mysql-5.1.34 ndb-7.0.6)id=5 @127.0.0.1 (mysql-5.1.34 ndb-7.0.6)id=6 @127.0.0.1 (mysql-5.1.34 ndb-7.0.6)
创建测试表
bin/mysql -uroot -h localhost -P 9306 --socket=/tmp/mysql.sockWelcome to the MySQL monitor. Commands end with ; or g.Your MySQL connection id is 2Server version: 5.1.34-ndb-7.0.6-cluster-gpl-log MySQL Cluster Server (GPL)Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.root@(none) 11:21:24>use testDatabase changedroot@test 11:21:26>create table test_ndb(i int,a varchar(20),primary key(i)) engine=ndb;090621 23:22:32 [Note] NDB Binlog: CREATE TABLE Event: REPL$test/test_ndb090621 23:22:32 [Note] NDB Binlog: logging ./test/test_ndb (UPDATED,USE_WRITE)090621 23:22:32 [Note] NDB Binlog: DISCOVER TABLE Event: REPL$test/test_ndb090621 23:22:32 [Note] NDB Binlog: DISCOVER TABLE Event: REPL$test/test_ndb090621 23:22:32 [Note] NDB Binlog: logging ./test/test_ndb (UPDATED,USE_WRITE)090621 23:22:32 [Note] NDB Binlog: logging ./test/test_ndb (UPDATED,USE_WRITE)Query OK, 0 rows affected (1.10 sec)root@test 11:22:32>insert into test_ndb values(1,'NinGoo');Query OK, 1 row affected (0.02 sec)[mysql@dbconsole mysql-cluster]$ ls -l data/data1/testtotal 12-rw-rw---- 1 mysql dba 8578 Jun 21 23:22 test_ndb.frm-rw-rw---- 1 mysql dba 0 Jun 21 23:22 test_ndb.ndb[mysql@dbconsole mysql-cluster]$ ls -l data/data2/testtotal 12-rw-rw---- 1 mysql dba 8578 Jun 21 23:22 test_ndb.frm-rw-rw---- 1 mysql dba 0 Jun 21 23:22 test_ndb.ndb[mysql@dbconsole mysql-cluster]$ ls -l data/data3/testtotal 12-rw-rw---- 1 mysql dba 8578 Jun 21 23:22 test_ndb.frm-rw-rw---- 1 mysql dba 0 Jun 21 23:22 test_ndb.ndb$ bin/mysql -uroot -P 9307 --socket=/tmp/mysql.sockWelcome to the MySQL monitor. Commands end with ; or g.Your MySQL connection id is 3Server version: 5.1.34-ndb-7.0.6-cluster-gpl-log MySQL Cluster Server (GPL)Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.root@(none) 11:24:38>use testReading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changedroot@test 11:24:41>select * from test_ndb;+---+--------+| i | a |+---+--------+| 1 | NinGoo |+---+--------+1 row in set (0.02 sec)
以上是"如何在同一台主机配置MySQL Cluster"这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注行业资讯频道!
节点
配置
数据
主机
实例
管理
三个
不同
内容
篇文章
进程
文件
目录
存储
学习
帮助
相同
两个
分布式
同时
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
金山区移动网络技术开发行业标准
德化网络安全检查
成都睿驰网络技术有限公司
黄浦区网络技术咨询
服务器可靠性与稳定性的区别
cssci数据库类型
服务器插移动硬盘没显示
女性如何识别网络安全
手机开发安卓软件开发
多级分类的数据库设计
工商银行软件开发实习工资
广元定制软件开发
浪潮kdb数据库
网络安全答题测试
之前的云服务器不可用怎么办
网络安全第一课登录入口
网络安全平台利润
云服务器怎样使用
2012服务器安全组未放行
软件开发培训机构认准极客时间
什么是网络安全中的鱼叉
网络安全法有几章几条
网络安全管理机制不健全
_是数据库安全的第一道保障
女性如何识别网络安全
辽宁一体化智慧医养软件开发
富盟网络技术有限公司
天琪我的世界服务器
统计网络安全保密应急预案
网络安全设备割接