企业实战_13_MyCat清除冗余数据

接上一篇:企业实战_12_MyCat水平扩展_分库分表
https://gblfy.blog.csdn.net/article/details/100059793

文章目录

          • 一、复制链路停止
            • 1. 清除冗余数据思路
            • 2. 登录node4
            • 3. 登录node3
            • 4. 登录node2
          • 二、删除冗余数据
            • 2.1. 删除订单模块无关的表
            • 2.2. 删除商品模块无关的表
            • 2.3. 删除商品模块无关的表
          • 三、验证
            • 3.1. 验证逻辑库中的表数量
            • 3.2. 查询逻辑表是否正常返回数据

一、复制链路停止
1. 清除冗余数据思路

首先,把node2、node3、node4的主从复制链路停止掉。
因为现在呢?虽然把莹莹切换到了mycat上,并且直接通过mycat对后端的3个物理数据库读写访问了,但是没实际上呢?
如果在node1上写数据,还会将数据同步到node2、node3、node4节点上,这样显然达不到垂直拆分的目的,垂直拆分呢,一方面想分担写的负载,另一方面呢,想减少每每个节点中数据数据量大小,要删除掉原本不属于该节点的数据。

2. 登录node4

104节点

# 登录数据库
mysql -uroot -p
Enter password: 123456# 停止复制链路
stop slave;# 清除主从同步的信息
reset slave all;# 查看链路,如果没有返回说明已经停止
show slave status \G

如下所示:

mysql> reset slave all;
Query OK, 0 rows affected (0.01 sec)mysql> show slave status \G
Empty set (0.00 sec)mysql> 
3. 登录node3

103节点

# 登录数据库
mysql -uroot -p
Enter password: 123456# 停止复制链路
stop slave;# 清除主从同步的信息
reset slave all;# 查看链路,如果没有返回说明已经停止
show slave status \G

如下所示:

mysql> reset slave all;
Query OK, 0 rows affected (0.01 sec)mysql> show slave status \G
Empty set (0.00 sec)mysql> 
4. 登录node2

102节点

# 登录数据库
mysql -uroot -p
Enter password: 123456# 停止复制链路
stop slave;# 清除主从同步的信息
reset slave all;# 查看链路,如果没有返回说明已经停止
show slave status \G

如下所示:

mysql> reset slave all;
Query OK, 0 rows affected (0.01 sec)mysql> show slave status \G
Empty set (0.00 sec)mysql> 
二、删除冗余数据
2.1. 删除订单模块无关的表

登录node2操作102节点

# 登录mysql
mysql -uroot -p# 使用order_db数据库
use order_db;# 删除前查看表有哪些?
show tables;# 删除前他与order模块无关的表,删除之前建议先将表盒数据进行备份# 删除除了订单和仓配模块的表
drop table product_brand_info;
drop table product_category;
drop table product_comment;
drop table product_info;
drop table product_supplier_info;
drop table product_pic_info;drop table customer_balance_log;
drop table customer_inf;
drop table customer_level_inf;
drop table customer_login;
drop table customer_login_log;
drop table customer_point_log;# 删除后查看表有哪些?
show tables;mysql> show tables;
+---------------------+
| Tables_in_order_db  |
+---------------------+
| order_cart          |
| order_customer_addr |
| order_detail        |
| order_master        |
| region_info         |
| serial              |
| shipping_info       |
| warehouse_info      |
| warehouse_proudct   |
+---------------------+
9 rows in set (0.00 sec)mysql> 
2.2. 删除商品模块无关的表

登录node3操作103节点

# 登录数据库
mysql -uroot -p#使用指定数据库
use product_db;# 删除除了订单和仓配模块的表
drop table customer_balance_log;
drop table customer_inf;
drop table customer_level_inf;
drop table customer_login;
drop table customer_login_log;
drop table customer_point_log;drop table order_master;
drop table order_detail;
drop table order_cart;
drop table order_customer_addr;
drop table region_info;
drop table shipping_info;
drop table warehouse_info;
drop table warehouse_proudct;
drop table serial;# 删除后查看表有哪些?
show tables;mysql> show tables;
+-----------------------+
| Tables_in_product_db  |
+-----------------------+
| product_brand_info    |
| product_category      |
| product_comment       |
| product_info          |
| product_pic_info      |
| product_supplier_info |
+-----------------------+
6 rows in set (0.00 sec)mysql> 
2.3. 删除商品模块无关的表

登录node4操作104节点

# 登录数据库
mysql -uroot -p#使用指定数据库
use customer_db;# 删除除了订单和仓配模块的表
drop table order_master;
drop table order_detail;
drop table order_cart;
drop table order_customer_addr;
drop table region_info;
drop table shipping_info;
drop table warehouse_info;
drop table warehouse_proudct;
drop table serial;drop table product_brand_info;
drop table product_category;
drop table product_comment;
drop table product_info;
drop table product_supplier_info;
drop table product_pic_info;# 删除后查看表有哪些?
show tables;mysql> show tables;
+-----------------------+
| Tables_in_customer_db |
+-----------------------+
| customer_balance_log  |
| customer_inf          |
| customer_level_inf    |
| customer_login        |
| customer_login_log    |
| customer_point_log    |
+-----------------------+
6 rows in set (0.00 sec)mysql>
三、验证
3.1. 验证逻辑库中的表数量
# 从任意节点重新登录mycat
mysql -uapp_imooc -p123456 -h192.168.92.101 -P8066# 使用imooc_db数据库
use imooc_db;# 查看逻辑库中的表 
show tables;# 执行日志
mysql> show tables;
+-----------------------+
| Tables in imooc_db    |
+-----------------------+
| customer_balance_log  |
| customer_inf          |
| customer_level_inf    |
| customer_login        |
| customer_login_log    |
| customer_point_log    |
| order_cart            |
| order_customer_addr   |
| order_detail          |
| order_master          |
| product_brand_info    |
| product_category      |
| product_comment       |
| product_info          |
| product_pic_info      |
| product_supplier_info |
| region_info           |
| shipping_info         |
| warehouse_info        |
| warehouse_proudct     |
+-----------------------+
20 rows in set (0.00 sec)mysql> 从上面可以看出,imooc_db逻辑库库中的表并减少,说明,我们看到的实际是逻辑库中的表,,而非物理库中的表。
3.2. 查询逻辑表是否正常返回数据
# 查询逻辑库中的某个表,验证是否正常返回数据
mysql> select count(*) from region_info;
+--------+
| COUNT0 |
+--------+
|      1 |
+--------+
1 row in set (1.06 sec)mysql> 
从上面可以看出,数据可以正常返回

下一篇:企业实战_14_MyCat跨分片查询_全局表
https://gblfy.blog.csdn.net/article/details/100059621

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/523435.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

苹果宣布加入CNCF;华为要求美国运营商支付专利费;微软删除最大的公开人脸识别数据集...

戳蓝字“CSDN云计算”关注我们哦!嗨,大家好,重磅君带来的【云重磅】特别栏目,如期而至,每周五第一时间为大家带来重磅新闻。把握技术风向标,了解行业应用与实践,就交给我重磅君吧!重…

企业实战_14_MyCat跨分片查询_全局表

接上一篇:企业实战_13_MyCat清除冗余数据 https://gblfy.blog.csdn.net/article/details/100057317 文章目录一、跨分片查询验证1. 登录mycat2. 使用逻辑数据库1.3. 执行跨分片查询1.4. 异常信息,问题定位1.5. 表分布1.6. 跨分片查询的解决方式1.7. 场景…

java创建四叉树_Java实现 LeetCode 427 建立四叉树

427. 建立四叉树我们想要使用一棵四叉树来储存一个 N x N 的布尔值网络。网络中每一格的值只会是真或假。树的根结点代表整个网络。对于每个结点, 它将被分等成四个孩子结点直到这个区域内的值都是相同的.每个结点还有另外两个布尔变量: isLeaf 和 val。isLeaf 当这个节点是一个…

漫画:什么是二分查找?

戳蓝字“CSDN云计算”关注我们哦!作者 | 蠢萌的小灰来源 | 程序员小灰————— 第二天 —————什么意思呢?我们来举两个栗子:给定一个有序数组 2,5,7,9,12,14,20&…

mysql和mysqldump出现command not found 问题解决

mysql和mysqldump出现command not found 问题解决 一、给mysql配置环境变量 #找到mysql安装路径 cd /app/mysql-5.7.25 #vim /etc/profile export MYSQL_HOME/app/mysql-5.7.25 :${MYSQL_HOME}/bin二、建立软连接 1、查找mysql安装路径 find / -name mysql 通常mysql安装路径…

如何给老婆解释什么是微服务?(文末有福利)

戳蓝字“CSDN云计算”关注我们哦!程序员有了老婆之后就是累,上次好不容易给她解释了什么是Restful,这不,麻烦又来了…一个周日的清晨,阳光洒在我的脸上,慢慢把我唤醒。我翻过身,感觉好像少了些什…

oracle19c连接MySQL_oracle19c的安装和使用navicat连接oracle数据库

一,数据的安装Oracle官方下载链接:https://www.oracle.com/downloads/#category-database首先去oracle官网下载,数据库里面包含了客户端,所以不需要再下载客户端了注意:有的人不下载数据库,只下载客户端为了…

Mycat_MySql更新数据库失败 --read-only

接上一篇:企业实战_20_Mycat-Web之UI监控 https://blog.csdn.net/weixin_40816738/article/details/100100053 #登录数据库 mysql -uroot -p #使用指定数据库 use 数据库名 #查看数据库处于什么状态下 show variables like read-only; #关闭read-only属性状态 set g…

Linux 运维必备的 13 款实用工具,拿好了

戳蓝字“CSDN云计算”关注我们哦!来源 | 高效运维本文介绍几款 Linux 运维比较实用的工具,希望对 Linux 运维人员有所帮助。1. 查看进程占用带宽情况 - NethogsNethogs 是一个终端下的网络流量监控工具可以直观的显示每个进程占用的带宽。下载&#xff1…

java joda datetime_Joda Time项目和java8时间api

Joda Time出现的背景在java1.0中,对日期和时间的支持只能依赖java.util.Date类。正如类名所表达的,这个类无法表示日期,只能以毫秒的精度表示时间。更糟糕的是它的易用性,由于某些未知的设计决策,这个类的易用性被深深…

企业实战_12_MyCat水平扩展_分库分表

接上一篇:企业实战_11_MyCat垂直拆分相关配置 https://gblfy.blog.csdn.net/article/details/100055838 文章目录一、概念理论理解1. 垂直拆分理解2. 水平扩展理解3. 水平扩展案例4. 水平扩展场景5. 水平拆分原则6. 水平扩展架构图二、关键问题解决方案2.1. 分片后如…

面试阿里,我还是挂在了第四轮……

戳蓝字“CSDN云计算”关注我们哦!作者 | 倪升武责编 | 郭 芮可能每个技术人都有个阿里梦,我也不例外。最近准备跳槽,前一阵子在准备各种面试,也面了几个大厂,包括阿里。是的,最后我挂在了第四轮。这篇文章…

php读取模板生成静态功能,php 生成静态页面的办法与实现代码详细版

php中主要用到的就是要用到fread()和fwirte()。而静态页面生成了之后,就会牵扯到修改的问题。这里可以用到正则匹配的方法来替换模版中改变的部位。不过此种方法太麻烦,值得推荐的方法是直接把原来生成的模版砍掉,重新生成,呵呵&a…

Mycat+Mysql 插入数据报错 i[Err] 1064 - partition table, insert must provide ColumnList

逻辑库结构和物理库表结构如下(逻辑库结构物理库表结构): CREATE TABLE order_key (id int(11) NOT NULL AUTO_INCREMENT COMMENT 主键,goods_name varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 商品名称,place varchar(2…

php微信支付使用ajax,接入微信公众号支付,选择支付方式后,只弹出“error’”(php)...

这个怎么感觉不用ajax去请求什么啊&#xff1f;WeixinJSBridge不是已经封装好公众号支付的方法了吗&#xff1f;如果你已经在php里面完成统一下单过程了&#xff0c;那直接调用WeixinJSBridge的支付方法就行了&#xff1a;var jsApiParamObj <?php echo $jsApiParamList; …

企业实战_16_MyCat全局自增ID

接上一篇&#xff1a;企业实战_15_MySql主从复制到MyCat总结 https://gblfy.blog.csdn.net/article/details/118657995 文章目录一、准备工作1. Mycat全局自增实现思路2. 创建mycat数据库3. 导入初始化脚本4. 登录验证二、配置文件修改2.1. server.xml配置2.2. 添加数据节点2.3…

微服务精华问答 | 如何理解中台战略和微服务

戳蓝字“CSDN云计算”关注我们哦&#xff01;微服务(Microservice Architecture)是近几年流行的一种架构思想,关于它的概念很难一言以蔽之。今天&#xff0c;就让我们来看看关于微服务更加有深度的问题吧。1Q&#xff1a;什么是微服务A&#xff1a;1&#xff09;一组小的服务&a…

php 对象转换成数组,PHP把对象转换为数组的问题

原始对象object(Qiniu\Http\Error)#24 (2) {["url":"Qiniu\Http\Error":private]>string(25) "http://rs.qbox.me/buckets"["response":"Qiniu\Http\Error":private]>object(Qiniu\Http\Response)#25 (6) {["sta…

华为内测基于Android 10.0的EMUI 10系统;2019年Q1真无线耳机市场份额,苹果占半壁江山……...

关注并标星星CSDN云计算极客头条&#xff1a;速递、最新、绝对有料。这里有企业新动、这里有业界要闻&#xff0c;打起十二分精神&#xff0c;紧跟fashion你可以的&#xff01;每周三次&#xff0c;打卡即read更快、更全了解泛云圈精彩newsgo go go 苹果获得悬停手势专利 可隔空…

企业实战_17_MyCat水平扩展_跨分片查询_ER分片

接上一篇&#xff1a;企业实战_16_MyCat全局自增ID https://blog.csdn.net/weixin_40816738/article/details/100064315 案例比较&#xff1a; 在垂直拆分场景中&#xff0c;针对字段个数少的类型为字典类型的表&#xff0c;我们可以使用全局表的方式解决。 在水平扩展场景中&a…