HA_Cluster: corosync+pacemaker+drbd+mysql
来源:SegmentFault
2023-02-24 19:45:03
0浏览
收藏
来到golang学习网的大家,相信都是编程学习爱好者,希望在这里学习数据库相关编程知识。下面本篇文章就来带大家聊聊《HA_Cluster: corosync+pacemaker+drbd+mysql》,介绍一下MySQL、HA、cluster、drbd,希望对大家的知识积累有所帮助,助力实战开发!
本文主要讲述HA_Cluster: corosync+pacemaker+drbd+mysql 的CRM资源配置, 各个软件的安装配置不再介绍
CRM配置DRBD资源:
1.基本配置:
crm(live)configure# property stonith-enabled=false #关闭stonith crm(live)configure# property no-quorum-policy=ignore #不具备法定票数时的行为: 忽略 crm(live)configure# rsc_defaults resource-stickiness=100 #默认资源粘性为100 crm(live)configure# verify crm(live)configure# commit
2.添加DRBD资源:
crm(live)configure# primitive drbd_data ocf:linbit:drbd params drbd_resource="data" op monitor role="Master" interval="50" timeout="30" op monitor role="Slave" interval interval-origin= interval= crm(live)configure# primitive drbd_data ocf:linbit:drbd params drbd_resource=data op monitor role=Master interval=50 timeout=30 op monitor role=Slave interval=60 timeout=30 op start timeout=240 op stop timeout=100 crm(live)configure# verify crm(live)configure# ms ms_drbd_data drbd_data meta master-max=1 master-node-max=1 clone-max=2 clone-node-max=1 notify=true crm(live)configure# verify crm(live)configure# commit
PS: heartbeat 和 linbit 都提供了drbd 的 RA ,本人实验时发现使用 heartbeat 提供的 RA 会出现无法选举 Master 节点的情况, 此处建议使用 linbit 提供的RA
如有人知道为什么 heartbeat 的 RA 选不出 Master 节点, 愿闻其详
测试DRBD服务:
root@drbd1:~# crm status Last updated: Sun May 22 22:04:35 2016 Last change: Mon May 23 06:02:13 2016 via cibadmin on drbd1 Stack: corosync Current DC: drbd1 (168495249) - partition with quorum Version: 1.1.10-42f2063 2 Nodes configured 2 Resources configured Online: [ drbd1 drbd2 ] Master/Slave Set: ms_drbd_data [drbd_data] Masters: [ drbd1 ] Slaves: [ drbd2 ] root@drbd1:~# crm node standby <strong>#离线drbd1</strong> root@drbd1:~# crm status Last updated: Mon May 23 06:07:22 2016 Last change: Mon May 23 06:07:14 2016 via crm_attribute on drbd1 Stack: corosync Current DC: drbd1 (168495249) - partition with quorum Version: 1.1.10-42f2063 2 Nodes configured 2 Resources configured Node drbd1 (168495249): standby Online: [ drbd2 ] Master/Slave Set: ms_drbd_data [drbd_data] Masters: [ drbd2 ] Stopped: [ drbd1 ] root@drbd1:~# crm node online <strong>#上线drbd1</strong> root@drbd1:~# crm status Last updated: Mon May 23 06:09:11 2016 Last change: Mon May 23 06:09:09 2016 via crm_attribute on drbd1 Stack: corosync Current DC: drbd1 (168495249) - partition with quorum Version: 1.1.10-42f2063 2 Nodes configured 2 Resources configured Online: [ drbd1 drbd2 ] Master/Slave Set: ms_drbd_data [drbd_data] Masters: [ drbd2 ] Slaves: [ drbd1 ] root@drbd2:~# crm node standby #离线drbd2 root@drbd2:~# crm node online #上线drbd2 root@drbd2:~# crm status Last updated: Sun May 22 22:11:47 2016 Last change: Mon May 23 06:11:18 2016 via crm_attribute on drbd2 Stack: corosync Current DC: drbd1 (168495249) - partition with quorum Version: 1.1.10-42f2063 2 Nodes configured 2 Resources configured Online: [ drbd1 drbd2 ] Master/Slave Set: ms_drbd_data [drbd_data] Masters: [ drbd1 ] Slaves: [ drbd2 ] -------------正常---------------
配置Filesystem资源:
crm(live)configure# primitive mount ocf:heartbeat:Filesystem params device=/dev/drbd0 directory=/var/lib/mysql fstype=ext3 op start timeout=60 op stop timeout=60 crm(live)configure# verify crm(live)configure# colocation mount_with_ms_drbd_data inf: mount ms_drbd_data:Master crm(live)configure# order mount_after_ms_drbd_data Mandatory: ms_drbd_data:promote mount:start crm(live)configure# verify crm(live)configure# commit
测试Filesystem资源:
root@drbd2:~# crm status Last updated: Mon May 23 20:28:19 2016 Last change: Mon May 23 20:27:37 2016 via crm_attribute on drbd1 Stack: corosync Current DC: drbd1 (168495249) - partition with quorum Version: 1.1.10-42f2063 2 Nodes configured 3 Resources configured Online: [ drbd1 drbd2 ] Master/Slave Set: ms_drbd_data [drbd_data] Masters: [ drbd2 ] Slaves: [ drbd1 ] mount (ocf::heartbeat:Filesystem): Started drbd2 #现在drbd0挂载在drbd2上 root@drbd2:~# crm node standby root@drbd2:~# crm node online root@drbd2:~# crm status Last updated: Mon May 23 20:28:31 2016 Last change: Mon May 23 20:28:28 2016 via crm_attribute on drbd2 Stack: corosync Current DC: drbd1 (168495249) - partition with quorum Version: 1.1.10-42f2063 2 Nodes configured 3 Resources configured Node drbd2 (168495262): standby Online: [ drbd1 ] Master/Slave Set: ms_drbd_data [drbd_data] Masters: [ drbd1 ] Stopped: [ drbd2 ] mount (ocf::heartbeat:Filesystem): Started drbd1 #成功转移到drbd1
配置mysql(此处直接使用apt-get安装)资源:
crm(live)configure# primitive mysqld lsb:mysql crm(live)configure# primitive mysql_ip ocf:heartbeat:IPaddr params ip=10.11.8.200 cidr_netmask=23 crm(live)configure# verify crm(live)configure# colocation mysql_ip_with_mount inf: mysql_ip mount crm(live)configure# colocation mysqld_with_mount inf: mysqld mount crm(live)configure# order mysqld_after_mount Mandatory: mount mysqld crm(live)configure# verify crm(live)configure# commit
查看CRM配置:
node $id="168495249" drbd1 \ attributes standby="off" node $id="168495262" drbd2 \ attributes standby="off" primitive drbd_data ocf:linbit:drbd \ params drbd_resource="data" \ op monitor role="Master" interval="50" timeout="30" \ op monitor role="Slave" interval="60" timeout="30" \ op start timeout="240" interval="0" \ op stop timeout="100" interval="0" primitive mount ocf:heartbeat:Filesystem \ primitive mount ocf:heartbeat:Filesystem \ params device="/dev/drbd0" directory="/var/lib/mysql" fstype="ext3" \ op start timeout="60" interval="0" \ op stop timeout="60" interval="0" \ meta target-role="Started" primitive mysql_ip ocf:heartbeat:IPaddr \ params ip="10.11.8.200" cidr_netmask="23" primitive mysqld lsb:mysql ms ms_drbd_data drbd_data \ meta master-max="1" master-node-max="1" clone-max="2" clone-node-max="1" notify="true" target-role="Started" colocation mount_with_ms_drbd_data inf: mount ms_drbd_data:Master colocation mysql_ip_with_mount inf: mysql_ip mount colocation mysqld_with_mount inf: mysqld mount order mount_after_ms_drbd_data Mandatory: ms_drbd_data:promote mount:start order mysqld_after_mount Mandatory: mount mysqld property $id="cib-bootstrap-options" \ dc-version="1.1.10-42f2063" \ cluster-infrastructure="corosync" \ stonith-enabled="false" \ no-quorum-policy="ignore" \ last-lrm-refresh="1464019270" rsc_defaults $id="rsc-options" \ resource-stickiness="100"
修改mysql监听所有地址:
root@drbd1:~# vim /etc/mysql/my.cnf #bind-address = 127.0.0.1 #注释这一行
测试服务:
root@drbd1:~# crm status Last updated: Tue May 24 00:55:04 2016 Last change: Tue May 24 00:42:45 2016 via crmd on drbd1 Stack: corosync Current DC: drbd1 (168495249) - partition with quorum Version: 1.1.10-42f2063 2 Nodes configured 5 Resources configured Online: [ drbd1 drbd2 ] Master/Slave Set: ms_drbd_data [drbd_data] Masters: [ drbd1 ] Slaves: [ drbd2 ] mount (ocf::heartbeat:Filesystem): Started drbd1 mysqld (lsb:mysql): Started drbd1 mysql_ip (ocf::heartbeat:IPaddr): Started drbd1
在drbd2上连接测试:
root@drbd2:~# mysql -h10.11.8.200 -ushiina -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 40 Server version: 5.6.30-0ubuntu0.14.04.1 (Ubuntu) Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases; +---------------------+ | Database | +---------------------+ | information_schema | | #mysql50#lost+found | | mysql | | performance_schema | +---------------------+ 4 rows in set (0.01 sec) mysql> create database ha_test; Query OK, 1 row affected (0.00 sec)
离线drbd1后再drbd1上连接测试:
root@drbd1:~# crm status Last updated: Mon May 23 21:13:24 2016 Last change: Mon May 23 21:13:22 2016 via cibadmin on drbd1 Stack: corosync Current DC: drbd1 (168495249) - partition with quorum Version: 1.1.10-42f2063 2 Nodes configured 5 Resources configured Online: [ drbd1 drbd2 ] Master/Slave Set: ms_drbd_data [drbd_data] Masters: [ drbd2 ] Slaves: [ drbd1 ] mount (ocf::heartbeat:Filesystem): Started drbd2 mysql_ip (ocf::heartbeat:IPaddr): Started drbd2 mysqld (lsb:mysql): Started drbd2 root@drbd1:~# mysql -h10.11.8.200 -ushiina -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 40 Server version: 5.6.30-0ubuntu0.14.04.1 (Ubuntu) Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | ha_test | | lost+found | | mysql | | performance_schema | +--------------------+ 5 rows in set (0.00 sec)
本篇关于《HA_Cluster: corosync+pacemaker+drbd+mysql》的介绍就到此结束啦,但是学无止境,想要了解学习更多关于数据库的相关知识,请关注golang学习网公众号!
版本声明
本文转载于:SegmentFault 如有侵犯,请联系study_golang@163.com删除

- 上一篇
- mysql 配置优化

- 下一篇
- MySQL避免索引列使用 OR 条件
查看更多
最新文章
-
- 数据库 · MySQL | 1小时前 |
- MySQL缓存优化技巧分享
- 424浏览 收藏
-
- 数据库 · MySQL | 2小时前 |
- MySQL内存优化技巧及参数设置解析
- 168浏览 收藏
-
- 数据库 · MySQL | 4小时前 |
- Mac安装MySQL问题及解决方法大全
- 477浏览 收藏
-
- 数据库 · MySQL | 7小时前 |
- MySQL新手必学命令大全
- 375浏览 收藏
-
- 数据库 · MySQL | 9小时前 |
- MySQL优化like查询的技巧与方法
- 458浏览 收藏
-
- 数据库 · MySQL | 11小时前 |
- 三种方式登录MySQL图文教程
- 153浏览 收藏
-
- 数据库 · MySQL | 12小时前 |
- MySQL数据备份方法与工具推荐
- 101浏览 收藏
-
- 数据库 · MySQL | 13小时前 |
- MySQL连接池配置与优化方法
- 233浏览 收藏
-
- 数据库 · MySQL | 1天前 |
- MySQL事务是什么?如何保证数据一致性?
- 421浏览 收藏
-
- 数据库 · MySQL | 1天前 |
- MySQL索引优化与性能提升技巧
- 272浏览 收藏
-
- 数据库 · MySQL | 1天前 |
- MySQL数据备份方法与策略详解
- 187浏览 收藏
-
- 数据库 · MySQL | 1天前 |
- MySQL无法启动的8个解决方法
- 388浏览 收藏
查看更多
课程推荐
-
- 前端进阶之JavaScript设计模式
- 设计模式是开发人员在软件开发过程中面临一般问题时的解决方案,代表了最佳的实践。本课程的主打内容包括JS常见设计模式以及具体应用场景,打造一站式知识长龙服务,适合有JS基础的同学学习。
- 542次学习
-
- GO语言核心编程课程
- 本课程采用真实案例,全面具体可落地,从理论到实践,一步一步将GO核心编程技术、编程思想、底层实现融会贯通,使学习者贴近时代脉搏,做IT互联网时代的弄潮儿。
- 511次学习
-
- 简单聊聊mysql8与网络通信
- 如有问题加微信:Le-studyg;在课程中,我们将首先介绍MySQL8的新特性,包括性能优化、安全增强、新数据类型等,帮助学生快速熟悉MySQL8的最新功能。接着,我们将深入解析MySQL的网络通信机制,包括协议、连接管理、数据传输等,让
- 498次学习
-
- JavaScript正则表达式基础与实战
- 在任何一门编程语言中,正则表达式,都是一项重要的知识,它提供了高效的字符串匹配与捕获机制,可以极大的简化程序设计。
- 487次学习
-
- 从零制作响应式网站—Grid布局
- 本系列教程将展示从零制作一个假想的网络科技公司官网,分为导航,轮播,关于我们,成功案例,服务流程,团队介绍,数据部分,公司动态,底部信息等内容区块。网站整体采用CSSGrid布局,支持响应式,有流畅过渡和展现动画。
- 484次学习
查看更多
AI推荐
-
- 边界AI平台
- 探索AI边界平台,领先的智能AI对话、写作与画图生成工具。高效便捷,满足多样化需求。立即体验!
- 418次使用
-
- 免费AI认证证书
- 科大讯飞AI大学堂推出免费大模型工程师认证,助力您掌握AI技能,提升职场竞争力。体系化学习,实战项目,权威认证,助您成为企业级大模型应用人才。
- 424次使用
-
- 茅茅虫AIGC检测
- 茅茅虫AIGC检测,湖南茅茅虫科技有限公司倾力打造,运用NLP技术精准识别AI生成文本,提供论文、专著等学术文本的AIGC检测服务。支持多种格式,生成可视化报告,保障您的学术诚信和内容质量。
- 561次使用
-
- 赛林匹克平台(Challympics)
- 探索赛林匹克平台Challympics,一个聚焦人工智能、算力算法、量子计算等前沿技术的赛事聚合平台。连接产学研用,助力科技创新与产业升级。
- 662次使用
-
- 笔格AIPPT
- SEO 笔格AIPPT是135编辑器推出的AI智能PPT制作平台,依托DeepSeek大模型,实现智能大纲生成、一键PPT生成、AI文字优化、图像生成等功能。免费试用,提升PPT制作效率,适用于商务演示、教育培训等多种场景。
- 570次使用
查看更多
相关文章
-
- golang MySQL实现对数据库表存储获取操作示例
- 2022-12-22 499浏览
-
- 搞一个自娱自乐的博客(二) 架构搭建
- 2023-02-16 244浏览
-
- B-Tree、B+Tree以及B-link Tree
- 2023-01-19 235浏览
-
- mysql面试题
- 2023-01-17 157浏览
-
- MySQL数据表简单查询
- 2023-01-10 101浏览