Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1298212
  • 博文数量: 127
  • 博客积分: 2286
  • 博客等级: 大尉
  • 技术积分: 1943
  • 用 户 组: 普通用户
  • 注册时间: 2010-06-10 10:37
文章分类

全部博文(127)

文章存档

2018年(1)

2015年(2)

2014年(1)

2013年(30)

2012年(88)

2011年(5)

分类: Mysql/postgreSQL

2012-04-06 11:08:19

0 配置信息
--------------------------------------------------
$ cat setup.conf
NDB_MGM_SERVERS="192.168.1.12:1186,192.168.1.14:1186"
MYSQL_ROOT=/mysql
DATA_ROOT=/data
MYSQL_CONFIG_DIR=/etc/mysql
STAGE_DIR=/stage
REP_SERVER=108.166.72.92

MCM_FILE=mcm-1.1.4_64-cluster-7.2.4_64-linux-rhel5-x86
MCM_USER=admin
MCM_PASS=admindemo
MCM_SITE_NAME=sitename002
MCM_VERSION=v7.2.4
MCM_CLUSTER_NAME=c01_clustername
MCM_HOSTS="192.168.1.12,192.168.1.14"
MCM_ARCH="ndb_mgmd@192.168.1.12,ndb_mgmd@192.168.1.14,ndbd@192.168.1.12,ndbd@192.168.1.14,mysqld@192.168.1.12,mysqld@192.168.1.14"

1. root用户的操作
--------------------------------------------------
#!/bin/bash
#Run as root or sudo

BASEDIR=$(dirname $0)
. $BASEDIR/setup.conf

#Add user for mysql
cp /etc/passwd /etc/passwd.orig
cp /etc/group /etc/group.orig
groupadd -g 6666 mysql
useradd -g 6666 -u 6666 -m mysql

mkdir -p $MYSQL_ROOT
chown mysql.mysql $MYSQL_ROOT
mkdir -p $DATA_ROOT
chown mysql.mysql $DATA_ROOT
mkdir $MYSQL_CONFIG_DIR
chown mysql.mysql $MYSQL_CONFIG_DIR


2. 安装软件MCM
--------------------------------------------------
#!/bin/bash
#run as mysql user
BASEDIR=$(dirname $0)
. $BASEDIR/setup.conf


cd $STAGE_DIR
#wget {MCM_FILE}.tar.gz
#rm -fr ${MCM_FILE}
#tar zxf ${MCM_FILE}.tar.gz -C $MYSQL_ROOT
# rm -f ${MCM_FILE}.tar.gz
#cd $MYSQL_ROOT
#ln -s ${MCM_FILE} mcm


#create the configure
cat < $MYSQL_CONFIG_DIR/mcmd.ini

[mcmd]
plugins=manager
manager-port = 1862

log-file = mcmd.log
log-level = message
manager-directory=$DATA_ROOT/mcm_data
pid-file=$DATA_ROOT/mcm_data/mcmd.pid

manager-username=$MCM_USER
manager-password=$MCM_PASS

EOF_conf

chmod 660 $MYSQL_CONFIG_DIR/mcmd.ini

#create the start script
cat < $MYSQL_CONFIG_DIR/mcmd_start.sh
#!/bin/bash

$MYSQL_ROOT/mcm/bin/mcmd --defaults-file=$MYSQL_CONFIG_DIR/mcmd.ini &

EOF_sh

chmod u+x $MYSQL_CONFIG_DIR/mcmd_start.sh
mkdir -p $DATA_ROOT/mcm_data

3. 建立cluster
--------------------------------------------------
cat 03_SetupMCM.mysql.sh
#!/bin/bash
#run as mysql user

BASEDIR=$(dirname $0)
. $BASEDIR/setup.conf
MCMexec="$MYSQL_ROOT/mcm/cluster/bin/mysql -u admin --password=$MCM_PASS --port=1862 -h 127.0.0.1"
echo $MCMexec

cat <
create site --hosts=$MCM_HOSTS $MCM_SITE_NAME;
list sites;
add package --basedir=$MYSQL_ROOT/mcm/cluster $MCM_VERSION;
list packages $MCM_SITE_NAME;
create cluster --package=$MCM_VERSION --processhosts=$MCM_ARCH $MCM_CLUSTER_NAME;

show status -r $MCM_CLUSTER_NAME;

set MaxNoOfConcurrentOperations:ndbd=100000 $MCM_CLUSTER_NAME;
set MaxNoOfConcurrentTransactions:ndbd=16384 $MCM_CLUSTER_NAME;

set MaxNoOfTables:ndbd=4096 $MCM_CLUSTER_NAME;
set MaxNoOfOrderedIndexes:ndbd=2048 $MCM_CLUSTER_NAME;
set MaxNoOfUniqueHashIndexes:ndbd=512 $MCM_CLUSTER_NAME;
set MaxNoOfAttributes:ndbd=24576 $MCM_CLUSTER_NAME;
set MaxNoOfTriggers:ndbd=14336 $MCM_CLUSTER_NAME;


set DataMemory:ndbd=4G,IndexMemory:ndbd=500M $MCM_CLUSTER_NAME;
set SendBufferMemory:ndbd+mysqld=4M $MCM_CLUSTER_NAME;


start cluster $MCM_CLUSTER_NAME;
show status -r $MCM_CLUSTER_NAME;

EOF_sql

常用MCM命令
--------------------------------------------------
1个MCM可以管理多个site,一个site可以有多个package和cluster


list sites; 先查看site
list clusters site_clustername;在看site下的cluster
show status -r c01_clustername; 最后看cluster的状态,看各个部件的状态,常用
show status -c c01_clustername; 查看整个cluster的状态


stop cluster -B c01_clustername; 在后台执行stop
stop cluster c01_clustername; 在前台执行stop命令


start cluster -B c01_clustername; 在后台执行
start cluster c01_clustername; 在前台执行

show status -r c01_clustername;


list packages site_clustername;
delete cluster c01_clustername;
delete package v7.2.4;
delete site site_clustername;


配置参数,批量修改最好先关闭cluster,否则每次都要做一次rolling restarts

set MaxNoOfConcurrentOperations:ndbd=100000 c01_clustername;
set MaxNoOfConcurrentTransactions:ndbd=16384 c01_clustername;

set MaxNoOfTables:ndbd=4096 c01_clustername;
set MaxNoOfOrderedIndexes:ndbd=2048 c01_clustername;
set MaxNoOfUniqueHashIndexes:ndbd=512 c01_clustername;
set MaxNoOfAttributes:ndbd=24576 c01_clustername;
set MaxNoOfTriggers:ndbd=14336 c01_clustername;


set DataMemory:ndbd=4G,IndexMemory:ndbd=500M c01_clustername;
set SendBufferMemory:ndbd+mysqld=4M c01_clustername;

阅读(3245) | 评论(5) | 转发(0) |
给主人留下些什么吧!~~

kerlion2012-06-27 11:11:15

这个严重的问题我也发现了,所以一定要保证你在启动一个datanode的时候其他datanode正常运行,否则很危险。我现在已决定不用MCM了,问题很多。

raputa2012-06-20 17:44:52

kerlion: 理论上cluster应该是不停的,如果停了,或重启肯定与事情,所以不需要自动启动cluster,但是mcmd会自动启动。.....
现在出现一个新的问题,每次启动mcmd的时候,都会初始化ndbd。这样很危险,里面的数据会全部被清空。我想请教一下,mcm在哪里可以手动设置一下,将--initial参数去掉。期待您的回复。

kerlion2012-06-05 10:50:41

我们决定已经放弃使用MCM了,因为除了安装方便外,平时管理维护有很多问题。

kerlion2012-06-05 10:49:36

理论上cluster应该是不停的,如果停了,或重启肯定与事情,所以不需要自动启动cluster,但是mcmd会自动启动。

raputa2012-06-04 17:55:22

很实用,我下了1.1.5的,已经成功安装。谢谢!
另外想问下,启动了mcmd进程后,不会自动启动cluster,可以通过设置启动么?比如,StopOnError这个参数可以么?还是说要单独写个脚本来启动。