Introduction
[Describe the content and purpose of this deployment.]
This document describes how to deploy a MySQL cluster on the Ubuntu Server.
Preparations
Before proceeding with this document, complete the following preliminary steps:
1. Install three Ubuntu servers;
Server1: ndbd 192.168.68.5
Server2: ndbd 192.168.68.6
Server3: mysqld-ndb-cluster 192.168.68.8
Ndbd (192.168.68.5 \ 192.168.68.6): Database node that stores data.
Mysqld-ndb-cluster (192.168.68.8): MySQL server node, management node, and cluster management.
Note:
This experiment is implemented on ubuntu server (8.04 ).
Management node: server3 (192.168.68.8)
Storage node: server1 (192.168.68.5), server2 (192.168.68.6)
2. Mysql-server databases are installed on all three servers.
Deployment Overview
1. Install the ubuntu server (8.04 in this tutorial );
2. Install the mysql-server database;
3. Configure my. cnf on these three servers;
4. Configure ndb_mgmd.cnf on the Management node (192.168.68.8;
5. Start mysql-ndb-mgm on the Management node server;
6. Start mysql-ndb on the storage node (192.168.68.5 \ 6;
7. Start the mysql-ndb service on the three servers respectively;
8. Test Management node.
Installation Steps
1. Install the ubuntu server. Install msyql and openssh during installation.
Cluster configuration
1. Configure my. cnf on the three servers.
Vim/etc/mysql/my. cnf
-------------- My. cnf start ---------------
Ubuntu @ ubuntu :~ $ Cat/etc/mysql/my. cnf
#
# The MySQL database server configuration file.
#
# You can copy this to one:
#-"/Etc/mysql/my. cnf" to set global options,
#-"~ /. My. cnf "to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with-help to get a list of available options and
#-Print-defaults to see which it wocould actually understand use.
#
# For explanations see
# Http://dev.mysql.com/doc/mysql/en/server-system-variables.html
# This will be passed to all mysql clients
# It has been reported that passwords shoshould be enclosed with ticks/quotes
# Escpecially if they contain "#" chars...
# Remember to edit/etc/mysql/debian. cnf when changing the socket location.
[Client]
Port = 3306
Socket =/var/run/mysqld. sock
# Here is entries for some specific programs
# The following values assume you have at least 32 M ram
# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[Mysqld_safe]
Socket =/var/run/mysqld. sock
Nice = 0
[Mysqld]
#
# * Basic Settings
#
#
# * IMPORTANT
# If you make changes to these settings and your system uses apparmor, you may
# Also need to also adjust/etc/apparmor. d/usr. sbin. mysqld.
#
User = mysql
Pid-file =/var/run/mysqld. pid
Socket =/var/run/mysqld. sock
Port = 3306
Basedir =/usr
Datadir =/var/lib/mysql
Tmpdir =/tmp
Language =/usr/share/mysql/english
Skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# Localhost which is more compatible and is not less secure.
# Bind-address = 127.0.0.1
#
# * Fine Tuning
#
Key_buffer = 16 M
Max_allowed_packet = 16 M
Thread_stack = 128 K
Thread_cache_size = 8
# Max_connections = 100
# Table_cache = 64
# Thread_concurrency = 10
#
# * Query Cache Configuration
#
Query_cache_limit = 1 M
Query_cache_size = 16 M
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# Log =/var/log/mysql. log
#
# Error logging goes to syslog. This is a Debian improvement
#
# Here you can see queries with especially long duration
# Log_slow_queries =/var/log/mysql/mysql-slow.log
# Long_query_time = 2
# Log-queries-not-using-indexes
#
# The following can be used as easy to replay backup logs or for replication.
# Note: if you are setting up a replication slave, see README. Debian about
# Other settings you may need to change.
# Server-id = 1
# Log_bin =/var/log/mysql/mysql-bin.log
Expire_logs_days = 10
Max_binlog_size = 100 M
# Binlog_do_db = include_database_name
# Binlog_ignore_db = include_database_name
#
# * BerkeleyDB
#
# Using BerkeleyDB is now discouraged as its support will cease in 5.1.12.
Skip-bdb
#
# * MyISAM
#
# MyISAM is enabled by default with a 10 MB datafile in/var/lib/mysql /.
# Read the manual for more MyISAM related options. There are unavailable!
# You might want to disable MyISAM to shrink the mysqld process by circa 100 MB.
# Skip-innodb
#
# * Security Features
#
# Read the manual, too, if you want chroot!
# Chroot =/var/lib/mysql/
#
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca ".
#
# Ssl-ca =/etc/mysql/cacert. pem
# Ssl-cert =/etc/mysql/server-cert.pem
# Ssl-key =/etc/mysql/server-key.pem
# The following is the IP address of the Management node.
Ndbcluster
Ndb-connectstring = 192.168.68.8
[Mysqldump]
Quick
Quote-names
Max_allowed_packet = 16 M
[Mysql]
# No-auto-rehash # faster start of mysql but no tab completition
[Isamchk]
Key_buffer = 16 M
#
# * NDB Cluster
#
# See/usr/share/doc/mysql-server-*/README. Debian for more information.
#
# The following configuration is read by the NDB Data Nodes (ndbd processes)
# Not from the NDB Management Nodes (ndb_mgmd processes ).
#
[MYSQL_CLUSTER]
Ndb-connectstring = 192.168.68.8
#
# * IMPORTANT: Additional settings that can override those from this file!
# The files must end with '. cnf', otherwise they'll be ignored.
#
! Includedir/etc/mysql/conf. d/
Ubuntu @ ubuntu :~ $
Prompt |
|
/Etc/mysql/my. cnf: Ndbcluster Ndb-connectstring = 192.168.68.13 And add [MYSQL_CLUSTER] Ndb-connectstring = 192.168.68.13 All three servers must be configured. |
2. Configure ndb_mgmd.cnf in the configuration (192.168.68.8) on the management node server.
Copy:
/Usr/share/doc/mysql-server-5.0/examples/ndb_mgmd.cnfTo/etc/mysql/ndb_mgmd.cnf
3. Edit ndb_mgmd.cnf in configuration (192.168.68.8) of the Management node server.
Ubuntu @ ubuntu :~ $ Sudo vim/etc/mysql/ndb_mgmd.cnf
[Ndbd default]
NoOfReplicas = 2
DataMemory = 10 MB
IndexMemory = 25 MB
MaxNoOfTables = 256
MaxNoOfOrderedIndexes = 256
MaxNoOfUniqueHashIndexes= 128
[Mysqld default]
[NDB_MGMD DEFAULT]
[Tcp default]
[NDB_MGMD]
Id = 1 # the NDB Management Node (this one)
HostName = 192.168.68.8
DataDir =/var/lib/mysql-cluster
[NDBD]
Id = 2 # the first NDB Data Node
HostName = 192.168.68.5
DataDir =/var/lib/mysql-cluster
[NDBD]
Id = 3 # the second NDB Data Node
HostName = 192.168.68.6
DataDir =/var/lib/mysql-cluster
[MYSQLD]
Id = 4 # the first SQL node
HostName = 192.168.68.5
[MYSQLD]
Id = 5 # the first SQL node
HostName = 192.168.68.6
4. The mysql-ndb-mgm service in the server management node server (192.168.68.8.
Sudo/etc/init. d/mysql-ndb-mgm start
5. Start mysql-ndb in the data storage server (192.168.68.5 \ 6.
Sudo/etc/init. d/mysql-ndb start
6. Finally, mysql service is started on three servers (192.168.68.5 \ 6 \ 8.
Sudo/etc/init. d/mysql start