文章目錄
一、軟體包
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
二、安裝[管理節點]
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[啟動管理節點]
三、安裝[資料節點]
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-bench --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('123456') where USER='root';
mysql> FLUSH PRIVILEGES;
mysql> quit
修改root使用者遠端存取的許可權:
# 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(初始化資料節點)
四、 查看管理節點
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>
以上為正常顯示
五、測試節點同步
a) 在其中一資料節點中/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) 在另一資料節點中/usr/local/mysql/bin/mysql –uroot –p
d) Create database member;
e) Use member;
f) flush tables ;
g) Show tables;
h) 可以看到admin表已同步
i) Select * from admin
j) 可以看到有一條記錄已同步
k) 叢集正常
六、相關命令
a) /usr/local/mysql/libexec/ndbd –initial(初始化資料節點)
b) /usr/bin/ndb_mgmd shutdown(關閉管理節點)
c) /usr/bin/ndb_mgmd -f /var/lib/mysql-cluster/config.ini(啟動管理節點)
d) /usr/bin/ndb_mgm查看叢集情況
e) Ps aux|grep mysql查看mysql是否啟動
f) Ps aux|grep ndb查看管理節點是否啟動
g) Ndb_mgm –e “show”;
h) Ndb_mgm>all stauts;
i) Ndb_mgm >2 status;(2為節點編號)
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;