mysql cluster technology under windowsxp

1. Preparation
a. System environment: Windows Xp system
b. Mysql version: MySQL Server 5.5
c. Mysql cluster version: mysql-cluster-gpl-noinstall-7.1.10-win32.zip
d. Computers with 3
Nodes
IP Address
Management (MGMD) node
192.168.18.8
MySQL server (SQL) node “A”
192.168.18.11
MySQL server (SQL) node “B”
192.168.18.17
Data (NDBD) node “A”
192.168.18.11
Data (NDBD) node "B"
192.168.18.17
(Note) As of March 23, 2011, the latest version can be downloaded from the official website. Download
address: http://www.mysql.com/downloads/cluster/
2. Install software
a, decompress mysql- cluster-gpl-noinstall-7.1.10-win32.zip package
b, installation configuration of Management node.
  The Management node must be installed under the C disk, and it is the following directory (this is running
  This node reports an error, saying that the corresponding directory cannot be found). Generate c:/mysql/bin and C:/mysql/mysql-cluster on the machine with IP 192.168.18.8
  (after the first startup, a
  file similar to ndb_1_config.bin.1 will be generated in this folder, which seems to be for future Start the loaded
  configuration ) and the c:/mysql/bin/cluster-logs directory,
  copy ndb_mgmd.exe and ndb_mgm.exe to the c:/mysql/bin directory of 192.168.18.8 in the downloaded and decompressed file directory mysql
  /bin Down. Generate two files under c:/mysql/bin of 192.168.18.8, my.ini and
  config.ini, the content of my.ini is:
[mysql_cluster]
# Options for management node process
config-file=C:/mysql/ bin/config.ini
Contents of config.ini:
[NDBD DEFAULT]
NoOfReplicas=2
[MYSQLD DEFAULT]
[NDB_MGMD DEFAULT]
[TCP DEFAULT]
# Managment Server
[NDB_MGMD]
HostName=192.168.18.8 #Management node server IP address
# Storage Engines  
DataDir=C:/mysql/bin/cluster-logs
[NDBD]
HostName=192.168.18.11 #MySQL cluster IP address
DataDir= D:/Program Files/mysqlcluster/datanode/mysql
/bin/cluster-data        
#If it does not exist, then Create one (you can specify the address yourself)
[NDBD]
HostName=192.168.18.17 #MySQL cluster IP address
DataDir= D:/Program Files/mysqlcluster/datanode/mysql
/bin/cluster-data        
#If it does not exist, create one ( You can specify the address by yourself)
[MYSQLD]
HostName=192.168.18.11
[MYSQLD]
HostName=192.168.18.17
c. Installation and configuration of Data nodes Generate D:/Program Files/mysqlcluster /datanode/mysql
on the machine with IP 192.168.18.17
/bin, D:/Program Files/mysqlcluster/datanode/mysql
/cluster-data, D:/Program Files/mysqlcluster/datanode/mysql/bin
/cluster-data. In the downloaded decompression folder/bin, copy ndbd.exe to the
D:/Program Files/mysqlcluster/datanode/mysql
/bin directory of the 192.168.18.17 machine, and in D:/Program Files/
The my.ini file is generated under the mysqlcluster/datanode/mysql/bin directory. The content of the file is:
[mysql_cluster]
# Options for data node process:
ndb-connectstring=192.168.18.8 # location of management server
   is also on the 192.168.18.11 machine The same configuration can also be copied directly to
the 192.168.18.11 machine.
d. Installation and configuration of SQL node
Generate the D:/Program Files/mysqlcluster/sqlnode directory on the machine with IP 192.168.18.17
, and copy the downloaded decompressed folder directly to the D:/Program
Files/mysqlcluster/sqlnode/mysql directory Next,
generate the my.ini file under D:/Program Files/mysqlcluster/sqlnode/mysql, the file content is:
[mysqld]
# Options for mysqld process:
ndbcluster # run NDB storage engine
ndb-connectstring=192.168.18.8
# location of management server
Similarly, copy the entire folder of D:/Program Files/mysqlcluster/sqlnode to the
same directory of the 192.168.18.11 machine.
3. Start the cluster
Start each node in order, first Management node, then Data
nodes, and finally SQL nodes.
a. Start the Management node
and enter the command line under the 192.168.18.8 machine, go to the c:/mysql/bin directory, and enter:
ndb_mgmd -f config.ini
b. Start the Data node
and enter the command line under the 192.168.18.17 machine, switch to Go to the D:/Program
Files/mysqlcluster/datanode/mysql/bin directory and enter:
ndbd --connect-string="nodeid1;host=192.168.18.8:1186"
to start the 192.168.18.11 machine in the same way, nodeid1 is based on the management node It
is determined by the id in the configuration file config.ini. If the id is 2, it will be nodeid2. If
the id is not specified in the configuration file, it will be executed in order.
(Note) At this point, you can open a new command line in the Management node, go to the
c:/mysql/bin directory and enter the command:
ndb_mgm
Start ndb_mgm.exe, and then enter the command:
ALL STATUS
to check whether the Data node connection is successful. After the startup is normal, you can continue to start
SQLnode
c. Start SQL node and  
enter the command line under the 192.168.18.17 machine, go to D:/Program
Files/ In the mysqlcluster/sqlnode/mysql/bin directory, enter:
mysqld --console
and start the SQL node under 192.168.18.11 in the same way.
(Note): Under the Management node machine, go to the c:/mysql/bin directory and
enter the command:
ndb_mgm
to start ndb_mgm.exe, and then enter the command:
SHOW
to view the connection status of each node.
The correct display should be:

ndb_mgm> show

Cluster Configuration

———————

[ndb_mgmd(MGM)] 1 node(s)

id=1 @192.168.18.8 (mysql-5.5 ndb-7.1.10)

[ndbd(NDB) ] 2 node(s)

id=2 @192.168.18.17 (mysql-5.5 ndb-7.1.10, Nodegroup: 0,

Master)

id=3 @192.168.18.11 (mysql-5.5 ndb-7.1.10, Nodegroup: 1)

[mysqld(API)] 2 node(s)


id=4 @192.168.18.17 (mysql-5.5 ndb-7.1.10)


id =5 @192.168.18.11 (mysql-5.5 ndb-7.1.10)

4. Test

C:\>mysql -u root test


mysql>create table city (nId mediumint unsigned not null

auto_increment primary key, sName varchar(20) not null )

engine = ndbcluster default charset utf8;

mysql>insert city values(1, 'city-1');
mysql>insert city values(1, 'city-2');

log in to mysql on another SQL node, from the table Get records in city:

C:\>mysql -u root test

mysql>select * from city;

When the cluster system works normally, you should be able to get all the previously inserted records.

Additional tests (single point of failure testing):

1. You can also manually stop a certain data node (Ctrl+C interrupts the DOS command ndbd.exe to stop the service) to see if all SQL nodes can work normally.

2. Perform database operations after a certain data node stops. Then restart the data node to see if all the SQL nodes in the cluster can get the complete data.

5. Close

ndb_mgm -e shutdown

or execute the shutdown command in the ndb_mgm environment.

The above command or shut down the management node service and all data nodes. Shutting down the cluster system

randomly or forcibly (shutting down or shutting down the process) will lead to data loss due to not all data being written back to the disk.

6. Common problems and extensions

Configuring and managing MySQL cluster systems is not an easy task. System problems caused by unreasonable configurations

are very common, such as network failures, memory limitations, etc., which will cause the arbitration system to forcibly shut down

data nodes.

If MySQL Server has already been installed on the machine, be sure to uninstall the original database

system. Note that the mysql.exe program in the cluster system is different from the management Client in the non-cluster system

.

It can also be combined with a load balancing system to provide stronger availability and data access efficiency.

There may be some unexpected failures in the cluster system due to unknown bugs or other reasons. Therefore, it is recommended that

when selecting a version, choose a version that has been approved by most people, not necessarily the latest version, which

is often not stable. Of course, don't choose a version that is too old and has limited functions.

7. Analysis of the advantages and disadvantages of mysql

1. Scalability

mysql cluster provides scalability in five different levels.

If you need more storage or capacity, you can dynamically add data nodes without affecting the service. You can dynamically add application nodes to improve performance and parallel processing capabilities. Clients connected to application

nodes can dynamically add additional CPUs, cores, and threads on data nodes to be

fully utilized by using multi-threaded NDB processes. Databases can be replicated to other databases for read

operations or used

2. Performance Mysql

cluster provides scalability at five different levels. When combined with the following features, it can

greatly improve performance:

NDB API or NDB/J
primary key lookup

and its distributed application Design

User-defined distinction

Parallelization

Batch transactions

High-performance network interface (SCI)

3. High availability

Data nodes can fail, but can be automatically resynchronized without affecting services or forcing application

nodes to reconnect. Furthermore, multiple management nodes and application nodes can be added to provide maximum

service. It is also possible to perform inter-cluster replication on different geographic unknowns.

4. After some modifications, the application program of mysql cluster can be faster than using other databases.
Mysql cluster disadvantages:
1. mysql cluster, data nodes, management servers, and clients must run on

LINUX or UNIX operating systems that support clusters. MYSQL Cluster 7.0 started on the development system (not the production system)

Provides support for the windows platform.

2. All machines in the cluster must have the same architecture.

3. Data storage
For example: unindexed data can be stored on disk, but indexed columns must be stored in memory.
The larger the database, the more memory and hardware you need.
4. Applications that use complete JOIN or full table scans are likely to experience extremely poor performance.
Because the data in the cluster is partitioned and distributed across multiple data nodes. Applications that use the primary key lookup method
can get the most benefit from the cluster's distributed data.
5. The NDB storage engine does not support foreign keys.
6. The NDB storage engine does not support full-text retrieval
. 7. Compared with other storage engines, the performance of the NDB storage engine will not be better

Guess you like

Origin blog.csdn.net/oligaga/article/details/132691377