ArticleDirectory
- MySQL cluster Cluster load configuration
MySQL cluster Cluster load configuration
I. Software Packages
A) MySQL-ndb-management-5.0.90-1.i386.rpm
B) MySQL-ndb-management-5.0.90-1.i386.rpm
C) mysql-5.0.27.tar.gz
2. Install [Management Nodes]
A) rpm-IVH MySQL-ndb-tools-5.0.90-1.i386.rpm
B) rpm-IVH MySQL-ndb-management-5.0.90-1.i386.rpm
C) mkdir/var/lib/MySQL-Cluster
D) CD/var/lib/MySQL-Cluster
E) touch config. ini
[Ndbd default]
Noofreplicas = 2
[Mysqld default]
[Ndb_mgmd default]
[TCP default]
# Managment Server
[Ndb_mgmd]
Hostname = 192.168.1.67
# Storage engines
[Ndbd]
Hostname = 192.168.1.91
Datadir =/usr/local/MySQL/Data
# Datadir =/var/lib/MySQL-Cluster
[Ndbd]
Hostname = 192.168.1.92
Datadir =/usr/local/MySQL/Data
# Datadir =/var/lib/MySQL-Cluster
[Mysqld]
[Mysqld]
F)/usr/bin/ndb_mgm-initial
G)/usr/bin/ndb_mgmd Shutdown
H)/usr/bin/ndb_mgmd-F/var/lib/MySQL-cluster/config. ini [start a management node]
I)/usr/sbin/ndb_mgmd-F/etc/ndb_mgmd.cnf
3. Install [data nodes]
A) CD/var/local/software
B) tar zxvf mysql-5.0.27.tar.gz
C) CD mysql-5.0.27
D ). /configure -- prefix =/usr/local/MySQL -- localstatedir =/usr/local/MySQL/data -- disable-maintainer-mode -- With-mysqld-user = MySQL -- With-Unix -socket-Path =/tmp/MySQL. sock -- without-comment -- without-Debug -- With-dependencies -- With-ndbcluster;
E) Make & make install
F) Finger MySQL
G) useradd MySQL
H) CD scripts
I)./mysql_install_db
J) chown-r MYSQL: MySQL/usr/local/MySQL
K) chown-r MYSQL: MySQL/usr/local/MySQL/Data
L) CD/usr/local/src/mysql-5.0.27/support-files/
(M) CP my-medium.cnf/etc/My. CNF
N) killall mysqld
O)/usr/local/MySQL/bin/mysqld_safe -- user = MySQL -- skip-grant-tables -- skip-Networking &
#/Usr/local/MySQL/bin/MySQL-u root MySQL
Mysql> Update user SET Password = PASSWORD ('000000') where user = 'root ';
Mysql> flush privileges;
Mysql> quit
Modify the remote access permission of the root user:
# Killall mysqld
#/Usr/local/MySQL/bin/mysqld_safe-user = MySQL &
#/Usr/local/MySQL/bin/MySQL-u root-p123456 MySQL
Mysql> grant all privileges on *. * To 'root' @ '%' identified by 'root' with grant option;
Mysql> flush privileges;
Mysql> quit
VI/etc/My. CNF
[Mysqld]
Ndbcluster
NDB-connectstring = 192.168.1.67
[Mysql_cluster]
NDB-connectstring = 192.168.1.67
Killall mysqld
/Usr/local/MySQL/bin/mysqld_safe &
/Usr/local/MySQL/libexec/ndbd-initial (initialize data node)
4. View Management Nodes
A)/usr/bin/ndb_mgmd Shutdown
B)/usr/bin/ndb_mgmd-F/var/lib/MySQL-cluster/config. ini
C)/usr/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 = 2 @ 192.168.1.91 (Version: 5.0.27, nodegroup: 0, Master)
Id = 3 @ 192.168.1.92 (Version: 5.0.27, nodegroup: 0)
[Ndb_mgmd (MGM)] 1 node (s)
Id = 1 @ 192.168.1.67 (Version: 5.0.90)
[Mysqld (API)] 2 node (s)
Id = 4 @ 192.168.1.92 (Version: 5.0.27)
Id = 5 @ 192.168.1.91 (Version: 5.0.27)
Ndb_mgm>
The above is displayed normally
V. Test node synchronization
A) In one of the data nodes,/usr/local/MySQL/bin/MySQL-uroot-P
B) Create Database member;
Use member;
Create Table admin (id int) engine = ndbcluster;
Insert into admin values (1 );
C) In another data node,/usr/local/MySQL/bin/MySQL-uroot-P
D) Create Database member;
E) Use member;
F) flush tables;
G) show tables;
H) the admin table is synchronized.
I) Select * from Admin
J) We can see that a record has been synchronized.
K) The cluster is normal.
Vi. Related commands
A)/usr/local/MySQL/libexec/ndbd-initial (initialize the data node)
B)/usr/bin/ndb_mgmd Shutdown (close the management node)
C)/usr/bin/ndb_mgmd-F/var/lib/MySQL-cluster/config. ini (start the management node)
D)/usr/bin/ndb_mgm to view Cluster Information
E) pS aux | grep MySQL check whether MySQL is started
F) pS aux | grep NDB check whether the management node is started
G) ndb_mgm-E "show ";
H) ndb_mgm> All stauts;
I) ndb_mgm> 2 status; (2 is the node number)
J) ndbd-no-wait-nodes = 2, 3
K) mysql> show engine NDB status;
L) ndb_mgm> clusterlog Info;
M) mysql> show status like 'ndb % ';
N) mysql> show warnings;
O) ndb_mgm> 2 stop;
P) show engines;
VI/etc/ndb_mgmd.cnf
[Ndbd default]
Noofreplicas = 2
Maxnoofconcurrentoperations = 10000
Datamemory = 1800 m
Indexmemory = 200 m
Maxnoofattributes = 500000 [Table creation failure]
Maxnooftables = 1760
Maxnoofuniquehashindexes = 5000
Maxnooforderedindexes = 5000
Maxnooftriggers = 4000
Timebetweenlocalcheckpoints = 2
Nooffragmentlogfiles = 100
Datadir =/var/lib/MySQL-Cluster
[Mysqld default]
[Ndb_mgmd default]
Datadir =/var/lib/MySQL-Cluster
[TCP default]
# Managment Server
[Ndb_mgmd]
Hostname = 192.168.1.67
# Storage engines
[Ndbd]
Hostname = 192.168.1.91
Maxnoofattributes = 500000
Datadir =/usr/local/MySQL/Data
# Datadir =/var/lib/MySQL-Cluster
[Ndbd]
Hostname = 192.168.1.92
Maxnoofattributes = 500000
Datadir =/usr/local/MySQL/Data
# Datadir =/var/lib/MySQL-Cluster
[Mysqld]
[Mysqld]
7. Install ipvsadm
A) rpm-IVH ipvsadm-1.24-8.1.i386.rpm
B) vi/opt/ipvsadm. Sh
#! /Bin/bash
Ipvsadm-C
Ipvsadm-a-t 59.64.28.94: 3306-s rr
Ipvsadm-a-t 59.64.28.94: 3306-r 59.64.28.91: 3306-g-W 1
Ipvsadm-a-t 59.64.28.94: 3306-r 59.64.28.92: 3306-g-W 1
/Etc/rc. d/init. d/ipvsadm save
C) chmod 755 ipvsadm. Sh
D) Service ipvsadm restart
E) vi/etc/sysconifg/ipvsadm
8. Install keepalived (Monitor heartbeat)
A) tar zxvf keepalived-1.1.15.tar.gz
B) ln-S/usr/src/kernels/2.6.18-164. el5-PAE-i686/usr/src/Linux
C) CD keepalived-1.1.15
D)./configure -- prefix =/usr/local/keepalive/-- With-kernel-Dir =/usr/src/Linux
E) Make
F) make install
G) CD/usr/local/keepalive/
H) CP/usr/local/keepalive/etc/rc. d/init. d/keepalived/etc/rc. d/init. d/
I) CP/usr/local/keepalive/etc/sysconfig/keepalived/etc/sysconfig/
J) mkdir/etc/keepalived
K) CP/usr/local/keepalive/etc/keepalived. CONF/etc/keepalived/
L) CP/usr/local/keepalive/sbin/keepalived/usr/sbin/
M) chkconfig -- add keepalived
N) chkconfig keepalived on
O) Service keepalived restart
P) vi/etc/keepalived. conf
! Configuration file for keepalived
Global_defs {
Notification_email {
Acassen@firewall.loc
Failover@firewall.loc
Sysadmin@firewall.loc
}
Notification_email_from Alexandre.Cassen@firewall.loc
Smtp_server 127.0.0.1
Smtp_connect_timeout 30
Router_id lvs_devel
}
Vrrp_instance vi_1 {
State master
Interface eth1
Lvs_sync_daemon_interface eth1
Virtual_router_id 51
Priority100
Advert_int 1
Authentication {
Auth_type pass
Auth_pass 1111
}
Virtual_ipaddress {
59.64.28.94 Dev eth1 label eth1: 1 (virtual IP)
}
}
Virtual_server 59.64.28.94 3306 {
Delay_loop 6
Lb_algo rr
Lb_kind Dr
Nat_mask 255.255.255.0
Persistence_timeout 60
Protocol TCP
Real_server 59.64.28.91 3306 {
Weight 1
Tcp_check {
Connect_timeout 10
Nb_get_retry 3
Delay_before_retry 3
Connect_port 3306
}
}
Real_server 59.64.28.92 3306 {
Weight 1
Tcp_check {
Connect_timeout 10
Nb_get_retry 3
Delay_before_retry 3
Connect_port 3306
}
}
}
Q) Service keepalived restart
R) ipvsadm
IP Virtual Server version 1.2.1 (size = 4096)
Prot localaddress: Port sched1_flags
-> Remoteaddress: port forward weight activeconn inactconn
TCP 59.64.28.94: MySQL RR persistent 60
-> 59.64.28.92: MySQL Route 1 0 0
-> 59.64.28.91: MySQL Route 1 0 0
S) ApplicationProgramChange the database connection host to 59 .. 64.28.94 for testing.
9. Related commands
A) Service ipvsadm restart
B) Service keepalived restart
C) ipvsadm
D) vi/usr/local/keepalive/etc/keepalived. conf [/etc/keepalived. conf]