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

Simple configuration of Mysql database cluster

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

Share

Shulou(Shulou.com)06/01 Report--

Environment:

192.168.5.155 mysql-mgm-node

192.168.5.156 mysql-sql-node1 mysql-data-node1

192.168.5.157 mysql-sql-node2 mysql-data-node2

Download the cluster software and upload it to each server.

1. Install the MGM node:

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

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

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

Create a log file storage directory

Mkdir / var/log/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:

[ndbd default]

NoOfReplicas=2

DataMemory=2048M

IndexMemory=512M

[ndb_mgmd]

Id=1

Hostname=192.168.5.155

DataDir=/var/log/mysql-cluster

[ndbd]

Id=11

HostName=192.168.5.156

DataDir=/usr/local/mysql/ndbdata

[ndbd]

Id=12

HostName=192.168.5.157

DataDir=/usr/local/mysql/ndbdata

[mysqld]

Id=21

HostName=192.168.5.156

[mysqld]

Id=22

HostName=192.168.5.157

[mysqld]

Id=23

2. Install data node and SQL node:

Yum install libaio

# groupadd mysql

# useradd mysql-g mysql

# mv mysql-cluster-gpl-7.2.9-linux2.6-x86_64.tar.gz / usr/local/

# cd / usr/local/

# tar zxvf mysql-cluster-gpl-7.2.9-linux2.6-x86_64.tar.gz

# rm-f mysql-cluster-gpl-7.2.9-linux2.6-x86_64.tar.gz

# mv mysql-cluster-gpl-7.2.9-linux2.6-x86_64 mysql

# chown-R mysql:mysql mysql

# cd mysql

# scripts/mysql_install_db-user=mysql

# cp support-files/my-medium.cnf / etc/my.cnf

# cp support-files/mysql.server / etc/init.d/mysqld

# vi / etc/my.cnf

Add:

Datadir=/usr/local/mysql/data/

Ndbcluster

Ndb-connectstring=192.168.5.155

[ndbd]

Connect-string=192.168.5.155

[mysql_cluster]

Ndb-connectstring=192.168.5.155

[ndb_mgm]

Connect-string=192.168.5.155

[ndb_mgmd]

Config-file=/var/lib/mysql-cluster/config.ini

3. Start related services

(1) start the services related to the management node:

# / usr/local/mysql/bin/ndb_mgmd-f / var/lib/mysql-cluster/config.ini

# netstat-lntpu

Tcp 0 0 0.0.0. 0. 0. 0. 0. 0. 0. 0. 0.

LISTEN 22907/ndb_mgmd

(2) start data node related services:

# / usr/local/mysql/bin/ndbd-- initial (the parameter-- initial is required for the first startup)

# netstat-lntpu

Mkdir / usr/local/mysql/ndbdata

Chmod 755 / usr/local/mysql/ndbdata

# service mysqld start

4. Functional testing:

[root@localhost bin] #. / ndb_mgm

-NDB Cluster-Management Client--

Ndb_mgm > show

Connected to Management Server at: localhost:1186

Cluster Configuration

-

[ndbd (NDB)] 2 node (s)

Id=11 @ 192.168.5.156 (mysql-5.5.28 ndb-7.2.9, Nodegroup: 0)

Id=12 @ 192.168.5.157 (mysql-5.5.28 ndb-7.2.9, Nodegroup: 0, Master)

[ndb_mgmd (MGM)] 1 node (s)

Id=1 @ 192.168.5.155 (mysql-5.5.28 ndb-7.2.9)

[mysqld (API)] 3 node (s)

Id=21 @ 192.168.5.156 (mysql-5.5.28 ndb-7.2.9)

Id=22 @ 192.168.5.157 (mysql-5.5.28 ndb-7.2.9)

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

You can close master to see whether the master status is transferred to another server; when An is off, modify B database and start A to see if the data is synchronized.

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