Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure MySQL Cluster on the same host

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly shows you "how to configure MySQL Cluster on the same host", which is easy to understand and clear. I hope it can help you solve your doubts. Let me lead you to study and learn this article "how to configure MySQL Cluster on the same host".

MySQL cluster is a cluster of share nothing and uses ndb storage engine. Unlike Oracle's RAC, which uses centralized storage, it is a distributed architecture, so it is easy to configure MySQL Cluster on the same host, which is much simpler than RAC.

In MySQL Cluster, there are three different nodes:

Management node: the daemon is ndb_mgmd, which is used to manage cluster.

Data node: the daemon is ndbd, which is used to store data

SQL node: the daemon is mysqld, which is a MySQL instance for client connections to access data.

This article will configure the above three nodes simultaneously on a 64-bit linux host. In the actual production environment, nodes can be deployed on the same or different machines as needed. This example consists of the following nodes:

A management node

Two data nodes

Three SQL nod

Download Mysql cluster, current version 7.0.6, http://dev.mysql.com/downloads/cluster/7.0.html

Extract and copy to the installation directory

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

Create a data directory for three MySQL instances

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

The Cluster configuration file is as follows

$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

The three MySQL instance configuration files are as follows

$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

Initialize three MySQL instances

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

Initialize the management node

Bin/ndb_mgmd-- initial-f conf/config.ini-- configdir=/u01/mysql-cluster

Go to the management node to view the configuration

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 | 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)

Initialize the data node

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

Start the SQL node

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 changeable! 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 createdwaters 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 logfile. / 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 logfile. / 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 tmp/mysql.sock'port 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 writablebin/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)

Create a test table

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) 23:22:32 [Note] NDB Binlog: logging. / test/test_ndb (UPDATED,USE_WRITE) Query OK, 0 rows affected (090621 sec) root@test 11:22:32 > insert into test_ndb values Query OK 1 row affected (0.02 sec) [mysql@dbconsole mysql-cluster] $ls-l data/data1/testtotal 12 RW ql@dbconsole mysql-cluster-1 mysql dba 8578 Jun 21 23:22 test_ndb.frm-rw-rw---- 1 mysql dba 0 Jun 21 23:22 test_ ndb.nbb [mys ql@dbconsole mysql-cluster] $ls-l data/data2/testtotal 12 RW ql@dbconsole mysql-cluster-1 mysql dba 8578 Jun 21 23:22 test_ndb.frm-rw-rw- -1 mysql dba 0 Jun 21 23:22 test_ ndb.ndb.ndb [MySQL @ dbconsole mysql-cluster] $ls-l data/data3/testtotal 12 RWMurray RWFok-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) above are all the contents of the article "how to configure MySQL Cluster on the same host". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report