日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

企业实战_13_MyCat清除冗余数据

發(fā)布時(shí)間:2024/9/27 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 企业实战_13_MyCat清除冗余数据 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

接上一篇:企業(yè)實(shí)戰(zhàn)_12_MyCat水平擴(kuò)展_分庫分表
https://gblfy.blog.csdn.net/article/details/100059793

文章目錄

          • 一、復(fù)制鏈路停止
            • 1. 清除冗余數(shù)據(jù)思路
            • 2. 登錄node4
            • 3. 登錄node3
            • 4. 登錄node2
          • 二、刪除冗余數(shù)據(jù)
            • 2.1. 刪除訂單模塊無關(guān)的表
            • 2.2. 刪除商品模塊無關(guān)的表
            • 2.3. 刪除商品模塊無關(guān)的表
          • 三、驗(yàn)證
            • 3.1. 驗(yàn)證邏輯庫中的表數(shù)量
            • 3.2. 查詢邏輯表是否正常返回?cái)?shù)據(jù)

一、復(fù)制鏈路停止
1. 清除冗余數(shù)據(jù)思路

首先,把node2、node3、node4的主從復(fù)制鏈路停止掉。
因?yàn)楝F(xiàn)在呢?雖然把瑩瑩切換到了mycat上,并且直接通過mycat對(duì)后端的3個(gè)物理數(shù)據(jù)庫讀寫訪問了,但是沒實(shí)際上呢?
如果在node1上寫數(shù)據(jù),還會(huì)將數(shù)據(jù)同步到node2、node3、node4節(jié)點(diǎn)上,這樣顯然達(dá)不到垂直拆分的目的,垂直拆分呢,一方面想分擔(dān)寫的負(fù)載,另一方面呢,想減少每每個(gè)節(jié)點(diǎn)中數(shù)據(jù)數(shù)據(jù)量大小,要?jiǎng)h除掉原本不屬于該節(jié)點(diǎn)的數(shù)據(jù)。

2. 登錄node4

104節(jié)點(diǎn)

# 登錄數(shù)據(jù)庫 mysql -uroot -p Enter password: 123456# 停止復(fù)制鏈路 stop slave;# 清除主從同步的信息 reset slave all;# 查看鏈路,如果沒有返回說明已經(jīng)停止 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節(jié)點(diǎn)

# 登錄數(shù)據(jù)庫 mysql -uroot -p Enter password: 123456# 停止復(fù)制鏈路 stop slave;# 清除主從同步的信息 reset slave all;# 查看鏈路,如果沒有返回說明已經(jīng)停止 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節(jié)點(diǎn)

# 登錄數(shù)據(jù)庫 mysql -uroot -p Enter password: 123456# 停止復(fù)制鏈路 stop slave;# 清除主從同步的信息 reset slave all;# 查看鏈路,如果沒有返回說明已經(jīng)停止 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>
二、刪除冗余數(shù)據(jù)
2.1. 刪除訂單模塊無關(guān)的表

登錄node2操作102節(jié)點(diǎn)

# 登錄mysql mysql -uroot -p# 使用order_db數(shù)據(jù)庫 use order_db;# 刪除前查看表有哪些? show tables;# 刪除前他與order模塊無關(guān)的表,刪除之前建議先將表盒數(shù)據(jù)進(jìn)行備份# 刪除除了訂單和倉配模塊的表 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. 刪除商品模塊無關(guān)的表

登錄node3操作103節(jié)點(diǎn)

# 登錄數(shù)據(jù)庫 mysql -uroot -p#使用指定數(shù)據(jù)庫 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. 刪除商品模塊無關(guān)的表

登錄node4操作104節(jié)點(diǎn)

# 登錄數(shù)據(jù)庫 mysql -uroot -p#使用指定數(shù)據(jù)庫 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>
三、驗(yàn)證
3.1. 驗(yàn)證邏輯庫中的表數(shù)量
# 從任意節(jié)點(diǎn)重新登錄mycat mysql -uapp_imooc -p123456 -h192.168.92.101 -P8066# 使用imooc_db數(shù)據(jù)庫 use imooc_db;# 查看邏輯庫中的表 show tables;# 執(zhí)行日志 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邏輯庫庫中的表并減少,說明,我們看到的實(shí)際是邏輯庫中的表,,而非物理庫中的表。
3.2. 查詢邏輯表是否正常返回?cái)?shù)據(jù)
# 查詢邏輯庫中的某個(gè)表,驗(yàn)證是否正常返回?cái)?shù)據(jù) mysql> select count(*) from region_info; +--------+ | COUNT0 | +--------+ | 1 | +--------+ 1 row in set (1.06 sec)mysql> 從上面可以看出,數(shù)據(jù)可以正常返回

下一篇:企業(yè)實(shí)戰(zhàn)_14_MyCat跨分片查詢_全局表
https://gblfy.blog.csdn.net/article/details/100059621

創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)

總結(jié)

以上是生活随笔為你收集整理的企业实战_13_MyCat清除冗余数据的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。