作者:微信小助手
<section style="margin-right: 8px;margin-bottom: 15px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);text-align: center;line-height: 1.75em;box-sizing: border-box !important;overflow-wrap: break-word !important;"> <span style="max-width: 100%;font-size: 18px;box-sizing: border-box !important;overflow-wrap: break-word !important;"><strong style="max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="max-width: 100%;letter-spacing: 1px;box-sizing: border-box !important;overflow-wrap: break-word !important;">线程</span></strong></span> </section> <section style="margin-right: 8px;margin-bottom: 15px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);letter-spacing: 1px;line-height: 1.75em;box-sizing: border-box !important;overflow-wrap: break-word !important;"> <span style="max-width: 100%;font-size: 15px;box-sizing: border-box !important;overflow-wrap: break-word !important;">线程的概念,百度是这样解释的:</span> </section> <section style="margin-right: 8px;margin-bottom: 15px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);letter-spacing: 1px;line-height: 1.75em;box-sizing: border-box !important;overflow-wrap: break-word !important;"> <span style="max-width: 100%;font-size: 15px;box-sizing: border-box !important;overflow-wrap: break-word !important;">线程(英语:Thread)是操作系统能够进行运算调度的最小单位。它被包含在进程之中,是进程中的实际运作单位。一条线程指的是进程中一个单一顺序的控制流,一个进程中可以并发多个线程,每条线程并行执行不同的任务。在Unix System V及SunOS中也被称为轻量进程(Lightweight Processes),但轻量进程更多指内核线程(Kernel Thread),而把用户线程(User Thread)称为线程。</span> </section> <section style="margin-right: 8px;margin-bottom: 15px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);letter-spacing: 1px;line-height: 1.75em;box-sizing: border-box !important;overflow-wrap: break-word !important;"> <strong style="max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="max-width: 100%;font-size: 15px;box-sizing: border-box !important;overflow-wrap: break-word !important;">1.1 线程与进程的区别</span></strong> </section> <section style="margin-right: 8px;margin-bottom: 15px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);text-align: center;line-height: 1.75em;box-sizing: border-box !important;overflow-wrap: break-word !important;"> <img class="rich_pages" data-ratio="0.5880952380952381" data-s="300,640" data-type="png" data-w="840" src="/upload/4a9d58f051ead1c52d18b62b6b1e93f2.png" style="box-sizing: border-box !important;overflow-wrap: break-word !important;width: 677px !important;visibility: visible !important;"> </section> <section style="margin-right: 8px;margin-bottom: 15px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);letter-spacing: 1px;line-height: 1.75em;box-sizing: border-box !important;overflow-wrap: break-word !important;"> <span style="max-width: 100%;font-size: 15px;box-sizing: border-box !important;overflow-wrap: break-word !important;">进程:</span> <span style="max-width: 100%;font-size: 15px;box-sizing: border-box !important;overflow-wrap: break-word !important;">指在系统中正在运行</span> <span style="max-width: 100%;font-size: 15px;box-sizing: border-box !important;overflow-wrap: break-word !important;">的一个应</span> <span style="max-width: 100%;font-size: 15px;box-sizing: border-box !important;overflow-wrap: break-word !important;">用程序;程</span> <span style="max-width: 100%;font-size: 15px;box-sizing: border-box !important;overflow-wrap: break-word !important;">序一旦运行就是进程;进程——资源分配的最小单位。</span> <br style="max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"> </section> <section style="margin-right: 8px;margin-bottom: 15px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);letter-spacing: 1px;line-height: 1.75em;box-sizing: border-box !important;overflow-wrap: break-word !important;"> <span style="max-width: 100%;font-size: 15px;box-sizing: border-box !important;overflow-wrap: break-word !important;">线程:系统分配处理器时间资源的基本单元,或者说进程之内独立执行的一个单元执行流。线程——程序执行的最小单位。</span> </section> <section style="margin-right: 8px;margin-bottom: 15px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);letter-spacing: 1px;line-height: 1.75em;box-sizing: border-box !important;overflow-wrap: break-word !important;"> <span style="max-width: 100%;font-size: 15px;box-sizing: border-box !important;overflow-wrap: break-word !important;">也就是,进程可以包含多个线程,而线程是程序执行的最小单位。</span> </section> <section style="margin-right: 8px;margin-bottom: 15px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);letter-spacing: 1px;line-height: 1.75em;box-sizing: border-box !important;overflow-wrap: break-word !important;"> <strong style="max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="max-width: 100%;font-size: 15px;box-sizing: border-box !important;overflow-wrap: break-word !important;">1.2 线程的状态</span></strong> </section> <section style="margin-right: 8px;margin-bottom: 15px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);text-align: center;line-height: 1.75em;box-sizing: border-box !important;overflow-wrap: break-word !important;"> <img class="rich_pages" data-ratio="0.6671122994652406" data-s="300,640" data-type="jpeg" data-w="748" src="/upload/6d6efe112ce19043d1cbb47a34a8d549.jpg" style="box-sizing: border-box !important;overflow-wrap: break-word !important;width: 677px !important;visibility: visible !important;"> </section> <ul class="list-paddingleft-2" style="margin-right: 8px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);overflow-wrap: break-word !important;"> <li style="max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"> <section style="margin-bottom: 15px;max-width: 100%;line-height: 1.75em;box-sizing: border-box !important;overflow-wrap: break-word !important;"> <span style="max-width: 100%;font-size: 15px;box-sizing: border-box !important;overflow-wrap: break-word !important;">NEW:</span> <span style="max-width: 100%;font-size: 15px;box-sizing: border-box !important;overflow-wrap: break-word !important;">线程刚创建</span> </section></li> <li style="max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"> <section style="margin-bottom: 15px;max-width: 100%;line-height: 1.75em;box-sizing: border-box !important;overflow-wrap: break-word !important;"> <span style="max-width: 100%;font-size: 15px;box-sizing: border-box !important;overflow-wrap: break-word !important;">RUNNABLE: 在JVM中正在运行的线程,其中运行状态可以有运行中RUNNING和READY两种状态,由系统调度进行状态改变。</span> </section></li> <li style="max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"> <section style="margin-bottom: 15px;max-width: 100%;line-height: 1.75em;box-sizing: border-box !important;overflow-wrap: break-word !important;"> <span style="max-width: 100%;font-size: 15px;box-sizing: border-box !important;overflow-wrap: break-word !important;">BLOCKED:线程处于阻塞状态,等待监视锁,可以重新进行同步代码块中执行</span> </section></li> <li style="max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"> <section style="margin-bottom: 15px;max-width: 100%;line-height: 1.75em;box-sizing: border-box !important;overflow-wrap: break-word !important;"> <span style="max-width: 100%;font-size: 15px;box-sizing: border-box !important;overflow-wrap: break-word !important;">WAITING : 等待状态</span> </section></li> <li style="max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"> <section style="margin-bottom: 15px;max-width: 100%;line-height: 1.75em;box-sizing: border-box !important;overflow-wrap: break-word !important;"> <span style="max-width: 100%;font-size: 15px;box-sizing: border-box !important;overflow-wrap: break-word !important;">TIMED_WAITING: 调用sleep() join() wait()方法可能导致线程处于等待状态</span> </section></li> <li style="max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"> <section style="margin-bottom: 15px;max-width: 100%;line-height: 1.75em;box-sizing: border-box !important;overflow-wrap: break-word !important;"> <span style="max-width: 100%;font-size: 15px;box-sizing: border-box !important;overflow-wrap: break-word !important;">TERMINATED: 线程执行完毕,已经退出</span> </section></li> </ul> <section style="margin-right: 8px;margin-bottom: 15px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);letter-spacing: 1px;line-height: 1.75em;box-sizing: border-box !important;overflow-wrap: break-word !important;"> <strong style="max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="max-width: 100%;font-size: 15px;box-sizing: border-box !important;overflow-wrap: break-word !important;">1.3 Notify和Wait :</span></strong> </section> <section style="margin-right: 8px;margin-bottom: 15px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);letter-spacing: 1px;line-height: 1.75em;box-sizing: border-box !important;overflow-wrap: break-word !important;"> <span style="max-width: 100%;font-size: 15px;box-sizing: border-box !important;overflow-wrap: break-word !important;">Notify和Wait 的作用</span> </section> <section style="margin-right: 8px;margin-bottom: 15px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);letter-spacing: 1px;line-height: 1.75em;box-sizing: border-box !important;overflow-wrap: break-word !important;"> <span style="max-width: 100%;font-size: 15px;box-sizing: border-box !important;overflow-wrap: break-word !important;">首先看源码给出的解释,这里翻译了一下:</span> </section> <section style="margin-right: 8px;margin-bottom: 15px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);letter-spacing: 1px;line-height: 1.75em;box-sizing: border-box !important;overflow-wrap: break-word !important;"> <span style="max-width: 100%;font-size: 15px;box-sizing: border-box !important;overflow-wrap: break-word !important;">Notify:</span> <span style="max-width: 100%;font-size: 15px;box-sizing: border-box !important;overflow-wrap: break-word !important;">唤醒一个正在等待这个对象的线程监控。如果有任何线程正在等待这个对象,那么它们中的一个被选择被唤醒。选择是任意的,发生在执行的酌情权。一个线程等待一个对象通过调用一个{@code wait}方法进行监视。</span> </section> <section style="margin-right: 8px;margin-bottom: 15px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);letter-spacing: 1px;line-height: 1.75em;box-sizing: border-box !important;overflow-wrap: break-word !important;"> <span style=
作者:微信小助手
<section style="box-sizing: border-box;font-size: 16px;"> <section style="margin-top: 10px;margin-bottom: 10px;box-sizing: border-box;" powered-by="xiumi.us"> <section style="padding-top: 10px;padding-right: 10px;padding-left: 10px;background-color: rgb(239, 239, 239);box-sizing: border-box;"> <span style="display: inline-block;width: 5%;line-height: 0.8;font-weight: bolder;font-size: 48px;box-sizing: border-box;" title="" opera-tn-ra-cell="_$.pages:0.layers:0.comps:0.txt1"> <section style="box-sizing: border-box;"> “ </section></span> <section style="display: inline-block;vertical-align: top;float: right;width: 90%;line-height: 1.5;font-size: 15px;color: rgb(89, 89, 89);box-sizing: border-box;"> <p style="box-sizing: border-box;"><span style="letter-spacing: 1px;">当一张百亿数据量的表放在你面前,你将面临着什么?加列?哭吧,怎么也得等个几天甚至几周。加索引?哭吧,不论你用 pt-online-schema,还是 gh-ost,你都面临着拷贝一张临时表用以存储临时数据,磁盘已经 80% 了,这一张表就占几百 G,你咋弄?</span></p> </section> <section style="clear: both;box-sizing: border-box;line-height: 0;"> <section style="line-height: 0;width: 0px;"> <svg viewbox="0 0 1 1" style="vertical-align:top;"></svg> </section> </section> </section> </section> </section> <section style="line-height: 1.75em;"> <br> </section> <section style="text-align: center;margin-left: 8px;margin-right: 8px;"> <img class="rich_pages" data-ratio="0.66640625" data-s="300,640" src="/upload/c84691e34f4c4bc260d9d99ecb17de8b.jpg" data-type="jpeg" data-w="1280" style=""> </section> <p style="text-align: center;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"><span style="font-size: 14px;letter-spacing: 1px;color: rgb(89, 89, 89);"><em>图片来自 Pexels</em></span></p> <section style="line-height: normal;"> <br> </section> <p style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"><span style="font-size: 15px;letter-spacing: 1px;color: rgb(71, 193, 168);">我先说几个最让你兴奋和开心的点吧:</span></p> <ul class="list-paddingleft-2" style="list-style-type: disc;"> <li><p><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">在 TiDB 里,你完全不用担心磁盘容量的问题。</span></p></li> <li><p><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">在 TiDB 里,原生支持 Online DDL,你完全不用担心第三方改表工具改表出现各种 Bug 的问题,相信用开源工具改过上 T 级别表的同学都遇到过或多或少的各类 error。</span></p></li> <li><p><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">在 TiDB 里,加列,主键扩容字段都是秒级的,比如我刚刚就刚对一张 19 亿的表加完了字段,1 秒完事,这在 MySQL 里要 8.0 才可以,而且还要求列在最后才行。</span></p></li> <li><p><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">在 TiDB 里,你会发现 count(*) 惊人的快,一张近 20 亿的表 coun(*) 大概在 1 分钟完事儿,当然,这取决于你的 KV 数量和磁盘性能。</span></p></li> <li><p><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">在 TiDB 里,从 MySQL 迁移将变得简单,图形化一键迁移,爽不爽?</span></p></li> <li><p><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">在 TiDB 里,绝大多数情况你会发现比单机 MySQL 有更好的性能,当然也不排除一些例外,例如 enum 这样奇葩的字段类型。<br style="-webkit-font-smoothing: antialiased;max-width: 100%;word-break: break-all;"></span></p></li> <li><p><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">在 TiDB 里,......,您且往下看,我慢慢和您说。</span></p></li> </ul> <p style="line-height: normal;"><br></p> <section style="box-sizing: border-box;font-size: 16px;"> <section style="border-bottom: 1px solid black;margin-top: 0.5em;margin-bottom: 0.5em;line-height: 1.2;box-sizing: border-box;" powered-by="xiumi.us"> <section style="display: inline-block;border-bottom: 6px solid rgb(89, 89, 89);margin-bottom: -1px;border-top-color: rgb(89, 89, 89);border-right-color: rgb(89, 89, 89);border-left-color: rgb(89, 89, 89);font-size: 20px;color: rgb(89, 89, 89);box-sizing: border-box;"> <p style="box-sizing: border-box;">使用背景</p> </section> </section> </section> <p style="line-height: normal;"><br></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">360 云平台对 360 集团各大业务线均有提供服务支持,涉及的数据库支持方案有:MySQL、Redis、MongoDB、ES、GP、PiKA。</span> </section> <p style="line-height: normal;"><br></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">其中 MySQL 至今已有过万的实例,目前,对于一些写入量大的业务,已经出现瓶颈。</span> </section> <p style="line-height: normal;"><br></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">例如磁盘空间,虽然我们可以通过分库分表的方式,拆分出来,但这对业务和 DBA 来说都是不小的工作量,最痛苦的无异于这些大表的改表。</span> </section> <p style="line-height: normal;"><br></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">无论是单表上 T,还是分库分表,对一张大表执行 DDL 的代价是非常大的。</span> </section> <p style="line-height: normal;"><br></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">针对业务爆发式增长的数据量,我们开始调研选型是否有其他数据库可以代替传统的 MySQL。</span> </section> <p style="line-height: normal;"><br></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">通过调研我们了解到 TiDB,迁移平滑,基本上无需业务变动代码,完全的事务 ACID 支持,分布式的架构,自带高可用、Online DDL。</span> </section> <p style="line-height: normal;"><br></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">截止目前,360 云平台这边有三套 TiDB 集群,总节点数在 50+。有 9 个业务线接入使用,有过百亿级表 Online 加索引的案例,总数据量目前在 80T。</span> </section> <p style="line-height: normal;"><br></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">版本上,我们从 3.0.1 一路跟随到 3.0.5,DM 版本从内测到 1.0.2 GA 版本,共计提出 9 个 Bug 或改进项反馈。</span> </section> <p style="line-height: normal;"><br></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">后续我们计划将 TiDB 上到 360 HULK 云平台上,并定制化开发一些功能为业务提供可视化的服务,以便让 360 集团更多的业务线接触到 TiDB、使用 TiDB。</span> </section> <p style="line-height: normal;"><br></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">版本的选择我们之所以从大版本 3 开始,也是看到了一些 2.X 版本的社区反馈,尤其是索引执行计划这块,3.X 版本较之前的版本会好很多。DM 版本我们是直接选取的最新版,后一路跟随新版本升级。</span> </section> <p style="line-height: normal;"><br></p> <section style="box-sizing: border-box;font-size: 16px;"> <section style="border-bottom: 1px solid black;margin-top: 0.5em;margin-bottom: 0.5em;line-height: 1.2;box-sizing: border-box;" powered-by="xiumi.us"> <section style="display: inline-block;border-bottom: 6px solid rgb(89, 89, 89);margin-bottom: -1px;border-top-color: rgb(89, 89, 89);border-right-color: rgb(89, 89, 89);border-left-color: rgb(89, 89, 89);font-size: 20px;color: rgb(89, 89, 89);box-sizing: border-box;"> <p style="box-sizing: border-box;">集群架构</p> </section> </section> </section> <p style="line-height: normal;"><br></p> <p style="text-align: center;margin-left: 8px;margin-right: 8px;line-height: 1.75em;margin-bottom: 5px;"><img data-ratio="0.6405797101449275" src="/upload/29f50a6d55a3d60893e959bad1987b43.jpg" data-type="jpeg" data-w="690" style="-webkit-font-smoothing: antialiased;margin-bottom: 15px;border-width: initial;border-style: none;border-color: initial;word-break: break-all;cursor: pointer;" title="1583751206916700.jpg"></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">整体架构上,我们除了 TiDB 集群外,还用到了 DM 和 Pump、Drainer 套件。</span> </section> <p style="line-height: normal;"><br></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;letter-spacing: 1px;color: rgb(71, 193, 168);">这块主要是由于我们使用 TiDB 的业务有两种:</span> </section> <p style="line-height: normal;"><br></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <strong><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">①老的 MySQL 业务,</span></strong> <span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">因单机磁盘受限,导致单实例磁盘无法支撑爆炸式增长的数据量,数据比较重要,需要备份和支持 7*24 小时的恢复。</span> </section> <p style="line-height: normal;"><br></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">这类业务我们用到 DM 套件来实现无障碍迁移,1TB 的导入时间在 16 小时,这里如果是比较大的数据源,且 TiDB 是全新集群,可以使用 TiDB-Lightning,速度可以更快。</span> </section> <p style="line-height: normal;"><br></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">Lightning 的实测导入速度,37 分钟,导完 2 张大表共计 54G 的数据,符合 100G/H 预估,</span> <span style="color: rgb(89, 89, 89);font-size: 15px;letter-spacing: 1px;">是 loader 的 3 倍速度,loader 用时 2 小时 4 分钟。</span> </section> <p style="line-height: normal;"><br></p> <p style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;margin-bottom: 5px;"><span style="color: rgb(71, 193, 168);font-size: 15px;letter-spacing: 1px;">说起 DM 使用这块文章后面会单独分享下这块需要注意的问题,如下图所示:</span></p> <p style="text-align: center;margin-left: 8px;margin-right: 8px;line-height: 1.75em;margin-bottom: 5px;"><img data-ratio="0.4876632801161103" src="/upload/4567d274b589665d561cf1bdbc9de622.jpg" data-type="jpeg" data-w="689" style="font-family: -apple-system, "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "WenQuanYi Micro Hei", "Microsoft Yahei", sans-serif;-webkit-font-smoothing: antialiased;margin-bottom: 15px;border-width: initial;border-style: none;border-color: initial;font-size: 16px;word-break: break-all;cursor: pointer;" title="1583751471331017.jpg"></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <strong><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">②全新的业务,</span></strong> <span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">或由业务自行导入到 TiDB 集群中,这种业务数据量一般都会比较大,也是看中了 TiDB 支持 ACID 和分布式的特点。</span> </section> <p style="line-height: normal;"><br></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">目前网盾业务有多张表都过 10 亿级别,其中有张表到达了 100 亿+,建索引花了近 10 天(这块其实我们应当注意,不是分布式就一张表就完事儿了,因为表量级过大,清理老旧数据都是个问题)。</span> </section> <p style="line-height: normal;"><br></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">TiDB 现在支持分区表,但我们在使用过程中发现性能上和普通表有差距,期待后续版本能够让分区表功能和性能更加的完善。</span> </section> <section style="line-height: normal;"> <br> </section> <section style="box-sizing: border-box;font-size: 16px;"> <section style="border-bottom: 1px solid black;margin-top: 0.5em;margin-bottom: 0.5em;line-height: 1.2;box-sizing: border-box;" powered-by="xiumi.us"> <section style="display: inline-block;border-bottom: 6px solid rgb(89, 89, 89);margin-bottom: -1px;border-top-color: rgb(89, 89, 89);border-right-color: rgb(89, 89, 89);border-left-color: rgb(89, 89, 89);font-size: 20px;color: rgb(89, 89, 89);box-sizing: border-box;"> <p style="box-sizing: border-box;">TiDB 在 360 云平台的使用情况</p> </section> </section> </section> <section style="line-height: normal;"> <br> </section> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">对于这一全新的数据库,我们本着大胆用,不拘泥于传统的态度进行使用。</span> </section> <section style="line-height: normal;"> <br> </section> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">我们的 MySQL 现在也正在适配 8.0 版本,MongoDB、ES 也都是时刻关注着新版本情况来评估是否适合云平台。</span> </section> <p style="line-height: normal;"><br></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">因此 TiDB 的上线也是从离线业务→边缘业务→核心业务来过渡的。</span> </section> <p style="line-height: normal;"><br></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">经过大量的测试、也参考了其他公司的使用情况,我们计划将 TiDB 纳入 360 HULK 云平台,并计划后期对其不断完善在云平台中的功能,对全公司业务线开放使用。</span> </section> <p style="line-height: normal;"><br></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">定制化开发一些 MySQL 已经具备的,例如 SQL 审核、慢查统计、冗余索引检测、自增索引阈值等各项基础功能等等。</span> </section> <p style="line-height: normal;"><br></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">虽然在使用过程中遇到了一些小问题,例如索引的选取、参数的调优,因为一些配置导致的性能抖动,但都得到了 PingCAP 同学快速的响应和回复,这对我们推进 TiDB 有重大的帮助。</span> </section> <p style="line-height: normal;"><br></p> <section style="box-sizing: border-box;font-size: 16px;"> <section style="margin-top: 10px;margin-bottom: 10px;box-sizing: border-box;" powered-by="xiumi.us"> <section style="width: 0.6em;display: inline-block;vertical-align: middle;box-sizing: border-box;"> <span style="width: 0.6em;height: 0.6em;display: block;opacity: 0.2;background-color: rgb(89, 89, 89);box-sizing: border-box;"></span> <span style="width: 0.6em;height: 0.6em;display: block;opacity: 0.6;margin-top: 2px;margin-bottom: 2px;background-color: rgb(89, 89, 89);box-sizing: border-box;"></span> <span style="width: 0.6em;height: 0.6em;display: block;opacity: 1;background-color: rgb(89, 89, 89);box-sizing: border-box;"></span> </section> <section style="display: inline-block;vertical-align: middle;font-size: 18px;padding-left: 5px;color: rgb(89, 89, 89);box-sizing: border-box;"> <p style="box-sizing: border-box;"><strong>一键迁移工具 DM 干货分享</strong></p> </section> </section> </section> <p style="line-height: normal;"><br></p> <h3 style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"><span style="font-size: 15px;letter-spacing: 1px;color: rgb(71, 193, 168);">DM 使用经验如下:</span></h3> <p style="line-height: normal;"><br></p> <h4 style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"><strong><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">①权限</span></strong></h4> <p style="line-height: normal;"><br></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">官网手册上只说明需要如下权限:</span> </section> <section style="line-height: normal;"> <br> </section> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;letter-spacing: 1px;color: rgb(71, 193, 168);">TiDB Lightning 需要以下权限:</span> </section> <ul class="list-paddingleft-2" style="list-style-type: disc;"> <li style="font-weight: bold;"><p><strong><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">SELECT</span></strong></p></li> <li style="font-weight: bold;"><p><strong><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">UPDATE</span></strong></p></li> <li style="font-weight: bold;"><p><strong><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">ALTER</span></strong></p></li> <li style="font-weight: bold;"><p><strong><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">CREATE</span></strong></p></li> <li style="font-weight: bold;"><p><strong><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">DROP</span></strong></p></li> </ul> <p style="line-height: normal;"><br></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;letter-spacing: 1px;color: rgb(71, 193, 168);">存储断点的数据库额外需要以下权限:</span> </section> <ul class="list-paddingleft-2" style="list-style-type: disc;"> <li style="font-weight: bold;"><p><strong><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">INSERT</span></strong></p></li> <li style="font-weight: bold;"><p><strong><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">DELETE</span></strong></p></li> </ul> <p style="line-height: normal;"><br></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;letter-spacing: 1px;color: rgb(71, 193, 168);">但实测过程中发现还需要如下权限:</span> </section> <ul class="list-paddingleft-2" style="list-style-type: disc;"> <li><p><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">上游 (REPLICATION SLAVE 权限必须具备,要不增量同步会 access deny)。</span></p></li> <li><p><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">下游 (不加 super 会导致 checksum table 无法执行)。</span></p></li> </ul> <p style="line-height: normal;"><br></p> <h4 style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"><strong><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">②TiKV Region Score</span></strong></h4> <section style="line-height: normal;"> <br> </section> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">PD 监控中 -Statistics-balance 中,有 Store-region-score 监控项,这里记录的是各个节点的 Score 得分,正常情况下,我们期望的结果是得分接近的,这说明无需进行 Region 大规模迁移。</span> </section> <section style="line-height: normal;"> <br> </section> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <strong><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">③PD 调度原理</span></strong> </section> <p style="line-height: normal;"><br></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">Region 负载均衡调度主要依赖 balance-leader 和 balance-region 两个调度器。</span> </section> <p style="line-height: normal;"><br></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;letter-spacing: 1px;color: rgb(71, 193, 168);">二者的调度目标是将 Region 均匀地分散在集群中的所有 Store 上,但它们各有侧重:</span> </section> <ul class="list-paddingleft-2" style="list-style-type: disc;"> <li><p><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">balance-leader 关注 Region 的 Leader,目的是分散处理客户端请求的压力。</span></p></li> <li><p><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">balance-region 关注 Region 的各个 Peer,目的是分散存储的压力,同时避免出现爆盘等状况。</span></p></li> </ul> <p style="line-height: normal;"><br></p> <p style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;margin-bottom: 5px;"><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">我们这里重点关注的是 balance-region,当它出现不均衡的时候,我们可以直接在监控中看到类似下图所示:</span></p> <p style="text-align: center;margin-left: 8px;margin-right: 8px;line-height: 1.75em;margin-bottom: 5px;"><img data-ratio="0.6347826086956522" src="/upload/e4a6cc8f40e090ca2a084d115adda7e5.jpg" data-type="jpeg" data-w="690" style="-webkit-font-smoothing: antialiased;margin-bottom: 15px;border-width: initial;border-style: none;border-color: initial;word-break: break-all;cursor: pointer;" title="1583752308283682.jpg"></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">调度期间,不可避免的会出现 IO 争用、磁盘的 lantency,都会出现不同程度的上涨,从业务上的反馈看,就会出现积压,响应不及时等等。而当 Region Balance 完成后, Duration 等都会恢复正常水平。</span> </section> <section style="line-height: normal;"> <br> </section> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;letter-spacing: 1px;color: rgb(71, 193, 168);">因此,我们要关注的地方有两点:</span> </section> <ul class="list-paddingleft-2" style="list-style-type: disc;"> <li><p><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">如何控制或减小 Region Balance 大规模迁移时对业务的影响;</span></p></li> <li><p><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">如何提前规避因磁盘导致的大规模 Region Balance。</span></p></li> </ul> <p style="line-height: normal;"><br></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">对于第一点,我们迁移的时候是有参数可以控制的。</span> <span style="color: rgb(89, 89, 89);font-size: 15px;letter-spacing: 1px;">这里无论是磁盘空间阈值,还是 Region Balance 调度速度,或者 Drop 大量表后调整空 Region Merge 的速度,其实都是可以通过 pd-ctl 的 config set 命令来实时调节。</span> </section> <section style="line-height: normal;"> <br> </section> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;letter-spacing: 1px;color: rgb(71, 193, 168);">例如:</span> </section> <ul class="list-paddingleft-2" style="list-style-type: disc;"> <li><p><strong><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">high-space-ratio 0.7 #设置空间充裕阈值为 0.7。</span></strong><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">当节点的空间占用比例小于指定值时,PD 调度时会忽略剩余空间这个指标,主要针对实际数据量进行均衡。</span></p></li> <li><p><strong><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">region-schedule-limit 8 #最多同时进行 8 个 Region 调度。</span></strong><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">这个值主要影响 Region Balance 的速度,值越大调度得越快,设置为 0 则关闭调度。Region 调度的开销较大,所以这个值不宜调得太大。也可以通过减小该值来限制调度region对集群产生的影响。</span></p></li> <li><p><strong><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">merge-schedule-limit 12 #最多同时进行 12 个 merge 调度。</span></strong><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">设置为 0 则关闭 Region Merge。Merge 调度的开销较大,所以这个值不宜调得过大。</span></p></li> <li><p><strong><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">leader-schedule-limit 8 #最多同时进行 8 个 leader 调度。</span></strong><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">这个值主要影响 Leader Balance 的速度,值越大调度得越快,设置为 0 则关闭调度。Leader 调度的开销较小,需要的时候可以适当调大。</span></p></li> <li><p><strong><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">max-merge-region-keys 50000 #设置 Region Merge 的 keyCount 上限为 50k。</span></strong><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">当 Region KeyCount 大于指定值时 PD 不会将其与相邻的 Region 合并。</span></p></li> <li><p><strong><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">max-merge-region-size 16 #设置 Region Merge 的 size 上限为 16M。</span></strong><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">当 Region Size 大于指定值时 PD 不会将其与相邻的 Region 合并。设置为 0 表示不开启 Region Merge 功能。</span></p></li> </ul> <p style="line-height: normal;"><br></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <strong><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">TIPS:</span></strong> <span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">理解了作用和原理,上述参数都可以根据需求自行控制。</span> </section> <section style="line-height: normal;"> <br> </section> <p style="text-align: justify;line-height: 1.75em;margin-left: 8px;margin-right: 8px;"><strong><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">例如当我们在 Drop 大量的表后,会产生很多的空 Region。</span></strong><span style="color: rgb(89, 89, 89);font-size: 15px;letter-spacing: 1px;">在 Region 数量较多的情况下,Raftstore 需要花费一些时间去处理大量 Region 的心跳,从而带来一些延迟,导致某些读写请求得不到及时处理。</span></p> <section style="line-height: normal;"> <br> </section> <p style="text-align: justify;line-height: 1.75em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">如果读写压力较大,Raftstore 线程的 CPU 使用率容易达到瓶颈,导致延迟进一步增加,进而影响性能表现。</span></p> <section style="line-height: normal;"> <br> </section> <p style="text-align: justify;line-height: 1.75em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">因此我们会希望尽快的进行 Region Merge,来避免过多的 Region 对集群造成性能损耗时,我们可以同时调小 max-merge-region-keys、max-merge-region-size,来让其更快的触发 Merge 操作,同时调大 merge-schedule-limit 提高并发度。</span></p> <section style="line-height: normal;"> <br> </section> <p style="text-align: justify;line-height: 1.75em;margin-left: 8px;margin-right: 8px;"><strong><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">例如当我们发现某台 KV 磁盘空间剩余 40% 开始大量调度时,</span></strong><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">我们可以将 high-space-ratio 调整到 0.7,以临时避免调度对业务产生的影响。</span></p> <section style="line-height: normal;"> <br> </section> <p style="text-align: justify;line-height: 1.75em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">我们也可以控制调度的并发度,来减少对业务产生的影响,实测这都是立竿见影的参数,大家如果遇到这些问题可供参考。</span></p> <section style="line-height: normal;"> <br> </section> <section style="text-align: justify;line-height: 1.75em;margin-left: 8px;margin-right: 8px;margin-bottom: 5px;"> <span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">对于第二点,尤其是使用 DM 期间,将 DM-worker 和 TiKV 混合部署的情况下,要注意清理全量备份留下的文件和 Relaylog。</span> </section> <p style="text-align: center;line-height: 1.75em;margin-left: 8px;margin-right: 8px;margin-bottom: 5px;"><img data-ratio="0.3443396226415094" src="/upload/a125517977c863298272eee6ae1cf04d.jpg" data-type="jpeg" data-w="424" title="1583752378344947.jpg" style="text-align: center;-webkit-font-smoothing: antialiased;margin-bottom: 15px;border-width: initial;border-style: none;border-color: initial;word-break: break-all;cursor: pointer;"></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">默认调度策略是当磁盘剩余的有效空间不足 40%,处于中间态时则同时考虑数据量和剩余空间两个因素做加权和当作得分,当得分出现比较大的差异时,就会开始调度。</span> </section> <p style="line-height: normal;"><br></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">所以 DM 导入完成后,要记得删除全量备份。就是 dumped_data.task_xxx 文件夹,这个全量备份一般都会比较大,如果 dm-worker 和 TiKV 混部,就会出现某个 TiKV 节点磁盘已使用率高于其他。</span> </section> <p style="line-height: normal;"><br></p> <p style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;margin-bottom: 5px;"><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">这时 PD 的 store region score 就会相比其他节点出现异常,引起性能抖动和 Duration 升高。</span></p> <p style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;margin-bottom: 5px;"><img data-ratio="0.9328358208955224" src="/upload/a81320e211c050f3e4bdf87384c645f8.jpg" data-type="jpeg" data-w="536" title="1583752409124728.jpg" style="text-align: center;font-family: -apple-system, "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "WenQuanYi Micro Hei", "Microsoft Yahei", sans-serif;-webkit-font-smoothing: antialiased;margin-bottom: 15px;border-width: initial;border-style: none;border-color: initial;font-size: 16px;word-break: break-all;cursor: pointer;"></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;margin-bottom: 5px;"> <span style="color: rgb(71, 193, 168);font-size: 15px;letter-spacing: 1px;">一直等待其追上后,才会像下图这样:</span> </section> <p style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;margin-bottom: 5px;"><img data-ratio="0.48985507246376814" src="/upload/8a694e5d10c659da02f361b83d3ecdcc.jpg" data-type="jpeg" data-w="690" style="-webkit-font-smoothing: antialiased;margin-bottom: 15px;border-width: initial;border-style: none;border-color: initial;word-break: break-all;cursor: pointer;" title="1583752489483514.jpg"></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;margin-bottom: 5px;"> <span style="font-size: 15px;letter-spacing: 1px;color: rgb(71, 193, 168);">此时,balancer 已达平衡状态:</span> </section> <p style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;margin-bottom: 5px;"><img data-ratio="0.75642965204236" src="/upload/8b18f4c2582214c43526f785d4894c36.jpg" data-type="jpeg" data-w="661" style="-webkit-font-smoothing: antialiased;margin-bottom: 15px;border-width: initial;border-style: none;border-color: initial;word-break: break-all;cursor: pointer;" title="1583752538954594.jpg"></p> <p style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;margin-bottom: 5px;"><span style="font-size: 15px;letter-spacing: 1px;color: rgb(71, 193, 168);">Duration 恢复正常水平,如下图 16:54 分时的情况:</span></p> <p style="text-align: center;margin-left: 8px;margin-right: 8px;line-height: 1.75em;margin-bottom: 5px;"><img data-ratio="0.26666666666666666" src="/upload/f4b7975445834a7c22679937df00726b.jpg" data-type="jpeg" data-w="690" style="-webkit-font-smoothing: antialiased;margin-bottom: 15px;border-width: initial;border-style: none;border-color: initial;word-break: break-all;cursor: pointer;" title="1583752577292967.jpg"></p> <p style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;margin-bottom: 5px;"><span style="font-size: 15px;letter-spacing: 1px;color: rgb(71, 193, 168);">QPS 也不再积压,恢复正常水准:</span></p> <p style="text-align: center;margin-left: 8px;margin-right: 8px;line-height: 1.75em;margin-bottom: 5px;"><img data-ratio="0.2594202898550725" src="/upload/8e09172ae170b2acc7d013d2f2f5ad71.jpg" data-type="jpeg" data-w="690" style="-webkit-font-smoothing: antialiased;margin-bottom: 15px;border-width: initial;border-style: none;border-color: initial;word-break: break-all;cursor: pointer;" title="1583752610787076.jpg"></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">关于 relay-log,默认是不清理的,就和 MySQL 的 expire_logs_days 一样,这块可以通过 dm-worker 的配置文件来进行配置。</span> </section> <p style="line-height: normal;"><br></p> <p style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;margin-bottom: 5px;"><span style="font-size: 15px;letter-spacing: 1px;color: rgb(71, 193, 168);">例如将 Expires 配置为 7,代表 7 天后删除:</span></p> <section style="font-size: 16px;color: rgb(62, 62, 62);line-height: 1.6;letter-spacing: 0px;font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;"> <pre style="font-size: inherit;color: inherit;line-height: inherit;"><code style="margin-right: 2px;margin-left: 2px;line-height: 18px;font-size: 14px;letter-spacing: 0px;font-family: Consolas, Inconsolata, Courier, monospace;border-radius: 0px;color: rgb(169, 183, 198);background: rgb(40, 43, 46);padding: 0.5em;word-wrap: normal !important;word-break: normal !important;overflow: auto !important;display: -webkit-box !important;"><span style="font-size: inherit;line-height: inherit;color: rgb(165, 218, 45);word-wrap: inherit !important;word-break: inherit !important;">[purge]</span><br><span style="font-size: inherit;line-height: inherit;color: rgb(165, 218, 45);word-wrap: inherit !important;word-break: inherit !important;">interval</span> = <span style="font-size: inherit;line-height: inherit;color: rgb(174, 135, 250);word-wrap: inherit !important;word-break: inherit !important;">3600</span><br><span style="font-size: inherit;line-height: inherit;color: rgb(165, 218, 45);word-wrap: inherit !important;word-break: inherit !important;">expires</span> = <span style="font-size: inherit;line-height: inherit;color: rgb(174, 135, 250);word-wrap: inherit !important;word-break: inherit !important;">7</span><br><span style="font-size: inherit;line-height: inherit;color: rgb(165, 218, 45);word-wrap: inherit !important;word-break: inherit !important;">remain-space</span> = <span style="font-size: inherit;line-height: inherit;color: rgb(174, 135, 250);word-wrap: inherit !important;word-break: inherit !important;">15</span><br></code></pre> </section> <p style="line-height: normal;"><br></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">Expires 来控制保留天数。</span> <span style="color: rgb(89, 89, 89);font-size: 15px;letter-spacing: 1px;">默认 expires=0,即没有过期时间,而 remain-space=15 意思是当磁盘只剩于 15G 的时候开始尝试清理,这种情况我们极少会碰到,因此这个清理方式其实基本上是用不到的。</span> </section> <p style="line-height: normal;"><br></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="color: rgb(89, 89, 89);font-size: 15px;letter-spacing: 1px;">所以建议有需要删除过期 relay-log 的小伙伴,直接配置 Expires 保留天数就可以了。</span> </section> <p style="line-height: normal;"><br></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">DM 导入完成后,应该提供是否在完成后自动删除全备文件的选项,可以默认不删,由使用者决定是否删除。</span> </section> <p style="line-height: normal;"><br></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">从使用者角度来说,全量备份目录无论是全量一次性导入还是 all 增量同步,后续都不会再使用到。</span> </section> <p style="line-height: normal;"><br></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">如果 dm-worker 和 TiKV 混部,会导致全备文件占据大量磁盘空间,引起 TiKV Region 评分出现异常,导致性能下降,已转化为 PRM 产品需求。</span> </section> <p style="line-height: normal;"><br></p> <p style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"><strong><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">④关于 DM 使用期间出现数据丢失的问题</span></strong></p> <section style="line-height: normal;"> <br> </section> <p style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;margin-bottom: 5px;"><span style="color: rgb(89, 89, 89);font-size: 15px;letter-spacing: 1px;">在早期还没有 dm-portal 自动化生成 task 时,我们都是自行编写 DM 的 task 同步文件。后来有了 dm-portal 自动化生成工具,只要图形页面点点点就可以了。</span></p> <p style="text-align: center;margin-left: 8px;margin-right: 8px;line-height: 1.75em;margin-bottom: 5px;"><img data-ratio="0.6459016393442623" src="/upload/42f1f92f664db0f0ee4ae36a005bfd22.jpg" data-type="jpeg" data-w="610" style="-webkit-font-smoothing: antialiased;margin-bottom: 15px;border-width: initial;border-style: none;border-color: initial;word-break: break-all;cursor: pointer;" title="1583752679901898.jpg"></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">但该工具目前有一个问题是,没有全库正则匹配,即便你只勾选一个库,他底层是默认把每张表都给你配置一遍。</span> </section> <p style="line-height: normal;"><br></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">这就会出现当上层 MySQL 新创建某张表的时候,下游会被忽略掉,例如当你使用改表工具 gh-ost 或者 pt-online-schema-change,你的临时表都会被当做为不在白名单内而被忽略,这个问题使用者需要注意。</span> </section> <section style="line-height: normal;"> <br> </section> <p style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;margin-bottom: 5px;"><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">我们也已经反馈给了官方。未来不久的版本估计就可以修复。</span></p> <section style="font-size: 16px;color: rgb(62, 62, 62);line-height: 1.6;letter-spacing: 0px;font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;"> <pre style="font-size: inherit;color: inherit;line-height: inherit;"><code style="margin-right: 2px;margin-left: 2px;line-height: 18px;font-size: 14px;letter-spacing: 0px;font-family: Consolas, Inconsolata, Courier, monospace;border-radius: 0px;color: rgb(169, 183, 198);background: rgb(40, 43, 46);padding: 0.5em;word-wrap: normal !important;word-break: normal !important;overflow: auto !important;display: -webkit-box !important;">[<span style="font-size: inherit;line-height: inherit;color: rgb(238, 220, 112);word-wrap: inherit !important;word-break: inherit !important;">"skip event"</span>] [task=task_20357] [unit=<span style="font-size: inherit;line-height: inherit;color: rgb(238, 220, 112);word-wrap: inherit !important;word-break: inherit !important;">"binlog replication"</span>] [event=query] [statement=<span style="font-size: inherit;line-height: inherit;color: rgb(238, 220, 112);word-wrap: inherit !important;word-break: inherit !important;">"ALTER TABLE `360`.`_data_201910_gho` ADD COLUMN `raw_url_md5` CHAR(32) NOT NULL DEFAULT '' COMMENT 'raw_url md5'"</span>]<br>[<span style="font-size: inherit;line-height: inherit;color: rgb(238, 220, 112);word-wrap: inherit !important;word-break: inherit !important;">"skip event"</span>] [task=task_20357] [unit=<span style="font-size: inherit;line-height: inherit;color: rgb(238, 220, 112);word-wrap: inherit !important;word-break: inherit !important;">"binlog replication"</span>] [event=query] [statement=<span style="font-size: inherit;line-height: inherit;color: rgb(238, 220, 112);word-wrap: inherit !important;word-break: inherit !important;">"ALTER TABLE `360`.`_data_201910_gho` ADD INDEX `idx_rawurl_md5`(`raw_url_md5`)"</span>] [schema=flow]<br>[<span style="font-size: inherit;line-height: inherit;color: rgb(238, 220, 112);word-wrap: inherit !important;word-break: inherit !important;">"skip event"</span>] [task=task_20357] [unit=<span style="font-size: inherit;line-height: inherit;color: rgb(238, 220, 112);word-wrap: inherit !important;word-break: inherit !important;">"binlog replication"</span>] [event=query] [statement=<span style="font-size: inherit;line-height: inherit;color: rgb(238, 220, 112);word-wrap: inherit !important;word-break: inherit !important;">"ALTER TABLE `360`.`_data_201910_gho` DROP INDEX `idx_raw_url`"</span>] [schema=flow]<br></code></pre> </section> <p style="line-height: normal;"><br></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">这里日志可以看到 event 被 skip 了。</span> </section> <section style="line-height: normal;"> <br> </section> <p style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"><strong><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">⑤关于 DM 使用期间偶发性 1062 主键冲突的问题</span></strong></p> <p style="line-height: normal;"><br></p> <p style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;margin-bottom: 5px;"><span style="color: rgb(89, 89, 89);font-size: 15px;letter-spacing: 1px;">query-error task 能看到具体的报错信息,下游看都没有该值:</span></p> <section style="font-size: 16px;color: rgb(62, 62, 62);line-height: 1.6;letter-spacing: 0px;font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;"> <pre style="font-size: inherit;color: inherit;line-height: inherit;"><code style="margin-right: 2px;margin-left: 2px;line-height: 18px;font-size: 14px;letter-spacing: 0px;font-family: Consolas, Inconsolata, Courier, monospace;border-radius: 0px;color: rgb(169, 183, 198);background: rgb(40, 43, 46);padding: 0.5em;word-wrap: normal !important;word-break: normal !important;overflow: auto !important;display: -webkit-box !important;">mysql> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">select</span> * <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">from</span> client <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">where</span> clientid=<span style="font-size: inherit;line-height: inherit;color: rgb(128, 128, 128);word-wrap: inherit !important;word-break: inherit !important;">'82b51e6f6eb64955487f978dd94a2c81e492f6170xxxxxxxxxxxxxxxxxxxxxxxxx';</span><br>Empty <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">set</span> (<span style="font-size: inherit;line-height: inherit;color: rgb(174, 135, 250);word-wrap: inherit !important;word-break: inherit !important;">0.00</span> sec)<br></code></pre> </section> <p style="line-height: normal;"><br></p> <p style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;margin-bottom: 5px;"><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">再去上游看,结果发现也没有值,业务逻辑应该是后来 delete 了:</span></p> <section style="font-size: 16px;color: rgb(62, 62, 62);line-height: 1.6;letter-spacing: 0px;font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;"> <pre style="font-size: inherit;color: inherit;line-height: inherit;"><code style="margin-right: 2px;margin-left: 2px;line-height: 18px;font-size: 14px;letter-spacing: 0px;font-family: Consolas, Inconsolata, Courier, monospace;border-radius: 0px;color: rgb(169, 183, 198);background: rgb(40, 43, 46);padding: 0.5em;word-wrap: normal !important;word-break: normal !important;overflow: auto !important;display: -webkit-box !important;">mysql> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">select</span> * <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">from</span> client <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">where</span> clientid=<span style="font-size: inherit;line-height: inherit;color: rgb(128, 128, 128);word-wrap: inherit !important;word-break: inherit !important;">'82b51e6f6eb64955487f978dd94a2c81e492f6170xxxxxxxxxxxxxxxxxxxxxxxxx';</span><br>Empty <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">set</span> (<span style="font-size: inherit;line-height: inherit;color: rgb(174, 135, 250);word-wrap: inherit !important;word-break: inherit !important;">0.00</span> sec)<br></code></pre> </section> <p style="line-height: normal;"><br></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;letter-spacing: 1px;color: rgb(71, 193, 168);">因为上游也没有值,去上�
作者:微信小助手
<p style="text-align: center;"><img class="rich_pages" data-ratio="0.11875" src="/upload/debb99064b4679d97f20510588e78bf1.gif" data-type="gif" data-w="640" style=""></p> <p style="margin: 15px 8px;max-width: 100%;box-sizing: border-box;min-height: 1em;font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;text-size-adjust: auto;orphans: 4;color: rgb(93, 94, 93);white-space: pre-wrap;line-height: 1.75em;text-align: right;overflow-wrap: break-word !important;"><span style="max-width: 100%;letter-spacing: 1px;font-size: 12px;color: rgb(178, 178, 178);box-sizing: border-box !important;overflow-wrap: break-word !important;">来源 | AI科技大本营</span><br></p> <section style="margin-right: 8px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, system-ui, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);line-height: 2em;box-sizing: border-box !important;overflow-wrap: break-word !important;"> <span style="max-width: 100%;font-size: 15px;letter-spacing: 1px;box-sizing: border-box !important;overflow-wrap: break-word !important;">光学字符识别(OCR)技术已经得到了广泛应用。比如发票上用来识别关键字样,搜题App用来识别书本上的试题。</span> </section> <section style="margin-right: 8px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, system-ui, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);line-height: 2em;box-sizing: border-box !important;overflow-wrap: break-word !important;"> <span style="font-size: 15px;letter-spacing: 1px;color: rgb(93, 94, 93);font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;orphans: 4;white-space: pre-wrap;"><br></span> </section> <p style="margin-right: 8px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, system-ui, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);line-height: 2em;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="max-width: 100%;font-size: 15px;letter-spacing: 1px;box-sizing: border-box !important;overflow-wrap: break-word !important;">近期,这个叫做chineseocr_lite的OCR项目开源了,这是一个超轻量级中文ocr,支持竖排文字识别,支持 ncnn 推理,psenet (8.5M) + crnn (6.3M) + anglenet (1.5M) 总模型仅17M。</span></p> <p style="margin-right: 8px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, system-ui, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);line-height: 2em;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="max-width: 100%;font-size: 15px;letter-spacing: 1px;box-sizing: border-box !important;overflow-wrap: break-word !important;"><br></span></p> <p style="margin-right: 8px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, system-ui, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);line-height: 2em;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="max-width: 100%;font-size: 15px;letter-spacing: 1px;box-sizing: border-box !important;overflow-wrap: break-word !important;">目前,这个开源项目已在GitHub上标星2400+。</span></p> <p style="margin-right: 8px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, system-ui, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);line-height: 2em;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="max-width: 100%;font-size: 15px;letter-spacing: 1px;box-sizing: border-box !important;overflow-wrap: break-word !important;"><br></span></p> <p style="margin-right: 8px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, system-ui, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);line-height: 2em;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="max-width: 100%;font-size: 15px;letter-spacing: 1px;box-sizing: border-box !important;overflow-wrap: break-word !important;">这个项目基于chineseocr与psenet实现中文自然场景文字检测及识别,环境是linux/macos。</span></p> <p style="margin-right: 8px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, system-ui, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);line-height: 2em;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="max-width: 100%;font-size: 15px;letter-spacing: 1px;box-sizing: border-box !important;overflow-wrap: break-word !important;"><br></span></p> <p style="margin-right: 8px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, system-ui, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);line-height: 2em;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="max-width: 100%;font-size: 15px;letter-spacing: 1px;box-sizing: border-box !important;overflow-wrap: break-word !important;">以下为可实现的功能:</span></p> <p style="margin-right: 8px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, system-ui, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);line-height: 2em;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="max-width: 100%;font-size: 15px;letter-spacing: 1px;box-sizing: border-box !important;overflow-wrap: break-word !important;"><br></span></p> <ul class="list-paddingleft-2" cid="n20" mdtype="list" data-mark="-" style="margin-right: 8px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, system-ui, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);line-height: 2em;box-sizing: border-box !important;overflow-wrap: break-word !important;"> <li style="margin-right: 8px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, system-ui, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);line-height: 2em;box-sizing: border-box !important;overflow-wrap: break-word !important;"><p style="margin-right: 8px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, system-ui, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);line-height: 2em;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="max-width: 100%;font-size: 15px;letter-spacing: 1px;box-sizing: border-box !important;overflow-wrap: break-word !important;"> 提供轻量的 backone 检测模型 psenet(8.5M),crnn_lstm_lite (9.5M) 和行文本方向分类网络(1.5M)</span></p></li> <li style="margin-right: 8px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, system-ui, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);line-height: 2em;box-sizing: border-box !important;overflow-wrap: break-word !important;"><p style="margin-right: 8px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, system-ui, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);line-height: 2em;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="max-width: 100%;font-size: 15px;letter-spacing: 1px;box-sizing: border-box !important;overflow-wrap: break-word !important;"> 任意方向文字检测,识别时判断行文本方向</span></p></li> <li style="margin-right: 8px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, system-ui, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);line-height: 2em;box-sizing: border-box !important;overflow-wrap: break-word !important;"><p style="margin-right: 8px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, system-ui, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);line-height: 2em;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="max-width: 100%;font-size: 15px;letter-spacing: 1px;box-sizing: border-box !important;overflow-wrap: break-word !important;"> crnn\crnn_lite lstm\dense识别(ocr-dense和ocr-lstm是搬运chineseocr 的)</span></p></li> <li style="margin-right: 8px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, system-ui, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);line-height: 2em;box-sizing: border-box !important;overflow-wrap: break-word !important;"><p style="margin-right: 8px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, system-ui, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);line-height: 2em;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="max-width: 100%;font-size: 15px;letter-spacing: 1px;box-sizing: border-box !important;overflow-wrap: break-word !important;"> 支持竖排文本识别</span></p></li> <li style="margin-right: 8px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, system-ui, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);line-height: 2em;box-sizing: border-box !important;overflow-wrap: break-word !important;"><p style="margin-right: 8px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, system-ui, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);line-height: 2em;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="max-width: 100%;font-size: 15px;letter-spacing: 1px;box-sizing: border-box !important;overflow-wrap: break-word !important;">ncnn实现psenet(未实现核扩展)</span></p></li> <li style="margin-right: 8px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, system-ui, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);line-height: 2em;box-sizing: border-box !important;overflow-wrap: break-word !important;"><p style="margin-right: 8px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, system-ui, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);line-height: 2em;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="max-width: 100%;font-size: 15px;letter-spacing: 1px;box-sizing: border-box !important;overflow-wrap: break-word !important;">ncnn实现crnn_dense(改变了全连接为conv1x1)</span></p></li> <li style="margin-right: 8px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, system-ui, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);line-height: 2em;box-sizing: border-box !important;overflow-wrap: break-word !important;"><p style="margin-right: 8px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, system-ui, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);line-height: 2em;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="max-width: 100%;font-size: 15px;letter-spacing: 1px;box-sizing: border-box !important;overflow-wrap: break-word !important;">ncnn实现shuuflenev2角度分类网络</span></p></li> <li style="margin-right: 8px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, system-ui, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);line-height: 2em;box-sizing: border-box !important;overflow-wrap: break-word !important;"><p style="margin-right: 8px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, system-ui, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);line-height: 2em;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="max-width: 100%;font-size: 15px;letter-spacing: 1px;box-sizing: border-box !important;overflow-wrap: break-word !important;">ncnn实现ocr整个流程</span></p></li> </ul> <p style="margin-right: 8px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, system-ui, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);line-height: 2em;box-sizing: border-box !important;overflow-wrap: break-word !important;"><br></p> <p style="margin-right: 8px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, system-ui, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);line-height: 2em;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="max-width: 100%;font-size: 15px;letter-spacing: 1px;box-sizing: border-box !important;overflow-wrap: break-word !important;">最近,项目作者对更新了可实现的功能。<br style="max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"></span></p> <p style="margin-right: 8px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, system-ui, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);line-height: 2em;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="max-width: 100%;font-size: 15px;letter-spacing: 1px;box-sizing: border-box !important;overflow-wrap: break-word !important;"><br></span></p> <ul class="list-paddingleft-2" style="margin-right: 8px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, system-ui, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);line-height: 2em;box-sizing: border-box !important;overflow-wrap: break-word !important;"> <li style="margin-right: 8px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, system-ui, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);line-height: 2em;box-sizing: border-box !important;overflow-wrap: break-word !important;"><p style="margin-right: 8px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, system-ui, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);line-height: 2em;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="max-width: 100%;font-size: 15px;letter-spacing: 1px;box-sizing: border-box !important;overflow-wrap: break-word !important;">nihui大佬实现的crnn_lstm推理</span></p></li> <li style="margin-right: 8px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, system-ui, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);line-height: 2em;box-sizing: border-box !important;overflow-wrap: break-word !important;"><p style="margin-right: 8px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, system-ui, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);line-height: 2em;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="max-width: 100%;font-size: 15px;letter-spacing: 1px;box-sizing: border-box !important;overflow-wrap: break-word !important;">升级crnn_lite_lstm_dw.pth模型crnn_lite_lstm_dw_v2.pth , 精度更高</span></p></li> <li style="margin-right: 8px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, system-ui, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);line-height: 2em;box-sizing: border-box !important;overflow-wrap: break-word !important;"><p style="margin-right: 8px;margin-left: 8px;max-width: 100%;font-family: -apple-system-font, system-ui, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);line-height: 2em;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="max-width: 100%;font-size: 15px;letter-spacing: 1px;box-sizing: border-box !important;overflow-wrap: break-word !important;">提供竖排文字样例以及字体库(旋转90度的字体)</span></p></li> </ul> <p style="margin: 15px 8px;max-width: 100%;box-sizing: border-box;min-height: 1em;font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;text-size-adjust: auto;orphans: 4;color: rgb(93, 94, 93);font-size: 1rem;white-space: pre-wrap;line-height: 1.75em;overflow-wrap: break-word !important;"><strong><span style="max-width: 100%;box-sizing: border-box;letter-spacing: 1px;font-size: 15px;color: rgb(0, 154, 131);overflow-wrap: break-word !important;">字体样式</span></strong></p> <section style="margin-right: 8px;margin-left: 8px;max-width: 100%;caret-color: rgb(51, 51, 51);font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;text-size-adjust: auto;text-align: center;box-sizing: border-box !important;overflow-wrap: break-word !important;"> <img class="rich_pages" data-ratio="0.6372549019607843" data-s="300,640" data-type="png" data-w="612" src="/upload/c0bc56e74532b66670e8cafe7aaec4fa.png" style="box-sizing: border-box !important;overflow-wrap: break-word !important;width: 612px !important;visibility: visible !important;"> </section> <h2 style="margin: 15px 8px;font-size: 1rem;max-width: 100%;box-sizing: border-box;font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;text-size-adjust: auto;min-height: 1em;orphans: 4;color: rgb(93, 94, 93);white-space: pre-wrap;line-height: 1.75em;overflow-wrap: break-word !important;"><span style="color: rgb(0, 154, 131);"><strong><span style="max-width: 100%;box-sizing: border-box;font-size: 15px;letter-spacing: 1px;overflow-wrap: break-word !important;">生成的竖排文本样例</span></strong></span><span style="max-width: 100%;box-sizing: border-box;font-size: 15px;letter-spacing: 1px;overflow-wrap: break-word !important;"></span></h2> <section style="margin-right: 8px;margin-left: 8px;max-width: 100%;caret-color: rgb(51, 51, 51);font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;text-size-adjust: auto;text-align: center;box-sizing: border-box !important;overflow-wrap: break-word !important;"> <img class="rich_pages" data-ratio="0.7848605577689243" data-s="300,640" data-type="png" data-w="502" src="/upload/1554d59f9827766b11e1907cda4f779b.png" style="box-sizing: border-box !important;overflow-wrap: break-word !important;width: 502px !important;visibility: visible !important;"> </section> <section style="margin: 15px 8px;max-width: 100%;box-sizing: border-box;font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;text-size-adjust: auto;min-height: 1em;orphans: 4;color: rgb(93, 94, 93);font-size: 1rem;white-space: pre-wrap;line-height: 1.75em;overflow-wrap: break-word !important;"> <span style="color: rgb(0, 154, 131);"><strong><span style="color: rgb(0, 154, 131);max-width: 100%;box-sizing: border-box;font-size: 15px;letter-spacing: 1px;overflow-wrap: break-word !important;">识别效果展示:</span></strong></span> </section> <section style="margin-right: 8px;margin-left: 8px;max-width: 100%;caret-color: rgb(51, 51, 51);font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;text-size-adjust: auto;text-align: center;box-sizing: border-box !important;overflow-wrap: break-word !important;"> <img class="rich_pages" data-ratio="1.4921875" data-s="300,640" data-type="png" data-w="768" src="/upload/28f870ecd1b7fd456c158a470a3023f7.png" style="box-sizing: border-box !important;overflow-wrap: break-word !important;width: 677px !important;visibility: visible !important;"> </section> <h2 style="margin: 15px 8px;font-size: 1rem;max-width: 100%;box-sizing: border-box;font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;text-size-adjust: auto;min-height: 1em;orphans: 4;color: rgb(93, 94, 93);white-space: pre-wrap;line-height: 1.75em;overflow-wrap: break-word !important;"><span style="color: rgb(0, 154, 131);"><strong><span style="color: rgb(0, 154, 131);max-width: 100%;box-sizing: border-box;font-size: 15px;letter-spacing: 1px;overflow-wrap: break-word !important;">ncnn检测识别展示(x86 cpu 单进程)</span></strong></span></h2> <section style="margin-right: 8px;margin-left: 8px;max-width: 100%;caret-color: rgb(51, 51, 51);font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;text-size-adjust: auto;text-align: center;box-sizing: border-box !important;overflow-wrap: break-word !important;"> <img class="rich_pages" data-ratio="1.2545045045045045" data-s="300,640" data-type="png" data-w="888" src="/upload/981610066b68a2a547b14c6c713f4d98.png" style="box-sizing: border-box !important;overflow-wrap: break-word !important;width: 459px;visibility: visible !important;height: 576px;"> </section> <section style="margin: 15px 8px;max-width: 100%;box-sizing: border-box;min-height: 1em;font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;text-size-adjust: auto;orphans: 4;color: rgb(93, 94, 93);font-size: 1rem;white-space: pre-wrap;line-height: 1.75em;overflow-wrap: break-word !important;"> <span style="max-width: 100%;font-size: 15px;letter-spacing: 1px;box-sizing: border-box !important;overflow-wrap: break-word !important;">项目地址:https://github.com/ouyanghuiyu/chineseocr_lite</span> </section> <section style="margin-right: 8px;margin-left: 8px;max-width: 100%;caret-color: rgb(51, 51, 51);font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;white-space: normal;text-size-adjust: auto;font-size: 15px;text-align: center;line-height: 1.75em;min-height: 1em;letter-spacing: 1.5px;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"> <br> </section> <section style="margin-right: 8px;margin-left: 8px;max-width: 100%;caret-color: rgb(51, 51, 51);font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;white-space: normal;text-size-adjust: auto;font-size: 15px;text-align: center;line-height: 1.75em;min-height: 1em;letter-spacing: 1.5px;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"> <span style="color: rgb(0, 0, 0);"><strong><span style="color: rgb(0, 0, 0);max-width: 100%;letter-spacing: 0.5px;font-size: 14px;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;">—end—</span></strong></span> </section> <p><br></p> <p style="text-align: right;"><span style="letter-spacing: 0.544px;text-align: right;caret-color: rgb(51, 51, 51);color: rgb(56, 56, 56);font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", "Apple Color Emoji", "Emoji Symbols Font", "Segoe UI Symbol", Arial, sans-serif;font-size: 14px;font-weight: 700;background-color: rgb(255, 255, 255);">你</span><span style="margin-right: 3px;margin-left: 3px;padding: 1px 3px;letter-spacing: 0.544px;text-align: right;caret-color: rgb(51, 51, 51);max-width: 100%;box-sizing: border-box;color: rgb(56, 56, 56);font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", "Apple Color Emoji", "Emoji Symbols Font", "Segoe UI Symbol", Arial, sans-serif;font-size: 14px;font-weight: 700;user-select: text;-webkit-user-drag: none;-webkit-tap-highlight-color: transparent;background-color: rgb(171, 224, 225);border-radius: 2px;overflow-wrap: break-word !important;">“在看”</span><span style="letter-spacing: 0.544px;text-align: right;caret-color: rgb(51, 51, 51);color: rgb(56, 56, 56);font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", "Apple Color Emoji", "Emoji Symbols Font", "Segoe UI Symbol", Arial, sans-serif;font-size: 14px;font-weight: 700;background-color: rgb(255, 255, 255);">我吗?♡</span></p>
作者:微信小助手
<p style="text-align: center;"><span style="font-size: 14px;letter-spacing: 0.5440000295639038px;text-align: center;max-width: 100%;color: rgb(255, 41, 65);line-height: 22.4px;">(给</span><span style="font-size: 14px;letter-spacing: 0.5440000295639038px;text-align: center;max-width: 100%;line-height: 22.4px;color: rgb(0, 128, 255);">ImportNew</span><span style="font-size: 14px;letter-spacing: 0.5440000295639038px;text-align: center;max-width: 100%;color: rgb(255, 41, 65);line-height: 22.4px;">加星标,提高Java技能)</span></p> <blockquote> <section style="letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);max-width: 100%;min-height: 1em;text-align: left;line-height: 1.5em;box-sizing: border-box !important;overflow-wrap: break-word !important;"> <span style="color: rgb(165, 165, 165);font-family: 微软雅黑, "Microsoft YaHei";caret-color: rgb(255, 0, 0);background-color: rgb(255, 255, 255);max-width: 100%;font-size: 14px;letter-spacing: normal;box-sizing: border-box !important;overflow-wrap: break-word !important;">来自:掘金,作者:何甜甜在吗<br></span> </section> <p style="letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);max-width: 100%;min-height: 1em;text-align: left;line-height: 1.5em;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="color: rgb(165, 165, 165);font-family: 微软雅黑, "Microsoft YaHei";caret-color: rgb(255, 0, 0);background-color: rgb(255, 255, 255);max-width: 100%;font-size: 14px;letter-spacing: normal;box-sizing: border-box !important;overflow-wrap: break-word !important;">juejin.im/post/5d7787625188252388753eae</span></p> </blockquote> <section style="line-height: 1.5em;"> <span style="font-size: 15px;letter-spacing: normal;">在项目开发过程中经常遇到时间处理,但是你真的用对了吗,理解阿里巴巴开发手册中禁用static修饰SimpleDateFormat吗?</span> </section> <section style="line-height: 1.5em;"> <br> </section> <section style="line-height: 1.5em;"> <span style="font-size: 15px;letter-spacing: normal;">通过阅读本篇文章你将了解到:</span> </section> <section style="line-height: 1.5em;"> <br> </section> <section style="line-height: 1.5em;"> <span style="font-size: 15px;letter-spacing: normal;color: rgb(0, 0, 0);">为什么需要LocalDate、LocalTime、LocalDateTime【java8新提供的类】。</span> </section> <section style="line-height: 1.5em;"> <br> </section> <p style="line-height: 1.5em;"><span style="font-size: 15px;letter-spacing: normal;color: rgb(0, 0, 0);">java8新的时间API的使用方式,包括创建、格式化、解析、计算、修改。</span></p> <section style="line-height: 1.5em;"> <br> </section> <h1 style="line-height: 1.5em;"><span style="color: rgb(171, 25, 66
作者:微信小助手
<section style="font-size: 14px;color: rgb(62, 62, 62);line-height: 1.6;letter-spacing: 0px;font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;" data-mpa-powered-by="yiban.io"> <p style="font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(62, 62, 62);background-color: rgb(255, 255, 255);text-size-adjust: auto;font-size: 15px;word-spacing: 2px;text-align: center;"><span style="letter-spacing: 0.544px;color: rgb(136, 136, 136);font-size: 14px;">点击蓝色“</span><span style="letter-spacing: 0.544px;font-size: 14px;color: rgb(0, 128, 255);">架构文摘</span><span style="letter-spacing: 0.544px;color: rgb(136, 136, 136);font-size: 14px;">”关注我哟</span></p> <p style="margin-bottom: 10px;font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(62, 62, 62);background-color: rgb(255, 255, 255);text-size-adjust: auto;font-size: 15px;word-spacing: 2px;text-align: center;"><span style="font-size: 14px;color: rgb(136, 136, 136);">加个“</span><span style="color: rgb(0, 128, 255);font-size: 14px;">星标</span><span style="font-size: 14px;color: rgb(136, 136, 136);">”,每天上午 09:25,干货推送!</span></p> <p style="letter-spacing: 0.544px;white-space: normal;font-family: -apple-system-font, system-ui, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;color: rgb(62, 62, 62);font-size: 14px;background-color: rgb(255, 255, 255);text-align: center;"><img data-backh="36" data-backw="578" data-ratio="0.0625" data-s="300,640" data-type="jpeg" data-w="640" width="100%" src="/upload/8c292e55ba5a23cb6ebc11f2a2c4fece.null" style="font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;widows: 1;word-spacing: 2px;color: rgb(136, 136, 136);visibility: visible !important;width: 677px !important;"></p> <p><br></p> <p><span style="font-size: 12px;color: rgb(136, 136, 136);">作者:吴汶泽 </span><br></p> <p><span style="font-size: 12px;color: rgb(136, 136, 136);">来源:https://segmentfault.com/a/1190000017197768</span></p> <p style="font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;">在进行多租户架构(Multi-tenancy)实现之前,先了解一下相关的定义吧:</p> <h3 style="line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;font-weight: bold;color: rgb(0, 172, 193);font-size: 1.3em;"><span style="font-size: inherit;color: inherit;line-height: inherit;">什么是多租户</span></h3> <p style="font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;">多租户技术或称多重租赁技术,简称<code style="font-size: inherit;line-height: inherit;padding: 2px 4px;border-radius: 4px;margin-right: 2px;margin-left: 2px;color: rgb(233, 105, 0);background: rgb(248, 248, 248);">SaaS</code>,是一种软件架构技术,是实现如何在多用户环境下(此处的多用户一般是面向企业用户)共用相同的系统或程序组件,并且可确保各用户间数据的隔离性。<br>简单讲:在一台服务器上运行单个应用实例,它为多个租户(客户)提供服务。从定义中我们可以理解:多租户是一种架构,目的是为了让多用户环境下使用同一套程序,且保证用户间数据隔离。那么重点就很浅显易懂了,多租户的重点就是同一套程序下实现多用户数据的隔离。</p> <h3 style="line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;font-weight: bold;color: rgb(0, 172, 193);font-size: 1.3em;"><span style="font-size: inherit;color: inherit;line-height: inherit;">数据隔离方案</span></h3> <p style="font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;">多租户在数据存储上存在三种主要的方案,分别是:</p> <h4 style="line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;font-weight: bold;color: rgb(0, 172, 193);font-size: 1.2em;"><span style="font-size: inherit;color: inherit;line-height: inherit;">独立数据库</span></h4> <p style="font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;">即一个租户一个数据库,这种方案的用户数据隔离级别最高,安全性最好,但成本较高。</p> <ul style="font-size: inherit;color: inherit;line-height: inherit;padding-left: 32px;" class="list-paddingleft-2"> <li style="font-size: inherit;color: inherit;line-height: inherit;margin-bottom: 0.5em;"><p><span style="font-size: inherit;color: inherit;line-height: inherit;">优点:为不同的租户提供独立的数据库,有助于简化数据模型的扩展设计,满足不同租户的独特需求;如果出现故障,恢复数据比较简单。</span></p></li> <li style="font-size: inherit;color: inherit;line-height: inherit;margin-bottom: 0.5em;"><p><span style="font-size: inherit;color: inherit;line-height: inherit;">缺点:增多了数据库的安装数量,随之带来维护成本和购置成本的增加。</span></p></li> </ul> <h4 style="line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;font-weight: bold;color: rgb(0, 172, 193);font-size: 1.2em;"><span style="font-size: inherit;color: inherit;line-height: inherit;">共享数据库,独立 Schema</span></h4> <p style="font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;">多个或所有租户共享Database,但是每个租户一个Schema(也可叫做一个user)。底层库比如是:DB2、ORACLE等,一个数据库下可以有多个SCHEMA。</p> <ul style="font-size: inherit;color: inherit;line-height: inherit;padding-left: 32px;" class="list-paddingleft-2"> <li style="font-size: inherit;color: inherit;line-height: inherit;margin-bottom: 0.5em;"><p><span style="font-size: inherit;color: inherit;line-height: inherit;">优点:为安全性要求较高的租户提供了一定程度的逻辑数据隔离,并不是完全隔离;每个数据库可支持更多的租户数量。</span></p></li> <li style="font-size: inherit;color: inherit;line-height: inherit;margin-bottom: 0.5em;"><p><span style="font-size: inherit;color: inherit;line-height: inherit;">缺点:如果出现故障,数据恢复比较困难,因为恢复数据库将牵涉到其他租户的数据;</span></p></li> </ul> <h4 style="line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;font-weight: bold;color: rgb(0, 172, 193);font-size: 1.2em;"><span style="font-size: inherit;color: inherit;line-height: inherit;">共享数据库,共享 Schema,共享数据表</span></h4> <p style="font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;">即租户共享同一个Database、同一个Schema,但在表中增加TenantID多租户的数据字段。这是共享程度最高、隔离级别最低的模式。</p> <p style="font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;">简单来讲,即每插入一条数据时都需要有一个客户的标识。这样才能在同一张表中区分出不同客户的数据,这也是我们系统目前用到的(provider_id)</p> <ul style="font-size: inherit;color: inherit;line-height: inherit;padding-left: 32px;" class="list-paddingleft-2"> <li style="font-size: inherit;color: inherit;line-height: inherit;margin-bottom: 0.5em;"><p><span style="font-size: inherit;color: inherit;line-height: inherit;">优点:三种方案比较,第三种方案的维护和购置成本最低,允许每个数据库支持的租户数量最多。</span></p></li> <li style="font-size: inherit;color: inherit;line-height: inherit;margin-bottom: 0.5em;"><p><span style="font-size: inherit;color: inherit;line-height: inherit;">缺点:隔离级别最低,安全性最低,需要在设计开发时加大对安全的开发量;数据备份和恢复最困难,需要逐表逐条备份和还原。</span></p></li> </ul> <h3 style="line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;font-weight: bold;color: rgb(0, 172, 193);font-size: 1.3em;"><span style="font-size: inherit;color: inherit;line-height: inherit;">利用MybatisPlus实现</span></h3> <p style="font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;">这里我们选用了第三种方案(<code style="font-size: inherit;line-height: inherit;padding: 2px 4px;border-radius: 4px;margin-right: 2px;margin-left: 2px;color: rgb(233, 105, 0);background: rgb(248, 248, 248);">共享数据库,共享 Schema,共享数据表</code>)来实现,也就意味着,每个数据表都需要有一个租户标识(<code style="font-size: inherit;line-height: inherit;padding: 2px 4px;border-radius: 4px;margin-right: 2px;margin-left: 2px;color: rgb(233, 105, 0);background: rgb(248, 248, 248);">provider_id</code>)</p> <p style="font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;">现在有数据库表(<code style="font-size: inherit;line-height: inherit;padding: 2px 4px;border-radius: 4px;margin-right: 2px;margin-left: 2px;color: rgb(233, 105, 0);background: rgb(248, 248, 248);">user</code>)如下:</p> <figure style="font-size: inherit;color: inherit;line-height: inherit;"> <img data-ratio="0.31537450722733246" src="/upload/19facc068f5565dc2cc3a756f610cea.png" data-type="png" data-w="761" style="font-size: inherit;color: inherit;line-height: inherit;display: block;margin-right: auto;margin-left: auto;" title=""> </figure> <p style="font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;">将<code style="font-size: inherit;line-height: inherit;padding: 2px 4px;border-radius: 4px;margin-right: 2px;margin-left: 2px;color: rgb(233, 105, 0);background: rgb(248, 248, 248);">provider_id</code>视为租户ID,用来隔离租户与租户之间的数据,如果要查询当前服务商的用户,SQL大致如下:</p> <pre style="font-size: inherit;color: inherit;line-height: inherit;"><code style="margin-right: 2px;margin-left: 2px;line-height: 18px;letter-spacing: 0px;font-family: Consolas, Inconsolata, Courier, monospace;border-radius: 0px;color: rgb(169, 183, 198);background: rgb(40, 43, 46);padding: 0.5em;overflow-wrap: normal !important;word-break: normal !important;overflow: auto !important;display: -webkit-box !important;"><span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">SELECT</span> * <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">FROM</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">user</span> t <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">WHERE</span> t.name <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">LIKE</span> <span style="font-size: inherit;line-height: inherit;color: rgb(238, 220, 112);overflow-wrap: inherit !important;word-break: inherit !important;">'%Tom%'</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">AND</span> t.provider_id = <span style="font-size: inherit;line-height: inherit;color: rgb(174, 135, 250);overflow-wrap: inherit !important;word-break: inherit !important;">1</span>;<br></code></pre> <p style="font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;">试想一下,除了一些系统共用的表以外,其他租户相关的表,我们都需要不厌其烦的加上AND t.provider_id = ?查询条件,稍不注意就会导致数据越界,数据安全问题让人担忧。</p> <p style="font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;">好在有了MybatisPlus这个神器,可以极为方便的实现多租户SQL解析器,官方文档如下:</p> <blockquote style="line-height: inherit;padding: 15px 15px 15px 1rem;font-size: 0.9em;color: rgb(129, 145, 152);border-left-width: 6px;border-left-color: rgb(220, 230, 240);background: rgb(242, 247, 251);overflow: auto;overflow-wrap: normal;word-break: normal;"> <p style="font-size: inherit;color: inherit;line-height: inherit;">http://mp.baomidou.com/guide/tenant.html</p> </blockquote> <p style="font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;">这里终于进入了正题,开始搭建一个极为简单的开发环境吧!</p> <h3 style="line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;font-weight: bold;color: rgb(0, 172, 193);font-size: 1.3em;"><span style="font-size: inherit;color: inherit;line-height: inherit;">新建SpringBoot环境</span></h3> <p style="font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;"><strong style="font-size: inherit;color: inherit;line-height: inherit;">POM文件如下,主要集成了MybatisPlus以及H2数据库(方便测试)</strong></p> <pre style="font-size: inherit;color: inherit;line-height: inherit;"><code style="margin-right: 2px;margin-left: 2px;line-height: 18px;letter-spacing: 0px;font-family: Consolas, Inconsolata, Courier, monospace;border-radius: 0px;color: rgb(169, 183, 198);background: rgb(40, 43, 46);padding: 0.5em;overflow-wrap: normal !important;word-break: normal !important;overflow: auto !important;display: -webkit-box !important;"><span style="font-size: inherit;line-height: inherit;color: rgb(91, 218, 237);overflow-wrap: inherit !important;word-break: inherit !important;"><?xml version="1.0" encoding="UTF-8"?></span><br><span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">project</span> <span style="line-height: inherit;color: rgb(165, 218, 45);overflow-wrap: inherit !important;word-break: inherit !important;">xmlns</span>=<span style="line-height: inherit;color: rgb(238, 220, 112);overflow-wrap: inherit !important;word-break: inherit !important;">"http://maven.apache.org/POM/4.0.0"</span> <span style="line-height: inherit;color: rgb(165, 218, 45);overflow-wrap: inherit !important;word-break: inherit !important;">xmlns:xsi</span>=<span style="line-height: inherit;color: rgb(238, 220, 112);overflow-wrap: inherit !important;word-break: inherit !important;">"http://www.w3.org/2001/XMLSchema-instance"</span><br> <span style="line-height: inherit;color: rgb(165, 218, 45);overflow-wrap: inherit !important;word-break: inherit !important;">xsi:schemaLocation</span>=<span style="line-height: inherit;color: rgb(238, 220, 112);overflow-wrap: inherit !important;word-break: inherit !important;">"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">modelVersion</span>></span>4.0.0<span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">modelVersion</span>></span><br><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">groupId</span>></span>com.wuwenze<span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">groupId</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">artifactId</span>></span>mybatis-plus-multi-tenancy<span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">artifactId</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">version</span>></span>0.0.1-SNAPSHOT<span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">version</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">packaging</span>></span>jar<span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">packaging</span>></span><br><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">name</span>></span>mybatis-plus-multi-tenancy<span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">name</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">description</span>></span>Demo project for Spring Boot<span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">description</span>></span><br><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">parent</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">groupId</span>></span>org.springframework.boot<span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">groupId</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">artifactId</span>></span>spring-boot-starter-parent<span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">artifactId</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">version</span>></span>2.1.0.RELEASE<span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">version</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">relativePath</span>/></span> <span style="font-size: inherit;line-height: inherit;color: rgb(128, 128, 128);overflow-wrap: inherit !important;word-break: inherit !important;"><!-- lookup parent from repository --></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">parent</span>></span><br><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">properties</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">project.build.sourceEncoding</span>></span>UTF-8<span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">project.build.sourceEncoding</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">project.reporting.outputEncoding</span>></span>UTF-8<span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">project.reporting.outputEncoding</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">java.version</span>></span>1.8<span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">java.version</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">properties</span>></span><br><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">dependencies</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">dependency</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">groupId</span>></span>org.springframework.boot<span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">groupId</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">artifactId</span>></span>spring-boot-starter<span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">artifactId</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">dependency</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">dependency</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">groupId</span>></span>org.springframework.boot<span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">groupId</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">artifactId</span>></span>spring-boot-starter-test<span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">artifactId</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">scope</span>></span>test<span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">scope</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">dependency</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">dependency</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">groupId</span>></span>org.projectlombok<span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">groupId</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">artifactId</span>></span>lombok<span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">artifactId</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">scope</span>></span>provided<span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">scope</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">dependency</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">dependency</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">groupId</span>></span>com.google.guava<span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">groupId</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">artifactId</span>></span>guava<span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">artifactId</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">version</span>></span>19.0<span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">version</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">dependency</span>></span><br><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">dependency</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">groupId</span>></span>com.baomidou<span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">groupId</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">artifactId</span>></span>mybatis-plus-boot-starter<span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">artifactId</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">version</span>></span>3.0.5<span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">version</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">dependency</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">dependency</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">groupId</span>></span>com.baomidou<span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">groupId</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">artifactId</span>></span>mybatis-plus<span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">artifactId</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">version</span>></span>3.0.5<span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">version</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">dependency</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">dependency</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">groupId</span>></span>com.baomidou<span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">groupId</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">artifactId</span>></span>mybatis-plus-generator<span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">artifactId</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">version</span>></span>3.0.5<span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">version</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">dependency</span>></span><br><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">dependency</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">groupId</span>></span>com.h2database<span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">groupId</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">artifactId</span>></span>h2<span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">artifactId</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">dependency</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">dependencies</span>></span><br><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">build</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">plugins</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">plugin</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">groupId</span>></span>org.springframework.boot<span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">groupId</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">artifactId</span>></span>spring-boot-maven-plugin<span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">artifactId</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">plugin</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">plugins</span>></span><br> <span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">build</span>></span><br><span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"></<span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">project</span>></span><br></code></pre> <p style="font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;"><strong style="font-size: inherit;color: inherit;line-height: inherit;">数据源配置(application.yml)</strong></p> <pre style="font-size: inherit;color: inherit;line-height: inherit;"><code style="margin-right: 2px;margin-left: 2px;line-height: 18px;letter-spacing: 0px;font-family: Consolas, Inconsolata, Courier, monospace;border-radius: 0px;color: rgb(169, 183, 198);background: rgb(40, 43, 46);padding: 0.5em;overflow-wrap: normal !important;word-break: normal !important;overflow: auto !important;display: -webkit-box !important;">spring:<br> datasource:<br> driver-<span style="font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;"><span style="line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">class</span>-<span style="line-height: inherit;color: rgb(165, 218, 45);overflow-wrap: inherit !important;word-break: inherit !important;">name</span>: <span style="line-height: inherit;color: rgb(165, 218, 45);overflow-wrap: inherit !important;word-break: inherit !important;">org.h2.Driver</span></span><br> schema: classpath:db/schema.sql<br> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">data</span>: classpath:db/<span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">data</span>.sql<br> url: jdbc:h2:mem:test<br> username: root<br> password: test<br><br>logging:<br> level:<br> com.wuwenze.mybatisplusmultitenancy: debug<br></code></pre> <p style="font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.5em;margin-bottom: 1.5em;"><strong style="font-size: inherit;color: inherit;line-height: inherit;">对应的H2数据库初始化schema文件</strong></p> <pre style="font-size: inherit;color: inherit;line-height: inherit;"><code style="margin-right: 2px;margin-left: 2px;line-height: 18px;letter-spacing: 0px;font-family: Consolas, Inconsolata, Courier, monospace;border-radius: 0px;color: rgb(169, 183, 198);background: rgb(40, 43, 46);padding: 0.5em;overflow-wrap: normal !important;word-break: normal !important;overflow: auto !important;display: -webkit-box !important;"><span style="font-size: inherit;line-height: inherit;color: rgb(128, 128, 128);overflow-wrap: inherit !important;word-break: inherit !important;">#schema.sql</span><br><span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">DROP</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">TABLE</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">IF</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">EXISTS</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">user</span>;<br><span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">CREATE</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">TABLE</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">user</span><br>(<br> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">id</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">BIGINT</span>(<span style="font-size: inherit;line-height: inherit;color: rgb(174, 135, 250);overflow-wrap: inherit !important;word-break: inherit !important;">20</span>) <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">NOT</span> <span style="font-size: inherit;line-height: inherit;color: rgb(174, 135, 250);overflow-wrap: inherit !important;word-break: inherit !important;">NULL</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">COMMENT</span> <span style="font-size: inherit;line-height: inherit;color: rgb(238, 220, 112);overflow-wrap: inherit !important;word-break: inherit !important;">'主键'</span>,<br> provider_id <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">BIGINT</span>(<span style="font-size: inherit;line-height: inherit;color: rgb(174, 135, 250);overflow-wrap: inherit !important;word-break: inherit !important;">20</span>) <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">NOT</span> <span style="font-size: inherit;line-height: inherit;color: rgb(174, 135, 250);overflow-wrap: inherit !important;word-break: inherit !important;">NULL</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">COMMENT</span> <span style="font-size: inherit;line-height: inherit;color: rgb(238, 220, 112);overflow-wrap: inherit !important;word-break: inherit !important;">'服务商ID'</span>,<br> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">name</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">VARCHAR</span>(<span style="font-size: inherit;line-height: inherit;color: rgb(174, 135, 250);overflow-wrap: inherit !important;word-break: inherit !important;">30</span>) <span style="font-size: inherit;line-height: inherit;color: rgb(174, 135, 250);overflow-wrap: inherit !important;word-break: inherit !important;">NULL</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">DEFAULT</span> <span style="font-size: inherit;line-height: inherit;color: rgb(174, 135, 250);overflow-wrap: inherit !important;word-break: inherit !important;">NULL</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">COMMENT</span> <span style="font-size: inherit;line-height: inherit;color: rgb(238, 220, 112);overflow-wrap: inherit !important;word-break: inherit !important;">'姓名'</span>,<br> PRIMARY <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">KEY</span> (<span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">id</span>)<br>);<br><br><br><span style="font-size: inherit;line-height: inherit;color: rgb(128, 128, 128);overflow-wrap: inherit !important;word-break: inherit !important;">#data.sql</span><br><span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">INSERT</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">INTO</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">user</span> (<span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">id</span>, provider_id, <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">name</span>) <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">VALUES</span> (<span style="font-size: inherit;line-height: inherit;color: rgb(174, 135, 250);overflow-wrap: inherit !important;word-break: inherit !important;">1</span>, <span style="font-size: inherit;line-height: inherit;color: rgb(174, 135, 250);overflow-wrap: inherit !important;word-break: inherit !important;">1</span>, <span style="font-size: inherit;line-height: inherit;color: rgb(238, 220, 112);overflow-wrap: inherit !important;word-break: inherit !important;">'Tony老师'</span>);<br><span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">INSERT</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">INTO</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">user</span> (<span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">id</span>, provider_id, <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">name</span>) <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">VALUES</span> (<span style="font-size: inherit;line-height: inherit;color: rgb(174, 135, 250);overflow-wrap: inherit !important;word-break: inherit !important;">2</span>, <span style="font-size: inherit;line-height: inherit;color: rgb(174, 135, 250);overflow-wrap: inherit !important;word-break: inherit !important;">1</span>, <span style="font-size: inherit;line-height: inherit;color: rgb(238, 220, 112);overflow-wrap: inherit !important;word-break: inherit !important;">'William老师'</span>);<br><span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);overflow-wrap: inherit !important;word-break: inherit !important;">INSERT</span> <span style="font-size: inherit;line-h
作者:微信小助手
<p style="text-align: center;"><span style="font-size: 14px;letter-spacing: 0.5440000295639038px;text-align: center;max-width: 100%;color: rgb(255, 41, 65);line-height: 22.4px;">(给</span><span style="font-size: 14px;letter-spacing: 0.5440000295639038px;text-align: center;max-width: 100%;line-height: 22.4px;color: rgb(0, 128, 255);">ImportNew</span><span style="font-size: 14px;letter-spacing: 0.5440000295639038px;text-align: center;max-width: 100%;color: rgb(255, 41, 65);line-height: 22.4px;">加星标,提高Java技能)</span></p> <blockquote> <p style="letter-spacing: 0.5440000295639038px;white-space: normal;background-color: rgb(255, 255, 255);max-width: 100%;min-height: 1em;text-align: left;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="max-width: 100%;font-size: 14px;box-sizing: border-box !important;overflow-wrap: break-word !important;">转自:博客园 作者:Alan_beijing</span></p> <p style="letter-spacing: 0.5440000295639038px;white-space: normal;background-color: rgb(255, 255, 255);max-width: 100%;min-height: 1em;text-align: left;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="font-size: 14px;">www.cnblogs.com/wangjiming/p/10384975.html</span></p> </blockquote> <section style="line-height: 1.5em;"> <span style="font-size: 15px;letter-spacing: normal;color: rgb(0, 0, 0);">在JAVA发展过程中,涌现出一系列的ORM框架,JPA,Hibernate,Mybatis和Spring jdbc,本系列,将来研究Mybatis。</span> </section> <section style="line-height: 1.5em;"> <span style="font-size: 15px;letter-spacing: normal;"><br></span> </section> <section style="line-height: 1.5em;"> <span style="font-size: 15px;letter-spacing: normal;"><img data-ratio="0.7150259067357513" src="/upload/8910f2904fb9e896bfeb0608c8a479bd.png" data-type="png" data-w="386"></span> </section> <section style="line-height: 1.5em;"> <span style="font-size: 15px;color: rgb(0, 0, 0);"><br></span> </section> <section style="line-height: 1.5em;"> <span style="font-size: 15px;color: rgb(0, 0, 0);">通过研究mybatis源码,可将mybatis的大致架构总结为下图:</span> </section> <section style="line-height: 1.5em;"> <span style="font-size: 15px;color: rgb(0, 0, 0);"><br></span> </section> <section style="line-height: 1.5em;"> <span style="font-size: 15px;letter-spacing: normal;color: rgb(0, 0, 0);">1.根据Mybatis源码,将其抽象为三层:基础支持层,核心处理层和接口层</span> </section> <section style="line-height: 1.5em;"> <span style="font-size: 15px;letter-spacing: normal;color: rgb(0, 0, 0);">2.基础支持层包括:数据源、事务管理、日志、类型转换、缓存、Bind、解析器等</span> </section> <section style="line-height: 1.5em;"> <span style="font-size: 15px;letter-spacing: normal;color: rgb(0, 0, 0);">3.核心处理层包括:配置解析、配置映射、SQL解析、SQL执行、结果集映射、插件等</span> </section> <section style="line-height: 1.5em;"> <span style="font-size: 15px;letter-spacing: normal;color: rgb(0, 0, 0);">4.接口层主要提供JAVA API</span> </section> <section style="line-height: 1.5em;"> <span style="font-size: 15px;letter-spacing: normal;"><br></span> </section> <section style="line-height: 1.5em;"> <span style="font-size: 15px;"> </span> <img data-ratio="0.5610738255033557" src="/upload/d05e6616d99c3c7dc39904d3adaeb4b8.png" data-type="png" data-w="745" height="317" style="border-width: 0px;border-style: initial;border-color: initial;max-width: 820px;" width="565"> </section> <section style="line-height: 1.5em;"> <span style="font-size: 15px;letter-spacing: normal;"><br></span> </section> <section style="line-height: 1.5em;"> <span style="font-size: 15px;letter-spacing: normal;color: rgb(0, 0, 0);">在本篇文章中,将基于该框架图,解决如下几个问题:</span> </section> <section style="line-height: 1.5em;"> <span style="font-size: 15px;letter-spacing: normal;color: rgb(0, 0, 0);"><br></span> </section> <section style="line-height: 1.5em;"> <span style="font-size: 15px;letter-spacing: normal;color: rgb(0, 0, 0);">Q1:结合代码解析mybatis的CRUD原理是怎样的?</span> </section> <section style="line-height: 1.5em;"> <span style="font-size: 15px;letter-spacing: normal;color: rgb(0, 0, 0);">Q2:为什么半自动化的Mybatis比自动化的Hibernate受欢迎?</span> </section> <section style="line-height: 1.5em;"> <span style="font-size: 15px;letter-spacing: normal;color: rgb(0, 0, 0);">Q3:Mybatis为什么能实现松耦合?</span> </section> <section style="line-height: 1.5em;"> <span style="font-size: 15px;letter-spacing: normal;"><br></span> </section> <p style="line-height: 1.5em;"><span style="color: rgb(171, 25, 66);"><strong><span style="font-size: 15px;letter-spacing: normal;">一 mybatis的CRUD原理</span></strong></span></p> <p style="line-height: 1.5em;"><span style="font-size: 15px;"><br></span></p> <p style="line-height: 1.5em;"><span style="color: rgb(0, 0, 0);font-size: 15px;">为了解决该问题,我们先来看看如下代码:<br></span></p> <p style="line-height: 1.5em;"><span style="font-size: 15px;color: rgb(0, 0, 0);"><br></span></p> <section style="line-height: 1.5em;"> <span style="font-size: 15px;color: rgb(0, 0, 0);">该代码实现的功能是:根据user_id查询用户信息。 从代码中,我们可以看出,大致分为四步:</span> </section> <section style="line-height: 1.5em;"> <span style="font-size: 15px;color: rgb(0, 0, 0);"><br></span> </section> <section style="line-height: 1.5em;"> <span style="font-size: 15px;letter-spacing: normal;color: rgb(0, 0, 0);">第一步:读取mybatis的全局配置文件mybatis-config.xml内容</span> </section> <section style="line-height: 1.5em;"> <span style="font-size: 15px;letter-spacing: normal;color: rgb(0, 0, 0);">第二步:创建SqlSessionFactory会话工厂</span> </section> <section style="line-height: 1.5em;"> <span style="font-size: 15px;letter-spacing: normal;color: rgb(0, 0, 0);">第三步:根据SqlSessionFactory创建SQL会话SqlSession</span> </section> <section style="line-height: 1.5em;"> <span style="font-size: 15px;letter-spacing: normal;color: rgb(0, 0, 0);">第四步:执行查询操作</span> </section> <section style="line-height: 1.5em;"> <span style="font-size: 15px;letter-spacing: normal;"><pre style="overflow-x:auto;"><code style="font-size: 0.85em;font-family: Consolas, Menlo, Courier, monospace;margin: 0px 0.15em;white-space: pre;overflow: auto;display: block;padding: 0.5em;color: rgb(171, 178, 191);text-size-adjust: none;min-width: 400px;background: none 0% 0% / auto repeat scroll padding-box border-box rgb(40, 44, 52);font-weight: 400;" data-wx-hl-code="public static void main(String[] args) throws IOException {&lt;br/&gt; //读取配置文件内容&lt;br/&gt; String resource = "demo/mybatis/resources/mybatis-config.xml";&lt;br/&gt; InputStream inputStream = Resources.getResourceAsStream(resource);&lt;br/&gt; //创建SqlSessionFactory&lt;br/&gt; SqlSessionFactory sqlSF = new SqlSessionFactoryBuilder().build(inputStream);&lt;br/&gt; //创建SqlSession&lt;br/&gt; SqlSession sqlS = sqlSF.openSession();&lt;br/&gt;&lt;br/&gt; //根据id查询&lt;br/&gt; try {&lt;br/&gt; //查询user_id=2的记录&lt;br/&gt; List<UserInfo> list = sqlS.selectList("getUserInfoById", 2);&lt;br/&gt; for (UserInfo user : list) {&lt;br/&gt; System.out.println("UserName:" + user.getUser_name() + ",Addr:" + user.getUser_addr());&lt;br/&gt; }&lt;br/&gt; } finally {&lt;br/&gt; sqlS.close();&lt;br/&gt; }&lt;br/&gt; }" data-wx-hl-lang="
作者:微信小助手
<p style="text-align: center;" data-mpa-powered-by="yiban.io"><img class="rich_pages" data-ratio="1.049074074074074" data-s="300,640" src="/upload/e64d9c0039b5a2495c45febef13eb91b.jpg" data-type="jpeg" data-w="1080" style=""></p> <h1 style="box-sizing: border-box;margin-top: 1.5rem;margin-bottom: 1rem;color: rgb(21, 153, 87);line-height: 1.35;font-size: 28px;text-align: start;white-space: normal;font-family: Menlo, Monaco, "Source Code Pro", Consolas, Inconsolata, "Ubuntu Mono", "DejaVu Sans Mono", "Courier New", "Droid Sans Mono", "Hiragino Sans GB", 微软雅黑, monospace !important;">前言</h1> <p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;font-size: 16px;white-space: pre-line;line-he
作者:微信小助手
<p style="max-width: 100%;min-height: 1em;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);text-indent: 2em;box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;font-size: 14px;color: rgb(136, 136, 136);box-sizing: border-box !important;word-wrap: break-word !important;">郑重声明:漫画人物和故事情节均是原创,未经同意禁止任何形式的转载,侵权将进入法律程序。大佬除外。</span></p> <p style="max-width: 100%;min-height: 1em;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);text-indent: 2em;box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;font-size: 14px;color: rgb(136, 136, 136);box-sizing: border-box !important;word-wrap: break-word !important;">欢迎大家转发文章,谢谢!</span></p> <p style="max-width: 100%;min-height: 1em;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);text-align: center;box-sizing: border-box !important;word-wrap: break-word !important;"><img class="" data-copyright="0" data-ratio="0.44802867383512546" data-s="300,640" data-type="jpeg" data-w="558" src="/upload/2ff1805dda7d70892bb3f61234ae0ac2.jpg" style="box-sizing: border-box !important;word-wrap: break-word !important;visibility: visible !important;width: 558px !important;"></p> <p style="max-width: 100%;min-height: 1em;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);text-indent: 2em;box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;color: rgb(136, 136, 136);box-sizing: border-box !important;word-wrap: break-word !important;">小史是一个非科班的程序员,虽然学的是电子专业,但是通过自己的努力成功通过了面试,现在要开始迎接新生活了。</span></p> <p style="max-width: 100%;min-height: 1em;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);text-indent: 2em;box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;color: rgb(136, 136, 136);box-sizing: border-box !important;word-wrap: break-word !important;">对小史面试情况感兴趣的同学可以观看<a href="http://mp.weixin.qq.com/s?__biz=MzIzMTE1ODkyNQ==&mid=2649410956&idx=1&sn=50942b435c41f60c1fc02b0d10c6b553&chksm=f0b6086ec7c181787c5b4a2936026941db14a4ac177e78f42d2374860999a0e8c3911858056f&scene=21#wechat_redirect" target="_blank" data-linktype="2" style="color: rgb(87, 107, 149);-webkit-tap-highlight-color: rgba(0, 0, 0, 0);max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;">面试现场系列</a>。</span></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="0.5628517823639775" data-s="300,640" src="/upload/ce39fdee7e3828ca1c32d809383acf72.jpg" data-type="jpeg" data-w="533" style=""></p> <p style="text-indent: 2em;"><br></p> <p style="text-indent: 2em;">随着央视诗词大会的热播,小史开始对诗词感兴趣,最喜欢的就是飞花令的环节。</p> <p class="p2"><br></p> <p style="text-indent: 2em;">但是由于小史很久没有背过诗词了,飞一个字很难说出一句,很多之前很熟悉的诗句也想不起来。</p> <p style="text-indent: 2em;"><br></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/260d2de164bb35b28f3d709e7fe45428.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/f6fe4ce748da747e0da89147532db04b.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/8c04395163b0f7110b5dd71a8303d772.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/a983e56a4c39ec78fca6281a711e9c51.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/53c9fb769ca4efbf6df01f0cbb74560b.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/9743c03d6181f134383e4a54c3c17357.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/ac1d224e4eab473e2b0b72f5b9b8c645.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/42e78004a1756f9dbd4673efdf6afd4b.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/c6d53a863620f4cdd8a7d9ba89c24f38.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/7f861516127189bf10322b64fa25469f.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: left;text-indent: 0em;"><strong style="max-width: 100%;letter-spacing: 0.544px;text-align: left;white-space: normal;background-color: rgb(255, 255, 255);box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;font-size: 18px;box-sizing: border-box !important;word-wrap: break-word !important;">【倒排索引】</span></strong></p> <p style="text-indent: 2em;"><br></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/329267e6c1e657776d5a03035e4d62de.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/b826ec2f4f5354916eb9b16bcd403f40.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/c66232c2ba41b4edb7bc2c25eb237405.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.1840796019900497" data-s="300,640" src="/upload/31a9b633e67644b15861b1bb90146f18.jpg" data-type="jpeg" data-w="402" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/88f11db3984bf512cb66edda518fc50c.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/6d58f3fd3fbdf8cf064f45f3554629e6.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: left;text-indent: 2em;">吕老师:但是我让你说出带“前”字的诗句,由于没有索引,你只能遍历脑海中所有诗词,当你的脑海中诗词量大的时候,就很难在短时间内得到结果了。</p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/3a7054af4769d828e15173ebade48d57.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/3361290f99cd2494296c61ba802124ec.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="0.9601990049751243" data-s="300,640" src="/upload/230f0fe69c57c1e5fa151b9d49841673.jpg" data-type="jpeg" data-w="402" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/54b6b18851b52642a5325fc2319d77ec.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/3153e55325cf2c723656d5964d84b03a.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/9f63ff12b13c980d72c10a7c3582e35f.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/f320234118bc37a35ff4527e77321ad9.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-indent: 0em;"><strong style="text-align: left;white-space: normal;max-width: 100%;letter-spacing: 0.544px;background-color: rgb(255, 255, 255);box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;font-size: 18px;box-sizing: border-box !important;word-wrap: break-word !important;">【索引量爆炸】</span></strong></p> <p style="text-indent: 2em;"><br></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/2a663bda1a15a7a31be3bece6145d34e.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="0.8349056603773585" data-s="300,640" src="/upload/7b858c26704572fa4e4b8ee0f3c31a18.jpg" data-type="jpeg" data-w="424" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/c4e722a6395648a7f5ce3f37b269444c.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="2.644278606965174" data-s="300,640" src="/upload/443b95185971c36edc7ac0bd026845f.jpg" data-type="jpeg" data-w="402" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/a8cc59fd0f42df7d0d3ab0a6114ceb0f.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/55ec85f40c6cdaf2c165d1cc00dffc34.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/a14c0010578bd81fe73816249862cb03.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/7c2816691a1ca61fd2dc96fd5688d341.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/4fbdf101bc5340119c5305bf509d4082.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/6221c12fa56574635863190706939826.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.8781094527363185" data-s="300,640" src="/upload/edcde07c2f14c297e9ad0c4a5d8f7f61.jpg" data-type="jpeg" data-w="402" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/130d1b44ffa3bac78a8f896bc256e783.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/cad373d81f99f336e70f3a0ed6ae7ded.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.8781094527363185" data-s="300,640" src="/upload/98c94a49661e6a2415edcda806408d1d.jpg" data-type="jpeg" data-w="402" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/a249e1cffab63464dd692d7ea7e5ff00.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.1741293532338308" data-s="300,640" src="/upload/6ea2b2419e62f647a9701bd7c9d7613c.jpg" data-type="jpeg" data-w="402" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/8d350699ae03a29b2fc02e5e63cb48db.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.1766169154228856" data-s="300,640" src="/upload/272ae5bcc9213f2d2aa3499df2b371e6.jpg" data-type="jpeg" data-w="402" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/f9a8ee774799a34412d819fc955e5a35.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-indent: 0em;"><strong style="white-space: normal;text-align: left;max-width: 100%;letter-spacing: 0.544px;background-color: rgb(255, 255, 255);box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;font-size: 18px;box-sizing: border-box !important;word-wrap: break-word !important;">【搜索引擎原理】</span></strong></p> <p style="text-indent: 2em;"><br></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/1676dbaaa86c31af76468e46757c96f6.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/24f85a11904447a8ba03cb04c6d92d49.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="0.9245283018867925" data-s="300,640" src="/upload/f4cb5834b7a9c6b2ea90f454236f3de9.jpg" data-type="jpeg" data-w="424" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/215c759b9d93ff10e4573d9929dfc2da.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/43ab76b69cdcc2fe52af29f3681e8c0d.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/a7b2f38af125fec4401d11a50c4d5a99.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/d908105e34386ad7c22cadab71767f4e.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/4f725555c54f940a4955909c80374c21.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.1766169154228856" data-s="300,640" src="/upload/541b371c0c6a32c4c010989552c8f1bf.jpg" data-type="jpeg" data-w="402" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/9377097e29edb9d5e3610611b1b034e4.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/6a9bdc27330cdb31e7a1b7c8ae415c7f.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/ca9023e9b135db8578bf0f1feb94bc9e.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/439cdbae4dc622098a7bdab6d16dca50.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.3962264150943395" data-s="300,640" src="/upload/60ee5be19cdfdbebf1db5fa2465ec495.jpg" data-type="jpeg" data-w="424" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/6268f88732fe19ac2379526649f62b52.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-indent: 0em;"><strong style="white-space: normal;text-align: left;max-width: 100%;letter-spacing: 0.544px;background-color: rgb(255, 255, 255);box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;font-size: 18px;box-sizing: border-box !important;word-wrap: break-word !important;">【elasticsearch简介】</span></strong></p> <p style="text-indent: 0em;"><br></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/2f3d854dd00f7188c9f6c595babc1324.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/df17ee822bed9a88c8efe8fdefd06e79.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/ad6295340ad5a30098e7a8f29f4b7b86.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/57560c7fa4c1b89ba885bc795e6134f2.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/2fe7c9ef3d43f7bb4424c31f2e85a235.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-indent: 2em;">吕老师:但是<span class="s1">lucene</span>还是一个库,必须要懂一点搜索引擎原理的人才能用的好,所以后来又有人基于<span class="s1">lucene</span>进行封装,写出了<span class="s1">elasticsearch</span>。</p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/dadfa1d74e626bcebda61a4208e79192.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/ad2bc40aa13c47b3c4abcb5cdde3a4bd.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/be0b5c58a61d68be79226346aa1ff0ad.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/50242586788c8234edfb4758055a1ff6.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/157bc5846ba1ea5529dd286182f3bb82.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/2c73db7be9b5216acd91e2e540d73ec8.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-indent: 0em;"><strong style="white-space: normal;text-align: left;max-width: 100%;letter-spacing: 0.544px;background-color: rgb(255, 255, 255);box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;font-size: 18px;box-sizing: border-box !important;word-wrap: break-word !important;">【elasticsearch基本概念】</span></strong></p> <p style="text-indent: 2em;"><br></p> <p style="text-align: center;"><img class="rich_pages" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/3e5f4e5e1fd129b444d064fafae81418.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="rich_pages" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/623299d66a1cb0f55b855a076b8e39ee.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="rich_pages" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/96eb01f4f01e12837e59862bd6c280fe.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="rich_pages" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/2a27f0cb64eb50a90c21af1b6547099a.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="rich_pages" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/afec305c8c6ff56171ec5978b5865216.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-indent: 2em;">吕老师:类型是用来定义数据结构的,你可以认为是<span class="s1">mysql</span>中的一张表。文档就是最终的数据了,你可以认为一个文档就是一条记录。</p> <p style="text-align: center;"><img class="rich_pages" data-copyright="0" data-ratio="1.0522388059701493" data-s="300,640" src="/upload/18c27d8905b6836454ff95673a015c4e.jpg" data-type="jpeg" data-w="402" style=""></p> <p style="text-align: center;"><img class="rich_pages" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/98db9c20871bbb99dffcc06653bbd484.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="rich_pages" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/5a4fc25c2fbe31926b53c6de4a5ba7f.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-indent: 2em;">吕老师:比如一首诗,有诗题、作者、朝代、字数、诗内容等字段,那么首先,我们可以建立一个名叫<span class="s1">poems</span>的索引,然后创建一个名叫<span class="s1">poem</span>的类型,类型是通过<span class="s1">mapping</span>来定义每个字段的类型,比如诗题、作者、朝代都是<span class="s1">keyword</span>类型,诗内容是<span class="s1">text</span>类型,而字数是<span class="s1">integer</span>类型,最后就是把数据组织成<span class="s1">json</span>格式存放进去了。</p> <p style="text-align: center;"><img class="rich_pages" data-copyright="0" data-ratio="3.2661691542288556" data-s="300,640" src="/upload/c8a86008eb022b2915bedb51b2126d09.jpg" data-type="jpeg" data-w="402" style=""></p> <p style="text-align: center;"><img class="rich_pages" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/1bc794f7ba8871fade8f4f771f476be.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="rich_pages" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/930cc64cc8a65b95e7911be318e2a84f.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-indent: 2em;">吕老师:这个问题问得好,这涉及到分词的问题,<span class="s1">keyword</span>类型是不会分词的,直接根据字符串内容建立反向索引,<span class="s1">text</span>类型在存入<span class="s1">elasticsearch</span>的时候,会先分词,然后根据分词后的内容建立反向索引。</p> <p style="text-align: center;"><img class="rich_pages" data-copyright="0" data-ratio="0.9353233830845771" data-s="300,640" src="/upload/917c9e0a6a9fbe05c5fab273ab58726e.jpg" data-type="jpeg" data-w="402" style=""></p> <p style="text-align: center;"><img class="rich_pages" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/be138e0ede7e939b2fbae5c822af2a1d.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="rich_pages" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/51100a504a15e240c2e48d331ff1b970.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-indent: 2em;"><span class="s1">吕老师:之前我们说过,</span>elasticsearch<span class="s1">把操作都封装成了</span>http<span class="s1">的</span>api<span class="s1">,我们只要给</span>elasticsearch<span class="s1">发送</span>http<span class="s1">请求就行。比如使用</span>curl -XPUT '<span class="s2">http://ip:port/poems</span>'<span class="s1">,就能建立一个名为</span>poems<span class="s1">的索引,其他操作也是类似的。</span></p> <p style="text-align: center;"><img class="rich_pages" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/1d4c5988901e447cff1d90ac4deff4d.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-indent: 0em;"><strong style="white-space: normal;text-align: left;max-width: 100%;letter-spacing: 0.544px;background-color: rgb(255, 255, 255);box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;font-size: 18px;box-sizing: border-box !important;word-wrap: break-word !important;">【elasticsearch分布式原理】</span></strong></p> <p style="text-indent: 2em;"><br></p> <p style="text-align: center;"><img class="rich_pages" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/6d6a8af1b8cff5478f0cbd89017f4179.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="rich_pages" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/f553a8929ac8f0cd1b42ba6c22b7d3d9.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-indent: 2em;">吕老师:没错,<span class="s1">elasticsearch</span>也是会对数据进行切分,同时每一个分片会保存多个副本,其原因和<span class="s1">hdfs</span>是一样的,都是为了保证分布式环境下的高可用。</p> <p style="text-align: center;"><img class="rich_pages" data-copyright="0" data-ratio="1.492537313432836" data-s="300,640" src="/upload/7acad273dc4f6bf89abbad27df6f6132.jpg" data-type="jpeg" data-w="402" style=""></p> <p style="text-align: center;"><img class="rich_pages" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/3f42f2666018d6a1ebd37cc7f7de6162.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="rich_pages" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/f9953748e9b9bc950bc5baf1025adbf7.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-indent: 2em;">吕老师:没错,在<span class="s1">elasticsearch</span>中,节点是对等的,节点间会通过自己的一些规则选取集群的<span class="s1">master</span>,<span class="s1">master</span>会负责集群状态信息的改变,并同步给其他节点。</p> <p style="text-align: center;"><img class="rich_pages" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/ceb5d93b3a9bcdd47e1c02c9b28b3545.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="rich_pages" data-copyright="0" data-ratio="1.1691542288557213" data-s="300,640" src="/upload/4038d8292d2ad80ead1abc11ecfc1d0b.jpg" data-type="jpeg" data-w="402" style=""></p> <p style="text-align: center;"><img class="rich_pages" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/61054315875780a2d4dbf817d3d5a398.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="rich_pages" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/dbdcf2f3d1870a5d0f140994319ebc2b.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="rich_pages" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/ee7fdfb8ad499676b8942ecf72d5b1c7.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-indent: 2em;">吕老师:注意,只有建立索引和类型需要经过<span class="s1">master</span>,数据的写入有一个简单的<span class="s1">routing</span>规则,可以<span class="s1">route</span>到集群中的任意节点,所以数据写入压力是分散在整个集群的。</p> <p style="text-align: center;"><img class="rich_pages" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/40701c5ad9fdbccc9359b9bebf1e3d46.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-indent: 0em;"><strong style="white-space: normal;text-align: left;max-width: 100%;letter-spacing: 0.544px;background-color: rgb(255, 255, 255);box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;font-size: 18px;box-sizing: border-box !important;word-wrap: break-word !important;">【elk系统】</span></strong></p> <p style="text-indent: 2em;"><br></p> <p style="text-align: center;"><img class="rich_pages" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/b73b537e9cf173ebad68fb7bd4b6cf03.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="rich_pages" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/5fcb32f2903422f408e4cb807578e577.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-indent: 2em;">吕老师:其实很多公司都用<span class="s1">elasticsearch</span>搭建<span class="s1">elk</span>系统,也就是日志分析系统。其中<span class="s1">e</span>就是<span class="s1">elasticsearch</span>,<span class="s1">l</span>是<span class="s1">logstash</span>,是一个日志收集系统,<span class="s1">k</span>是<span class="s1">kibana</span>,是一个数据可视化平台。</p> <p style="text-align: center;"><img class="rich_pages" data-copyright="0" data-ratio="1.6019900497512438" data-s="300,640" src="/upload/9ca834e25bc1566b41248a8624a3d6db.jpg" data-type="jpeg" data-w="402" style=""></p> <p style="text-align: center;"><img class="rich_pages" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/e053c6c7bd24c4afaa0f7d65263d6e59.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="rich_pages" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/39428dae1a51ab8803880a01e59baa43.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-indent: 2em;">吕老师:分析日志的用处可大了,你想,假如一个分布式系统有<span class="s1">1000</span>台机器,系统出现故障时,我要看下日志,还得一台一台登录上去查看,是不是非常麻烦?</p> <p style="text-align: center;"><img class="rich_pages" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/c19cc1255d0d49a36cddfe1e44e241ad.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="rich_pages" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/9fefd674ac87a9051242210c88f8db2f.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-indent: 2em;">吕老师:但是如果日志接入了<span class="s1">elk</span>系统就不一样。比如系统运行过程中,突然出现了异常,在日志中就能及时反馈,日志进入<span class="s1">elk</span>系统中,我们直接在<span class="s1">kibana</span>就能看到日志情况。如果再接入一些实时计算模块,还能做实时报警功能。</p> <p style="text-align: center;"><img class="rich_pages" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/f0d1dcf88c93810bb86f19e43a6ec685.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="rich_pages" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/7b026905ca08eaf77c423042b2616559.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-align: center;"><img class="rich_pages" data-copyright="0" data-ratio="1.0223214285714286" data-s="300,640" src="/upload/43ce189fffd2556945603495b6d81fe4.jpg" data-type="jpeg" data-w="448" style=""></p> <p style="text-indent: 0em;"><strong style="white-space: normal;text-align: left;max-width: 100%;letter-spacing: 0.544px;background-color: rgb(255, 255, 255);box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;font-size: 18px;box-sizing: border-box !important;word-wrap: break-word !important;">【笔记】</span></strong></p> <p style="text-indent: 2em;"><br></p> <p style="text-indent: 2em;">小史学完了<span class="s1">elasticsearch</span>,在笔记本上写下了如下记录:</p> <p style="text-indent: 2em;"><span class="s1">1</span>、反向索引又叫倒排索引,是根据文章内容中的关键字建立索引</p> <p style="text-indent: 2em;"><span class="s1">2</span>、搜索引擎原理就是建立反向索引</p> <p style="text-indent: 2em;"><span class="s1">3</span>、<span class="s1">elasticsearch</span>在<span class="s1">lucene</span>的基础上进行封装,实现了分布式搜索引擎</p> <p style="text-indent: 2em;"><span class="s1">4</span>、<span class="s1">elasticsearch</span>中的索引、类型和文档的概念比较重要,类似于<span class="s1">mysql</span>中的数据库、表和行</p> <p style="text-indent: 2em;">5<span class="s2">、</span>elasticsearch<span class="s2">也是</span>master-slave<span class="s2">架构,也实现了数据的分片和备份</span></p> <p style="text-indent: 2em;">6<span class="s2">、</span>elasticsearch<span class="s2">一个典型应用就是</span>elk<span class="s2">日志分析系统</span></p> <p class="p3"><br></p> <p style="text-indent: 2em;">写完,又高高兴兴背诗去了。</p> <p class="p3"><br></p> <p class="p1" style="text-align: center;">观书有感</p> <p class="p1" style="text-align: center;">朱熹</p> <p class="p1" style="text-align: center;">半亩方塘一鉴开,天光云影共徘徊。</p> <p class="p1" style="text-align: center;">问渠那得清如许?为有源头活水来。</p> <p style="text-indent: 2em;"><br></p> <hr style="max-width: 100%;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);box-sizing: border-box !important;word-wrap: break-word !important;"> <p style="max-width: 100%;min-height: 1em;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);text-indent: 2em;box-sizing: border-box !important;word-wrap: break-word !important;"><br style="max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"></p> <p style="max-width: 100%;min-height: 1em;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);text-indent: 2em;box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;color: rgb(136, 136, 136);font-size: 14px;box-sizing: border-box !important;word-wrap: break-word !important;">生活现场是互联网侦察推出的现场系列中的另一个板块,旨在通过生活中的场景,来解释大数据微服务技术中的基本原理,希望对大家学习技术原理有所帮助。</span></p> <p style="max-width: 100%;min-height: 1em;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);text-indent: 2em;box-sizing: border-box !important;word-wrap: break-word !important;"><br style="max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"></p> <p style="max-width: 100%;min-height: 1em;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);text-indent: 2em;box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;color: rgb(136, 136, 136);font-size: 14px;box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;letter-spacing: 0.544px;box-sizing: border-box !important;word-wrap: break-word !important;">往期回顾</span></span></p> <p style="max-width: 100%;min-height: 1em;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);text-indent: 2em;box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;color: rgb(136, 136, 136);font-size: 14px;box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;letter-spacing: 0.544px;box-sizing: border-box !important;word-wrap: break-word !important;"><a href="http://mp.weixin.qq.com/s?__biz=MzIzMTE1ODkyNQ==&mid=2649411489&idx=1&sn=cc830718ac8af0287a0f2c4a880a87c9&chksm=f0b60a43c7c18355a89616d96dd7fec3529c0c307f282a14c9efba46f25cc504d71f61b93cc3&scene=21#wechat_redirect" target="_blank" data-itemshowtype="0" data-linktype="2">【生活现场】从洗袜子到hbase存储原理解析</a><br></span></span></p> <p style="max-width: 100%;min-height: 1em;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);text-indent: 2em;box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;color: rgb(136, 136, 136);font-size: 14px;box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;letter-spacing: 0.544px;box-sizing: border-box !important;word-wrap: break-word !important;"><a href="http://mp.weixin.qq.com/s?__biz=MzIzMTE1ODkyNQ==&mid=2649411210&idx=1&sn=749f6a034d91ed3292a9f7167dee9c41&chksm=f0b60b68c7c1827e82d4d3ba39cd1acd4f564ec556ef7bbc023d6517fe563a34f3d385244b7a&scene=21#wechat_redirect" target="_blank" data-itemshowtype="0" data-linktype="2" style="color: rgb(87, 107, 149);-webkit-tap-highlight-color: rgba(0, 0, 0, 0);max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;">【生活现场】从生日请客到hdfs工作原理解析</a><br style="max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"></span></span></p> <p style="max-width: 100%;min-height: 1em;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);text-indent: 2em;box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;color: rgb(136, 136, 136);font-size: 14px;box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;letter-spacing: 0.544px;box-sizing: border-box !important;word-wrap: break-word !important;"><a href="http://mp.weixin.qq.com/s?__biz=MzIzMTE1ODkyNQ==&mid=2649411054&idx=1&sn=f5fc02ccfb32cbe0421f13255027ae3f&chksm=f0b6080cc7c1811a7a333994bd77f2b57b6d6962e90d52ef173b06345f309ce6ecfa62519b7e&scene=21#wechat_redirect" target="_blank" data-linktype="2" style="color: rgb(87, 107, 149);-webkit-tap-highlight-color: rgba(0, 0, 0, 0);max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;">【生活现场】从打牌到map-reduce工作原理解析</a><br style="max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"></span></span></p> <p style="max-width: 100%;min-height: 1em;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);text-indent: 2em;box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;color: rgb(136, 136, 136);font-size: 14px;box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;letter-spacing: 0.544px;box-sizing: border-box !important;word-wrap: break-word !important;"><a href="http://mp.weixin.qq.com/s?__biz=MzIzMTE1ODkyNQ==&mid=2649410963&idx=1&sn=dab123af8a39a0d7eb3d06c22b5d7ad9&chksm=f0b60871c7c18167801f71b952f3201835f9deb30aaec5fbfce2fe4769124e29cdfe52f20bed&scene=21#wechat_redirect" target="_blank" data-linktype="2" style="color: rgb(87, 107, 149);-webkit-tap-highlight-color: rgba(0, 0, 0, 0);max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;">【生活现场】从搬家到容器技术docker应用场景解析</a></span></span></p> <p style="max-width: 100%;min-height: 1em;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);box-sizing: border-box !important;word-wrap: break-word !important;"><br style="max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"></p> <p style="max-width: 100%;min-height: 1em;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);text-align: center;box-sizing: border-box !important;word-wrap: break-word !important;"><img class="" data-copyright="0" data-ratio="0.5" data-s="300,640" data-type="jpeg" data-w="400" src="/upload/27a0fd22d324a1af95f534078afa17c1.jpg" style="box-sizing: border-box !important;word-wrap: break-word !important;width: 400px !important;visibility: visible !important;"></p> <p><br></p>
作者:微信小助手
<section class="xmteditor" style="display:none;" data-tools="新媒体管家" data-label="powered by xmt.cn"></section> <p style="text-align: center;"><img class="rich_pages" data-ratio="0.10025062656641603" data-s="300,640" src="/upload/7c40ff0276ccfdbc1921f28067646510.png" data-type="png" data-w="399" style=""></p> <p style="text-align: center;"><img class="rich_pages" data-ratio="0.23416666666666666" src="/upload/dcb64950a27454fb05ff8a2f9b7a1173.gif" data-type="gif" data-w="1200" style=""></p> <section style="font-size: 14px;line-height: 1.8;letter-spacing: 1.2px;padding-right: 8px;padding-left: 8px;box-sizing: border-box;"> <section class="horizontal-tb" style="box-sizing: border-box;" powered-by="xiumi.us"> <p style="white-space: normal;box-sizing: border-box;"><br style="box-sizing: border-box;"></p> </section> <section style="margin-right: 0%;margin-left: 0%;text-align: center;box-sizing: border-box;" powered-by="xiumi.us"> <section style="display: inline-block;box-sizing: border-box;"> <section style="border-radius: 0.5em;border-color: rgb(207, 207, 207);border-style: solid;border-width: 1px;padding: 10px;display: inline-block;box-sizing: border-box;"> <section class="horizontal-tb" style="text-align: justify;line-height: 1.4em;box-sizing: border-box;" powered-by="xiumi.us"> <p style="margin-bottom: 10px;white-space: normal;box-sizing: border-box;"><span style="box-sizing: border-box;">本文字数:</span><strong style="box-sizing: border-box;"><span style="color: rgb(79, 181, 215);box-sizing: border-box;">4849</span></strong><strong style="box-sizing: border-box;"><span style="color: rgb(79, 181, 215);box-sizing: border-box;">字</span></strong></p> <p style="white-space: normal;box-sizing: border-box;"><span style="box-sizing: border-box;">预计阅读时间:</span><span style="box-sizing: border-box;"><strong style="color: rgb(79, 181, 215);letter-spacing: 0px;box-sizing: border-box;">20分钟</strong></span></p> </section> </section> <section style="width: 0px;border-top: 0.8em solid rgb(207, 207, 207);margin: auto;border-left: 0.8em solid transparent !important;border-right: 0.8em solid transparent !important;box-sizing: border-box;"></section> </section> </section> <section class="horizontal-tb" style="box-sizing: border-box;" powered-by="xiumi.us"> <p style="white-space: normal;box-sizing: border-box;"><br style="box-sizing: border-box;"></p> </section> <section style="margin-right: 0%;margin-left: 0%;text-align: center;box-sizing: border-box;" powered-by="xiumi.us"> <section style="display: inline-block;vertical-align: top;box-sizing: border-box;"> <section style="width: 45px;height: 5px;line-height: 5px;background-color: rgb(255, 203, 58);box-sizing: border-box;"></section> <section class="horizontal-tb" style="margin-top: -3px;margin-bottom: -3px;transform: rotate(0deg);border-width: 1px;border-style: solid;border-color: rgb(0, 0, 0);padding-left: 8px;padding-right: 8px;font-size: 16px;box-sizing: border-box;"> <p style="box-sizing: border-box;"><strong style="box-sizing: border-box;">导读<br style="box-sizing: border-box;"></strong></p> </section> <section style="width: 45px;height: 5px;margin-left: auto;line-height: 5px;background-color: rgb(255, 203, 58);box-sizing: border-box;"></section> </section> </section> <section class="horizontal-tb" style="letter-spacing: 1.2px;line-height: 1.75;padding-right: 8px;padding-left: 8px;box-sizing: border-box;" powered-by="xiumi.us"> <p><br></p> <p>Hbase是一个高可靠性,高性能、列存储、可伸缩、多版本的Nosql的分布式数据存储系统,而Hbase的表设计是发挥出Hbase优异性能的关键所在。一个好的Hbase的表设计在满足业务需求下遵循哪些规则呢?如何设计出既满足业务需求性能又好的的Hbase表呢?今天我们就来谈谈Hbase的表设计策略。</p> <p><br></p> <section> Hbase非常适用于数据量大、写入>读取、写入并发量高的业务场景之下。在介绍表设计策略之前,先来介绍一下有关Hbase表设计需要知道的相关基本概念。 </section> </section> <section class="horizontal-tb" style="box-sizing: border-box;" powered-by="xiumi.us"> <p style="white-space: normal;box-sizing: border-box;"><br style="box-sizing: border-box;"></p> </section> <section style="margin: 10px 0% 20px;box-sizing: border-box;" powered-by="xiumi.us"> <section style="display: inline-block;width: 100%;vertical-align: top;border-width: 1px;border-radius: 0px;border-style: solid none;border-color: rgb(62, 62, 62);box-sizing: border-box;"> <section style="box-sizing: border-box;" powered-by="xiumi.us"> <section style="align-items: center;display: flex;margin: -3px 0%;box-sizing: border-box;"> <section style="display: inline-block;vertical-align: bottom;width: auto;flex: 0 0 auto;border-width: 0px 0px 0px 2px;border-radius: 1px;border-style: none none none solid;border-color: rgb(62, 62, 62);overflow: hidden;box-sizing: border-box;"> <section style="text-align: center;margin-right: 0%;margin-left: 0%;transform: translate3d(-10px, 0px, 0px);box-sizing: border-box;" powered-by="xiumi.us"> <section style="display: inline-block;min-width: 10%;max-width: 100%;vertical-align: top;transform: matrix(1, 0, -0.2, 1, 0, 0);-webkit-transform: matrix(1, 0, -0.2, 1, 0, 0);-moz-transform: matrix(1, 0, -0.2, 1, 0, 0);-o-transform: matrix(1, 0, -0.2, 1, 0, 0);border-style: solid;border-width: 2px;border-radius: 0px;border-color: rgb(62, 62, 62);padding: 6px 10px 6px 20px;background-color: rgb(255, 222, 23);box-sizing: border-box;"> <section class="horizontal-tb" style="text-align: justify;line-height: 1;letter-spacing: 0px;box-sizing: border-box;" powered-by="xiumi.us"> <p style="white-space: normal;box-sizing: border-box;"><br style="box-sizing: border-box;"></p> </section> </section> </section> </section> <section style="display: inline-block;vertical-align: bottom;width: auto;flex: 1 1 auto;border-width: 0px;box-sizing: border-box;"> <section class="horizontal-tb" style="font-size: 18px;line-height: 1;letter-spacing: 1px;box-sizing: border-box;" powered-by="xiumi.us"> <p style="white-space: normal;box-sizing: border-box;"><strong style="box-sizing: border-box;">HBase数据模型</strong></p> </section> </section> <section style="display: inline-block;vertical-align: bottom;width: auto;flex: 0 0 auto;border-width: 0px;border-radius: 1px;border-style: none;border-color: rgb(62, 62, 62);overflow: hidden;box-sizing: border-box;"> <section style="text-align: center;margin: -2px 0%;transform: translate3d(10px, 0px, 0px);-webkit-transform: translate3d(10px, 0px, 0px);-moz-transform: translate3d(10px, 0px, 0px);-o-transform: translate3d(10px, 0px, 0px);box-sizing: border-box;" powered-by="xiumi.us"> <section style="display: inline-block;min-width: 10%;max-width: 100%;vertical-align: top;transform: matrix(1, 0, -0.2, 1, 0, 0);-webkit-transform: matrix(1, 0, -0.2, 1, 0, 0);-moz-transform: matrix(1, 0, -0.2, 1, 0, 0);-o-transform: matrix(1, 0, -0.2, 1, 0, 0);border-style: solid;border-width: 2px;border-radius: 0px;border-color: rgb(62, 62, 62);padding: 6px 10px;background-color: rgb(255, 222, 23);box-sizing: border-box;"> <section class="horizontal-tb" style="text-align: justify;line-height: 1;letter-spacing: 0px;box-sizing: border-box;" powered-by="xiumi.us"> <p style="white-space: normal;box-sizing: border-box;"><br style="box-sizing: border-box;"></p> </section> </section> </section> </section> </section> </section> </section> </section> <section class="horizontal-tb" style="letter-spacing: 1.2px;line-height: 1.75;padding-right: 8px;padding-left: 8px;box-sizing: border-box;" powered-by="xiumi.us"> <p><span style="font-size: 17px;">•</span><span style="font-size: 15px;"><strong>表</strong></span><span style="background-color: rgb(248, 248, 248);color: rgb(233, 105, 0);font-size: inherit;font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0px;">Table</span></p> <p>对应于关系型数据库中的一张张表,HBase以“表”为单位组织数据,表由多行组成;</p> <p><br></p> <p><span style="font-size: 18px;">•</span><strong>行</strong> <span style="background-color: rgb(248, 248, 248);color: rgb(233, 105, 0);font-size: inherit;font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0px;">Colum</span></p> <p>行由一个<span style="background-color: rgb(248, 248, 248);color: rgb(233, 105, 0);font-size: inherit;font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0px;">RowKey</span>和多个列族组成,一个行有一个<span style="background-color: rgb(248, 248, 248);color: rgb(233, 105, 0);font-size: inherit;font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0px;">RowKey</span>,用来唯一标识;</p> <p><br></p> <p><span style="font-size: 18px;">•</span><strong>行键</strong><span style="background-color: rgb(248, 248, 248);color: rgb(233, 105, 0);font-size: inherit;font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0px;">RowKey</span></p> <p>Rowkey类似RDBMS的主键,唯一标识该行,是定位该行的索引;</p> <p><br></p> <p><span style="font-size: 18px;">•</span><strong>列族</strong><span style="background-color: rgb(248, 248, 248);color: rgb(233, 105, 0);font-size: inherit;font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0px;">Row Family</span></p> <p>每一行由若干列族组成,每个列族下可包含多个列,列族是列共性的一些体现。注意:物理上,同一列族的数据存储在一起的;</p> <p><br></p> <p><span style="font-size: 18px;">•</span><strong>列限定符</strong><span style="background-color: rgb(248, 248, 248);color: rgb(233, 105, 0);font-size: inherit;font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0px;">Row Qualifier</span></p> <p>列由列族和列限定符唯一指定;<span style="letter-spacing: 1.2px;box-sizing: border-box;"></span></p> <p><br></p> <p><span style="font-size: 17px;">•</span><strong>单元格</strong><span style="background-color: rgb(248, 248, 248);color: rgb(233, 105, 0);font-size: inherit;font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0px;">Cell</span></p> <p>单元格由<span style="background-color: rgb(248, 248, 248);color: rgb(233, 105, 0);font-size: inherit;font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0px;">RowKey</span>、列族、列限定符唯一定位,单元格之中存放一个值(Value)和一个版本号;</p> <p><br></p> <p><span style="font-size: 18px;">•</span><strong>时间戳</strong><span style="background-color: rgb(248, 248, 248);color: rgb(233, 105, 0);font-size: inherit;font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0px;">TimStamp</span></p> <p>单元格内不同版本的值按时间倒序排列,最新的数据排在最前面;</p> <p><br></p> <p><span style="font-size: 18px;">•</span><strong>区</strong><span style="background-color: rgb(248, 248, 248);color: rgb(233, 105, 0);font-size: inherit;font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0px;">Region</span></p> <p>HBase自动把表水平(按<span style="background-color: rgb(248, 248, 248);color: rgb(233, 105, 0);font-size: inherit;font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0px;">Row</span>)划分成多个区 (<span style="background-color: rgb(248, 248, 248);color: rgb(233, 105, 0);font-size: inherit;font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0px;">Region</span>),每个<span style="background-color: rgb(248, 248, 248);color: rgb(233, 105, 0);font-size: inherit;font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0px;">Region</span>会保存一个表里面某段连续的数据。</p> </section> <section class="horizontal-tb" style="box-sizing: border-box;" powered-by="xiumi.us"> <p style="white-space: normal;box-sizing: border-box;"><br style="box-sizing: border-box;"></p> </section> <section style="margin: 10px 0% 20px;box-sizing: border-box;" powered-by="xiumi.us"> <section style="display: inline-block;width: 100%;vertical-align: top;border-width: 1px;border-radius: 0px;border-style: solid none;border-color: rgb(62, 62, 62);box-sizing: border-box;"> <section style="box-sizing: border-box;" powered-by="xiumi.us"> <section style="align-items: center;display: flex;margin: -3px 0%;box-sizing: border-box;"> <section style="display: inline-block;vertical-align: bottom;width: auto;flex: 0 0 auto;border-width: 0px 0px 0px 2px;border-radius: 1px;border-style: none none none solid;border-color: rgb(62, 62, 62);overflow: hidden;box-sizing: border-box;"> <section style="text-align: center;margin-right: 0%;margin-left: 0%;transform: translate3d(-10px, 0px, 0px);box-sizing: border-box;" powered-by="xiumi.us"> <section style="display: inline-block;min-width: 10%;max-width: 100%;vertical-align: top;transform: matrix(1, 0, -0.2, 1, 0, 0);-webkit-transform: matrix(1, 0, -0.2, 1, 0, 0);-moz-transform: matrix(1, 0, -0.2, 1, 0, 0);-o-transform: matrix(1, 0, -0.2, 1, 0, 0);border-style: solid;border-width: 2px;border-radius: 0px;border-color: rgb(62, 62, 62);padding: 6px 10px 6px 20px;background-color: rgb(255, 222, 23);box-sizing: border-box;"> <section class="horizontal-tb" style="text-align: justify;line-height: 1;letter-spacing: 0px;box-sizing: border-box;" powered-by="xiumi.us"> <p style="white-space: normal;box-sizing: border-box;"><br style="box-sizing: border-box;"></p> </section> </section> </section> </section> <section style="display: inline-block;vertical-align: bottom;width: auto;flex: 1 1 auto;border-width: 0px;box-sizing: border-box;"> <section class="horizontal-tb" style="font-size: 18px;line-height: 1;letter-spacing: 1px;box-sizing: border-box;" powered-by="xiumi.us"> <p style="white-space: normal;box-sizing: border-box;"><strong style="box-sizing: border-box;">列描述</strong></p> </section> </section> <section style="display: inline-block;vertical-align: bottom;width: auto;flex: 0 0 auto;border-width: 0px;border-radius: 1px;border-style: none;border-color: rgb(62, 62, 62);overflow: hidden;box-sizing: border-box;"> <section style="text-align: center;margin: -2px 0%;transform: translate3d(10px, 0px, 0px);-webkit-transform: translate3d(10px, 0px, 0px);-moz-transform: translate3d(10px, 0px, 0px);-o-transform: translate3d(10px, 0px, 0px);box-sizing: border-box;" powered-by="xiumi.us"> <section style="display: inline-block;min-width: 10%;max-width: 100%;vertical-align: top;transform: matrix(1, 0, -0.2, 1, 0, 0);-webkit-transform: matrix(1, 0, -0.2, 1, 0, 0);-moz-transform: matrix(1, 0, -0.2, 1, 0, 0);-o-transform: matrix(1, 0, -0.2, 1, 0, 0);border-style: solid;border-width: 2px;border-radius: 0px;border-color: rgb(62, 62, 62);padding: 6px 10px;background-color: rgb(255, 222, 23);box-sizing: border-box;"> <section class="horizontal-tb" style="text-align: justify;line-height: 1;letter-spacing: 0px;box-sizing: border-box;" powered-by="xiumi.us"> <p style="white-space: normal;box-sizing: border-box;"><br style="box-sizing: border-box;"></p> </section> </section> </section> </section> </section> </section> </section> </section> <section class="horizontal-tb" style="letter-spacing: 1.2px;line-height: 1.75;padding-right: 8px;padding-left: 8px;box-sizing: border-box;" powered-by="xiumi.us"> <p style="margin-bottom: 10px;white-space: normal;box-sizing: border-box;">常用的列描述有:</p> <p><span style="font-size: 18px;">•</span><span style="background-color: rgb(248, 248, 248);color: rgb(233, 105, 0);font-size: inherit;font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0px;">BLOOMFILTER</span></p> <p>表示是否开启<span style="background-color: rgb(248, 248, 248);color: rgb(233, 105, 0);font-size: inherit;font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0px;">Bloomfilter</span>,以及<span style="background-color: rgb(248, 248, 248);color: rgb(233, 105, 0);font-size: inherit;font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0px;">Bloomfilte</span><span style="background-color: rgb(248, 248, 248);color: rgb(233, 105, 0);font-size: inherit;font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0px;">r</span>的细粒度;</p> <p><br></p> <p><span style="font-size: 18px;">•</span><span style="background-color: rgb(248, 248, 248);color: rgb(233, 105, 0);font-size: inherit;font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0px;">COMPRESSION</span></p> <p>表示是否开启压缩,以及使用压缩的方式;</p> <p><br></p> <p><span style="font-size: 18px;">•</span><span style="background-color: rgb(248, 248, 248);color: rgb(233, 105, 0);font-size: inherit;font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0px;">VERSIONS</span></p> <p>表示允许存储的数据最大版本数;</p> <p><br></p> <p><span style="font-size: 18px;">•</span><span style="background-color: rgb(248, 248, 248);color: rgb(233, 105, 0);font-size: inherit;font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0px;">TTL</span></p> <p>表示允许数据存活的最大时间;</p> <p><br></p> <p><span style="font-size: 18px;">•</span><span style="background-color: rgb(248, 248, 248);color: rgb(233, 105, 0);font-size: inherit;font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0px;">MINVERSION</span></p> <p>表示数据保存的最少版本数。</p> </section> <section class="horizontal-tb" style="box-sizing: border-box;" powered-by="xiumi.us"> <p style="white-space: normal;box-sizing: border-box;"><br style="box-sizing: border-box;"></p> </section> <section style="margin: 10px 0% 20px;box-sizing: border-box;" powered-by="xiumi.us"> <section style="display: inline-block;width: 100%;vertical-align: top;border-width: 1px;border-radius: 0px;border-style: solid none;border-color: rgb(62, 62, 62);box-sizing: border-box;"> <section style="box-sizing: border-box;" powered-by="xiumi.us"> <section style="align-items: center;display: flex;margin: -3px 0%;box-sizing: border-box;"> <section style="display: inline-block;vertical-align: bottom;width: auto;flex: 0 0 auto;border-width: 0px 0px 0px 2px;border-radius: 1px;border-style: none none none solid;border-color: rgb(62, 62, 62);overflow: hidden;box-sizing: border-box;"> <section style="text-align: center;margin-right: 0%;margin-left: 0%;transform: translate3d(-10px, 0px, 0px);box-sizing: border-box;" powered-by="xiumi.us"> <section style="display: inline-block;min-width: 10%;max-width: 100%;vertical-align: top;transform: matrix(1, 0, -0.2, 1, 0, 0);-webkit-transform: matrix(1, 0, -0.2, 1, 0, 0);-moz-transform: matrix(1, 0, -0.2, 1, 0, 0);-o-transform: matrix(1, 0, -0.2, 1, 0, 0);border-style: solid;border-width: 2px;border-radius: 0px;border-color: rgb(62, 62, 62);padding: 6px 10px 6px 20px;background-color: rgb(255, 222, 23);box-sizing: border-box;"> <section class="horizontal-tb" style="text-align: justify;line-height: 1;letter-spacing: 0px;box-sizing: border-box;" powered-by="xiumi.us"> <p style="white-space: normal;box-sizing: border-box;"><br style="box-sizing: border-box;"></p> </section> </section> </section> </section> <section style="display: inline-block;vertical-align: bottom;width: auto;flex: 1 1 auto;border-width: 0px;box-sizing: border-box;"> <section class="horizontal-tb" style="font-size: 16px;line-height: 1;letter-spacing: 1px;box-sizing: border-box;" powered-by="xiumi.us"> <p style="white-space: normal;box-sizing: border-box;"><strong style="box-sizing: border-box;">列描述角度的设计策略</strong></p> </section> </section> <section style="display: inline-block;vertical-align: bottom;width: auto;flex: 0 0 auto;border-width: 0px;border-radius: 1px;border-style: none;border-color: rgb(62, 62, 62);overflow: hidden;box-sizing: border-box;"> <section style="text-align: center;margin: -2px 0%;transform: translate3d(10px, 0px, 0px);-webkit-transform: translate3d(10px, 0px, 0px);-moz-transform: translate3d(10px, 0px, 0px);-o-transform: translate3d(10px, 0px, 0px);box-sizing: border-box;" powered-by="xiumi.us"> <section style="display: inline-block;min-width: 10%;max-width: 100%;vertical-align: top;transform: matrix(1, 0, -0.2, 1, 0, 0);-webkit-transform: matrix(1, 0, -0.2, 1, 0, 0);-moz-transform: matrix(1, 0, -0.2, 1, 0, 0);-o-transform: matrix(1, 0, -0.2, 1, 0, 0);border-style: solid;border-width: 2px;border-radius: 0px;border-color: rgb(62, 62, 62);padding: 6px 10px;background-color: rgb(255, 222, 23);box-sizing: border-box;"> <section class="horizontal-tb" style="text-align: justify;line-height: 1;letter-spacing: 0px;box-sizing: border-box;" powered-by="xiumi.us"> <p style="white-space: normal;box-sizing: border-box;"><br style="box-sizing: border-box;"></p> </section> </section> </section> </section> </section> </section> </section> </section> <section style="margin: 10px 0% 15px;box-sizing: border-box;" powered-by="xiumi.us"> <section style="display: inline-block;width: 100%;border-width: 0px 0px 0px 5px;border-style: solid;border-left-color: rgb(253, 209, 0);border-right-color: rgb(253, 209, 0);padding-left: 5px;border-bottom-left-radius: 0px;box-sizing: border-box;"> <section class="horizontal-tb" style="box-sizing: border-box;" powered-by="xiumi.us"> <p style="white-space: normal;box-sizing: border-box;"><span style="font-size: 16px;"><strong style="box-sizing: border-box;">BLOOMFILTER</strong></span></p> </section> </section> </section> <section class="horizontal-tb" style="line-height: 1.75;padding-right: 8px;padding-left: 8px;box-sizing: border-box;" powered-by="xiumi.us"> <p style="line-height: 1.75em;"><span style="background-color: rgb(248, 248, 248);color: rgb(233, 105, 0);font-size: inherit;font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0px;">BloomFilter</span>的原理这里不过多描述。是否采用<span style="background-color: rgb(248, 248, 248);color: rgb(233, 105, 0);font-size: inherit;font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0px;">BloomFilter</span>需要根据实际业务考虑。由于<span style="background-color: rgb(248, 248, 248);color: rgb(233, 105, 0);font-size: inherit;font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0px;">BloomFilter</span>的原理,BloomFilter可以快速确认某个<span style="background-color: rgb(248, 248, 248);color: rgb(233, 105, 0);font-size: inherit;font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0px;">Rowkey</span>或<span style="background-color: rgb(248, 248, 248);color: rgb(233, 105, 0);font-size: inherit;font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0px;">Rowkey</span><span style="background-color: rgb(248, 248, 248);color: rgb(233, 105, 0);font-size: inherit;font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0px;"> </span>+ <span style="background-color
作者:微信小助手
<section style="box-sizing: border-box;font-size: 16px;"> <section style="margin-top: 10px;margin-bottom: 10px;box-sizing: border-box;" powered-by="xiumi.us"> <section style="padding-top: 10px;padding-right: 10px;padding-left: 10px;background-color: rgb(239, 239, 239);box-sizing: border-box;"> <span style="display: inline-block;width: 5%;line-height: 0.8;font-weight: bolder;font-size: 48px;box-sizing: border-box;" title="" opera-tn-ra-cell="_$.pages:0.layers:0.comps:0.txt1"> <section style="box-sizing: border-box;"> “ </section></span> <section style="display: inline-block;vertical-align: top;float: right;width: 90%;line-height: 1.5;font-size: 15px;color: rgb(89, 89, 89);box-sizing: border-box;"> <p style="box-sizing: border-box;"><span style="letter-spacing: 1px;">本文将结合实例 demo,阐述 30 条有关于优化 SQL 的建议,多数是实际开发中总结出来的,希望对大家有帮助。</span></p> </section> <section style="clear: both;box-sizing: border-box;line-height: 0;"> <section style="line-height: 0;width: 0px;"> <svg viewbox="0 0 1 1" style="vertical-align:top;"></svg> </section> </section> </section> </section> </section> <p style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"><br></p> <p style="text-align: center;"><img class="rich_pages" data-ratio="0.56171875" data-s="300,640" src="/upload/471a26cd3018b21a5d6ba291b636c74b.jpg" data-type="jpeg" data-w="1280" style=""></p> <section style="text-align: center;line-height: 1.75em;"> <span style="font-size: 14px;color: rgb(89, 89, 89);letter-spacing: 1px;"><em>图片来自 Pexels</em></span> </section> <section style="box-sizing: border-box;font-size: 16px;"> <section style="margin: 10px 0%;box-sizing: border-box;" powered-by="xiumi.us"> <section style="display: inline-block;vertical-align: middle;width: 40%;padding-right: 10px;box-sizing: border-box;line-height: 0;"> <section style="line-height: 0;width: 0px;"> <svg viewbox="0 0 1 1" style="vertical-align:top;"></svg> </section> </section> <section style="display: inline-block;vertical-align: middle;width: 20%;box-sizing: border-box;"> <section style="font-size: 21px;margin-right: 0%;margin-left: 0%;text-align: center;box-sizing: border-box;" powered-by="xiumi.us"> <section style="border-width: 1px;border-style: solid;border-color: rgba(255, 255, 255, 0);background-color: rgb(89, 89, 89);display: inline-block;width: 1.8em;height: 1.8em;line-height: 1.8em;border-radius: 100%;margin-left: auto;margin-right: auto;font-size: 20px;color: rgb(255, 255, 255);box-sizing: border-box;"> <p style="box-sizing: border-box;"><strong style="box-sizing: border-box;">1</strong></p> </section> </section> </section> <section style="display: inline-block;vertical-align: middle;width: 40%;padding-left: 10px;box-sizing: border-box;line-height: 0;"> <section style="line-height: 0;width: 0px;"> <svg viewbox="0 0 1 1" style="vertical-align:top;"></svg> </section> </section> </section> </section> <p style="line-height: normal;"><br></p> <h3 style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"><strong><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">查询 SQL 尽量不要使用 select *,而是 select 具体字段</span></strong></h3> <p style="line-height: normal;"><br></p> <p style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"><span style="font-size: 15px;letter-spacing: 1px;color: rgb(71, 193, 168);">反例子:</span></p> <section style="font-size: 16px;color: rgb(62, 62, 62);line-height: 1.6;letter-spacing: 0px;font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;"> <pre style="font-size: inherit;color: inherit;line-height: inherit;"><code style="margin-right: 2px;margin-left: 2px;line-height: 18px;font-size: 14px;letter-spacing: 0px;font-family: Consolas, Inconsolata, Courier, monospace;border-radius: 0px;color: rgb(169, 183, 198);background: rgb(40, 43, 46);padding: 0.5em;word-wrap: normal !important;word-break: normal !important;overflow: auto !important;display: -webkit-box !important;"><span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">select</span> * <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">from</span> employee;<br></code></pre> </section> <section style="line-height: normal;"> <br> </section> <p style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;margin-bottom: 5px;"><span style="font-size: 15px;letter-spacing: 1px;color: rgb(71, 193, 168);">正例子:</span></p> <section style="font-size: 16px;color: rgb(62, 62, 62);line-height: 1.6;letter-spacing: 0px;font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;"> <pre style="font-size: inherit;color: inherit;line-height: inherit;"><code style="margin-right: 2px;margin-left: 2px;line-height: 18px;font-size: 14px;letter-spacing: 0px;font-family: Consolas, Inconsolata, Courier, monospace;border-radius: 0px;color: rgb(169, 183, 198);background: rgb(40, 43, 46);padding: 0.5em;word-wrap: normal !important;word-break: normal !important;overflow: auto !important;display: -webkit-box !important;"><span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">select</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">id</span>,<span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">name</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">from</span> employee;<br></code></pre> </section> <p style="line-height: normal;"><br></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;letter-spacing: 1px;color: rgb(71, 193, 168);">理由如下:</span> </section> <ul class="list-paddingleft-2" style="list-style-type: disc;"> <li><p><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">只取需要的字段,节省资源、减少网络开销。</span></p></li> <li><p><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">select * 进行查询时,很可能就不会使用到覆盖索引了,就会造成回表查询。</span></p></li> </ul> <p style="line-height: normal;"><br></p> <section style="box-sizing: border-box;font-size: 16px;"> <section style="margin: 10px 0%;box-sizing: border-box;" powered-by="xiumi.us"> <section style="display: inline-block;vertical-align: middle;width: 40%;padding-right: 10px;box-sizing: border-box;line-height: 0;"> <section style="line-height: 0;width: 0px;"> <svg viewbox="0 0 1 1" style="vertical-align:top;"></svg> </section> </section> <section style="display: inline-block;vertical-align: middle;width: 20%;box-sizing: border-box;"> <section style="font-size: 21px;margin-right: 0%;margin-left: 0%;text-align: center;box-sizing: border-box;" powered-by="xiumi.us"> <section style="border-width: 1px;border-style: solid;border-color: rgba(255, 255, 255, 0);background-color: rgb(89, 89, 89);display: inline-block;width: 1.8em;height: 1.8em;line-height: 1.8em;border-radius: 100%;margin-left: auto;margin-right: auto;font-size: 20px;color: rgb(255, 255, 255);box-sizing: border-box;"> <p style="box-sizing: border-box;"><strong style="box-sizing: border-box;">2</strong></p> </section> </section> </section> <section style="display: inline-block;vertical-align: middle;width: 40%;padding-left: 10px;box-sizing: border-box;line-height: 0;"> <section style="line-height: 0;width: 0px;"> <svg viewbox="0 0 1 1" style="vertical-align:top;"></svg> </section> </section> </section> </section> <h3 style="line-height: normal;"><br></h3> <h3 style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"><strong><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">如果知道查询结果只有一条或者只要最大/最小一条记录,建议用 limit 1</span></strong></h3> <h3 style="line-height: normal;"><br></h3> <h3 style="text-align: justify;line-height: 1.75em;margin-left: 8px;margin-right: 8px;margin-bottom: 5px;"><span style="font-size: 15px;letter-spacing: 1px;color: rgb(71, 193, 168);">假设现在有 employee 员工表,要找出一个名字叫 jay 的人:</span></h3> <section style="font-size: 16px;color: rgb(62, 62, 62);line-height: 1.6;letter-spacing: 0px;font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;"> <pre style="font-size: inherit;color: inherit;line-height: inherit;"><code style="margin-right: 2px;margin-left: 2px;line-height: 18px;font-size: 14px;letter-spacing: 0px;font-family: Consolas, Inconsolata, Courier, monospace;border-radius: 0px;color: rgb(169, 183, 198);background: rgb(40, 43, 46);padding: 0.5em;word-wrap: normal !important;word-break: normal !important;overflow: auto !important;display: -webkit-box !important;"><span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">CREATE</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">TABLE</span> <span style="font-size: inherit;line-height: inherit;color: rgb(238, 220, 112);word-wrap: inherit !important;word-break: inherit !important;">`employee`</span> (<br> <span style="font-size: inherit;line-height: inherit;color: rgb(238, 220, 112);word-wrap: inherit !important;word-break: inherit !important;">`id`</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">int</span>(<span style="font-size: inherit;line-height: inherit;color: rgb(174, 135, 250);word-wrap: inherit !important;word-break: inherit !important;">11</span>) <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">NOT</span> <span style="font-size: inherit;line-height: inherit;color: rgb(174, 135, 250);word-wrap: inherit !important;word-break: inherit !important;">NULL</span>,<br> <span style="font-size: inherit;line-height: inherit;color: rgb(238, 220, 112);word-wrap: inherit !important;word-break: inherit !important;">`name`</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">varchar</span>(<span style="font-size: inherit;line-height: inherit;color: rgb(174, 135, 250);word-wrap: inherit !important;word-break: inherit !important;">255</span>) <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">DEFAULT</span> <span style="font-size: inherit;line-height: inherit;color: rgb(174, 135, 250);word-wrap: inherit !important;word-break: inherit !important;">NULL</span>,<br> <span style="font-size: inherit;line-height: inherit;color: rgb(238, 220, 112);word-wrap: inherit !important;word-break: inherit !important;">`age`</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">int</span>(<span style="font-size: inherit;line-height: inherit;color: rgb(174, 135, 250);word-wrap: inherit !important;word-break: inherit !important;">11</span>) <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">DEFAULT</span> <span style="font-size: inherit;line-height: inherit;color: rgb(174, 135, 250);word-wrap: inherit !important;word-break: inherit !important;">NULL</span>,<br> <span style="font-size: inherit;line-height: inherit;color: rgb(238, 220, 112);word-wrap: inherit !important;word-break: inherit !important;">`date`</span> datetime <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">DEFAULT</span> <span style="font-size: inherit;line-height: inherit;color: rgb(174, 135, 250);word-wrap: inherit !important;word-break: inherit !important;">NULL</span>,<br> <span style="font-size: inherit;line-height: inherit;color: rgb(238, 220, 112);word-wrap: inherit !important;word-break: inherit !important;">`sex`</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">int</span>(<span style="font-size: inherit;line-height: inherit;color: rgb(174, 135, 250);word-wrap: inherit !important;word-break: inherit !important;">1</span>) <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">DEFAULT</span> <span style="font-size: inherit;line-height: inherit;color: rgb(174, 135, 250);word-wrap: inherit !important;word-break: inherit !important;">NULL</span>,<br> PRIMARY <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">KEY</span> (<span style="font-size: inherit;line-height: inherit;color: rgb(238, 220, 112);word-wrap: inherit !important;word-break: inherit !important;">`id`</span>)<br>) <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">ENGINE</span>=<span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">InnoDB</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">DEFAULT</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">CHARSET</span>=utf8;<br></code></pre> </section> <section style="line-height: normal;"> <br> </section> <p style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;margin-bottom: 5px;"><span style="font-size: 15px;letter-spacing: 1px;color: rgb(71, 193, 168);">反例:</span></p> <section style="font-size: 16px;color: rgb(62, 62, 62);line-height: 1.6;letter-spacing: 0px;font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;"> <pre style="font-size: inherit;color: inherit;line-height: inherit;"><code style="margin-right: 2px;margin-left: 2px;line-height: 18px;font-size: 14px;letter-spacing: 0px;font-family: Consolas, Inconsolata, Courier, monospace;border-radius: 0px;color: rgb(169, 183, 198);background: rgb(40, 43, 46);padding: 0.5em;word-wrap: normal !important;word-break: normal !important;overflow: auto !important;display: -webkit-box !important;"><span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">select</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">id</span>,<span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">name</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">from</span> employee <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">where</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">name</span>=<span style="font-size: inherit;line-height: inherit;color: rgb(238, 220, 112);word-wrap: inherit !important;word-break: inherit !important;">'jay'</span><br></code></pre> </section> <p style="line-height: normal;"><br></p> <p style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;margin-bottom: 5px;"><span style="font-size: 15px;letter-spacing: 1px;color: rgb(71, 193, 168);">正例:</span></p> <section style="font-size: 16px;color: rgb(62, 62, 62);line-height: 1.6;letter-spacing: 0px;font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;"> <pre style="font-size: inherit;color: inherit;line-height: inherit;"><code style="margin-right: 2px;margin-left: 2px;line-height: 18px;font-size: 14px;letter-spacing: 0px;font-family: Consolas, Inconsolata, Courier, monospace;border-radius: 0px;color: rgb(169, 183, 198);background: rgb(40, 43, 46);padding: 0.5em;word-wrap: normal !important;word-break: normal !important;overflow: auto !important;display: -webkit-box !important;"><span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">select</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">id</span>,<span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">name</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">from</span> employee <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">where</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">name</span>=<span style="font-size: inherit;line-height: inherit;color: rgb(238, 220, 112);word-wrap: inherit !important;word-break: inherit !important;">'jay'</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">limit</span> <span style="font-size: inherit;line-height: inherit;color: rgb(174, 135, 250);word-wrap: inherit !important;word-break: inherit !important;">1</span>;<br></code></pre> </section> <p style="line-height: normal;"><br></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;letter-spacing: 1px;color: rgb(71, 193, 168);">理由如下:</span> </section> <ul class="list-paddingleft-2" style="list-style-type: disc;"> <li><p><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">加上 limit 1 后,只要找到了对应的一条记录,就不会继续向下扫描了,效率将会大大提高。</span></p></li> <li><p><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">当然,如果 name 是唯一索引的话,是不必要加上 limit 1 了,因为 limit 的存在主要就是为了防止全表扫描,从而提高性能,如果一个语句本身可以预知不用全表扫描,有没有 limit ,性能的差别并不大。</span></p></li> </ul> <section style="line-height: normal;"> <br> </section> <section style="box-sizing: border-box;font-size: 16px;"> <section style="margin: 10px 0%;box-sizing: border-box;" powered-by="xiumi.us"> <section style="display: inline-block;vertical-align: middle;width: 40%;padding-right: 10px;box-sizing: border-box;line-height: 0;"> <section style="line-height: 0;width: 0px;"> <svg viewbox="0 0 1 1" style="vertical-align:top;"></svg> </section> </section> <section style="display: inline-block;vertical-align: middle;width: 20%;box-sizing: border-box;"> <section style="font-size: 21px;margin-right: 0%;margin-left: 0%;text-align: center;box-sizing: border-box;" powered-by="xiumi.us"> <section style="border-width: 1px;border-style: solid;border-color: rgba(255, 255, 255, 0);background-color: rgb(89, 89, 89);display: inline-block;width: 1.8em;height: 1.8em;line-height: 1.8em;border-radius: 100%;margin-left: auto;margin-right: auto;font-size: 20px;color: rgb(255, 255, 255);box-sizing: border-box;"> <p style="box-sizing: border-box;"><strong style="box-sizing: border-box;">3</strong></p> </section> </section> </section> <section style="display: inline-block;vertical-align: middle;width: 40%;padding-left: 10px;box-sizing: border-box;line-height: 0;"> <section style="line-height: 0;width: 0px;"> <svg viewbox="0 0 1 1" style="vertical-align:top;"></svg> </section> </section> </section> </section> <p style="line-height: normal;"><br></p> <h3 style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"><strong><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">应尽量避免在 where 子句中使用 or 来连接条件</span></strong></h3> <p style="line-height: normal;"><br></p> <p style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;margin-bottom: 5px;"><span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">新建一个 user 表,它有一个普通索引 userId,表结构如下:</span></p> <section style="font-size: 16px;color: rgb(62, 62, 62);line-height: 1.6;letter-spacing: 0px;font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;"> <pre style="font-size: inherit;color: inherit;line-height: inherit;"><code style="margin-right: 2px;margin-left: 2px;line-height: 18px;font-size: 14px;letter-spacing: 0px;font-family: Consolas, Inconsolata, Courier, monospace;border-radius: 0px;color: rgb(169, 183, 198);background: rgb(40, 43, 46);padding: 0.5em;word-wrap: normal !important;word-break: normal !important;overflow: auto !important;display: -webkit-box !important;"><span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">CREATE</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">TABLE</span> <span style="font-size: inherit;line-height: inherit;color: rgb(238, 220, 112);word-wrap: inherit !important;word-break: inherit !important;">`user`</span> (<br> <span style="font-size: inherit;line-height: inherit;color: rgb(238, 220, 112);word-wrap: inherit !important;word-break: inherit !important;">`id`</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">int</span>(<span style="font-size: inherit;line-height: inherit;color: rgb(174, 135, 250);word-wrap: inherit !important;word-break: inherit !important;">11</span>) <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">NOT</span> <span style="font-size: inherit;line-height: inherit;color: rgb(174, 135, 250);word-wrap: inherit !important;word-break: inherit !important;">NULL</span> AUTO_INCREMENT,<br> <span style="font-size: inherit;line-height: inherit;color: rgb(238, 220, 112);word-wrap: inherit !important;word-break: inherit !important;">`userId`</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">int</span>(<span style="font-size: inherit;line-height: inherit;color: rgb(174, 135, 250);word-wrap: inherit !important;word-break: inherit !important;">11</span>) <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">NOT</span> <span style="font-size: inherit;line-height: inherit;color: rgb(174, 135, 250);word-wrap: inherit !important;word-break: inherit !important;">NULL</span>,<br> <span style="font-size: inherit;line-height: inherit;color: rgb(238, 220, 112);word-wrap: inherit !important;word-break: inherit !important;">`age`</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">int</span>(<span style="font-size: inherit;line-height: inherit;color: rgb(174, 135, 250);word-wrap: inherit !important;word-break: inherit !important;">11</span>) <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">NOT</span> <span style="font-size: inherit;line-height: inherit;color: rgb(174, 135, 250);word-wrap: inherit !important;word-break: inherit !important;">NULL</span>,<br> <span style="font-size: inherit;line-height: inherit;color: rgb(238, 220, 112);word-wrap: inherit !important;word-break: inherit !important;">`name`</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">varchar</span>(<span style="font-size: inherit;line-height: inherit;color: rgb(174, 135, 250);word-wrap: inherit !important;word-break: inherit !important;">255</span>) <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">NOT</span> <span style="font-size: inherit;line-height: inherit;color: rgb(174, 135, 250);word-wrap: inherit !important;word-break: inherit !important;">NULL</span>,<br> PRIMARY <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">KEY</span> (<span style="font-size: inherit;line-height: inherit;color: rgb(238, 220, 112);word-wrap: inherit !important;word-break: inherit !important;">`id`</span>),<br> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">KEY</span> <span style="font-size: inherit;line-height: inherit;color: rgb(238, 220, 112);word-wrap: inherit !important;word-break: inherit !important;">`idx_userId`</span> (<span style="font-size: inherit;line-height: inherit;color: rgb(238, 220, 112);word-wrap: inherit !important;word-break: inherit !important;">`userId`</span>)<br>) <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">ENGINE</span>=<span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">InnoDB</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">DEFAULT</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">CHARSET</span>=utf8;<br></code></pre> </section> <p style="line-height: normal;"><br></p> <section style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;"> <span style="font-size: 15px;color: rgb(89, 89, 89);letter-spacing: 1px;">假设现在需要查询 userid 为 1 或者年龄为 18 岁的用户,很容易有以下 SQL。</span> </section> <section style="line-height: normal;"> <br> </section> <p style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;margin-bottom: 5px;"><span style="font-size: 15px;letter-spacing: 1px;color: rgb(71, 193, 168);">反例:</span></p> <section style="font-size: 16px;color: rgb(62, 62, 62);line-height: 1.6;letter-spacing: 0px;font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;"> <pre style="font-size: inherit;color: inherit;line-height: inherit;"><code style="margin-right: 2px;margin-left: 2px;line-height: 18px;font-size: 14px;letter-spacing: 0px;font-family: Consolas, Inconsolata, Courier, monospace;border-radius: 0px;color: rgb(169, 183, 198);background: rgb(40, 43, 46);padding: 0.5em;word-wrap: normal !important;word-break: normal !important;overflow: auto !important;display: -webkit-box !important;"><span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">select</span> * <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">from</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">user</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">where</span> userid=<span style="font-size: inherit;line-height: inherit;color: rgb(174, 135, 250);word-wrap: inherit !important;word-break: inherit !important;">1</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">or</span> age =<span style="font-size: inherit;line-height: inherit;color: rgb(174, 135, 250);word-wrap: inherit !important;word-break: inherit !important;">18</span><br></code></pre> </section> <p style="line-height: normal;"><br></p> <p style="text-align: justify;margin-left: 8px;margin-right: 8px;line-height: 1.75em;margin-bottom: 5px;"><span style="font-size: 15px;letter-spacing: 1px;color: rgb(71, 193, 168);">正例:</span></p> <section style="font-size: 16px;color: rgb(62, 62, 62);line-height: 1.6;letter-spacing: 0px;font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;"> <pre style="font-size: inherit;color: inherit;line-height: inherit;"><code style="margin-right: 2px;margin-left: 2px;line-height: 18px;font-size: 14px;letter-spacing: 0px;font-family: Consolas, Inconsolata, Courier, monospace;border-radius: 0px;color: rgb(169, 183, 198);background: rgb(40, 43, 46);padding: 0.5em;word-wrap: normal !important;word-break: normal !important;overflow: auto !important;display: -webkit-box !important;">//使用union all <br><span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">select</span> * <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">from</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">user</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">where</span> userid=<span style="font-size: inherit;line-height: inherit;color: rgb(174, 135, 250);word-wrap: inherit !important;word-break: inherit !important;">1</span> <br><span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">union</span> all <br><span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">select</span> * <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">from</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">user</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">where</span> age = <span style="font-size: inherit;line-height: inherit;color: rgb(174, 135, 250);word-wrap: inherit !important;word-break: inherit !important;">18</span><br><br>//或者分开两条<span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">sql</span>写:<br><span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">select</span> * <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">from</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">user</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">where</span> userid=<span style="font-size: inherit;line-height: inherit;color: rgb(174, 135, 250);word-wrap: inherit !important;word-break: inherit !important;">1</span><br><span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">select</span> * <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !important;word-break: inherit !important;">from</span> <span style="font-size: inherit;line-height: inherit;color: rgb(248, 35, 117);word-wrap: inherit !import