Mysql数据库集群简单配置
环境:
成都创新互联公司专业为企业提供平川网站建设、平川做网站、平川网站设计、平川网站制作等企业网站建设、网页设计与制作、平川企业网站模板建站服务,10多年平川做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。
192.168.5.155 MySQL-mgm-node
192.168.5.156 mysql-sql-node1 mysql-data-node1
192.168.5.157 mysql-sql-node2 mysql-data-node2
下载cluster软件并上传至各服务器。
1、安装MGM节点:
创建安装目录
mkdir -p /usr/local/mysql/bin
mkdir -p /usr/local/mysql/ndbdata
添加执行文件路径
vi ~/.bash_profile
PATH=$PATH:$HOME/bin:/usr/local/mysql/bin
拷贝执行文件
cp bin/ndb_mgmd /usr/local/mysql/bin
cp bin/ndb_mgm /usr/local/mysql/bin
创建日志文件存储目录
mkdir /var/log/mysql-cluster
创建配置文件目录及文件
mkdir /usr/local/mysql/cluster-conf
vi /usr/local/mysql/cluster-conf/config.ini
编辑配置文件:
[ndbd default]
NoOfReplicas=2
DataMemory=2048M
IndexMemory=512M
[ndb_mgmd]
id=1
hostname=192.168.5.155
DataDir=/var/log/mysql-cluster
[ndbd]
id=11
HostName=192.168.5.156
DataDir=/usr/local/mysql/ndbdata
[ndbd]
id=12
HostName=192.168.5.157
DataDir=/usr/local/mysql/ndbdata
[mysqld]
id=21
HostName=192.168.5.156
[mysqld]
id=22
HostName=192.168.5.157
[mysqld]
id=23
2、安装数据节点及SQL节点:
yum install libaio
#groupadd mysql
#useradd mysql -g mysql
#mv mysql-cluster-gpl-7.2.9-linux2.6-x86_64.tar.gz /usr/local/
#cd /usr/local/
#tar zxvf mysql-cluster-gpl-7.2.9-linux2.6-x86_64.tar.gz
#rm -f mysql-cluster-gpl-7.2.9-linux2.6-x86_64.tar.gz
#mv mysql-cluster-gpl-7.2.9-linux2.6-x86_64 mysql
#chown -R mysql:mysql mysql
#cd mysql
#scripts/mysql_install_db --user=mysql
#cp support-files/my-medium.cnf /etc/my.cnf
#cp support-files/mysql.server /etc/init.d/mysqld
#vi /etc/my.cnf
添加:
datadir=/usr/local/mysql/data/
ndbcluster
ndb-connectstring=192.168.5.155
[ndbd]
connect-string=192.168.5.155
[mysql_cluster]
ndb-connectstring=192.168.5.155
[ndb_mgm]
connect-string=192.168.5.155
[ndb_mgmd]
config-file=/var/lib/mysql-cluster/config.ini
3、启动相关服务
(1)启动管理节点相关服务:
#/usr/local/mysql/bin/ndb_mgmd -f /var/lib/mysql-cluster/config.ini
#netstat -lntpu
tcp 0 0 0.0.0.0:1186 0.0.0.0:*
LISTEN 22907/ndb_mgmd
(2)启动数据节点相关服务:
#/usr/local/mysql/bin/ndbd --initial (初次启动需要加 --initial参数)
#netstat -lntpu
mkdir /usr/local/mysql/ndbdata
chmod 755 /usr/local/mysql/ndbdata
#service mysqld start
4、功能测试:
[root@localhost 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=11 @192.168.5.156 (mysql-5.5.28 ndb-7.2.9, Nodegroup: 0)
id=12 @192.168.5.157 (mysql-5.5.28 ndb-7.2.9, Nodegroup: 0, Master)
[ndb_mgmd(MGM)] 1 node(s)
id=1 @192.168.5.155 (mysql-5.5.28 ndb-7.2.9)
[mysqld(API)] 3 node(s)
id=21 @192.168.5.156 (mysql-5.5.28 ndb-7.2.9)
id=22 @192.168.5.157 (mysql-5.5.28 ndb-7.2.9)
id=23 (not connected, accepting connect from any host)
可关闭master,看master状态是否转移到另外一台;在A关闭状态下,修改B数据库,启动A,看数据是否同步。
标题名称:Mysql数据库集群简单配置
转载注明:http://cdiso.cn/article/gghdsc.html