Mysql-cluster 7.x installation (Linux and Windows)

Source: Internet
Author: User
Tags centos server

Linux

Http://www.cnblogs.com/smalldirector/archive/2011/12/28/2304353.html

MySQL Cluster is a high-utility, high-redundancy version of MySQL suitable for distributed computing environments. It employs the NDB Cluster storage engine, allowing multiple MySQL servers to run in 1 Cluster. MySQL Cluster is a technology that allows the Cluster of an "in-memory" database to be deployed in a system that is not shared. With no shared architecture, the system can use inexpensive hardware and has no special requirements for hardware and software. In addition, because each component has its own memory and disk, there is no single point of failure.

First we download MySQL Cluster, download the link address for MySQL Cluster 7.1.17, we use the server for CentOS server and Ubuntu server, so we download the version for Linux generic.

Now I have three servers, two are CentOS server, one is Ubuntu server, the first two server as data node and SQL node (data node and SQL node on the same machine),

The latter as management Node, if there is no real machine, can be simulated with the virtual machine, the following is my IP deployment:

1 192.168.56.10     Data node + Sql node
2 192.168.56.20 Data node +sql node
3 192.168.56.30 Management Node

Here is the approximate topology diagram structure of my machine:

Next we need to do a detailed configuration of these nodes:

1. Configure Data node and SQL node

Currently we are using three machine strategy, so put these two nodes on the same machine, so we in a configuration on it.

First of all, we 192.168.56.10 this machine on the operation configuration, 192.168.56.20 operation configuration and such

We need to perform subordinate operations under the root account, and if you encounter a problem with command not found in CentOS, refer to my Blogcentos system Bash:groupadd:command not found problem

Next we will create a new user group and user with the following command:

1 Groupadd MySQL
2 useradd–g MySQL MySQL

Place the MySQL cluster under/usr/local/and execute the command:

1 tar-c/usr/local-xzvf mysql-cluster-gpl-7.1.17-linux-i686-glibc23.tar.gz
2 Ln-s/usr/local/mysql-cluster-gpl-7.1.17-linux-i686-glibc23/usr/local/mysql

Go to the MySQL directory and execute the database initialization command:

1 scripts/mysql_install_db--user=mysql

To make a permission change operation, the command is:

1 chown-r Root.
2 chown-r MySQL Data
3 chgrp-r MySQL.

2. Configure Management Node

Put the NDB_MGMD and NDB_MGM script files under the/usr/local/bin directory with the following command:

1 TAR-ZXVF mysql-5.1.56-ndb-7.1.17-linux-i686-glibc23.tar.gz
2 CD Mysql-5.1.56-ndb-7.1.17-linux-i686-glibc23
3 CP bin/ndb_mgm*/usr/local/bin

To change its corresponding permissions, the command is:

1 Cd/usr/local/bin
2 chmod +x ndb_mgm*

To create a new directory/var/lib/mysql-cluster/, the command is:

Mkdir-p/var/lib/mysql-cluster/

3. Configure the configuration files of three machines

The configuration file my.cnf is created under the/etc directory for both data nodes, with the following contents:

[Mysqld]
Ndbcluster
Datadir=/usr/local/mysql/data
Basedir=/usr/local/mysql
port=3306
[Mysql_cluster]
ndb-connectstring=192.168.56.10

If the MySQL database "Communications link failure due to underlying exception" issue appears during the run, please refer to this blog post for configuration.

For the 192.168.56.20 machine just replace the ndb-connectstring.

Create a Config.ini file under the Management node machine/etc directory with the contents:

1 [ndbd Default]
2 noofreplicas=2
3 datamemory=80m
4 indexmemory=18m

6 [NDB_MGMD]
7 nodeid=1
8 hostname=192.168.56.30
9 Datadir=/var/lib/mysql-cluster

[NDBD]
nodeid=2
hostname=192.168.56.10
Datadir=/usr/local/mysql/data

[NDBD]
Nodeid=3
hostname=192.168.56.20
Datadir=/usr/local/mysql/data

[Mysqld]
[Mysqld]

4. Start the cluster environment

First we need to start the Management node 192.168.56.30 machine, execute the command:

1 ndb_mgmd-f/etc/config.ini--initial

If the default Config directory '/usr/local/mysql/mysql-cluster ' does not exist this error message, create this folder manually.

Next we need to start the data node in 192.168.56.10 and 192.168.56.20, the command is:

1 bin/ndbd--initial

The first time to enable the need to add-initial parameters, the second start cannot add this parameter. Both machines execute the command separately.

Next, start the SQL node for both machines, and the command is:

1 Bin/mysqld_safe--user=mysql &

Both machines need to execute this command.
Finally go to the admin console to see if our cluster is configured to complete, enter the command:

1 Ndb_mgm–e Show

If the following information appears, the configuration is successful:

If you do not see the above information, it may be a firewall problem, you can choose to switch the CentOS firewall, the command is:

1/etc/init.d/iptables stop

Of course you can choose to configure the firewall, open up some necessary ports, you can refer to my other article CentOS Open 3306 port

Close the cluster and execute the command:

1 ndb_mgm–e shutdown

Windows

Http://www.xifenfei.com/1237.html

MySQL cluster configuration (windows2 machine Simulation)
1. Environmental planning
Win7 192.168.1.1 (Management node, storage node, SQL node)
WIN03 192.168.1.2 (storage node, SQL node)

2. Install cluster (Zip package)
Win7 Machine installed in D:\mysql-cluster
WIN03 Machine installed in C:\mysql-cluster
Storage node storage paths are: D:\mysql-cluster\ndbdata and C:\mysql-cluster\ndbdata

3. Win7 machine configuration
Create a D:\mysql-cluster\config.txt file with the content:

[NDBD DEFAULT]
noofreplicas=2
[NDB_MGMD]
Nodeid=1
hostname=192.168.1.1
Datadir=d:\mysql-cluster\data
[NDBD]
Nodeid=21
hostname=192.168.1.1
Datadir=d:\mysql-cluster\ndbdata
[NDBD]
Nodeid=22
hostname=192.168.1.2
Datadir=c:\mysql-cluster\ndbdata
[MYSQLD]
nodeid=11
hostname=192.168.1.1
[MYSQLD]
Nodeid=12
hostname=192.168.1.2

Copy D:\mysql-cluster\my-small.ini to C:\windows\my.ini and add
[Mysqld]
Ndbcluster
ndb-connectstring=192.168.1.1
[Mysql_cluster]
ndb-connectstring=192.168.1.1

4. WIN03 machine Configuration
Copy C:\mysql-cluster\my-small.ini to C:\windows\my.ini and add
[Mysqld]
Ndbcluster
ndb-connectstring=192.168.1.1
[Mysql_cluster]
ndb-connectstring=192.168.1.1

5. Start
5.1) Start the Management node (Win7)
D:\mysql-cluster\bin>ndb_mgmd.exe–-config-file=d:\mysql-cluster\config.txt–-configdir=d:\mysql-cluster

5.2) Start the storage node (no sequencing, first start using –initial, all storage nodes must be started before the SQL node can be started, so if only one node is tested, only

Modify Config.txt to one node)
Win7
D:\mysql-cluster\bin>ndbd.exe–-initial
Win03
C:\mysql-cluster\bin>ndbd.exe

5.3) Start the SQL node (no sequencing)
Win03
C:\mysql-cluster\bin>mysqld.exe–-defaults-file=c:\windows\my.ini
Win7
D:\mysql-cluster\bin>mysqld.exe–-defaults-file=c:\windows\my.ini

6. Check whether the start is successful
6.1) View status
D:\mysql-cluster\bin>ndb_mgm.exe

Output:
–ndb cluster-management client–

Input:
Ndb_mgm> Show

Output:
Connected to Management Server at:192.168.1.1:1186
Cluster Configuration
———————
[NDBD (NDB)] 2 node (s)
Id=21 @192.168.1.1 (mysql-5.1.56 ndb-7.1.15, nodegroup:0, Master)
Id=22 @192.168.1.2 (mysql-5.1.56 ndb-7.1.15, nodegroup:0)

[NDB_MGMD (MGM)] 1 node (s)
Id=1 @192.168.1.1 (mysql-5.1.56 ndb-7.1.15)

[Mysqld (API)] 2 node (s)
id=11 @192.168.1.1 (mysql-5.1.56 ndb-7.1.15)
Id=12 @192.168.1.2 (mysql-5.1.56 ndb-7.1.15)

6.2 Data Manipulation Testing
Create a table on Win7 and insert data
C:\users\xifenfei>mysql-uroot

Output:
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 2
Server VERSION:5.1.56-NDB-7.1.15-CLUSTER-GPL MySQL Cluster Server (GPL)

Copyright (c), Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of the Oracle Corporation and/or its
Affiliates. Other names trademarks of their respective
Owners.

Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.

mysql> use test;
Database changed
Mysql> CREATE TABLE City (
-ID mediumint unsigned NOT NULL auto_incremen
, name varchar (a) NOT NULL default "
Engine = ndbcluster default CharSet UTF8;
Query OK, 0 rows affected (9.60 sec)

Mysql> INSERT INTO city values (1, ' city1′);
Query OK, 1 row affected (0.41 sec)

Mysql> INSERT INTO city values (2, ' city2′);
Query OK, 1 row affected (0.01 sec)

Mysql> SELECT * from the city;
+--+ ——-+
| ID | name |
+--+ ——-+
| 1 | City1 |
| 2 | City2 |
+--+ ——-+
2 rows in Set (0.00 sec)

WIN03 Machine View Data
C:\mysql-cluster\bin>mysql-uroot

Output:
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 2
Server VERSION:5.1.56-NDB-7.1.15-CLUSTER-GPL MySQL Cluster Server (GPL)

Copyright (c), Oracle and/or its affiliates. All rights reserved.
This software comes with absolutely NO WARRANTY. This is the free software,
And you is welcome to modify and redistribute it under the GPL v2 license

Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.

mysql> use test;
Database changed
Mysql> Show tables;
+ —————-+
| Tables_in_test |
+ —————-+
| City |
+ —————-+
1 row in Set (0.11 sec)

Mysql> SELECT * from the city;
+--+ ——-+
| ID | name |
+--+ ——-+
| 1 | City1 |
| 2 | City2 |
+--+ ——-+
2 rows in Set (0.05 sec)

Today, doing experiments in that Daoteng MySQL database, later found that the service could not be started, check the log error as follows:

2015-01-07 17:48:54 9136 [ERROR] InnoDB:. \ibdata1 can ' t be opened in Read-write mode
2015-01-07 17:48:54 9136 [ERROR] innodb:the system tablespace must be writable!
2015-01-07 17:48:54 9136 [ERROR] Plugin ' InnoDB ' init function returned ERROR.
2015-01-07 17:48:54 9136 [ERROR] Plugin ' InnoDB ' registration as a STORAGE ENGINE failed.
2015-01-07 17:48:54 9136 [ERROR] unknown/unsupported storage Engine:innodb
2015-01-07 17:48:54 9136 [ERROR] Aborting

Workaround:

1. Open the Task Manager to terminate the MYSQLD process;

2. Open the Data folder of the MySQL installation directory and delete the following 2 files:

Ib_logfile0 and Ib_logfile1

3. Restart MySQL

Issue: [Warning] TIMESTAMP with implicit DEFAULT value is deprecated.
--explicit_defaults_for_timestamp Server Option (see
Documentation for more details).

Solve:

My.ini [mysqld] Add:

#开启查询缓存
Explicit_defaults_for_timestamp=true

Mysql-cluster 7.x installation (Linux and Windows)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.