设为首页 收藏本站
查看: 845|回复: 0

[经验分享] mysql集群mysql-cluster安装

[复制链接]

尚未签到

发表于 2018-9-27 08:42:35 | 显示全部楼层 |阅读模式
  这两天看了一下 mysql-cluster 从  5.0.X 的时候做过测试,后来就在也没有看过,后来google时,说有些改善,所以就研究了一下。今天只把配置过程写下来,改天把LVS 和  测试结果发来,不过也拿不出什么测试结果,因为现在手头上没有实体服务器,虚拟机器做并发测试没有什么意义呵呵。
  

hostname      IP地址       应用服务  DB1         192.168.6.162     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- --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= 192.168.6.162
  [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 @192.168.6.162 (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=192.168.6.162
  [mysql_cluster]
  ndb-connectstring=192.168.6.162
  

/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 @192.168.6.162 (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=192.168.6.162
  [mysql_cluster]
  ndb-connectstring=192.168.6.162
  

  启动 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 @192.168.6.162 (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 数据库·结束



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-602570-1-1.html 上篇帖子: mysql 行转列 列转行 下篇帖子: 【MySQL】MySQL审计操作记录
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表