Mysql_cluster 部署(精华版)
目录
一、安装包及说明2
1.1、下载地址2
1.2、环境说明2
1.3、安装MYSQL_Cluster2
1.4、安装MGM管理节点2
1.5、安装NDB数据节点3
1.6、安装SQL数据节点4
1.7、常见问题及启动顺序5
一、 安装包及说明
1.1、下载地址
http://www.mysql.com/downloads/cluster/7.1.html#downloads
mysql-cluster-gpl-7.1.15-linux-x86_64-glibc23.tar.gz (200M)
1.2、环境说明
MGM:--192.168.8.20
SQL :--192.168.8.20
NDB1:--192.168.8.21
NDB1:--192.168.8.21
1.3、安装MYSQL_Cluster
在MGM管理节点、SQL节点、NDB节点执行同一操作
#:groupadd mysql
#:useradd mysql –g mysql –s /sbin/nologin
#: tar –xvf mysql-cluster-gpl-7.1.15-linux-x86_64-glibc23.tar.gz
#:mv mysql-cluster-gpl-7.1.15-linux-x86_64-glibc23 /usr/local/mysql_cluster
#:#:vim /etc/profile
MYSQL_CLUSTER=/usr/local/mysql_cluster/bin
PATH=$PATH:$HOME/bin:$MYSQL_CLUSTER
export PATH
1.4、安装MGM管理节点
#:mkdir -p /opt/mgm/logs
#:mkdir /opt/conf
#: cp /soft/mgm-conf/config.ini /opt/conf/
#:vim /opt/conf
# Options affecting ndbd processes on all home/data nodes:
[ndbd default]
NoOfReplicas=2
DataMemory=200M # How much memory to allocate for home/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" home/database takes up
# only about 500KB, this should be more than enough for
# this example Cluster setup.
MaxNoOfAttributes=999999
MaxNoOfConcurrentTransactions=10240
LogLevelStatistic=15
LogLevelCheckpoint=15
LogLevelConnection=15
LogLevelError=15
LogLevelInfo=15
[ndb_mgmd]
NodeId=1
Hostname=192.168.8.20
Datadir=/opt/mgm/logs
LogDestination=FILE:filename=ndb_1_cluster.log,maxsize=10000000,maxfiles=6
ArbitrationRank=0
[ndbd]
NodeId=10
Hostname=192.168.8.21
Datadir=/opt/db1/data
backupdatadir=/opt/db1/databak
[ndbd]
NodeId=11
Hostname=192.168.8.21
Datadir=/opt/db2/data
backupdatadir=/opt/db2/databak
[mysqld]
NodeId=20
[api]
[api]
[api]
[api]
[api]
启动管理节点
#:ndb_mgmd -f /opt/conf/config.ini --configdir=/opt/conf/
1.5、安装NDB数据节点
#:mkdir -p /opt/db1/data && mkdir /opt/db1/databak
#:mkdir -p /opt/db2/data && mkdir /opt/db2/databak
#:mkdir /opt/conf
#:cp /soft/ndb-conf/my.cnf /opt/conf
#:vim /opt/conf/my.cnf
[mysqld]
ndbcluster
ndb-connectstring=192.168.8.20
[mysql_cluster]
ndb-connectstring=192.168.8.20
启动NDB节点
#:ndbd --defaults-file=/opt/conf/my.cnf && ndbd --defaults-file=/opt/conf/my.cnf
1.6、安装SQL数据节点
#: cp /opt/soft/slq-conf/my.cnf /usr/local/mysql_cluster
#:cp /usr/local/mysqlcluster/support-files/mysql.server /etc/init.d/mysql
#:vim /etc/init.d/mysql
basedir=/usr/local/mysql_cluster
datadir=/opt/sql/data
#:vim /usr/local/mysql_cluster/my.cnf
# Options for mysqld process:
[mysqld]
max_connections=200000
datadir=/opt/sql/data/
port=3307
socket=/tmp/mysql.sock
character-set-server=utf8
default-storage-engine=ndbcluster
server-id=20
ndbcluster
# run NDB storage engine
ndb-connectstring=192.168.8.20
ndb-force-send=1
ndb-use-exact-count=0
ndb-extra-logging=1
ndb-autoincrement-prefetch-sz=512
engine-condition-pushdown=1
ndb-cluster-connection-pool=1
key_buffer_size=16M
max_allowed_packet=10M
sort_buffer_size=256K
read_buffer_size=128K
read_rnd_buffer_size=256K
table_lock_wait_timeout=16
memlock
sysdate_is_now
thread-cache-size=512
table-open_cache=512
max_prepared_stmt_count=24576
lower-case-table-names=0
# Timeout
interactive_timeout=43200
wait_timeout=43200
connect_timeout=60
skip-name-resolve
[ndbd]
connect-string=192.168.8.21
[ndbd_mgm]
connect-string=192.168.8.20
[mysql_cluster]
ndb-connectstring=192.168.8.20
# location of management server
#:初始化
cripts/mysql_install_db --user=mysql --basedir=/usr/local/services/mysql_cluster/ --datadir=/opt/sql/data/
启动SQL节点
#:/etc/init.d/mysql start
1.7、常见问题及启动顺序
启动顺序
MGM-->NDBD-->SQL
关闭顺序
关闭
SQL-->MGM (NDBD)
当关闭掉MGM后。NDBD也会停掉
关闭MGM
ndb_mgm –e shutdown
测试:
ndbd_mgm –e show