I am trying to configure a mysql cluster in CentOS but i had some issues I dont know how to solve and I would really appreciate some help.
The mysql cluster environment:
DB1 - 192.168.50.101 - Management Server (MGM) node.
DB2 - 192.168.50.102 - Storage Server (NDBD) node 1.
DB3 - 192.168.50.103 - Storage Server (NDBD) node 2.
The steps I followed to configure the whole cluster:
Configure the Management Server node (192.168.50.101)
1.1 Install mysql server and start it:
# yum install mysql mysql-server
# chkconfig --levels 235 mysqld on
# /etc/init.d/mysqld start
1.2 Install cluster packages:
# rpm -ivh MySQL-ndb-management-5.0.90-1.glibc23.i386.rpm
# rpm -ivh MySQL-ndb-tools-5.0.90-1.glibc23.i386.rpm
1.3 Create cluster directory and the config.ini file
# mkdir /var/lib/mysql-cluster
# cd /var/lib/mysql-cluster
# vi config.ini
1.4 write the cluster config content in the config.ini
[NDBD DEFAULT]
NoOfReplicas=2
DataMemory=80M # How much memory to allocate for data storage
IndexMemory=18M # How much memory to allocate for index storage
# For DataMemory and IndexMemory, we have used the
# default values. Since the .world. database takes up
# only about 500KB, this should be more than enough for
# this example Cluster setup.
[MYSQLD DEFAULT]
[NDB_MGMD DEFAULT]
[TCP DEFAULT]
# Management Section (MGM)
[NDB_MGMD]
#NodeId = 1
# IP address of the management node
HostName=192.168.50.101
# Storage Server Section (NDBD)
[NDBD]
#NodeId = 2
# IP address of the Storage Server (NDBD) node 1
HostName=192.168.50.102
DataDir=/var/lib/mysql
BackupDataDir=/var/lib/backup
DataMemory=100M
[NDBD]
#NodeId = 3
# IP address of the Storage Server (NDBD) node 2
HostName=192.168.50.103
DataDir=/var/lib/mysql
BackupDataDir=/var/lib/backup
DataMemory=100M
# one [MYSQLD] per storage node
# 2 Clients MySQL
[MYSQLD]
#NodeId = 5
[MYSQLD]
#NodeId = 6
1.5 Start the Management Service
# ndb_mgmd
1.6 Enter to the admin console
# ndb_mgm
1.7 Use the command SHOW to check the nodes status
ndb_mgm> show
Connected to Managemente Server at: localhost:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 2 nodes
id=2 (not connected, accepting connect from 192.168.50.102)
id=3 (not connected, accepting connect from 192.168.50.103)
[ndb_mgmd(MGM)] 1 node
id=1 #192.168.50.101 (Version: 5.0.95)
[mysqld(API)] 2 nodes
id=5 (not connected, accepting connect from any host)
id=6 (not connected, accepting connect from any host)
The management node configuration is OK, so let's configure one Storage Server node (192.168.50.102).
2.1 Install the mysql server, like the step 1.1 .
2.2 Download the MYSQL Cluster from "http://dev.mysql.com/downloads/cluster/"
2.3 Extract the content and copy the files ndb to /usr/bin/.
2.4 Connect the Storage Server node to the Management Server.
ndbd --connect-string=192.168.50.101 --initial -n
And here is the problem. In the Management Server, the next error is displayed:
ndb_mgm > Node 2: Forced node shutdown completed. Ocurred during startphase 0.
Caused by error 2350: 'Invalid configuration received from Management
Server(Configuration error). Permanent error, external action needed'.
And in the Storage Server node, the displayed warning is:
[ndbd] INFO -- Angel connected to '102.168.50.101:1186'
[ndbd] INFO -- Angel allocated nodeid: 2
[ndbd] WARNING -- Configuration didn't contain generation (likely old ndb_mgmd
Does someone know what I should do to fix the problem?
Thank you!
In case it helps somone else, I'll paste in here the response given on the MySQL Forum...
it looks like you're trying to mix management node binaries from your repository (very old version) with non-Cluster MySQL Server (not allowed) with data nodes from mysql.com (very new).
The first step should be to use binaries for all of the nodes from mysql.com.
If you'd like to try out the browser-driven auto-installer to make your life simpler then take a look at http://www.clusterdb.com/mysql-cluster/auto-installer-labs-release/ or if you'd like to set things up by hand then take a look at http://www.clusterdb.com/mysql-cluster/deploying-mysql-cluster-over-multiple-hosts/
Hello Andrew,
thank you very much for your reply. Indeed, I was using an old mysql version in the mgm node.
I downloaded all from http://www.mysql.com/downloads/cluster/ ,set every node like I said before and connected the data node to the manage node using:
shell> /usr/local/mysql/bin/ndbd --connect-string=192.168.56.101
-- Angel connected to 192.168.56.101:1186
-- Angel allocated nodeid: 2
Also, i checked the manage node using the command show:
ndb_mbm> show
Cluster Configuration
[ndbd(NDB)] 2 nodes
id=2 #192.168.50.102(mysql-5-5.29 ndb-7.2.10, starting, Nodegroup:0)
id=3 (not connected, accepting connect from 192.168.50.103)
[ndb_mgmd(MGM)] 1 node
id=1 #192.168.50.101 (Version: 5.0.95)
[mysqld(API)] 2 nodes
id=5 (not connected, accepting connect from any host)
id=6 (not connected, accepting connect from any host)
As you can see, the data node (id 2) is connecting to the mgm node, but when i try to start the data node (id 2) mysql, it will not start...
shell> /etc/init.d/mysql start
Starting MySQL.................................The server quit without updating PID file (/usr/loca/mysql/data/localhost.node2-1. {FAILED])
I checked the problem, and it seems that mysql does not like the config I wrote in /etc/my.cnf.
At the beggining I had:
-- my.cnf --
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
And after I added the ndbcluster config:
-- my.cnf --
[client]
port = 3306
socket = /tmp/mysql.sock
[mysqld]
port = 3306
ndbcluster
ndb-connectstring=192.168.56.107
[mysqld_cluster]
ndb-connectstring=192.168.56.107
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
The thing is if I comment out the ndbluster part, mysql starts correctly, but if the ndbcluster line or the ndb-connectstring line is not commented, mysql does start. What should I do? I do not understand why the mysql does not start when it has the ndbcluster configuration. Is there something wrong?
I notice that you only have one of the two ndbd processes running (and it's still in the starting state). This will prevent the mysqld connecting to the cluster and so you need to start the second ndbd first and wait until ndb_mgm reports them both as being in the running state.
I also tried to connect first both nbdb, but they get stuck on the starting stage:
ndb_mgm> show
Cluster Configuration
[ndbd(NDB)] 2 nodes
id=2 #192.168.50.102(mysql-5-5.29 ndb-7.2.10, starting, Nodegroup:0)
id=3 #192.168.50.103(mysql-5-5.29 ndb-7.2.10, starting, Nodegroup:0)
[ndb_mgmd(MGM)] 1 node
id=1 #192.168.50.101 (mysql-5-5.29 ndb-7.2.10)
[mysqld(API)] 2 nodes
id=5 (not connected, accepting connect from any host)
id=6 (not connected, accepting connect from any host)
I checked the mgm log (ndb_l_cluster.log):
[MgmtSrvr] INFO -- Node 3: Initial start, waiting for 2 to connect, nodes [all: 2 and 3 connected: 3 no-wait:]
[MgmtSrvr] INFO -- Node 2: Initial start, waiting for 3 to connect, nodes [all: 2 and 3 connected: 3 no-wait:]
Even I tried to start them from the mgm:
ndb_mgm> 2 start
Database node 2 is being started.
ndb_mgm> 3 start
Database node 3 is being started.
But there is no "node 2 : Start initiated" message...
I am running the cluster in three virtual machines with CentOS 6.3. Is it the problem? Maybe the config file?
Normally this type of start up problem results from firewall rules blocking access to random high ports on another node in the cluster. Ndbd nodes use these to communicate with each other.
The solution is to either allow all connections between these hosts or to specific ports defined by ServerPort.
See: http://dev.mysql.com/doc/refman/5.5/en/mysql-cluster-ndbd-definition.html#ndbparam-ndbd-serverport
and
http://johanandersson.blogspot.com/2009/05/cluster-fails-to-start-self-diagnosis.html
Matthew, you were right! I allowed the ports between all nodes and all is working fine!
Thank you very much, Matthew and Andrew!
Related
I've been trying with intermittent success to restore my ndb_backups to a new cluster.
We have a 6 NDB node cluster with 3 API nodes. When I run an ndb_restore, usually the first 2 or 3 node backups get pulled in without issue. But the 4th and 5th node fail with the following error:
Temporary error: 266: Time-out in NDB, probably caused by deadlock
Temporary error: 266: Time-out in NDB, probably caused by deadlock
Retried transaction 10 times.
Last error266: Time-out in NDB, probably caused by deadlock
...Unable to recover from errors. Exiting...
Strangely, sometimes I can simply rerun all 6 backups and it finishes successfully.
I'm hoping someone knows what kind of tweaks I can make to my configuration to optimize this process. Here are my version numbers and configs:
mysql-5.6.22 ndb-7.3.8
My mgm configuration file:
######################
#MGM CONFIG
######################
[ndbd default]
# Options affecting ndbd processes on all data nodes:
NoOfReplicas=2 # Number of replicas
DataMemory=8144M # How much memory to allocate for data storage
IndexMemory=8144M # How much memory to allocate for index storage
# For DataMemory and IndexMemory, we have used the
# default values. Since the "world" database takes up
# only about 500KB, this should be more than enough for
# this example Cluster setup.
[ndb_mgmd]
# Management process options:
hostname=192.168.207.133 # Hostname or IP address of MGM node
NodeId=1
[ndb_mgmd]
# Management process options:
hostname=192.168.207.45 # Hostname or IP address of MGM node
NodeId=2
[ndbd]
# Options for data node "A":
hostname=192.168.207.135 # Hostname or IP address
NodeId=3
[ndbd]
# Options for data node "B":
hostname=192.168.207.171 # Hostname or IP address
NodeId=4
[ndbd]
# Options for data node "C":
hostname=192.168.207.174 # Hostname or IP address
NodeId=5
[ndbd]
# Options for data node "D":
hostname=192.168.207.27 # Hostname or IP address
NodeId=6
[ndbd]
# Options for data node "E":
hostname=192.168.207.169 # Hostname or IP address
NodeId=7
[ndbd]
# Options for data node "F":
hostname=192.168.207.178 # Hostname or IP address
NodeId=8
[mysqld]
hostname=192.168.207.177
NodeId=10
[mysqld]
hostname=192.168.207.35
NodeId=11
[mysqld]
hostname=192.168.207.148
NodeId=12
My mysqld and ndb node config
######################
#API AND NDB CONFIG
######################
[mysqld]
ndbcluster
[mysql_cluster]
ndb-connectstring=192.168.207.133,192.168.207.45 # location of management server
Really hope someone can help. I've been at this for a month. We use data blobs quite extensively and I understand that this can cause these time-outs, but I'm most curious to find out why the 6-node restore sometimes succeeds and sometimes doesn't, and how I can go about ensuring the restore is successful every time.
I'm very open to try things and repost. I'm new to mysql cluster and have learned piles in the past few months, but am eager to learn more.
Thanks in advance,
GT
ndb_mgmd does not seem to correctly read the config file
this is part of my config file
[ndbd]
# Options for data node "A":
# (one [ndbd] section per data node)
hostname=abhyas.db01 # Hostname or IP address
datadir=/usr/local/mysql/data # Directory for this data node's data files
[ndbd]
# Options for data node "B":
hostname=abhyas.db02 # Hostname or IP address
datadir=/usr/local/mysql/data # Directory for this data node's data files
[mysqld]
# SQL node options:
hostname=abhyas.dbmgr # Hostname or IP address
# (additional mysqld connections can be
# specified for this node for various
# purposes such as running ndb_restore)
but
ndb_mgm
shows something different
[root#abhyas abhyas_mgr]# ndb_mgm
-- NDB Cluster -- Management Client --
ndb_mgm> SHOW
Connected to Management Server at: abhyas.dbmgr:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=2 (not connected, accepting connect from abhyas.db01)
id=3 (not connected, accepting connect from abhyas.db01)
[ndb_mgmd(MGM)] 1 node(s)
id=1 #192.168.102.134 (mysql-5.6.25 ndb-7.4.7)
[mysqld(API)] 1 node(s)
id=4 (not connected, accepting connect from abhyas.dbmgr)
ndb_mgm> EXIT
As you can see, in my config file I have abhyas.db01 and abhyas.db02 as the hosts.
But the cluster config shows NDB nodes as two nodes, both from abhyas.db01. (This is not what I want, not right now atleast).
[ndbd(NDB)] 2 node(s)
id=2 (not connected, accepting connect from abhyas.db01)
id=3 (not connected, accepting connect from abhyas.db01)
Now, I made a mistake to start the ndb_mgmd with the config.ini file had [ndbd] entries both pointing to abhyas.db01, but I promptly shut down the ndb_mgm and changed the entry in the config file to show as I have pasted above.
But for some reason, ndb_mgmd still takes the old configuration ?
How do I fix this ?
Thanks.
PS - No, this is not a firewall issue. iptables is off. Besides, ndbd from abhyas.db01 is able to connect successfully anyway.
Nevermind, figured it out.
just had to specify --reload option while starting ndb_mgmd
i.e
ndb_mgmd --reload --config-file /home/abhyas_mgr/config.ini
[root#abhyas bin]# ndb_mgmd --reload --config-file /home/abhyas_mgr/config.ini
MySQL Cluster Management Server mysql-5.6.25 ndb-7.4.7
[root#abhyas bin]# ndb_mgm
-- NDB Cluster -- Management Client --
ndb_mgm> show
Connected to Management Server at: abhyas.dbmgr:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=2 (not connected, accepting connect from abhyas.db01)
id=3 (not connected, accepting connect from abhyas.db02)
[ndb_mgmd(MGM)] 1 node(s)
id=1 #192.168.102.134 (mysql-5.6.25 ndb-7.4.7)
[mysqld(API)] 1 node(s)
id=4 (not connected, accepting connect from abhyas.dbmgr)
ndb_mgm>
viola!
Answer by #anu is correct.
But first -
You would need to shutdown the management cluster PID first, by issuing a command -
ndb_mgm -e "SHUTDOWN"
then, a --reload
ndb_mgmd --reload --config-file /var/lib/mysql-cluster/config.ini
I am trying to deploy a mysql cluster (4 machines) with 1 node manager, 1 sql node, and 2 data nodes. I am following these tutorials which are complimentary (first part, second part, third part, fourth part) from the official mysql website. However I have a problem with the SQL Node which is always not connected, as you can see here in the node manager:
$ sudo ndb_mgm -e show
Connected to Management Server at: localhost:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=2 #10.31.35.40 (mysql-5.6.23 ndb-7.4.5, starting, Nodegroup: 0)
id=3 #10.31.35.42 (mysql-5.6.23 ndb-7.4.5, starting, Nodegroup: 0)
[ndb_mgmd(MGM)] 1 node(s)
id=1 #10.31.37.108 (mysql-5.6.23 ndb-7.4.5)
[mysqld(API)] 1 node(s)
id=4 (not connected, accepting connect from 10.31.35.41)
I don't know why the SQL node is not connected to the management node !! I looked for similar problems in google but I still can't resolve my problem !
I tried several times to do:
/etc/init.d/mysql.server stop
and
/etc/init.d/mysql.server start
but in vain.
Here is also the output of mysqld in verbose mode which mentions a problem I don't know what its cause:
ubuntu#10-31-35-41:/usr/local/mysql/bin$ sudo mysqld --verbose --help
150404 5:26:00 [Note] Plugin 'FEDERATED' is disabled.
150404 5:26:00 [ERROR] mysqld: unknown option '--ndbcluster'
......
Also when I try to see the location of the mysqld_safe (which I think is not normal since as you can see in the first part of the tutorial the folder was put in /usr/local/mysql (and I am supposed to use the mysql.server, isn't it ?)), I have
$ which mysqld_safe
/usr/bin/mysqld_safe
Moreover, I don't know if there is a conflict with the previous installed package of mysql
This is /etc/mysql/my.cnf (in the sql node, which is the same in the working data nodes):
[mysqld]
# Options for mysqld process:
ndbcluster # run NDB storage engine
[mysql_cluster]
# Options for MySQL Cluster processes:
ndb-connectstring=10.31.37.108 # location of management server
This is the config.ini file in the ndb_mgm:
[ndbd default]
# Options affecting ndbd processes on all data nodes:
NoOfReplicas=2 # Number of replicas
DataMemory=80M # How much memory to allocate for data storage
IndexMemory=18M # How much memory to allocate for index storage
# For DataMemory and IndexMemory, we have used the
# default values. Since the "world" database takes up
# only about 500KB, this should be more than enough for
# this example Cluster setup.
[tcp default]
# TCP/IP options:
portnumber=2202 # This the default; however, you can use any
# port that is free for all the hosts in the cluster
# Note: It is recommended that you do not specify the port
# number at all and simply allow the default value to be used
# instead
[ndb_mgmd]
# Management process options:
hostname=10.31.37.108 # Hostname or IP address of MGM node
datadir=/var/lib/mysql-cluster # Directory for MGM node log files
[ndbd]
# Options for data node "A":
# (one [ndbd] section per data node)
hostname=10.31.35.40 # Hostname or IP address
datadir=/usr/local/mysql/data # Directory for this data node's data files
[ndbd]
# Options for data node "B":
hostname=10.31.35.42 # Hostname or IP address
datadir=/usr/local/mysql/data # Directory for this data node's data files
[mysqld]
# SQL node options:
hostname=10.31.35.41 # Hostname or IP address
# (additional mysqld connections can be
# specified for this node for various
# purposes such as running ndb_restore)
Thank you very much in advance for your help !!
To resolve the problem I changed the permissions on the /usr/local/mysql/data directory as follows:
sudo chown -R ubuntu data/
so now instead of:
$ /usr/local/mysql/support-files/mysql.server restart
* MySQL server PID file could not be found!
Starting MySQL
. * The server quit without updating PID file (/usr/local/mysql/data/ip-172-31-46-103.pid).
I get now:
$ /usr/local/mysql/support-files/mysql.server restart
Shutting down MySQL
.. *
Starting MySQL
. *
I'm playing with MySql Cluster and faced a problem with not common configuration. The most of tutorials describes configuration where data node and MySQL Server node residing on the same PC. But I'm trying to put management node and MySQL server node to PC 'A' and data node to PC 'B'. Unfortunately when I'm trying to run data node ndbd.exe shutting down immediately and leaves the following message in Windows Event Viewer: "Failed to allocate nodeid, error: 'Error: Could not alloc node id at pcA.ip.address port 1186: Connection done from wrong host ip pcB.ip.address'.".
My configuration files are following:
PC 'A' config.ini:
[ndbd default]
noofreplicas=2
[ndbd]
hostname=pcB.ip.address
nodeid=2
[ndb_mgmd]
nodeid = 1
hostname=pcA.ip.address
[mysqld]
nodeid=4
hostname=pcA.ip.address
my.cnf used by mysqld on PC 'A':
[mysqld]
ndb-nodeid=4
ndbcluster
datadir="D:\ProgramData\MySQL\MySQL Cluster 7.3\data4"
port=3306
server-id=3306
my.cnf on PC 'B':
[ndbd]
connect-string="pcA.ip.address"
Can someone say what is wrong with these files above? As I said I couldn't find tutorirals for such cluster configuration.
Thanks in advance.
In your setup, you're declaring to replicas, but you have only one:
[ndbd default]
noofreplicas=2
Node configuration looks fine, but you could try using a empty ndbd definition, then reloading ndb_mgmd daemon to ensure it's applied
[ndbd]
I am having trouble with the initial start up of the mysql-cluster management node and would appreciate any help I can get about this issue. See my two examples of failure below followed by my config.ini file. The first example shows the basic command to start the daemon and the error it produces. The second attempts to skip the process I believe caused the error in the first, but only results in a different error (one that I can find no solution to).
~$ ndb_mgmd -f /var/lib/mysql-cluster/config.ini
MySQL Cluster Management Server mysql - 5.5.25 ndb-7.2.7
2012-07-27 16:44:51 [MgmtSrvr] INFO -- The default config directory '/user/local
/mysql/mysql-cluster' does not exist. Trying to create it...
Failed to create directory '/usr/local/mysql/mysql-cluster', error: 2 2012-07-27 16:44:51
[MgmtSrvr] ERROR -- Could not create directory '/usr/local/mysql/mysql-cluster'.
Either create it manually or specify a different directory with --configdir=
~$ ndb_mgmd --skip-config-cache -f /var/lib/mysql-cluster/config.ini
MySQL Cluster Management Server mysql - 5.5.25 ndb-7.2.7
2012-07-27 16:44:51 [MgmtSrvr] INFO -- Skipping check of config directory since config cache is disabled.
Failed to parse parameters for log handler: 'FILE:filename=/var/lib/mysql-cluster/ndb_1_cluster.log,maxsize=1000000,
maxfiles=6', error:13 '(null)'
/var/lib/mysql-cluster/config.ini:
[ndbd default]
# Options affecting ndbd processes on all data nodes:
NoOfReplicas=2 # Number of replicas
DataMemory=80M # How much memory to allocate for data storage
IndexMemory=18M # How much memory to allocate for index storage
[tcp default]
# TCP/IP options:
[ndb_mgmd]
# Management process options:
hostname=192.168.0.3 # Hostname or IP address of MGM node
datadir=/var/lib/mysql-cluster # Directory for MGM node log files
NodeId=1
[ndbd]
# Options for data node-1:
# (one [ndbd] section per data node)
hostname=192.168.0.1 # Hostname or IP address
datadir=/usr/local/mysql/data # Directory for this data node's data files
NodeId=2
[ndbd]
# Options for data node-2:
hostname=192.168.0.2 # Hostname or IP address
datadir=/usr/local/mysql/data # Directory for this data node's data files
NodeId=3
[mysqld]
# SQL node options:
hostname=192.168.0.4 # Hostname
You should try running that commands with sudo:
~$ sudo ndb_mgmd -f /var/lib/mysql-cluster/config.ini
~$ sudo ndb_mgmd --skip-config-cache -f /var/lib/mysql-cluster/config.ini
Your problem seems to be with permissions, not configuration.