全部博文(535)
分类: LINUX
2011-05-13 10:56:35
操作系统:CentOS release 5.5
Mysql:
详情参考mysql的官方手册。
数据节点和mysql节点的安装
1.检查系统中是否已经存在mysql用户和组。
查看/etc/passwd和/etc/group文件,检查系统是否已存在mysql用户和组。
如果不存在,用以下命令添加:
shell> groupadd mysql
shell> useradd –g mysql mysql
2.解压安装。
shell> chown –R root .
shell> chown –R mysql data
shell> chgrp –R mysql .
2.4复制执行文件,加入系统启动项:
shell> cp support-files/mysql.server /etc/rc.d/init.d/
shell> chmod +x /etc/rc.d/init.d/mysql.server
shell> chkconfig –add mysql.server
管理节点的安装
1.解压安装
shell> cd /var/tmp
2.修改权限
3.1创建数据节点和mysql节点的my.cnf配置文件
shell> vi /etc/my.cnf
my.cnf内容如下:
[mysqld]
# Options for mysqld process:
ndbcluster# run NDB storage engine
ndb-connectstring=192.168.0.10# location of management server
[mysql_cluster]
# Options for ndbd process:
ndb-connectstring=192.168.0.10# location of management server
3.2创建管理节点的config.ini配置文件
shell> mkdir /var/lib/mysql-cluster
shell> cd /var/lib/mysql-cluster
shell> vi config.ini
config.ini内容如下:
[ndbd default]
# Options affecting ndbd processes on all data nodes:
NoOfReplicas=2# Number of replicas
DataMemory=80M# How much memory to allocate for data storage
IndexMemory=18M# How much memory to allocate for index storage
# For DataMemory and IndexMemory, we have used the
# default values. Since the "world" database takes up
# only about 500KB, this should be more than enough for
# 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 the cluster
# Note: It is recommended that you do not specify the port
# number at all and simply allow the default value to be used
# instead
[ndb_mgmd]
# Management process options:
hostname=192.168.0.10# Hostname or IP address of MGM node
datadir=/var/lib/mysql-cluster# Directory for MGM node log files
[ndbd]
# Options for data node "A":
# (one [ndbd] section per data node)
hostname=192.168.0.30# Hostname or IP address
datadir=/usr/local/mysql/data# Directory for this data node's data files
[ndbd]
# Options for data node "B":
hostname=192.168.0.40# Hostname or IP address
datadir=/usr/local/mysql/data# Directory for this data node's data files
[mysqld]
# SQL node options:
hostname=192.168.0.20# Hostname or IP address
# (additional mysqld connections can be
# specified for this node for various
# purposes such as running ndb_restore)
1.启动管理服务器:(正常情况下,它们位于/usr/local/mysql/bin目录下)。
shell> ndb_mgmd
2.启动数据节点。首次为给定的DB节点启动ndbd时,应使用“—initial”选项
shell> cd /usr/local/mysql/bin
shell> ./ndbd --initial
shell> ./ndbd
3.启动mysql节点。
shell> cd /usr/local/mysql/bin
shell> mysqld_safe --user=mysql &
如果要进入mysql客户端
shell> ./mysql
好了,大功告成。你要对数据进行任何常规操作,建数据库,建表之类的可以在mysql节点进行,和正常的mysql没有什么区别。
如果要查看集群的状态,可以在管理节点启动管理客户端,用show命令:
shell> ndb_mgm
ndb_mgm> show
如果要关闭集群:
shell> ndb_mgm –e shutdown
集群管理客户端命令
ndb_mgm> show
ndb_mgm> nodeID
STOP
ndb_mgm> ndoeID
START
ndb_mgm> nodeID
RESTART
ndb_mgm> CREATE NODEGROUP
3,4
ndb_mgm> ALL REPORT
MEMORY
ndb_mgm> START BACKUP
NOWAIT
ndb_mgm> ndb_desc -c 192.168.1.10 -d n ips -p
mysql> source
PATH/script.sql
mysql> delimiter
//
mysql> show procedure
status;
mysql> SHOW DATABASES;
mysql> SHOW TABLES;
mysql> DESCRIBE table_name;
mysql> SELECT
DATABASE();
mysql> select user();
mysql> select current_user();