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) |