1. Environment Description
Mysql manager node: 192.168.0.1
MysqlServer node: 192.168.0.100
Mysql node: 192.168.0.160
Mysql node: 192.168.0.161
Note: At least four servers are required for the mysql cluster. We recommend that you add five more MySQL servers.
2. Install the mysql Binary Package
2.1 preparations before installation
Download the mysql-max-4.1.13-pc-linux-gnu-i686.tar.gz package
(Note: mysql instances that can be used as clusters are mysql-max. The download location is www.mysql.org)
# Groupadd mysql
# Useradd-g mysql
# Cd/usr/local
# Tar xfz mysql-max-4.1.13-pc-linux-gnu-i686.tar.gz
# Ln-s/usr/local/mysql-max-4.1.13-pc-linux-gnu-i686/opt/mysql4.1.13
2.2 install binary mysql packages on the manager, server, and node nodes respectively.
# Cd mysql4.1.13
# Scripts/mysql_install_db -- user = mysql (directory execution is required; otherwise, an error occurs)
# Chown-R root/opt/mysql4.1.13
# Chgrp-R mysql/opt/mysql4.1.13
# Chown-R mysql. mysql/opt/mysql4.1.13/data
# Cp support-files/mysql. server/etc/rc. d/init. d/configure mysql startup settings
# Chmod + x/etc/rc. d/init. d/mysql. server
# Chkconfig -- add mysql. server
3. configure server and note nodes
On machines 192.168.0.160 and 192.168.0.161
#./Mysql-help this command can be used to view the order of my. cnf files during mysql startup.
Default options are read from the following files in the given order:
/Etc/my. cnf/usr/local/mysql-max-4.1.13/data/my. cnf ~ /. My. cnf
# Cp support-files/my-medium.cnf data/my. cnf test the mysql configuration file under data
Vi/usr/local/mysql-max-4.1.13-pc-linux-gnu-i686/data/my. cnf
[MYSQLD]
Ndbcluster
Ndb-connectstring = 192.168.0.1
[MYSQL_CLUSTER]
Ndb-connectstring = 192.168.0.1
4. Configure the Management Node
On the host 192.168.0.1
# Mkdir/var/lib/mysql-cluster
# Cd/var/lib/mysql-cluster
# Vi config. ini
[Ndbd default] # Options affecting ndbd processes on all data nodes:
NoOfReplicas = 2 # Number of replicas
DataMemory = 80 M # How much memory to allocate for data storage
IndexMemory = 52 M # How much memory to allocate for index storage
# For DataMemory and IndexMemory, we have used
# Default values. Since the "world" database takes up
# Only about 500KB, this shoshould be more than enough
# 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 cluster
# Note: It is recommended beginning with MySQL 5.0 that
# You do not specify the portnumber at all and simply allow
# The default value to be used instead
# Management process options (define a Management node .)
[NDB_MGMD]
Hostname = 192.168.0.1 # management node Hostname or IP address of MGM node
Datadir =/var/lib/mysql-cluster # Directory for MGM node logfiles
# Options for data node "A" (defines the cluster data node .)
# (One [NDBD] section per data node)
[NDBD]
Hostname = 192.168.0.160 # Node Hostname or IP address
Datadir =/usr/local/mysql/data # Directory for this data node's datafiles
# Options for data node "B" (defines the cluster data node .)
[NDBD]
Hostname = 192.168.0.161 # Node Hostname or IP address
Datadir =/usr/local/mysql/data # Directory for this data node's datafiles
# SQL node options (define an SQL server node .)
[MYSQLD]
Hostname = 192.168.0.100 # SQL node Hostname or IP address
# Datadir =/usr/local/mysql/data # Directory for SQL node's datafiles
# (Additional mysqld connections can be
# Specified for this node for various
# Purposes such as running ndb_restore)
[NDB_MGMD]: No comments can be added to the end; otherwise, the following message is displayed:
Error line 17: [TCP] Unknown parameter: [NDB_MGMD] # Management process options
Error line 17: cocould not parse name-value pair in config file.
[SHM]: Defines shared-memory connections between nodes. before MySQL 4.1.9, this function must be compiled using -- with-ndb-shm option. From MySQL 4.1.9-max, it is enabled by default.