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 Cluster 7.2.4 Cluster in MySQL

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

It is believed that many inexperienced people have no idea about how to configure Cluster 7.2.4 cluster in MySQL. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

Prepare 3 servers for 32-bit and 64-bit versions

202.38.128.153 dbs2 64 bit

202.122.32.68 dbs1 64 bit

192.168.32.22 erpdbtest 32 bit

Management Node (ndb_mgmd) 192.168.32.22 erpdbtest 32-bit

Data Node (ndbd) 202.122.32.68 dbs1 64 bit 202.38.128.153 dbs2 64 bit

SQL Node (mysqld) 202.122.32.68 dbs1 64 bit 202.38.128.153 dbs2 64 bit

Wget http://dev.mysql.com/get/Downloads/MySQL-Cluster-7.2/mysql-cluster-gpl-7.2.4-linux2.6-i686.tar.gz/from/http://gd.tuwien.ac.at/db/mysql/

Www.2cto.com

Uninstall Mysql

Rpm-qa | grep SQL

Rpm-e mysql...

Delete / etc/my.cnf / var/lib/mysql

Turn off the firewall

Iptables is a firewall included in most distributions. In the default installation of RHEL, the firewall is turned on and starts at random. If you want to turn off the firewall, you can use the following command:

Service iptables stop

After the above command is executed, the effect can only be maintained until the next restart. The configuration after reboot is restored. If you want to be able to keep the firewall off after reboot, you can use the following command:

Chkconfig-level 35 iptables off

Close SELinux

SELinux, whose full name is Security-EnhancedLinux, is an access control system developed by NSA of the US National Security Agency. SELinux can guarantee the security of Linux system to the maximum extent.

In the default installation of the Linux system, SELinux is enabled by default, and the configuration file is / etc/selinux/config. In general, the "permissive" mode is used in the testing process, so that a warning will only be issued when the SELinux rules are violated, and then the rules will be modified. Finally, the user feels whether to implement a strict "enforcing" policy to prohibit violations of the rule policy. Rules determine how SELinux works and how it works, and policies determine specific security details such as file system and file consistency. During installation, you can choose to activate, warn, or close SELinux. The default setting is activate.

In order to prevent SELinux from affecting the cluster function, it is necessary to turn off the function of the SELinux system.

1. Install the management node (192.168.32.22)

Extract the file www.2cto.com

Tar-zvxf mysql-cluster-gpl-7.2.4-linux2.6-i686.tar.gz

Create an installation directory

Mkdir-p / usr/local/mysql/bin

Mkdir-p / usr/local/mysql/ndbdata

Add execution file path

Vi / .bash_profile

PATH=$PATH:$HOME/bin:/usr/local/mysql/bin

Copy execution file

Cd mysql-cluster-gpl-7.2.4-linux2.6-i686

Cp bin/ndb_mgmd / usr/local/mysql/bin

Cp bin/ndb_mgm / usr/local/mysql/bin

Create a log file storage directory

Mkdir / var/lib/mysql-cluster

Create configuration file directories and files

Mkdir / usr/local/mysql/cluster-conf

Vi / usr/local/mysql/cluster-conf/config.ini

Edit the configuration file:

# the following is the content of configuration file #

[ndbd default]

NoOfReplicas=2 # number of replication members

DataMemory=80M # memory that can be allocated to the data store

IndexMemory=18M # Index stores memory that can be allocated

[ndb_mgmd] # define the IP address or hostname of the management node

Id=1

Hostname=192.168.32.22

DataDir=/var/lib/mysql-cluster

[ndbd] # define a data node

Id=11

HostName=202.122.32.68

DataDir=/usr/local/mysql/ndbdata

[ndbd] www.2cto.com

Id=12

HostName=202.38.128.153

DataDir=/usr/local/mysql/ndbdata

[mysqld] # define SQL node

Id=21

HostName=202.122.32.68

[mysqld]

Id=22

HostName=202.38.128.153

[mysqld]

Id=23

# above are the contents of the configuration file #

2. Install the data node (202.122.32.68 dbs1 202.38.128.153 dbs2)

Extract the file

Tar-zxvf mysql-cluster-gpl-7.2.4-linux2.6-x86_64.tar.gz

Create an installation directory

Mkdir-p / usr/local/mysql/bin

Mkdir-p / usr/local/mysql/ndbdata

Copy execution file

Cp mysql-cluster-gpl-7.2.4-linux2.6-x86_64/bin/ndbd / usr/local/mysql/bin

Add execution file path

Vi / .bash_profile

PATH=$PATH:$HOME/bin:/usr/local/mysql/bin

Create a profile:

Vi / etc/my.cnf

Add the following to the host:

[mysql_cluster] # configure data node connection management node

Ndb-connectstring=192.168.32.22

3. Install the SQL node (202.122.32.68 dbs1 202.38.128.153 dbs2):

Www.2cto.com

Extract the file

Tar-zxvf mysql-cluster-gpl-7.2.4-linux2.6-x86_64.tar.gz

Copy installation files

Mv mysql-cluster-gpl-7.2.4-linux2.6-x86_64 / usr/local/mysql

Add mysql user

Groupadd mysql

Useradd-g mysql mysql

Add permission

Chown-R mysql:mysql / usr/local/mysql

Copy configuration fil

Cp / usr/local/mysql/support-files/my-large.cnf / etc/my.cnf

Initialization

Cd / usr/local/

Scripts/mysql_install_db-user=mysql

Copy the files required by the daemon

Cp / usr/local/mysql/support-files/mysql.server / etc/rc.d/init.d/mysqld

Configure daemon

Chkconfig-add mysqld

Chkconfig-level 35 mysqld on

Add execution file path

Vi / .bash_profile

PATH=$PATH:$HOME/bin:/usr/local/mysql/bin

Change the configuration file

Vi / etc/my.cnf

Edit the following information separately:

[mysqld] # configure the SQL node to connect to the management node

Port = 3306

Socket = / tmp/mysql.sock

Ndbcluster

Ndb-connectstring=192.168.32.22

4. Start and shut down mysql cluster

Www.2cto.com

Startup sequence: manage servers-> Storage nodes-> SQL nodes

A, start the management node

Rm mysql/mysql-cluster/ndb_1_config.bin.1 # is not required and should be added if there are any changes to config.ini

Ndb_mgmd-f / usr/local/mysql/cluster-conf/config.ini

B. Start the storage node

Ndbd-initial # (options must be added for the first startup, backup / restore, and configuration file modifications also need to be performed)

Ndbd # is not the first time to start a command that needs to be executed

C. Start the SQL node

/ etc/rc.d/init.d/mysqld start or service mysqld start

After startup, you can use mysql-uroot-p to verify the mysql service status.

Closing order: SQL Node-> Management Node

A. Close the SQL node

/ etc/rc.d/init.d/mysqld stop or service mysqld stop

B. Close the management node

Ndb_mgm > shutdown

5. Verify the correctness of the configuration

You need to start the management node first, then start the data node, and then start the sql node after startup, otherwise you will make an error.

1. Execute on the management node: ndb_mgm-> show

Ndb_mgm > show

Cluster Configuration

-

[ndbd (NDB)] 2 node (s)

Id=11 @ 202.122.32.68 (mysql-5.5.19 ndb-7.2.4, Nodegroup: 0, Master) starts up

Id=12 @ 202.38.128.153 (mysql-5.5.19 ndb-7.2.4, starting, Nodegroup: 0) is starting

[ndb_mgmd (MGM)] 1 node (s)

Id=1 @ 192.168.32.22 (mysql-5.5.19 ndb-7.2.4)

[mysqld (API)] 3 node (s)

Id=21 @ 202.122.32.68 (mysql-5.5.19 ndb-7.2.4)

Id=22 @ 202.38.128.153 (mysql-5.5.19 ndb-7.2.4)

Id=23 (not connected, accepting connect from any host)

Www.2cto.com

Normal state

Ndb_mgm > show

Cluster Configuration

-

[ndbd (NDB)] 2 node (s)

Id=11 @ 202.122.32.68 (mysql-5.5.19 ndb-7.2.4, Nodegroup: 0, Master)

Id=12 @ 202.38.128.153 (mysql-5.5.19 ndb-7.2.4, Nodegroup: 0)

[ndb_mgmd (MGM)] 1 node (s)

Id=1 @ 192.168.32.22 (mysql-5.5.19 ndb-7.2.4)

[mysqld (API)] 3 node (s)

Id=21 @ 202.122.32.68 (mysql-5.5.19 ndb-7.2.4)

Id=22 @ 202.38.128.153 (mysql-5.5.19 ndb-7.2.4)

Id=23 (not connected, accepting connect from any host)

2. Create a database in one of the SQL nodes and add data. Do not operate until the start-up is finished.

Mysql-uroot-p

Create database ndbtest

Use ndbtest

CREATE TABLE `t1` (

`id`int (11) NOT NULL AUTO_INCREMENT

PRIMARY KEY (`id`)

) ENGINE=ndbcluster DEFAULT CHARSET=gbk

NDB: Could not acquire global schema lock (266) Time-out in NDB

If you add a database on one node before startup is complete, you cannot synchronize to other nodes.

3. On another SQL node, if the added database and data can exist, the configuration is successful.

Go to the sql node and create tables in the test database

CREATE TABLE `t1` (www.2cto.com

`id`int (11) NOT NULL AUTO_INCREMENT

PRIMARY KEY (`id`)

) ENGINE=ndbcluster DEFAULT CHARSET=gbk

Switch to 2 data node servers ~ / mysql/data/ndb_2_fs and ~ / mysql/data/ndb_3_fs

Or go directly to the database to check, the data has been synchronized!

Shut down the cluster service

Shutting down the sql node is equivalent to stopping the mysql service, and external data will no longer come in. Then close the management node

~ / mysql/bin/ndb_mgm-e shutdown

Rm ~ / mysql/mysql-cluster/ndb_1_config.bin.1 # is not required and should be added if there are any changes to config.ini

After doing so, both the management node and the data node will stop serving

Notes:

1: if you find the ndbd process shutting down on one machine and the ndbd process on the other machine shutting down, you need to modify the parameter NoOfReplicas.

2:./ndbd-initial cannot be executed on all data node machines at the same time. If executed, all data will be deleted.

3: you can manipulate mysqld nodes in the same way as non-clustered databases

4: every time you modify the config.ini file and restart ndb_mgmd, you need to delete the ndb_1_config.bin.1 file under the mysql-cluster file.

Because he calls this file by default

It is important that the 5:NDB cluster does not support automatic database discovery, and once the world database and its tables are created on one data node, you need to issue the command CREATE DATABASE world on each SQL node in the cluster, followed by FLUSH TABLES. In this way, the node can identify the database and read its table definition. (the database will also be synchronized automatically under this version of MySQL Cluster 7.1.5)

6: if the relevant node server starts, pay attention to check the relevant log files in the ~ / mysql/mysql-cluster directory for error messages.

The order of option values for each [mysqld], [ndbd] and [ndb_mgmd] configuration in the configuration file of the management node should be as follows:

[mysqld]

Id=4

HostName=192.168.208.3

Id is followed by HostName at the top. If the order is wrong, when the SQL or data node connects to the management node, the management node cannot be positioned correctly.

To its corresponding node configuration.

Because the corresponding node configuration cannot be located, when the client node starts (. / mysqld or. / ndbd) when there are no empty nodes left

It will also be reported:

Configuration error: Error: Could not alloc node id at 192.168.0.231 port 1186: No free www.2cto.com

Node id found for mysqld

(API). Failed to initialize consumers

Empty nodes are all empty nodes with no HostName option specified. Empty nodes can be used to dynamically configure some dynamic IP nodes.

In general, the configuration file of the management node should reserve more than 3 empty nodes, because one node needs to be connected when backing up, as follows:

[mysqld]

Id=6

# ps-ef | grep mysql

Root 13882 10 15:25 pts/5 00:00:00 / bin/sh / usr/local/mysql/bin/mysqld_safe-- datadir=/usr/local/mysql/data-- pid-file=/usr/local/mysql/data/dbs1.pid

Mysql 14185 13882 0 15:25 pts/5 00:00:00 / usr/local/mysql/bin/mysqld-basedir=/usr/local/mysql-datadir=/usr/local/mysql/data-plugin-dir=/usr/local/mysql/lib/plugin-user=mysql-log-error=/usr/local/mysql/data/dbs1.err-pid-file=/usr/local/mysql/data/dbs1.pid-socket=/tmp/mysql.sock-port=3306

After reading the above, have you mastered how to configure the Cluster 7.2.4 cluster in MySQL? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

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