首页 > mysql > mysql集群mysql-cluster安装

mysql集群mysql-cluster安装

2010年4月23日 eric 发表评论 阅读评论

这两天看了一下 mysql-cluster 从 5.0.X 的时候做过测试,后来就在也没有看过,后来google时,说有些改善,所以就研究了一下。今天只把配置过程写下来,改天把LVS 和 测试结果发来,不过也拿不出什么测试结果,因为现在手头上没有实体服务器,虚拟机器做并发测试没有什么意义呵呵。

hostname      IP地址       应用服务
DB1         www.nginxs.com     MGM
DB2         192.168.6.160     NDBD,MYSQLD
DB3         192.168.6.188     NDBD2, MYSQLD
DB4         192.168.6.191     MYSQLD

一.DB1 管理节点 MGM

./configure --prefix=/usr/local/mysql/ --with-charset=utf8 --with-collation=utf8_general_ci --with-client-ldflags=-all-static -with-mysqld-ldflags=-all-static --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-unix-socket-path=/tmp/mysql.sock --sysconfdir=/usr/local/mysql/etc --without-debug --with-mysqld-user=mysql --with-plugin=innobase --with-plugin-ndbcluster --with-plugin-partition
make
make install
cd /usr/local/mysql
mkdir mysql-cluster
cd mysql-cluster
vim config.ini

[ndbd default]
NoOfReplicas= 2
[MYSQLD DEFAULT]
[ndb_mgmd default]
DataDir= /usr/local/mysql/mysql-cluster
[ndb_mgmd]
HostName= www.nginxs.com
[ndbd]
HostName= 192.168.6.160
DataDir= /usr/local/mysql/mysql-cluster
[ndbd]
HostName= 192.168.6.188
DataDir= /usr/local/mysql/mysql-cluster
[mysqld]
HostName= 192.168.6.160
[mysqld]
HostName= 192.168.6.188
[mysqld]
HostName= 192.168.6.191
/usr/local/mysql/libexec/ndb_mgmd -f /usr/local/mysql/mysql-cluster/config.ini
/usr/local/mysql/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=2 (not connected, accepting connect from 192.168.6.160)
id=3 (not connected, accepting connect from 192.168.6.188)

[ndb_mgmd(MGM)] 1 node(s)
id=1 @www.nginxs.com (Version: 5.1.45)

[mysqld(API)] 3 node(s)
id=4 (not connected, accepting connect from 192.168.6.160)
id=5 (not connected, accepting connect from 192.168.6.188)
id=6 (not connected, accepting connect from 192.168.6.191)

可以看到ndb_mgmd 是 连上的,nbd 和 mysqld 还没有连上~

二.在两个ndbd 节点 DB1,DB2 安装mysql

./configure --prefix=/usr/local/mysql/ --with-charset=utf8 --with-collation=utf8_general_ci --with-client-ldflags=-all-static -with-mysqld-ldflags=-all-static --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-unix-socket-path=/tmp/mysql.sock --sysconfdir=/usr/local/mysql/etc --without-debug --with-mysqld-user=mysql --with-plugin=innobase --with-plugin-ndbcluster --with-plugin-partition

groupadd mysql
useradd -g mysql mysql
cd /usr/local/mysql
chown root.mysql . -R
/usr/local/mysql/bin/mysql_install_db --user=mysql

vim /usr/local/mysql/etc/my.cnf
[mysqld]
basedir = /usr/local/mysql/
datadir = /usr/local/mysql/var
user = mysql
port = 3306
socket = /tmp/mysql.sock
ndbcluster
ndb-connectstring=www.nginxs.com
[mysql_cluster]
ndb-connectstring=www.nginxs.com
/usr/local/mysql/libexec/ndbd --initial ### 第一次启动需要 --initial 以后在启动不需要加

随后启动两台ndbd 节点上的 mysql 服务

/usr/local/mysql/bin/mysqld_safe --user=mysql &

然后在 MGM 服务器上查看

/usr/local/mysql/bin/ndb_mgm
-- NDB Cluster -- Management Client --
ndb_mgm> show
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=2 @192.168.6.160 (Version: 5.1.45, Nodegroup: 0)
id=3 @192.168.6.188 (Version: 5.1.45, Nodegroup: 0, Master)
[ndb_mgmd(MGM)] 1 node(s)
id=1 @www.nginxs.com (Version: 5.1.45)
[mysqld(API)] 3 node(s)
id=4 @192.168.6.160 (Version: 5.1.45)
id=5 @192.168.6.188 (Version: 5.1.45)
id=6 (not connected, accepting connect from 192.168.6.191)

从上面可以看出 两个 ndbd 节点 和 ndbd 上的两个mysql 服务已经连接上了。
三.DB4安装mysql节点

./configure --prefix=/usr/local/mysql/ --with-charset=utf8 --with-collation=utf8_general_ci --with-client-ldflags=-all-static -with-mysqld-ldflags=-all-static --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-unix-socket-path=/tmp/mysql.sock --sysconfdir=/usr/local/mysql/etc --without-debug --with-mysqld-user=mysql --with-plugin=innobase --with-plugin-ndbcluster --with-plugin-partition
groupadd mysql
useradd -g mysql mysql
cd /usr/local/mysql
chown root.mysql . -R
/usr/local/mysql/bin/mysql_install_db --user=mysql
vim /usr/local/mysql/etc/my.cnf
[mysqld]
basedir = /usr/local/mysql/
datadir = /usr/local/mysql/var
user = mysql
port = 3306
socket = /tmp/mysql.sock
ndbcluster
ndb-connectstring=www.nginxs.com
[mysql_cluster]
ndb-connectstring=www.nginxs.com

启动 mysql 服务

/usr/local/mysql/bin/mysqld_safe --user=mysql &

回到 MGM 上查看是否正常

DB1 $> /usr/local/mysql/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=2 @192.168.6.160 (Version: 5.1.45, Nodegroup: 0)
id=3 @192.168.6.188 (Version: 5.1.45, Nodegroup: 0, Master)
[ndb_mgmd(MGM)] 1 node(s)
id=1 @www.nginxs.com (Version: 5.1.45)
[mysqld(API)] 3 node(s)
id=4 @192.168.6.160 (Version: 5.1.45)
id=5 @192.168.6.188 (Version: 5.1.45)
id=6 @192.168.6.191 (Version: 5.1.45)

好了,一切正常了,现在回到 mysql 节点上 创建和删除数据看是否同步。
那么就登录 DB2 的 mysql

DB2 $> /usr/local/mysql/bin/mysql -uroot -p
Mysql >show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
+--------------------+
2 rows in set (0.00 sec)
Mysql > create database eric;
Query OK, 1 row affected (0.39 sec)
Mysql >show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| eric |
| mysql |
+--------------------+
3 rows in set (0.01 sec)

好了,在看 DB3 DB4 上是否同步

Db3 $> /usr/local/mysql/bin/mysql -uroot -p
Mysql $> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| eric |
| mysql |
+--------------------+
DB4 $> /usr/local/mysql/bin/mysql -uroot -p
Mysql $> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| eric |
| mysql |
+--------------------+

都看到了 eric 数据库·结束

转载请注明:文章转载自:Eric's linux and nginx! (http://www.nginxs.com)
本文地址:http://www.nginxs.com/linux/137.html

分类: mysql 标签: ,
  1. 2017年11月13日16:12 | #1

    Simply desire to say your article is as astounding.
    The clearness to your publish is simply cool and i can think you are an expert on this subject.
    Well with your permission let me to take hold of your RSS feed to keep updated with forthcoming post.
    Thank you 1,000,000 and please continue the gratifying work.

  2. 2017年11月15日18:22 | #2

    To keep your belongings in safety?

  3. 2017年11月15日22:51 | #3

    Very descriptive post, I loved that bit. Will there
    be a part 2?

  4. 2017年11月21日07:23 | #4

    My programmer is trying to persuade me to move to .net from
    PHP. I have always disliked the idea because of the
    costs. But he’s tryiong none the less. I’ve been using WordPress on a variety of websites for
    about a year and am nervous about switching to another platform.

    I have heard fantastic things about blogengine.net.
    Is there a way I can import all my wordpress content into it?
    Any kind of help would be greatly appreciated!

  5. 2017年11月27日17:23 | #5

    I’m not that much of a internet reader to be honest but your blogs really
    nice, keep it up! I’ll go ahead and bookmark your site to come back later.

    Many thanks

  6. 2017年11月28日03:24 | #6

    Roaccutane Commander order levitra without a prescription Cialis Efectos En La Mujer Discount Pharmacy From Canada Propecia Caduta Indotta

  7. 2017年11月30日15:53 | #7

    On Line Prescription For Viagra Viagra Precio Farmacia buy cialis Cheap On Line Doryx Free Shipping Viagra At 21 Cents Per Pill Cialis 10 Mg Durata

  8. 2017年11月30日17:33 | #8

    Comparaison Viagra Tadalafil Levitra online pharmacy Acheter Kamagra Oral Jelly Priligy Usa Sale

  9. 2017年12月6日16:01 | #9

    Do you have any video of that? I’d like to find out more details.

  10. 2017年12月7日19:59 | #10

    Woah! I’m really enjoying the template/theme of this blog.
    It’s simple, yet effective. A lot of times it’s very difficult to get that “perfect balance” between superb usability
    and visual appeal. I must say you’ve done a awesome job with this.
    In addition, the blog loads very fast for me on Safari.

    Outstanding Blog!

  11. 2017年12月18日06:50 | #11

    Its like you read my mind! You appear to know a lot about this,
    like you wrote the book in it or something. I think that you could do with a few pics to drive the message home a bit, but
    instead of that, this is fantastic blog. A
    fantastic read. I’ll definitely be back.

  12. 2018年1月3日12:59 | #12

    online loans for bad credit
    payday loans
    payday loans
    payday loans online bad credit

  13. 2018年1月5日15:49 | #13

    Fantastic beat ! I would like to apprentice while you amend your site, how could i subscribe for a blog site?
    The account helped me a acceptable deal. I had been tiny bit acquainted of this your broadcast provided
    bright clear concept

  14. 2018年1月14日00:03 | #14

    I do not even know how I finished up right here,
    however I thought this submit was once good. I do not understand who you’re however definitely you’re
    going to a famous blogger in the event you aren’t already.

    Cheers!

  15. 2018年1月14日11:17 | #15

    online slots
    online slots
    online casino
    casino games
    online casino

  16. 2018年1月15日13:11 | #16

    Highly descriptive blog, I loved that bit. Will there be a part 2?

  17. 2018年1月17日23:44 | #17

    payday loans online no credit check
    payday loans no credit check
    payday loans online no credit check
    payday loans no credit
    payday loans online no credit check

  18. 2018年1月18日16:22 | #18

    top rated free online casino games
    online casino real money
    casino online free
    casino games free online

  19. 2018年1月19日20:41 | #19

    400 free slot games
    free casino games vegas world
    free slot machines play
    las vegas casinos free slots
    usa online slots real money

评论分页
1 2 3 4 137
订阅评论
0+5= (必填)