MySQL容量规划之tcpcopy应用之道
官方文档:https://github.com/session-replay-tools/mysql-replay-module
tcpcopy可以将正式环境上来自客户端的请求复制一份到测试端并复现,想要真实的对MySQL进行容量规划,可以借助tcpcopy来将线上的流量
呈倍数的增长,将其复制到测试环境,从而快速定位测试环境出现瓶颈时负载情况,进而做好容量的全局把控
部署
伪装客户端IP:1.1.1.4
online server:1.1.1.1
target server :1.1.1.2
assistant server:1.1.1.3
前提条件:
1、三个节点的网络互通无网卡的安全限制(大多数云环境设置了安全限制),tcpcopy通过 -c 选项可以将线上服务器抓取的包复制一份并将来源IP
伪装成指定的客户端IP发送给target,如果进行了安全限制,一个网卡无法绑定2个IP,所以online server则会拒绝发送复制包,在online server
上通过tcpdump抓取的包将会如下
tcpdump -i eth0 -nn port 3306 and host 1.1.1.4

每隔3秒online server会发送RST
关于tcp标志

正常情况下伪客户端会和target建立三次握手
2、操作系统关闭rp_filter,内核2.6版本默认是关闭
echo 0 > /proc/sys/net/ipv4/conf/all/rp_filter
3、按照官方文档将MySQL服务的用户名密码写入配置文件
4、assistant server关闭路由功能,默认是关闭的
echo > /proc/sys/net/ipv4/ip_forward
具体操作
online server
/usr/local/src/tcpcopy/objs/tcpcopy -x -1.1.1.2: -s 1.1.1.3 -c 1.1.1.4 -n -d
# 如果是多实例,sourcePort-targetIP:targetPort,以逗号分隔
/usr/local/src/tcpcopy/objs/tcpcopy -x 3306-1.1.1.2:3306,3307-1.1.1.2:3307 -s 1.1.1.3 -c 1.1.1.4 -n 3 -d
target server
/usr/local/src/intercept/objs/intercept -i eth0 -F tcp and src port -d
assistant server
route add -host 1.1.1.4 gw 1.1.1.3
# mysql -h1.1.1.1 -uadmin -p123123 -P3306
# 创建带有主键的表t2
CREATE TABLE `t2` (
`id` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
# 创建无约束字段的表t3
CREATE TABLE `t3` (
`id` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8
# 然后在两个表中分别插入一条数据
insert into t2 values(1);
insert into t3 values(1);
target server
mysql> show processlist;
+------+-------------+---------------------+------+---------+---------+--------------------------------------------------------+------------------+
| Id | User | Host | db | Command | Time | State | Info |
+------+-------------+---------------------+------+---------+---------+--------------------------------------------------------+------------------+
| 11 | system user | | NULL | Connect | 3044244 | Slave has read all relay log; waiting for more updates | NULL |
| 12 | system user | | NULL | Connect | 3044248 | Waiting for an event from Coordinator | NULL |
| 13 | system user | | NULL | Connect | 3044248 | Waiting for an event from Coordinator | NULL |
| 14 | system user | | NULL | Connect | 3044248 | Waiting for an event from Coordinator | NULL |
| 15 | system user | | NULL | Connect | 3044248 | Waiting for an event from Coordinator | NULL |
| 3961 | root | localhost | NULL | Query | 0 | starting | show processlist |
| 3962 | admin | 1.1.1.4:24695 | NULL | Sleep | 5 | | NULL |
| 3963 | admin | 1.1.1.4:24286 | NULL | Sleep | 5 | | NULL |
| 3964 | admin | 1.1.1.4:24759 | NULL | Sleep | 5 | | NULL |
+------+-------------+---------------------+------+---------+---------+--------------------------------------------------------+------------------+
9 rows in set (0.00 sec)
mysql> select * from t2;
+----+
| id |
+----+
| 1 |
+----+
1 row in set (0.00 sec)
mysql> select * from t3;
+------+
| id |
+------+
| 1 |
| 1 |
| 1 |
+------+
3 rows in set (0.00 sec)
可以看到同时3倍的流量复制效应,对应的是3个回话;表t2有约束,tcpcopy会处理冲突的部分,
所以最后看到的是t1表中只有一条数据,而t2表中则是3倍流量复制的结果
MySQL容量规划之tcpcopy应用之道的更多相关文章
- 二 mysql容量规划,性能测试
何为基线- 当前运行状态记录.快照- 用于和未来的状态进行对比- 未来时刻产生关键事件后的新状态,作为下一个基线基线数据收集,关注哪些要点- 系统负载- MySQL运行状态- 相应的业务指标1.系统& ...
- MySQL容量规划和性能测试
性能容量关键指标: 每秒tps,峰值tps 基础数据量,日均增长数据量 最大连接数 内存分配 IOPS 重点关注指标: 业务指标: 每秒并发用户请求.每秒订单数.用户请求响应时长 折算成性能指标: q ...
- MongoDB的容量规划及硬件配置
mongo是基于内存的数据库,应尽量将工作集中的数据全部加载到内存中,即内存应大于工作集 本文译自Chad Tindel的英文博客: http://www.mongodb.com/blog/post/ ...
- web容量规划
容量和性能 容量规划是基于当前性能判断系统需要什么及什么时候需要,它既是资本支出合理化证明过程也是一个技术变更; 性能调优是优化已存在的系统性能; 一般服务的升级步骤是:性能调优 -> ...
- 新上线MySQL数据库规划
新上线MySQL数据库规划1.删除test库2.删除root用户或者让root用户只可在本机登陆而对于有业务访问的数据库,在做删除root用户前需要依次确认 function.procedure.ev ...
- Hbase集群类型|集群配置|服务器选型|磁盘容量规划
HBase和Hadoop的集群类型 1.单机模式 主要用于开发工作,一台机器上运行所有的守护进程,或者一台机器运行多个虚拟机.一般用于评估和测试. 2.小型集群 20台机器以内的集群,不同的机器运行不 ...
- Elasticsearch集群规模和容量规划的底层逻辑
转载自: https://mp.weixin.qq.com/s?__biz=MzI2NDY1MTA3OQ==&mid=2247484628&idx=1&sn=666e416ae ...
- elasticsearch容量规划
https://docs.bonsai.io/article/123-capacity-planning Capacity Planning Capacity planning is the proc ...
- 三万字、91道MySQL面试题。 附PDF
文末领取面试题 高清PDF 数据库基础知识 1. 为什么要使用数据库 数据保存在内存 优点:存取速度快 缺点:数据不能永久保存 数据保存在文件 优点:数据永久保存 缺点:1)速度比内存操作慢,频繁的I ...
随机推荐
- Java 多个if 和多个else if 的区别
int a=1; if(a==1){System.out.println("1");} if(a==2){System.out.println("2");} i ...
- python搭建ftp服务器
1 # coding: utf-8 import os from pyftpdlib.authorizers import DummyAuthorizer from pyftpdlib.handler ...
- leetcode134 Gas Station
思路: https://leetcode.com/problems/gas-station/discuss/269604/Java-Greedy-thought-process 关键是要想清楚如果从加 ...
- thinkphp写的登录注册的小demo
和asp.net类似,一个FormAction对应Form文件夹 demo结构: ‘ 对于项目结构有疑问的: http://www.thinkphp.cn/document/60.html login ...
- Fragment 创建及替换
1.Fragment的产生与介绍 Android运行在各种各样的设备中,有小屏幕的手机,超大屏的平板甚至电视.针对屏幕尺寸的差距,很多情况下,都是先针对手机开发一套App,然后拷贝一份,修改布局以适应 ...
- Codeforces Round #318 (Div. 2) A Bear and Elections (优先队列模拟,水题)
优先队列模拟一下就好. #include<bits/stdc++.h> using namespace std; priority_queue<int>q; int main( ...
- Example of how to implement a view-based source list (NSOutlineView) using Cocoa Bindings
You tagged this with the cocoa-bindings tag, so I assume you mean "with bindings." I whipp ...
- JS中的事件、事件冒泡和事件捕获、事件委托
https://www.cnblogs.com/diver-blogs/p/5649270.html https://www.cnblogs.com/Chen-XiaoJun/p/6210987.ht ...
- QT5:先导篇 全局定义
一.简介 <QtGlobal>头文件包含了Qt类库的一些全局定义,包含基本数据类型 函数和宏 二.全局变量定义 <QtGlobal>定义的数据类型: Qt数据类型 ...
- IjkPlayer播放器秒开优化以及常用Option设置
https://blog.csdn.net/shareus/article/details/78585260 ijkplayer点播和直播视频 问题 解决及优化 https://blog.csdn. ...