Mysql-cluster-gpl-7.1.19 compilation and Installation

Source: Internet
Author: User

Mysql-cluster-gpl-7.1.19 compilation and Installation

Reference: http://www.xtopace.com/database/mysql-cluster-7-1%E7%BC%96%E8%AF%91%E5% AE %89%E8%A3%85%E6%95%99%E7%A8%8B.html

Software Download:
Ftp://mirror.switch.ch/mirror/mysql/Downloads/MySQL-Cluster-7.1/
Select mysql-cluster-gpl-7.1.19.tar.gz download

Configuration Description: the cluster is installed on two nodes. One node runs multiple services. gd86 is a management node, a data node, and an SQL node.
Datadir =/sdb1/MySQL-cluster/Data
[Ndb_mgmd] MGM node gd86
[Ndbd] data nodes (NDB node) gd86 and gd87
[Mysqld] SQL nodes gd86 and gd87

Compile and install the mysql-cluster-gpl-7.1.19 by doing the following on all nodes
========================================================== ======================================
Groupadd MySQL # create a MySQL Group
Useradd-G MySQL # create a MySQL user

Mkdir-P/sdb1/MySQL-Cluster
Mkdir-P/sdb1/MySQL-cluster/etc
Mkdir-P/sdb1/MySQL-cluster/tmp
Mkdir-P/sdb1/MySQL-cluster/Data

Tar zxf mysql-cluster-gpl-7.1.19.tar.gz

CD mysql-cluster-gpl-7.1.19

. /Configure -- prefix =/sdb1/MySQL-cluster -- With-charset = GBK -- With-collation = gbk_chinese_ci -- With-client-ldflags =-all-static-with-mysqld-ldflags =-all-static -- enable-runner er -- With-extra-charsets = Complex -- enable-thread-safe-client -- With-big-tables
-- With-Readline -- With-SSL -- With-embedded-server -- enable-local-infile -- With-Unix-socket-Path =/sdb1/MySQL-cluster/tmp/MySQL. sock -- sysconfdir =/sdb1/MySQL-cluster/etc -- without-Debug -- With-mysqld-user = MySQL -- With-plugins = max

Make & make install

Rm-RF mysql-cluster-gpl-7.1.19
========================================================== ======================================

(1) create a cluster configuration file on the Management node gd86.
[Root @ gd86 mysql-cluster] # Vim ETC/config. ini
[Ndbd default]
Noofreplicas = 2 #2 replicas
[Mysqld default]
[Ndb_mgmd default]
Datadir =/sdb1/MySQL-cluster/data # data storage directory
[Ndb_mgmd] # management Node
Hostname = gd86
[Ndbd] # Data Node
Hostname = gd86
Datadir =/sdb1/MySQL-cluster/Data
[Ndbd] # Data Node
Hostname = gd87
Datadir =/sdb1/MySQL-cluster/Data
[Mysqld] # SQL Node
Hostname = gd86
[Mysqld] # SQL Node
Hostname = gd87

(2) Start the ndb_mgmd service on the MGM node of the Management Node
[Root @ gd86 mysql-cluster] # libexec/ndb_mgmd-f etc/config. ini
MySQL Cluster Management Server mysql-5.1.56 ndb-7.1.19
[Root @ gd86 mysql-cluster] # ps-Ef | grep NDB
Root 20227 1 0? 00:00:07/sdb1/MySQL-cluster/libexec/ndb_mgmd-f Data/config. ini
Root 20886 20806 0 00:00:00 pts/1 grep NDB

View the cluster status on the MGM Node
[Root @ gd86 mysql-cluster] # bin/ndb_mgm
-- NDB Cluster -- management client --
Ndb_mgm> show # view the cluster status on the Management Node
Connected to management server at: localhost: 1186
Cluster configuration
---------------------
[Ndbd (NDB)] 2 node (s) from here we can see that both data (ndbd) nodes are not started
Id = 2 (not connected, accepting connect from gd86)
Id = 3 (not connected, accepting connect from gd87)

[Ndb_mgmd (MGM)] 1 node (s) Management node started successfully
Id = 1 @ 10.10.104.86 mysql-5.1.56 ndb-7.1.19)

[Mysqld (API)] 2 node (s) Two MySQL nodes are not started
Id = 4 (not connected, accepting connect from gd86)
Id = 5 (not connected, accepting connect from gd87)

Ndb_mgm> exit

(3) perform the following (1) (2) (3) (4) operations on each data node (NDB node ):

(1) create a data dictionary
Specify the data directory and user.
[Root @ gd87 mysql-cluster] # bin/mysql_install_db -- user = MySQL -- datadir =/sdb1/MySQL-cluster/Data
--------------------------------------------
Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
Support-files/MySQL. Server to the right place for your system

Please remember to set a password for the MySQL Root User!
To do so, start the server, then issue the following commands:

/Sdb1/MySQL-cluster/bin/mysqladmin-u Root Password 'new-password'
/Sdb1/MySQL-cluster/bin/mysqladmin-u root-H gd87 password 'new-password'

Alternatively you can run:
/Sdb1/MySQL-cluster/bin/mysql_secure_installation

Which will also give you the option of removing the test
Databases and anonymous user created by default. This is
Stronugly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon:
CD/sdb1/MySQL-cluster;/sdb1/MySQL-cluster/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
CD/sdb1/MySQL-cluster/MySQL-test; Perl mysql-test-run.pl

Please report any problems with the/sdb1/MySQL-cluster/bin/mysqlbug script!
--------------------------------------------
(2) Create the my. CNF configuration file
[Root @ gd87 mysql-cluster] # Vim ETC/My. CNF

[Mysqld]
Basedir =/sdb1/MySQL-cluster/
Datadir =/sdb1/MySQL-cluster/Data
User = MySQL
Port = 3306
Socket =/sdb1/MySQL-cluster/tmp/MySQL. Sock
Ndbcluster
# Manage node IP addresses
NDB-connectstring = 10.10.104.86
[Mysql_cluster]
# Manage node IP addresses
NDB-connectstring = 10.10.104.86

(3) Start the ndbd Service
The -- initial option must be added when the ndbd service is started for the first time.
[Root @ gd87 mysql-cluster] # libexec/ndbd -- Initial
16:43:06 [ndbd] info -- angel connected to '10. 10.104.86: 1186'
2012-04-29 16:43:06 [ndbd] info -- angel allocated nodeid: 3

(4) Replace the owner of all content in the mysql-cluster directory with the MySQL user and MySQL group.
[Root @ gd87 mysql-cluster] # chown-r MYSQL: MySQL *

After the ndbd service on gd86 and gd87 is successfully started,
You can view the cluster status on the Management node or data node.
========================================================== ========================================================== ==========
[Root @ gd86 mysql-cluster] # bin/ndb_mgm
-- NDB Cluster -- management client --
Ndb_mgm> show
Connected to management server at: 10.10.104.86: 1186
Cluster configuration
---------------------
[Ndbd (NDB)] 2 node (s) We can see that the ndbd service on both data nodes is started.
Id = 2 @ 10.10.104.86 (mysql-5.1.56 ndb-7.1.19, nodegroup: 0, Master)
Id = 3 @ 10.10.104.87 (mysql-5.1.56, nodegroup: 0)

[Ndb_mgmd (MGM)] 1 node (s)
Id = 1 @ 10.10.104.86 mysql-5.1.56 ndb-7.1.19)

[Mysqld (API)] 2 node (s)
Id = 4 (not connected, accepting connect from gd86)
Id = 5 (not connected, accepting connect from gd87)
========================================================== ========================================================== ==========

(4) perform (1) (2) (4) and (5) operations in (3) on each SQL Node

(5) Start the mysqld Process
[Root @ gd87 mysql-cluster] # bin/mysqld_safe &
[1] 11304
[Root @ gd87 mysql-cluster] #120429 17:11:18 mysqld_safe logging to '/var/log/mysqld. log '.
120429 17:11:18 mysqld_safe starting mysqld daemon with databases from/sdb1/MySQL-cluster/Data

[Root @ gd87 mysql-cluster] #120429 17:11:19 mysqld_safe mysqld from PID file/var/run/mysqld. PID ended

[1] + done bin/mysqld_safe

Service startup failed. Check the log/var/log/mysqld. log and find the following statement:
######################################## ##
120429 17:11:19 [note] NDB [0]: nodeid: 5, all storage nodes connected
120429 17:11:19 [Warning] NDB: Server Id set to zero-changes logged to bin log with server ID zero will be logged with another server ID by slave mysqlds
120429 17:11:19 [note] Starting cluster BINLOG thread
120429 17:11:19 [Error] fatal error: Can't open and lock privilege tables: Table 'mysql. host' doesn' t exist
120429 17:11:19 mysqld_safe mysqld from PID file/var/run/mysqld. PID ended
######################################## ##
The solution is to specify the data directory when creating a data dictionary on all data nodes or SQL nodes. The command is as follows:
[Root @ gd87 mysql-cluster] # bin/mysql_install_db -- user = MySQL -- datadir =/sdb1/MySQL-cluster/Data
Then, restart the MySQL process,
[Root @ gd87 mysql-cluster] # ps-Ef | grep MySQL
Root 11495 11229 0 00:00:00 pts/8/bin/sh bin/mysqld_safe
MySQL 11587 11495 0 00:00:00 pts/8/sdb1/MySQL-cluster/libexec/mysqld -- basedir =/sdb1/MySQL-cluster -- datadir =/sdb1/MySQL-cluster/data -- user = MySQL -- log-error =/var/log/mysqld. log -- PID-file =/var/run/mysqld. PID -- socket =/sdb1/MySQL-cluster/tmp/MySQL. sock
-- Port = 3306
Root 11610 11229 0 00:00:00 pts/8 grep -- color = auto MySQL

After the mysqld service on gd86 and gd87 data nodes is successfully started,
You can view the cluster status on the Management node or data node.
[Root @ gd86 mysql-cluster] # bin/ndb_mgm
-- NDB Cluster -- management client --
Ndb_mgm> show
Connected to management server at: 10.10.104.86: 1186
Cluster configuration
---------------------
[Ndbd (NDB)] 2 node (s)
Id = 2 @ 10.10.104.86 (mysql-5.1.56 ndb-7.1.19, nodegroup: 0, Master)
Id = 3 @ 10.10.104.87 (mysql-5.1.56, nodegroup: 0)

[Ndb_mgmd (MGM)] 1 node (s)
Id = 1 @ 10.10.104.86 mysql-5.1.56 ndb-7.1.19)

[Mysqld (API)] 2 node (s) Two MySQL nodes are successfully started.
Id = 4 @ 10.10.104.86 mysql-5.1.56 ndb-7.1.19)
Id = 5 @ 10.10.104.87 (mysql-5.1.56 ndb-7.1.19)

$ $

(5) test MySQL cluster on the SQL node. Test NDB engine synchronization.

Create a data table on the first MySQL node gd87.
Create a data table stuinfo in the test database and insert the data.

[Root @ gd87 mysql-cluster] # bin/mysqladmin-uroot password '000000' change the password of the root user to 111111
[Root @ gd87 mysql-cluster] # bin/MySQL-uroot-P connect to MySQL Cluster
Enter password:
Welcome to the MySQL monitor. commands end with; or \ G.
Your MySQL connection ID is 4
Server version: 5.1.56-ndb-7.1.19 Source Distribution

Copyright (c) 2000,201 0, Oracle and/or its affiliates. All rights reserved.
This software comes with absolutely no warranty. This is free software,
And you are 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> show databases;
+ -------------------- +
| Database |
+ -------------------- +
| Information_schema |
| MySQL |
| Ndb_3_fs |
| Ndbinfo |
| Test |
+ -------------------- +
5 rows in SET (0.00 Sec)

Mysql> select now (), @ version;
+ --------------------- + ------------------- +
| Now () | @ version |
+ --------------------- + ------------------- +
| 17:31:55 | 5.1.56-ndb-7.1.19 |
+ --------------------- + ------------------- +
1 row in SET (0.00 Sec)

Mysql> use test;
Database changed
Mysql> show tables;
Empty set (0.02 Sec)

Mysql> Create Table stuinfo (stuid int (5) primary key, name varchar (30) engine = NDB; when creating a table, specify the Data Engine as NDB.
Query OK, 0 rows affected (0.29 Sec)

Mysql> insert into stuinfo values (1, 'zhankunlin ');
Query OK, 1 row affected (0.00 Sec)

Mysql> select * From stuinfo;
+ ------- + ------------ +
| Stuid | Name |
+ ------- + ------------ +
| 1 | zhankunlin |
+ ------- + ------------ +
1 row in SET (0.00 Sec)

View the data on the second MySQL node gd86.

[Root @ gd86 mysql-cluster] # bin/mysqladmin-uroot password '000000' modify the root user password of the MySQL database. The following error occurs:
Bin/mysqladmin: connect to server at 'localhost' failed
Error: 'Can't connect to local MySQL server through socket '/var/lib/MySQL. Sock' (2 )'
Check that mysqld is running and that the socket: '/var/lib/MySQL. Sock' exists!

This is because the socket used is not/var/lib/MySQL. Sock, but/sdb1/MySQL-cluster/tmp/MySQL. Sock,

This is specified in the configuration file ETC/My. CNF. In fact, it can be not specified during compilation. In this case, the default socket is used, that is,/var/lib/MySQL. Sock.
Therefore, run the following command:
[Root @ gd86 mysql-cluster] # bin/mysqladmin-uroot password '000000'-S/sdb1/MySQL-cluster/tmp/MySQL. Sock
Socket is also specified during login.
[Root @ gd86 mysql-cluster] # bin/MySQL-uroot-p-S/sdb1/MySQL-cluster/tmp/MySQL. Sock
Enter password:
Mysql> use test;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with-

Database changed
Mysql> show tables;
+ ---------------- +
| Tables_in_test |
+ ---------------- +
| Stuinfo |
+ ---------------- +
1 row in SET (0.03 Sec)

Mysql> select * From stuinfo;
+ ------- + ------------ +
| Stuid | Name |
+ ------- + ------------ +
| 1 | zhankunlin |
+ ------- + ------------ +
1 row in SET (0.00 Sec)

We can see that the data can also be viewed in gd86, and we can see that the data is synchronized.

$ $

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.