心 涯

NET&JAVA&PHP(要跨界,你不只要跨「脑」的界限,更要跨越「心」的界限,不怕改变,不怕再学习!)

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

一、软件包

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;

posted on 2010-11-03 11:19  witer666  阅读(728)  评论(0编辑  收藏  举报