Quickstart Guide to Manage your Cluster
The following scripts for managing your cluster are installed in the $NDB_DIR/scripts directory:
- init-start-cluster-Xnode.sh
- This script is used to start a cluster for the first time. It will initialise the database, and destroy all existing data in the database.
- start-noinit-cluster-Xnode.sh
- This script is used for normal start of a cluster (after the cluster has been initialised and started a first time). It will start the cluster and the database.
- shutdown-cluster.sh
- This script is used to shutdown a cluster and any MySQL Servers attached to the cluster.
- mgm-client.sh [-c hostname]
- This script is used to start the management client application, used to monitor the state of the cluster.
- mysql-client-X.sh
- This script is used to start the command-line mysql client application (called mysql) connecting to MySQL Server number X in the cluster.
- start-mysqld-X.sh
- This script is used to start MySQL Server (mysqld) number X and connect the MySQL server to the cluster.
- stop-mysqld-X.sh
- This script is used to stop MySQL Server number X that is connected to the cluster.
- rolling-restart-X.sh
- This script is used to perform a rolling restart for a cluster. It is performed to effect parameter changes for the cluster, and to reclaim fragmented memory.
- memory-usage.sh
- This script prints out the current data memory and index memory usage of the data nodes, by 'tail and grep' of the cluster log. You can set the tail length using a switch.
- enter-singleuser-mode.sh
- This script ensures on a single MySQL Server (or API node) can access the cluster. Call this script before you are alter a table to add/remove a column (you don't need single-user-mode for index add/drop from 5.1)
- exit-singleuser-mode.sh
- This script causes the cluster to exit single-user mode. Call it after you have completed your alter table operations.
- start-backup.sh
- This script calls the ndb_mgm command "START BACKUP", making a consistent snapshot of the running database that can later be restored with mysql/bin/ndb_restore
- copy-backup.sh
- When you create a backup, the backup files are stored at all the different nodes in the cluster. This script copies all the backup files from the hosts and places them into a single archive in the $NDB_HOME/backups directory.
Here we use the scripts to initialize a cluster, shutdown a cluster, start a cluster (normal start), and add a table to a cluster using the mysql client.
# For Distributed clusters installations only: you need to start the cluster logged in as user 'mysql': su mysql # For both Localhost and Distributed cluster installations, execute all following steps # For localhost, $NDB_DIR=~/.mysql/ndb . For distributed, $NDB_DIR=/var/lib/mysql-cluster/ndb cd $NDB_DIR/scripts # initialize for the first time your 2-node cluster, and start it ./init-start-cluster-2node.sh # Ask the mgmt client to show the state of the nodes/mysql servers in the cluster ./mgm-client.sh -e show # Shutdown the cluster ./shutdown-cluster.sh # Normal start of the 2-node cluster ./start-noinit-cluster-2node.sh # Start a mysql client ./mysql-client.sh mysql> use test; Database changed mysql> create table ndb_table (id int, name varchar(64)); Query OK, 0 rows affected (0.55 sec) mysql> show create table ndb_table; +-----------+------------------------------------------------------------------------------+ | Table | Create Table | +-----------+------------------------------------------------------------------------------+ | ndb_table | CREATE TABLE `ndb_table` ( `id` int(11) DEFAULT NULL, `name` varchar(64) DEFAULT NULL ) ENGINE=ndbcluster DEFAULT CHARSET=latin1 | +-----------+------------------------------------------------------------------------------+ 1 row in set (0.00 sec) mysql>quit # shutdown the cluster again ./shutdown-cluster.sh
Adding MySQL Servers
You can add mysql servers after you have created a cluster.
New scripts for starting and stopping the mysql server will be added to the directory: $NDB/scripts/. The cluster startup and shutdown scripts will also be updated to add the new mysql server.
Processes
- ndb_mgmd - the management server process
- ndbd - the data node processes (each ndbd process also has an angel process)
- mysqld - the MySQL server processes
Output Directories
The following directories are created in ~/.mysql:
- mysql[-version] : this directory contains the MySQL Server and NDB binaries
- mysql : is optionally created as a symbolic link to the currently used version
- logs : this directory contains the log files written by the ndb_mgmd, ndbd and mysqld processes. 'cluster.log' is the main log file; it is written by the ndb_mgmd process.
- ndb[-version] : this directory contains the NDB data directories for the nodes in the cluster, and the MySQL Server data directories.
- ndb : is optionally created as a symbolic link to the currently used version
- [backups] : is created when you call the copy-backup.sh script after having successfully called start-backup.sh
