相忘 發表於 2018-1-11 10:01:00

MongoDB 入门篇

<h2>1.1 数据库管理系统</h2>
<p align="center">&nbsp;<img src="https://images2017.cnblogs.com/blog/1190037/201801/1190037-20180106140307112-257991728.png" alt=""></p>
<p>    在了解MongoDB之前需要先了解先数据库管理系统</p>
<h3>1.1.1 什么是数据?</h3>
<p>  数据(英语:data),是指未经过处理的原始记录。</p>
<p>  一般而言,数据缺乏组织及分类,无法明确的表达事物代表的意义,它可能是一堆的杂志、一大叠的报纸、数种的开会记录或是整本病人的病历纪录。数据描述事物的符号记录,是可定义为意义的实体,涉及事物的存在形式。是关于事件之一组离散且客观的事实描述,是构成讯息和知识的原始材料。</p>
<h3>1.1.2 什么是数据库管理系统?</h3>
<p>  数据库管理系统(英语:database management system,缩写:DBMS) 是一种针对对象数据库,为管理数据库而设计的大型电脑软件管理系统。</p>
<p>  具有代表性的数据管理系统有:Oracle、Microsoft SQL Server、Access、MySQL及PostgreSQL等。通常数据库管理师会使用数据库管理系统来创建数据库系统。</p>
<p>  现代DBMS使用不同的数据库模型追踪实体、属性和关系。在个人电脑、大型计算机和主机上应用最广泛的数据库管理系统是关系型DBMS(relational DBMS)。在关系型数据模型中,用二维表格表示数据库中的数据。这些表格称为关系。</p>
<p>  数据库管理系统主要分为俩大类:RDBMS、NOSQL</p>
<p>  关于RDBMS的更多信息参考:http://www.cnblogs.com/clsn/category/1131345.html</p>
<h3>1.1.3 常见数据库管理系统?</h3>
<p>常见的数据库管理系统,及其排名情况如下:</p>
<p align="center">&nbsp;<img src="https://images2017.cnblogs.com/blog/1190037/201801/1190037-20180106140440190-1132493229.png" alt=""></p>
<p align="center">图 - 数据库管理系统使用情况世界排名</p>
<p align="right">数据来源:https://db-engines.com/en/ranking</p>
<h2>1.2 NoSQL是什么?</h2>
<h3>1.2.1 NoSQL简介</h3>
<p>  NoSQL是对不同于传统的关系数据库的数据库管理系统的统称。</p>
<p>  两者存在许多显著的不同点,其中最重要的是NoSQL不使用SQL作为查询语言。其数据存储可以不需要固定的表格模式,也经常会避免使用SQL的JOIN操作,一般有水平可扩展性的特征。</p>
<p>  NoSQL一词<span style="background-color: rgba(255, 255, 0, 1)"><strong>最早出现于</strong><strong>1998</strong><strong>年</strong></span>,是Carlo Strozzi开发的一个轻量、开源、不提供SQL功能的关系数据库。</p>
<p><strong>  <span style="text-decoration: underline">2009</span></strong><strong><span style="text-decoration: underline">年</span></strong>,Last.fm的Johan Oskarsson发起了一次关于分布式开源数据库的讨论,来自Rackspace的<span style="background-color: rgba(255, 255, 0, 1)"><strong>Eric Evans</strong>再次提出了NoSQL的概念</span>,这时的NoSQL主要指非关系型、分布式、不提供ACID的数据库设计模式。</p>
<p>  2009年在亚特兰大举行的"no:sql(east)"讨论会是一个里程碑,其口号是"select fun, profit from real_world where relational=false;"。因此,<span style="text-decoration: underline">对</span><span style="text-decoration: underline">NoSQL</span><span style="text-decoration: underline">最普遍的解释是“非关联型的”,强调Key-Value Stores</span><span style="text-decoration: underline">和文档数据库的优点,而不是单纯的反对RDBMS</span>。</p>
<p>  基于2014年的收入,NoSQL市场领先企业是MarkLogic,MongoDB和Datastax。基于2015年的人气排名,最受欢迎的NoSQL数据库是<strong><span style="text-decoration: underline">MongoDB</span></strong><strong><span style="text-decoration: underline">,Apache Cassandra</span></strong><strong><span style="text-decoration: underline">和Redis</span></strong>.</p>
<h3>1.2.2 NoSQL数据库四大家族</h3>
<p>NoSQL中的四大家族主要是:列存储、键值、图像存储、文档存储,其类型产品主要有以下这些。</p>
<table class="MsoTableGrid" style="width: 100%; border-style: none" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="width: 16.22%; border-width: 1pt; border-color: rgba(0, 0, 0, 1); background: rgba(146, 208, 80, 1); padding: 0 5.4pt" width="16%">
<p class="MsoNormal" style="text-align: center" align="center"><strong><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; color: rgba(255, 255, 255, 1); mso-themecolor: background1">存储类型</span></strong></p>
</td>
<td style="width: 83.78%; border-width: 1pt 1pt 1pt initial; border-color: rgba(0, 0, 0, 1) rgba(0, 0, 0, 1) rgba(0, 0, 0, 1) initial; border-left-style: none; background: rgba(146, 208, 80, 1); padding: 0 5.4pt" colspan="2" width="83%">
<p class="MsoNormal" style="text-align: center" align="center"><strong><span style="color: rgba(255, 255, 255, 1); mso-themecolor: background1" lang="EN-US">NoSQL</span></strong></p>
</td>
</tr>
<tr style="mso-yfti-irow: 1; height: 9.5pt">
<td style="width: 16.22%; border-width: initial 1pt 1pt; border-color: initial rgba(0, 0, 0, 1) rgba(0, 0, 0, 1); border-top-style: none; background: rgba(146, 208, 80, 1); padding: 0 5.4pt; height: 9.5pt" rowspan="3" width="16%">
<p class="MsoNormal" style="text-align: center" align="center"><strong><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">键值存储</span></strong></p>
</td>
<td style="width: 27.12%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(0, 0, 0, 1); border-right-width: 1pt; border-right-color: rgba(0, 0, 0, 1); background: rgba(255, 192, 0, 1); padding: 0 5.4pt; height: 9.5pt" width="27%">
<p class="MsoNormal" style="text-align: center" align="center"><strong><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">最终一致性键值存储</span></strong></p>
</td>
<td style="width: 56.66%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(0, 0, 0, 1); border-right-width: 1pt; border-right-color: rgba(0, 0, 0, 1); padding: 0 5.4pt; height: 9.5pt" width="56%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><span lang="EN-US">Cassandra</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">、</span><span lang="EN-US">Dynamo</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">、</span><span lang="EN-US">Riak</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">、</span><span lang="EN-US">Hibari</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">、</span><span lang="EN-US">Virtuoso</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">、</span><span lang="EN-US">Voldemort</span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 2; height: 9.5pt">
<td style="width: 27.12%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(0, 0, 0, 1); border-right-width: 1pt; border-right-color: rgba(0, 0, 0, 1); background: rgba(0, 176, 240, 1); padding: 0 5.4pt; height: 9.5pt" width="27%">
<p class="MsoNormal" style="text-align: center" align="center"><strong><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">内存键值存储</span></strong></p>
</td>
<td style="width: 56.66%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(0, 0, 0, 1); border-right-width: 1pt; border-right-color: rgba(0, 0, 0, 1); padding: 0 5.4pt; height: 9.5pt" width="56%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><span lang="EN-US">Memcached</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">、</span><span lang="EN-US">Redis</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">、</span><span lang="EN-US">Oracle Coherence</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">、</span><span lang="EN-US">NCache</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">、</span><span lang="EN-US"> Hazelcast</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">、</span><span lang="EN-US">Tuple space</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">、</span><span lang="EN-US">Velocity</span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 3; height: 9.5pt">
<td style="width: 27.12%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(0, 0, 0, 1); border-right-width: 1pt; border-right-color: rgba(0, 0, 0, 1); background: rgba(250, 191, 143, 1); padding: 0 5.4pt; height: 9.5pt" width="27%">
<p class="MsoNormal" style="text-align: center" align="center"><strong><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">持久化键值存储</span></strong></p>
</td>
<td style="width: 56.66%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(0, 0, 0, 1); border-right-width: 1pt; border-right-color: rgba(0, 0, 0, 1); padding: 0 5.4pt; height: 9.5pt" width="56%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><span lang="EN-US">BigTable</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">、</span><span lang="EN-US">LevelDB</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">、</span><span lang="EN-US">Tokyo Cabinet</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">、</span><span lang="EN-US">Tarantool</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">、</span><span lang="EN-US">TreapDB</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">、</span><span lang="EN-US">Tuple space</span></p>
</td>
</tr>
<tr>
<td style="width: 16.22%; border-width: initial 1pt 1pt; border-color: initial rgba(0, 0, 0, 1) rgba(0, 0, 0, 1); border-top-style: none; background: rgba(146, 208, 80, 1); padding: 0 5.4pt" width="16%">
<p class="MsoNormal" style="text-align: center" align="center"><strong><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">文档存储</span></strong></p>
</td>
<td style="width: 83.78%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(0, 0, 0, 1); border-right-width: 1pt; border-right-color: rgba(0, 0, 0, 1); padding: 0 5.4pt" colspan="2" width="83%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><span lang="EN-US">MongoDB</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">、</span><span lang="EN-US">CouchDB</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">、</span><span lang="EN-US">SimpleDB</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">、</span><span lang="EN-US"> Terrastore </span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">、</span><span lang="EN-US"> BaseX </span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">、</span><span lang="EN-US">Clusterpoint </span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">、</span><span lang="EN-US"> Riak</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">、</span><span lang="EN-US">No2DB</span></p>
</td>
</tr>
<tr>
<td style="width: 16.22%; border-width: initial 1pt 1pt; border-color: initial rgba(0, 0, 0, 1) rgba(0, 0, 0, 1); border-top-style: none; background: rgba(146, 208, 80, 1); padding: 0 5.4pt" width="16%">
<p class="MsoNormal" style="text-align: center" align="center"><strong><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">图存储</span></strong></p>
</td>
<td style="width: 83.78%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(0, 0, 0, 1); border-right-width: 1pt; border-right-color: rgba(0, 0, 0, 1); padding: 0 5.4pt" colspan="2" width="83%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><span lang="EN-US">FlockDB</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">、</span><span lang="EN-US">DEX</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">、</span><span lang="EN-US">Neo4J</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">、</span><span lang="EN-US">AllegroGraph</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">、</span><span lang="EN-US">InfiniteGraph</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">、</span><span lang="EN-US">OrientDB</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">、</span><span lang="EN-US">Pregel</span></p>
</td>
</tr>
<tr>
<td style="width: 16.22%; border-width: initial 1pt 1pt; border-color: initial rgba(0, 0, 0, 1) rgba(0, 0, 0, 1); border-top-style: none; background: rgba(146, 208, 80, 1); padding: 0 5.4pt" width="16%">
<p class="MsoNormal" style="text-align: center" align="center"><strong><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">列存储</span></strong></p>
</td>
<td style="width: 83.78%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(0, 0, 0, 1); border-right-width: 1pt; border-right-color: rgba(0, 0, 0, 1); padding: 0 5.4pt" colspan="2" width="83%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><span lang="EN-US">Hbase</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">、</span><span lang="EN-US">Cassandra</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">、</span><span lang="EN-US">Hypertable</span></p>
</td>
</tr>
</tbody>
</table>
<h3>1.2.3 NoSQL的优势</h3>
<p>  高可扩展性、分布式计算、没有复杂的关系、低成本</p>
<p>  架构灵活、半结构化数据</p>
<h3>1.2.4 NoSQL与RDBMS对比&nbsp;</h3>
<table class="MsoTable15Grid4Accent4" style="width: 100%; border-style: none" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="width: 55.54%; border-width: 1pt initial 1pt 1pt; border-color: rgba(128, 100, 162, 1) initial rgba(128, 100, 162, 1) rgba(128, 100, 162, 1); border-right-style: none; background: rgba(128, 100, 162, 1); padding: 0 5.4pt" valign="top" width="55%">
<p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 5" align="center"><strong><span style="font-size: 18pt; color: rgba(255, 255, 255, 1); mso-themecolor: background1" lang="EN-US">NoSQL</span></strong></p>
</td>
<td style="width: 44.46%; border-width: 1pt 1pt 1pt initial; border-color: rgba(128, 100, 162, 1) rgba(128, 100, 162, 1) rgba(128, 100, 162, 1) initial; border-left-style: none; background: rgba(128, 100, 162, 1); padding: 0 5.4pt" valign="top" width="44%">
<p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 1" align="center"><strong><span style="font-size: 18pt; color: rgba(255, 255, 255, 1); mso-themecolor: background1" lang="EN-US">RDBMS</span></strong></p>
</td>
</tr>
<tr>
<td style="width: 55.54%; border-width: initial 1pt 1pt; border-color: initial rgba(178, 161, 199, 1) rgba(178, 161, 199, 1); border-top-style: none; background: rgba(229, 223, 236, 1); padding: 0 5.4pt" valign="top" width="55%">
<p class="MsoNormal"><strong><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">代表着不仅仅是</span><span lang="EN-US">SQL </span></strong></p>
<p class="MsoNormal"><strong><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">没有声明性查询语言</span> </strong></p>
<p class="MsoNormal"><strong><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">没有预定义的模式</span> </strong></p>
<p class="MsoNormal"><strong><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">键</span><span lang="EN-US"> - </span></strong><strong><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">值对存储,列存储,文档存储,图形数据库</span> </strong></p>
<p class="MsoNormal"><strong><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">最终一致性,而</span></strong><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; mso-bidi-font-weight: bold">非</span><span lang="EN-US">ACID</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; mso-bidi-font-weight: bold">属性</span></p>
<p class="MsoNormal"><strong><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">非结构化和不可预知的数据</span> </strong></p>
<p class="MsoNormal"><strong><span lang="EN-US">CAP</span></strong><strong><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">定理</span> </strong></p>
<p class="MsoNormal"><strong><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">高性能,高可用性和可伸缩性</span></strong></p>
</td>
<td style="width: 44.46%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(178, 161, 199, 1); border-right-width: 1pt; border-right-color: rgba(178, 161, 199, 1); background: rgba(229, 223, 236, 1); padding: 0 5.4pt" valign="top" width="44%">
<p class="MsoNormal"><strong><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">高度组织化结构化数据</span> </strong></p>
<p class="MsoNormal"><strong><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">结构化查询语言(</span><span lang="EN-US">SQL</span></strong><strong><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">)</span><span lang="EN-US"> (SQL) </span></strong></p>
<p class="MsoNormal"><strong><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">数据和关系都存储在单独的表中。</span> </strong></p>
<p class="MsoNormal"><strong><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">数据操纵语言,数据定义语言</span> </strong></p>
<p class="MsoNormal"><strong><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">严格的一致性</span> </strong></p>
<p class="MsoNormal"><strong><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">基础事务</span> </strong></p>
</td>
</tr>
</tbody>
</table>
<h2>1.3 MongoDB简介</h2>
<h3><span style="font-size: 1.17em">1.3.1 MongoDB是什么</span></h3>
<p align="center"><img src="https://images2017.cnblogs.com/blog/1190037/201801/1190037-20180106140932003-1386849701.png" alt="">&nbsp;</p>
<p>    MongoDB并非芒果的意思,而是源于 Humongous(巨大)一词。</p>
<h3>1.3.2 MongoDB的特性</h3>
<p>  MongoDB的3大技术特色如下所示:</p>
<p align="center">&nbsp;<img src="https://images2017.cnblogs.com/blog/1190037/201801/1190037-20180106140946346-1583437802.png" alt=""></p>
<p>除了上图所示的还<strong>支持</strong>:</p>
<p>  二级索引、动态查询、全文搜索 、聚合框架、MapReduce、GridFS、地理位置索引、内存引擎 、地理分布等一系列的强大功能。</p>
<p>但是其也有些许的<span style="color: rgba(255, 0, 0, 1)"><strong>缺点</strong></span>,例如:</p>
<blockquote>
<p>  多表关联: 仅仅支持Left Outer Join</p>
<p>  SQL 语句支持: 查询为主,部分支持</p>
<p>  多表原子事务: 不支持</p>
<p>  多文档原子事务:不支持</p>
<p>  16MB 文档大小限制,不支持中文排序 ,服务端 Javascript 性能欠佳</p>
</blockquote>
<h3>1.3.3 关系型数据库与mongodb对比</h3>
<p><strong>存储方式对比</strong></p>
<p><strong>&nbsp; </strong>&nbsp;&nbsp; 在传统的关系型数据库中,存储方式是以表的形式存放,而在MongoDB中,以文档的形式存在。</p>
<p align="center"><img src="https://images2017.cnblogs.com/blog/1190037/201801/1190037-20180106141025909-1190563513.png" alt="">&nbsp;</p>
<p>&nbsp;&nbsp; 数据库中的对应关系,及存储形式的说明</p>
<p align="center">&nbsp;<img src="https://images2017.cnblogs.com/blog/1190037/201801/1190037-20180106141036237-258431155.png" alt=""></p>
<p>MongoDB与SQL的结构对比详解</p>
<div align="center">
<table class="MsoTable15Grid4Accent1" style="width: 100%; border-style: none" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="width: 41.98%; border-width: 1pt initial 1pt 1pt; border-color: rgba(79, 129, 189, 1) initial rgba(79, 129, 189, 1) rgba(79, 129, 189, 1); border-right-style: none; background: rgba(79, 129, 189, 1); padding: 0 5.4pt" valign="top" width="41%">
<p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 5" align="center"><span style="font-size: 18pt"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif; color: rgba(255, 255, 255, 1); mso-themecolor: background1" lang="EN-US">SQL Terms/Concepts</span></strong></span></p>
</td>
<td style="width: 58.02%; border-width: 1pt 1pt 1pt initial; border-color: rgba(79, 129, 189, 1) rgba(79, 129, 189, 1) rgba(79, 129, 189, 1) initial; border-left-style: none; background: rgba(79, 129, 189, 1); padding: 0 5.4pt" valign="top" width="58%">
<p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 1" align="center"><span style="font-size: 18pt"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif; color: rgba(255, 255, 255, 1); mso-themecolor: background1" lang="EN-US">MongoDB Terms/Concepts</span></strong></span></p>
</td>
</tr>
<tr>
<td style="width: 41.98%; border-width: initial 1pt 1pt; border-color: initial rgba(149, 179, 215, 1) rgba(149, 179, 215, 1); border-top-style: none; background: rgba(219, 229, 241, 1); padding: 0 5.4pt; text-align: center" valign="top" width="41%">
<p class="MsoNormal"><span style="font-size: 14pt"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">database</span></strong></span></p>
</td>
<td style="width: 58.02%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(149, 179, 215, 1); border-right-width: 1pt; border-right-color: rgba(149, 179, 215, 1); background: rgba(219, 229, 241, 1); padding: 0 5.4pt; text-align: center" valign="top" width="58%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif; font-size: 14pt" lang="EN-US">database</span></p>
</td>
</tr>
<tr>
<td style="width: 41.98%; border-width: initial 1pt 1pt; border-color: initial rgba(149, 179, 215, 1) rgba(149, 179, 215, 1); border-top-style: none; padding: 0 5.4pt; text-align: center" valign="top" width="41%">
<p class="MsoNormal"><span style="font-size: 14pt"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">table</span></strong></span></p>
</td>
<td style="width: 58.02%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(149, 179, 215, 1); border-right-width: 1pt; border-right-color: rgba(149, 179, 215, 1); padding: 0 5.4pt; text-align: center" valign="top" width="58%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif; font-size: 14pt" lang="EN-US">collection</span></p>
</td>
</tr>
<tr>
<td style="width: 41.98%; border-width: initial 1pt 1pt; border-color: initial rgba(149, 179, 215, 1) rgba(149, 179, 215, 1); border-top-style: none; background: rgba(219, 229, 241, 1); padding: 0 5.4pt; text-align: center" valign="top" width="41%">
<p class="MsoNormal"><span style="font-size: 14pt"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">row</span></strong></span></p>
</td>
<td style="width: 58.02%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(149, 179, 215, 1); border-right-width: 1pt; border-right-color: rgba(149, 179, 215, 1); background: rgba(219, 229, 241, 1); padding: 0 5.4pt; text-align: center" valign="top" width="58%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif; font-size: 14pt" lang="EN-US">document or BSON document</span></p>
</td>
</tr>
<tr>
<td style="width: 41.98%; border-width: initial 1pt 1pt; border-color: initial rgba(149, 179, 215, 1) rgba(149, 179, 215, 1); border-top-style: none; padding: 0 5.4pt; text-align: center" valign="top" width="41%">
<p class="MsoNormal"><span style="font-size: 14pt"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">column</span></strong></span></p>
</td>
<td style="width: 58.02%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(149, 179, 215, 1); border-right-width: 1pt; border-right-color: rgba(149, 179, 215, 1); padding: 0 5.4pt; text-align: center" valign="top" width="58%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif; font-size: 14pt" lang="EN-US">field</span></p>
</td>
</tr>
<tr>
<td style="width: 41.98%; border-width: initial 1pt 1pt; border-color: initial rgba(149, 179, 215, 1) rgba(149, 179, 215, 1); border-top-style: none; background: rgba(219, 229, 241, 1); padding: 0 5.4pt; text-align: center" valign="top" width="41%">
<p class="MsoNormal"><span style="font-size: 14pt"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">index</span></strong></span></p>
</td>
<td style="width: 58.02%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(149, 179, 215, 1); border-right-width: 1pt; border-right-color: rgba(149, 179, 215, 1); background: rgba(219, 229, 241, 1); padding: 0 5.4pt; text-align: center" valign="top" width="58%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif; font-size: 14pt" lang="EN-US">index</span></p>
</td>
</tr>
<tr>
<td style="width: 41.98%; border-width: initial 1pt 1pt; border-color: initial rgba(149, 179, 215, 1) rgba(149, 179, 215, 1); border-top-style: none; padding: 0 5.4pt; text-align: center" valign="top" width="41%">
<p class="MsoNormal"><span style="font-size: 14pt"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">table joins</span></strong></span></p>
</td>
<td style="width: 58.02%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(149, 179, 215, 1); border-right-width: 1pt; border-right-color: rgba(149, 179, 215, 1); padding: 0 5.4pt; text-align: center" valign="top" width="58%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif; font-size: 14pt" lang="EN-US">embedded documents and linking</span></p>
</td>
</tr>
<tr>
<td style="width: 41.98%; border-width: initial 1pt 1pt; border-color: initial rgba(149, 179, 215, 1) rgba(149, 179, 215, 1); border-top-style: none; background: rgba(219, 229, 241, 1); padding: 0 5.4pt; text-align: center" valign="top" width="41%">
<p class="MsoNormal"><span style="font-size: 14pt"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">primary key</span></strong></span></p>
<p class="MsoNormal"><span style="font-size: 14pt"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">Specify any unique column or</span></strong></span></p>
<p class="MsoNormal"><span style="font-size: 14pt"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">column combination as </span></strong></span></p>
<p class="MsoNormal"><span style="font-size: 14pt"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">primary key.</span></strong></span></p>
</td>
<td style="width: 58.02%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(149, 179, 215, 1); border-right-width: 1pt; border-right-color: rgba(149, 179, 215, 1); background: rgba(219, 229, 241, 1); padding: 0 5.4pt; text-align: center" valign="top" width="58%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif; font-size: 14pt" lang="EN-US">primary key</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif; font-size: 14pt" lang="EN-US">In MongoDB, the primary key is </span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif; font-size: 14pt" lang="EN-US">automatically set to the _id field.</span></p>
</td>
</tr>
<tr>
<td style="width: 41.98%; border-width: initial 1pt 1pt; border-color: initial rgba(149, 179, 215, 1) rgba(149, 179, 215, 1); border-top-style: none; padding: 0 5.4pt; text-align: center" valign="top" width="41%">
<p class="MsoNormal"><span style="font-size: 14pt"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">aggregation (e.g. group by)</span></strong></span></p>
</td>
<td style="width: 58.02%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(149, 179, 215, 1); border-right-width: 1pt; border-right-color: rgba(149, 179, 215, 1); padding: 0 5.4pt; text-align: center" valign="top" width="58%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif; font-size: 14pt" lang="EN-US">aggregation pipeline</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif; font-size: 14pt" lang="EN-US">See the SQL to Aggregation Mapping </span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif; font-size: 14pt" lang="EN-US">Chart.</span></p>
</td>
</tr>
</tbody>
</table>
</div>
<h3>1.3.4 MongoDB数据存储格式</h3>
<p><span style="background-color: rgba(255, 255, 0, 1)"><strong>JSON</strong><strong>格式</strong></span></p>
<p>  JSON 数据格式与语言无关,脱胎于 JavaScript,但目前很多编程语言都支持 JSON 格式数据的生成和解析。JSON 的官方 MIME 类型是 application/json,文件扩展名是 .json。</p>
<p>  MongoDB 使用JSON(JavaScript ObjectNotation)文档存储记录。</p>
<p>  JSON数据库语句可以容易被解析。</p>
<p>  Web 应用大量使用,NAME-VALUE 配对</p>
<p align="center"><img src="https://images2017.cnblogs.com/blog/1190037/201801/1190037-20180106141205628-1994652076.png" alt="">&nbsp;</p>
<p><span style="background-color: rgba(255, 255, 0, 1)"><strong>BSON</strong><strong>格式</strong></span></p>
<p>  BSON是由10gen开发的一个数据格式,目前主要用于MongoDB中,是MongoDB的数据存储格式。BSON基于JSON格式,选择JSON进行改造的原因主要是JSON的通用性及JSON的schemaless的特性。&nbsp;</p>
<p>  二进制的JSON,JSON文档的二进制编码存储格式</p>
<p>  BSON有JSON没有的Date和BinData</p>
<p>  MongoDB中document以BSON形式存放</p>
<p>例如:</p>
<div>
<div class="cnblogs_code">
<pre><span style="color: rgba(128, 128, 128, 1)">&gt;</span> db.meeting.<span style="color: rgba(0, 0, 255, 1)">insert</span>({meeting:“M1 June",Date:"<span style="color: rgba(128, 0, 0, 1); font-weight: bold">2018</span><span style="color: rgba(128, 128, 128, 1)">-</span><span style="color: rgba(128, 0, 0, 1); font-weight: bold">01</span><span style="color: rgba(128, 128, 128, 1)">-</span><span style="color: rgba(128, 0, 0, 1); font-weight: bold">06</span>"});</pre>
</div>
</div>
<h3>1.3.5 MongoDB的优势</h3>
<p>&nbsp;   📢 MongoDB是开源产品</p>
<p>&nbsp;   📢 On GitHub Url:https://github.com/mongodb</p>
<p>&nbsp;   📢&nbsp; Licensed under the AGPL,有开源的社区版本</p>
<p>&nbsp;   📢 起源&amp; 赞助by MongoDB公司,提供商业版licenses 许可</p>
<p>&nbsp;&nbsp;   这些优势造就了mongodb的丰富的功能:</p>
<p>  JSON 文档模型、动态的数据模式、二级索引强大、查询功能、自动分片、水平扩展、自动复制、高可用、文本搜索、企业级安全、聚合框架MapReduce、大文件存储GridFS</p>
<h3>1.3.6 高可用的复制集群</h3>
<p>  自动复制和故障切换</p>
<p>  多数据中心支持滚动维护无需关机支持最多50个成员</p>
<p align="center"><img src="https://images2017.cnblogs.com/blog/1190037/201801/1190037-20180106141337862-2036189439.png" alt=""></p>
<h3>1.3.7 水平扩展</h3>
<p>  这种方式是目前构架上的主流形式,指的是通过增加服务器数量来对系统扩容。在这样的构架下,单台服务器的配置并不会很高,可能是配置比较低、很廉价的 PC,每台机器承载着系统的一个子集,所有机器服务器组成的集群会比单体服务器提供更强大、高效的系统容载量。</p>
<p align="center"><img src="https://images2017.cnblogs.com/blog/1190037/201801/1190037-20180106141352596-1511440780.png" alt="">&nbsp;</p>
<p>  这样的问题是系统构架会比单体服务器复杂,搭建、维护都要求更高的技术背景。分片集群架构如下图所示:</p>
<p align="center"><img src="https://images2017.cnblogs.com/blog/1190037/201801/1190037-20180106141415143-1288477019.png" alt=""></p>
<h3>1.3.8 各存储引擎的对比</h3>
<table class="MsoTable15Grid4Accent3" style="width: 100%; border-style: none" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr style="mso-yfti-irow: -1; mso-yfti-firstrow: yes; mso-yfti-lastfirstrow: yes; height: 38.4pt">
<td style="width: 20.3%; border-width: 1pt initial 1pt 1pt; border-color: rgba(155, 187, 89, 1) initial rgba(155, 187, 89, 1) rgba(155, 187, 89, 1); border-right-style: none; background: rgba(155, 187, 89, 1); padding: 0 5.4pt; height: 38.4pt" nowrap="nowrap" width="20%">&nbsp;</td>
<td style="width: 13.56%; border-width: 1pt initial; border-color: rgba(155, 187, 89, 1) initial; border-left-style: none; border-right-style: none; background: rgba(155, 187, 89, 1); padding: 0 5.4pt; height: 38.4pt" width="13%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 1"><strong><span style="mso-bidi-font-size: 12.0pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; color: rgba(255, 255, 255, 1); mso-themecolor: background1; mso-font-kerning: 0pt" lang="EN-US">MySQL InnoDB</span></strong></p>
</td>
<td style="width: 13.62%; border-width: 1pt initial; border-color: rgba(155, 187, 89, 1) initial; border-left-style: none; border-right-style: none; background: rgba(155, 187, 89, 1); padding: 0 5.4pt; height: 38.4pt" width="13%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 1"><strong><span style="mso-bidi-font-size: 12.0pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; color: rgba(255, 255, 255, 1); mso-themecolor: background1; mso-font-kerning: 0pt" lang="EN-US">MySQL NDB</span></strong></p>
</td>
<td style="width: 14.32%; border-width: 1pt initial; border-color: rgba(155, 187, 89, 1) initial; border-left-style: none; border-right-style: none; background: rgba(155, 187, 89, 1); padding: 0 5.4pt; height: 38.4pt" nowrap="nowrap" width="14%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 1"><strong><span style="mso-bidi-font-size: 12.0pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; color: rgba(255, 255, 255, 1); mso-themecolor: background1; mso-font-kerning: 0pt" lang="EN-US">Oracle</span></strong></p>
</td>
<td style="width: 18.88%; border-width: 1pt initial; border-color: rgba(155, 187, 89, 1) initial; border-left-style: none; border-right-style: none; background: rgba(155, 187, 89, 1); padding: 0 5.4pt; height: 38.4pt" width="18%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 1"><strong><span style="mso-bidi-font-size: 12.0pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; color: rgba(255, 255, 255, 1); mso-themecolor: background1; mso-font-kerning: 0pt" lang="EN-US">MongoDB MAPI</span></strong></p>
</td>
<td style="width: 19.3%; border-width: 1pt 1pt 1pt initial; border-color: rgba(155, 187, 89, 1) rgba(155, 187, 89, 1) rgba(155, 187, 89, 1) initial; border-left-style: none; background: rgba(155, 187, 89, 1); padding: 0 5.4pt; height: 38.4pt" width="19%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 1"><strong><span style="mso-bidi-font-size: 12.0pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; color: rgba(255, 255, 255, 1); mso-themecolor: background1; mso-font-kerning: 0pt" lang="EN-US">MongoDB WiredTiger</span></strong></p>
</td>
</tr>
<tr style="mso-yfti-irow: 0; height: 23.4pt">
<td style="width: 20.3%; border-width: initial 1pt 1pt; border-color: initial rgba(194, 214, 155, 1) rgba(194, 214, 155, 1); border-top-style: none; background: rgba(234, 241, 221, 1); padding: 0 5.4pt; height: 23.4pt" nowrap="nowrap" width="20%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 68"><span style="font-size: 15pt; font-family: 黑体; mso-bidi-font-family: Arial; mso-font-kerning: 0pt; mso-bidi-font-weight: bold">事务</span></p>
</td>
<td style="width: 13.56%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); background: rgba(234, 241, 221, 1); padding: 0 5.4pt; height: 23.4pt" nowrap="nowrap" width="13%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 64"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">YES</span></p>
</td>
<td style="width: 13.62%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); background: rgba(234, 241, 221, 1); padding: 0 5.4pt; height: 23.4pt" nowrap="nowrap" width="13%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 64"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">YES</span></p>
</td>
<td style="width: 14.32%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); background: rgba(234, 241, 221, 1); padding: 0 5.4pt; height: 23.4pt" nowrap="nowrap" width="14%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 13.05pt; mso-char-indent-count: 1.0; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 64"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">ES</span></p>
</td>
<td style="width: 18.88%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); background: rgba(234, 241, 221, 1); padding: 0 5.4pt; height: 23.4pt" nowrap="nowrap" width="18%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 64"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">NO</span></p>
</td>
<td style="width: 19.3%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); background: rgba(234, 241, 221, 1); padding: 0 5.4pt; height: 23.4pt" nowrap="nowrap" width="19%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 64"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">NO</span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 1; height: 23.4pt">
<td style="width: 20.3%; border-width: initial 1pt 1pt; border-color: initial rgba(194, 214, 155, 1) rgba(194, 214, 155, 1); border-top-style: none; padding: 0 5.4pt; height: 23.4pt" nowrap="nowrap" width="20%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 4"><span style="font-size: 15pt; font-family: 黑体; mso-bidi-font-family: Arial; mso-font-kerning: 0pt; mso-bidi-font-weight: bold">锁粒度</span></p>
</td>
<td style="width: 13.56%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); padding: 0 5.4pt; height: 23.4pt" nowrap="nowrap" width="13%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">ROW-level</span></p>
</td>
<td style="width: 13.62%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); padding: 0 5.4pt; height: 23.4pt" nowrap="nowrap" width="13%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">ROW-level</span></p>
</td>
<td style="width: 14.32%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); padding: 0 5.4pt; height: 23.4pt" nowrap="nowrap" width="14%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">ROW-level</span></p>
</td>
<td style="width: 18.88%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); padding: 0 5.4pt; height: 23.4pt" nowrap="nowrap" width="18%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">Collection-level</span></p>
</td>
<td style="width: 19.3%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); padding: 0 5.4pt; height: 23.4pt" nowrap="nowrap" width="19%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">Document-level</span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 2; height: 24.6pt">
<td style="width: 20.3%; border-width: initial 1pt 1pt; border-color: initial rgba(194, 214, 155, 1) rgba(194, 214, 155, 1); border-top-style: none; background: rgba(234, 241, 221, 1); padding: 0 5.4pt; height: 24.6pt" nowrap="nowrap" width="20%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 68"><span style="font-size: 16pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt; mso-bidi-font-weight: bold" lang="EN-US">Geospatial</span></p>
</td>
<td style="width: 13.56%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); background: rgba(234, 241, 221, 1); padding: 0 5.4pt; height: 24.6pt" nowrap="nowrap" width="13%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 64"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">YES</span></p>
</td>
<td style="width: 13.62%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); background: rgba(234, 241, 221, 1); padding: 0 5.4pt; height: 24.6pt" nowrap="nowrap" width="13%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 64"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">YES</span></p>
</td>
<td style="width: 14.32%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); background: rgba(234, 241, 221, 1); padding: 0 5.4pt; height: 24.6pt" nowrap="nowrap" width="14%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 64"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">YES</span></p>
</td>
<td style="width: 18.88%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); background: rgba(234, 241, 221, 1); padding: 0 5.4pt; height: 24.6pt" nowrap="nowrap" width="18%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 64"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">YES</span></p>
</td>
<td style="width: 19.3%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); background: rgba(234, 241, 221, 1); padding: 0 5.4pt; height: 24.6pt" nowrap="nowrap" width="19%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 64"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">YES</span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 3; height: 24.6pt">
<td style="width: 20.3%; border-width: initial 1pt 1pt; border-color: initial rgba(194, 214, 155, 1) rgba(194, 214, 155, 1); border-top-style: none; padding: 0 5.4pt; height: 24.6pt" nowrap="nowrap" width="20%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 4"><span style="font-size: 16pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt; mso-bidi-font-weight: bold" lang="EN-US">MVCC</span></p>
</td>
<td style="width: 13.56%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); padding: 0 5.4pt; height: 24.6pt" nowrap="nowrap" width="13%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">YES</span></p>
</td>
<td style="width: 13.62%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); padding: 0 5.4pt; height: 24.6pt" nowrap="nowrap" width="13%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">NO</span></p>
</td>
<td style="width: 14.32%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); padding: 0 5.4pt; height: 24.6pt" nowrap="nowrap" width="14%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">YES</span></p>
</td>
<td style="width: 18.88%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); padding: 0 5.4pt; height: 24.6pt" nowrap="nowrap" width="18%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">NO</span></p>
</td>
<td style="width: 19.3%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); padding: 0 5.4pt; height: 24.6pt" nowrap="nowrap" width="19%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">NO</span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 4; height: 24.6pt">
<td style="width: 20.3%; border-width: initial 1pt 1pt; border-color: initial rgba(194, 214, 155, 1) rgba(194, 214, 155, 1); border-top-style: none; background: rgba(234, 241, 221, 1); padding: 0 5.4pt; height: 24.6pt" nowrap="nowrap" width="20%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 68"><span style="font-size: 16pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt; mso-bidi-font-weight: bold" lang="EN-US">Replication</span></p>
</td>
<td style="width: 13.56%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); background: rgba(234, 241, 221, 1); padding: 0 5.4pt; height: 24.6pt" nowrap="nowrap" width="13%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 64"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">YES</span></p>
</td>
<td style="width: 13.62%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); background: rgba(234, 241, 221, 1); padding: 0 5.4pt; height: 24.6pt" nowrap="nowrap" width="13%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 64"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">YES</span></p>
</td>
<td style="width: 14.32%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); background: rgba(234, 241, 221, 1); padding: 0 5.4pt; height: 24.6pt" nowrap="nowrap" width="14%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 64"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">YES</span></p>
</td>
<td style="width: 18.88%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); background: rgba(234, 241, 221, 1); padding: 0 5.4pt; height: 24.6pt" nowrap="nowrap" width="18%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 64"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">YES</span></p>
</td>
<td style="width: 19.3%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); background: rgba(234, 241, 221, 1); padding: 0 5.4pt; height: 24.6pt" nowrap="nowrap" width="19%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 64"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">YES</span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 5; height: 71.1pt">
<td style="width: 20.3%; border-width: initial 1pt 1pt; border-color: initial rgba(194, 214, 155, 1) rgba(194, 214, 155, 1); border-top-style: none; padding: 0 5.4pt; height: 71.1pt" nowrap="nowrap" width="20%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 4"><span style="font-size: 15pt; font-family: 黑体; mso-bidi-font-family: Arial; mso-font-kerning: 0pt; mso-bidi-font-weight: bold">外键</span></p>
</td>
<td style="width: 13.56%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); padding: 0 5.4pt; height: 71.1pt" nowrap="nowrap" width="13%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">YES</span></p>
</td>
<td style="width: 13.62%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); padding: 0 5.4pt; height: 71.1pt" nowrap="nowrap" width="13%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">YES(From 7.3)</span></p>
</td>
<td style="width: 14.32%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); padding: 0 5.4pt; height: 71.1pt" nowrap="nowrap" width="14%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">YES</span></p>
</td>
<td style="width: 18.88%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); padding: 0 5.4pt; height: 71.1pt" nowrap="nowrap" width="18%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">NO</span></p>
</td>
<td style="width: 19.3%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); padding: 0 5.4pt; height: 71.1pt" nowrap="nowrap" width="19%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">NO</span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 6; height: 23.4pt">
<td style="width: 20.3%; border-width: initial 1pt 1pt; border-color: initial rgba(194, 214, 155, 1) rgba(194, 214, 155, 1); border-top-style: none; background: rgba(234, 241, 221, 1); padding: 0 5.4pt; height: 23.4pt" nowrap="nowrap" width="20%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 68"><span style="font-size: 15pt; font-family: 黑体; mso-bidi-font-family: Arial; mso-font-kerning: 0pt; mso-bidi-font-weight: bold">数据库集群</span></p>
</td>
<td style="width: 13.56%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); background: rgba(234, 241, 221, 1); padding: 0 5.4pt; height: 23.4pt" nowrap="nowrap" width="13%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 64"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">NO</span></p>
</td>
<td style="width: 13.62%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); background: rgba(234, 241, 221, 1); padding: 0 5.4pt; height: 23.4pt" nowrap="nowrap" width="13%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 64"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">YES</span></p>
</td>
<td style="width: 14.32%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); background: rgba(234, 241, 221, 1); padding: 0 5.4pt; height: 23.4pt" nowrap="nowrap" width="14%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 64"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">YES</span></p>
</td>
<td style="width: 18.88%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); background: rgba(234, 241, 221, 1); padding: 0 5.4pt; height: 23.4pt" nowrap="nowrap" width="18%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 64"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">YES</span></p>
</td>
<td style="width: 19.3%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); background: rgba(234, 241, 221, 1); padding: 0 5.4pt; height: 23.4pt" nowrap="nowrap" width="19%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 64"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">YES</span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 7; height: 24.6pt">
<td style="width: 20.3%; border-width: initial 1pt 1pt; border-color: initial rgba(194, 214, 155, 1) rgba(194, 214, 155, 1); border-top-style: none; padding: 0 5.4pt; height: 24.6pt" nowrap="nowrap" width="20%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 4"><span style="font-size: 16pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt; mso-bidi-font-weight: bold" lang="EN-US">B-TREE</span><span style="font-size: 15pt; font-family: 黑体; mso-bidi-font-family: 'Segoe UI'; mso-font-kerning: 0pt; mso-bidi-font-weight: bold">索引</span></p>
</td>
<td style="width: 13.56%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); padding: 0 5.4pt; height: 24.6pt" nowrap="nowrap" width="13%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">YES</span></p>
</td>
<td style="width: 13.62%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); padding: 0 5.4pt; height: 24.6pt" nowrap="nowrap" width="13%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">YES</span></p>
</td>
<td style="width: 14.32%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); padding: 0 5.4pt; height: 24.6pt" nowrap="nowrap" width="14%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">YES</span></p>
</td>
<td style="width: 18.88%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); padding: 0 5.4pt; height: 24.6pt" nowrap="nowrap" width="18%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">YES</span></p>
</td>
<td style="width: 19.3%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); padding: 0 5.4pt; height: 24.6pt" nowrap="nowrap" width="19%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">YES</span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 8; height: 23.4pt">
<td style="width: 20.3%; border-width: initial 1pt 1pt; border-color: initial rgba(194, 214, 155, 1) rgba(194, 214, 155, 1); border-top-style: none; background: rgba(234, 241, 221, 1); padding: 0 5.4pt; height: 23.4pt" nowrap="nowrap" width="20%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 68"><span style="font-size: 15pt; font-family: 黑体; mso-bidi-font-family: Arial; mso-font-kerning: 0pt; mso-bidi-font-weight: bold">全文检索</span></p>
</td>
<td style="width: 13.56%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); background: rgba(234, 241, 221, 1); padding: 0 5.4pt; height: 23.4pt" nowrap="nowrap" width="13%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 64"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">YES</span></p>
</td>
<td style="width: 13.62%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); background: rgba(234, 241, 221, 1); padding: 0 5.4pt; height: 23.4pt" nowrap="nowrap" width="13%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 64"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">NO</span></p>
</td>
<td style="width: 14.32%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); background: rgba(234, 241, 221, 1); padding: 0 5.4pt; height: 23.4pt" nowrap="nowrap" width="14%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 64"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">YES</span></p>
</td>
<td style="width: 18.88%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); background: rgba(234, 241, 221, 1); padding: 0 5.4pt; height: 23.4pt" nowrap="nowrap" width="18%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 64"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">YES</span></p>
</td>
<td style="width: 19.3%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); background: rgba(234, 241, 221, 1); padding: 0 5.4pt; height: 23.4pt" nowrap="nowrap" width="19%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 64"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">YES</span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 9; height: 23.4pt">
<td style="width: 20.3%; border-width: initial 1pt 1pt; border-color: initial rgba(194, 214, 155, 1) rgba(194, 214, 155, 1); border-top-style: none; padding: 0 5.4pt; height: 23.4pt" nowrap="nowrap" width="20%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 4"><span style="font-size: 15pt; font-family: 黑体; mso-bidi-font-family: Arial; mso-font-kerning: 0pt; mso-bidi-font-weight: bold">数据压缩</span></p>
</td>
<td style="width: 13.56%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); padding: 0 5.4pt; height: 23.4pt" nowrap="nowrap" width="13%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">YES</span></p>
</td>
<td style="width: 13.62%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); padding: 0 5.4pt; height: 23.4pt" nowrap="nowrap" width="13%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">NO</span></p>
</td>
<td style="width: 14.32%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); padding: 0 5.4pt; height: 23.4pt" nowrap="nowrap" width="14%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">YES</span></p>
</td>
<td style="width: 18.88%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); padding: 0 5.4pt; height: 23.4pt" nowrap="nowrap" width="18%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">NO</span></p>
</td>
<td style="width: 19.3%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); padding: 0 5.4pt; height: 23.4pt" nowrap="nowrap" width="19%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">YES</span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 10; height: 23.4pt">
<td style="width: 20.3%; border-width: initial 1pt 1pt; border-color: initial rgba(194, 214, 155, 1) rgba(194, 214, 155, 1); border-top-style: none; background: rgba(234, 241, 221, 1); padding: 0 5.4pt; height: 23.4pt" nowrap="nowrap" width="20%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 68"><span style="font-size: 15pt; font-family: 黑体; mso-bidi-font-family: Arial; mso-font-kerning: 0pt; mso-bidi-font-weight: bold">存储限制</span></p>
</td>
<td style="width: 13.56%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); background: rgba(234, 241, 221, 1); padding: 0 5.4pt; height: 23.4pt" nowrap="nowrap" width="13%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 64"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">64TB</span></p>
</td>
<td style="width: 13.62%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); background: rgba(234, 241, 221, 1); padding: 0 5.4pt; height: 23.4pt" nowrap="nowrap" width="13%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 64"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">384EB</span></p>
</td>
<td style="width: 14.32%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); background: rgba(234, 241, 221, 1); padding: 0 5.4pt; height: 23.4pt" nowrap="nowrap" width="14%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 64"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">NO</span></p>
</td>
<td style="width: 18.88%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); background: rgba(234, 241, 221, 1); padding: 0 5.4pt; height: 23.4pt" nowrap="nowrap" width="18%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 64"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">NO</span></p>
</td>
<td style="width: 19.3%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); background: rgba(234, 241, 221, 1); padding: 0 5.4pt; height: 23.4pt" nowrap="nowrap" width="19%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 64"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">NO</span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 11; mso-yfti-lastrow: yes; height: 23.4pt">
<td style="width: 20.3%; border-width: initial 1pt 1pt; border-color: initial rgba(194, 214, 155, 1) rgba(194, 214, 155, 1); border-top-style: none; padding: 0 5.4pt; height: 23.4pt" nowrap="nowrap" width="20%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto; mso-yfti-cnfc: 4"><span style="font-size: 15pt; font-family: 黑体; mso-bidi-font-family: Arial; mso-font-kerning: 0pt; mso-bidi-font-weight: bold">表分区</span></p>
</td>
<td style="width: 13.56%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); padding: 0 5.4pt; height: 23.4pt" nowrap="nowrap" width="13%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">YES</span></p>
</td>
<td style="width: 13.62%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); padding: 0 5.4pt; height: 23.4pt" nowrap="nowrap" width="13%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">YES</span></p>
</td>
<td style="width: 14.32%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); padding: 0 5.4pt; height: 23.4pt" nowrap="nowrap" width="14%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">YES</span></p>
</td>
<td style="width: 18.88%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); padding: 0 5.4pt; height: 23.4pt" nowrap="nowrap" width="18%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">YES </span><strong><span style="mso-bidi-font-size: 12.0pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">(</span></strong><span style="font-size: 13pt; font-family: 黑体; mso-bidi-font-family: 'Segoe UI'; mso-font-kerning: 0pt">分片</span><strong><span style="mso-bidi-font-size: 12.0pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">)</span></strong></p>
</td>
<td style="width: 19.3%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); padding: 0 5.4pt; height: 23.4pt" nowrap="nowrap" width="19%">
<p class="MsoNormal" style="margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto"><span style="font-size: 13pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">YES </span><strong><span style="mso-bidi-font-size: 12.0pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">(</span></strong><span style="font-size: 13pt; font-family: 黑体; mso-bidi-font-family: 'Segoe UI'; mso-font-kerning: 0pt">分片</span><strong><span style="mso-bidi-font-size: 12.0pt; font-family: &quot;Segoe UI&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US">)</span></strong></p>
</td>
</tr>
</tbody>
</table>
<h3>1.3.9 数据库功能和性能对比</h3>
<p><span style="font-size: 14px">  由下图可以看出MongoDB数据库的性能扩展能力及功能都较好,都能够在数据库中,站立一足之地。</span></p>
<p align="center"><img src="https://images2017.cnblogs.com/blog/1190037/201801/1190037-20180106141454581-697200462.png" alt="">&nbsp;</p>
<h3>1.3.10 MongoDB适用场景</h3>
<p>  网站数据、缓存等大尺寸、低价值的数据</p>
<p>  在高伸缩性的场景,用于对象及JSON数据的存储。</p>
<p align="center"><img src="https://images2017.cnblogs.com/blog/1190037/201801/1190037-20180106141505581-1516716311.png" alt=""></p>
<h3>1.3.11 MongoDB 慎用场景</h3>
<table class="MsoNormalTable" style="width: 100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr style="mso-yfti-irow: 0; mso-yfti-firstrow: yes; height: 41.4pt">
<td style="width: 37.9%; border-width: 1pt 1pt 3pt; border-color: rgba(255, 255, 255, 1); background: rgba(199, 218, 174, 1); padding: 3.1pt 0.75pt 0; height: 41.4pt" width="37%">
<p class="MsoNormal" style="text-align: center" align="center"><strong><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">慎用场景</span></strong></p>
</td>
<td style="width: 62.1%; border-width: 1pt 1pt 3pt initial; border-color: rgba(255, 255, 255, 1) rgba(255, 255, 255, 1) rgba(255, 255, 255, 1) initial; border-left-style: none; background: rgba(199, 218, 174, 1); padding: 3.1pt 0.75pt 0; height: 41.4pt" width="62%">
<p class="MsoNormal" style="text-align: center" align="center"><strong><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">原因</span></strong></p>
</td>
</tr>
<tr style="mso-yfti-irow: 1; height: 80.4pt">
<td style="width: 37.9%; border-width: initial 1pt 1pt; border-color: initial rgba(255, 255, 255, 1) rgba(255, 255, 255, 1); border-top-style: none; background: rgba(236, 242, 229, 1); padding: 2.9pt 0.75pt 0; height: 80.4pt" width="37%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><strong><span lang="EN-US">PB </span></strong><strong><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">数据持久存储大数据分析数据湖</span></strong></p>
</td>
<td style="width: 62.1%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(255, 255, 255, 1); border-right-width: 1pt; border-right-color: rgba(255, 255, 255, 1); background: rgba(236, 242, 229, 1); padding: 2.9pt 0.75pt 0; height: 80.4pt" width="62%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><span lang="EN-US">Hadoop</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">、</span><span lang="EN-US">Spark</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">提供更多分析运算功能和工具,并行计算能力更强</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><span lang="EN-US">MongoDB + Hadoop/Spark</span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 2; height: 70.3pt">
<td style="width: 37.9%; border-width: initial 1pt 1pt; border-color: initial rgba(255, 255, 255, 1) rgba(255, 255, 255, 1); border-top-style: none; background: rgba(245, 248, 243, 1); padding: 3.9pt 0.75pt 0; height: 70.3pt" width="37%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><strong><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">搜索场景:文档有几十个字段,需要按照任意字段搜索并排序限制等</span></strong></p>
</td>
<td style="width: 62.1%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(255, 255, 255, 1); border-right-width: 1pt; border-right-color: rgba(255, 255, 255, 1); background: rgba(245, 248, 243, 1); padding: 3.9pt 0.75pt 0; height: 70.3pt" width="62%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">不建索引查询太慢,索引太多影响写入及更新操作</span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 3; height: 64.65pt">
<td style="width: 37.9%; border-width: initial 1pt 1pt; border-color: initial rgba(255, 255, 255, 1) rgba(255, 255, 255, 1); border-top-style: none; background: rgba(236, 242, 229, 1); padding: 3.9pt 0.75pt 0; height: 64.65pt" width="37%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><strong><span lang="EN-US">ERP</span></strong><strong><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">、</span><span lang="EN-US">CRM</span></strong><strong><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">或者类似复杂应用,几十上百个对象互相关联</span></strong></p>
</td>
<td style="width: 62.1%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(255, 255, 255, 1); border-right-width: 1pt; border-right-color: rgba(255, 255, 255, 1); background: rgba(236, 242, 229, 1); padding: 3.1pt 0.75pt 0; height: 64.65pt" width="62%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">关联支持较弱,事务较弱</span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 4; height: 64.65pt">
<td style="width: 37.9%; border-width: initial 1pt 1pt; border-color: initial rgba(255, 255, 255, 1) rgba(255, 255, 255, 1); border-top-style: none; background: rgba(245, 248, 243, 1); padding: 3.9pt 0.75pt 0; height: 64.65pt" width="37%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><strong><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">需要参与远程事务,或者需要跨表,跨文档原子性更新的</span></strong></p>
</td>
<td style="width: 62.1%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(255, 255, 255, 1); border-right-width: 1pt; border-right-color: rgba(255, 255, 255, 1); background: rgba(245, 248, 243, 1); padding: 3.9pt 0.75pt 0; height: 64.65pt" width="62%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><span lang="EN-US">MongoDB&nbsp; </span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">事务支持仅限于本机的单文档事务</span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 5; mso-yfti-lastrow: yes; height: 64.65pt">
<td style="width: 37.9%; border-width: initial 1pt 1pt; border-color: initial rgba(255, 255, 255, 1) rgba(255, 255, 255, 1); border-top-style: none; background: rgba(236, 242, 229, 1); padding: 3.1pt 0.75pt 0; height: 64.65pt" width="37%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><strong><span lang="EN-US">100% </span></strong><strong><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">写可用:任何时间写入不能停</span></strong></p>
</td>
<td style="width: 62.1%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(255, 255, 255, 1); border-right-width: 1pt; border-right-color: rgba(255, 255, 255, 1); background: rgba(236, 242, 229, 1); padding: 3.9pt 0.75pt 0; height: 64.65pt" width="62%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><span lang="EN-US">MongoDB</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">换主节点时候会有短暂的不可写设计所限</span></p>
</td>
</tr>
</tbody>
</table>
<h3>1.3.12 什么时候该MongDB&nbsp;</h3>
<table class="MsoNormalTable" style="width: 100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr style="mso-yfti-irow: 0; mso-yfti-firstrow: yes; height: 34pt">
<td style="width: 67.16%; border-width: 1pt 1pt 3pt; border-color: rgba(255, 255, 255, 1); background: rgba(0, 143, 0, 1); padding: 3.1pt 0.75pt 0; height: 34pt" valign="top" width="67%">
<p class="MsoNormal" style="margin: 3.1pt 0 0.0001pt 6.5pt; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto"><span style="font-size: 18pt; font-family: 宋体; mso-bidi-font-family: 宋体; color: rgba(255, 255, 255, 1); mso-font-kerning: 0pt">应用特征</span></p>
</td>
<td style="width: 32.84%; border-width: 1pt 1pt 3pt initial; border-color: rgba(255, 255, 255, 1) rgba(255, 255, 255, 1) rgba(255, 255, 255, 1) initial; border-left-style: none; background: rgba(0, 143, 0, 1); padding: 3.1pt 0.75pt 0; height: 34pt" valign="top" width="32%">
<p class="MsoNormal" style="margin: 3.1pt 0 0.0001pt 6.5pt; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto"><strong><span style="font-size: 18pt; font-family: &quot;Calibri&quot;, sans-serif; mso-fareast-font-family: 宋体; color: rgba(255, 255, 255, 1); letter-spacing: -0.05pt; mso-font-kerning: 0pt" lang="EN-US">Yes/No?</span></strong></p>
</td>
</tr>
<tr style="mso-yfti-irow: 1; height: 49.3pt">
<td style="width: 67.16%; border-width: initial 1pt 1pt; border-color: initial rgba(255, 255, 255, 1) rgba(255, 255, 255, 1); border-top-style: none; background: rgba(236, 242, 229, 1); padding: 5.3pt 0.75pt 0; height: 49.3pt" valign="top" width="67%">
<p class="MsoNormal" style="margin: 5.3pt 0 0.0001pt 6.5pt; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto"><span style="font-size: 16pt; font-family: 宋体">我的数据量是有亿万级或者需要不断扩容</span></p>
</td>
<td style="width: 32.84%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(255, 255, 255, 1); border-right-width: 1pt; border-right-color: rgba(255, 255, 255, 1); background: rgba(236, 242, 229, 1); padding: 0.75pt 0.75pt 0; height: 49.3pt" valign="top" width="32%">&nbsp;</td>
</tr>
<tr style="mso-yfti-irow: 2; height: 37.9pt">
<td style="width: 67.16%; border-width: initial 1pt 1pt; border-color: initial rgba(255, 255, 255, 1) rgba(255, 255, 255, 1); border-top-style: none; background: rgba(245, 248, 243, 1); padding: 3.1pt 0.75pt 0; height: 37.9pt" valign="top" width="67%">
<p class="MsoNormal" style="margin: 3.1pt 0 0.0001pt 6.5pt; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto"><span style="font-size: 16pt; font-family: 宋体; letter-spacing: 0.95pt">需要<span lang="EN-US">2000-3000</span>以上的读写每秒</span></p>
</td>
<td style="width: 32.84%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(255, 255, 255, 1); border-right-width: 1pt; border-right-color: rgba(255, 255, 255, 1); background: rgba(245, 248, 243, 1); padding: 0.75pt 0.75pt 0; height: 37.9pt" valign="top" width="32%">&nbsp;</td>
</tr>
<tr style="mso-yfti-irow: 3; height: 37.9pt">
<td style="width: 67.16%; border-width: initial 1pt 1pt; border-color: initial rgba(255, 255, 255, 1) rgba(255, 255, 255, 1); border-top-style: none; background: rgba(236, 242, 229, 1); padding: 3.1pt 0.75pt 0; height: 37.9pt" valign="top" width="67%">
<p class="MsoNormal" style="margin: 3.1pt 0 0.0001pt 6.5pt; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto"><span style="font-size: 16pt; font-family: 宋体">新应用,需求会变,数据模型无法确定</span></p>
</td>
<td style="width: 32.84%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(255, 255, 255, 1); border-right-width: 1pt; border-right-color: rgba(255, 255, 255, 1); background: rgba(236, 242, 229, 1); padding: 0.75pt 0.75pt 0; height: 37.9pt" valign="top" width="32%">&nbsp;</td>
</tr>
<tr style="mso-yfti-irow: 4; height: 37.9pt">
<td style="width: 67.16%; border-width: initial 1pt 1pt; border-color: initial rgba(255, 255, 255, 1) rgba(255, 255, 255, 1); border-top-style: none; background: rgba(245, 248, 243, 1); padding: 3.1pt 0.75pt 0; height: 37.9pt" valign="top" width="67%">
<p class="MsoNormal" style="margin: 3.1pt 0 0.0001pt 6.5pt; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto"><span style="font-size: 16pt; font-family: 宋体">我需要整合多个外部数据源</span></p>
</td>
<td style="width: 32.84%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(255, 255, 255, 1); border-right-width: 1pt; border-right-color: rgba(255, 255, 255, 1); background: rgba(245, 248, 243, 1); padding: 0.75pt 0.75pt 0; height: 37.9pt" valign="top" width="32%">&nbsp;</td>
</tr>
<tr style="mso-yfti-irow: 5; height: 37.9pt">
<td style="width: 67.16%; border-width: initial 1pt 1pt; border-color: initial rgba(255, 255, 255, 1) rgba(255, 255, 255, 1); border-top-style: none; background: rgba(236, 242, 229, 1); padding: 3.1pt 0.75pt 0; height: 37.9pt" valign="top" width="67%">
<p class="MsoNormal" style="margin: 3.1pt 0 0.0001pt 6.5pt; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto"><span style="font-size: 16pt; font-family: 宋体; letter-spacing: 0.9pt">我的系统需要<span lang="EN-US">99.999%</span>高可用</span></p>
</td>
<td style="width: 32.84%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(255, 255, 255, 1); border-right-width: 1pt; border-right-color: rgba(255, 255, 255, 1); background: rgba(236, 242, 229, 1); padding: 0.75pt 0.75pt 0; height: 37.9pt" valign="top" width="32%">&nbsp;</td>
</tr>
<tr style="mso-yfti-irow: 6; height: 37.9pt">
<td style="width: 67.16%; border-width: initial 1pt 1pt; border-color: initial rgba(255, 255, 255, 1) rgba(255, 255, 255, 1); border-top-style: none; background: rgba(245, 248, 243, 1); padding: 3.1pt 0.75pt 0; height: 37.9pt" valign="top" width="67%">
<p class="MsoNormal" style="margin: 3.1pt 0 0.0001pt 6.5pt; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto"><span style="font-size: 16pt; font-family: 宋体">我的系统需要大量的地理位置查询</span></p>
</td>
<td style="width: 32.84%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(255, 255, 255, 1); border-right-width: 1pt; border-right-color: rgba(255, 255, 255, 1); background: rgba(245, 248, 243, 1); padding: 0.75pt 0.75pt 0; height: 37.9pt" valign="top" width="32%">&nbsp;</td>
</tr>
<tr style="mso-yfti-irow: 7; height: 37.9pt">
<td style="width: 67.16%; border-width: initial 1pt 1pt; border-color: initial rgba(255, 255, 255, 1) rgba(255, 255, 255, 1); border-top-style: none; background: rgba(236, 242, 229, 1); padding: 3.1pt 0.75pt 0; height: 37.9pt" valign="top" width="67%">
<p class="MsoNormal" style="margin: 3.1pt 0 0.0001pt 6.5pt; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto"><span style="font-size: 16pt; font-family: 宋体">我的系统需要提供最小的<span lang="EN-US">latency</span></span></p>
</td>
<td style="width: 32.84%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(255, 255, 255, 1); border-right-width: 1pt; border-right-color: rgba(255, 255, 255, 1); background: rgba(236, 242, 229, 1); padding: 0.75pt 0.75pt 0; height: 37.9pt" valign="top" width="32%">&nbsp;</td>
</tr>
<tr style="mso-yfti-irow: 8; mso-yfti-lastrow: yes; height: 37.9pt">
<td style="width: 67.16%; border-width: initial 1pt 1pt; border-color: initial rgba(255, 255, 255, 1) rgba(255, 255, 255, 1); border-top-style: none; background: rgba(245, 248, 243, 1); padding: 3.1pt 0.75pt 0; height: 37.9pt" valign="top" width="67%">
<p class="MsoNormal" style="margin: 3.1pt 0 0.0001pt 6.5pt; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto"><span style="font-size: 16pt; font-family: 宋体">我要管理的主要数据对象<span style="letter-spacing: 1.7pt" lang="EN-US">&lt;10</span></span></p>
</td>
<td style="width: 32.84%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(255, 255, 255, 1); border-right-width: 1pt; border-right-color: rgba(255, 255, 255, 1); background: rgba(245, 248, 243, 1); padding: 0.75pt 0.75pt 0; height: 37.9pt" valign="top" width="32%">&nbsp;</td>
</tr>
</tbody>
</table>
<p>  在上面的表格中进行选择,但有1个yes的时候:可以考虑MongoDB;当有2个以上yes的时候:不会后悔的选择!</p>
<h2>1.4 MongoDB的部署</h2>
<p>  MongoDB官网:https://www.mongodb.com/</p>
<p>  CentOS6.X版本软件下载地址:https://www.mongodb.org/dl/linux/x86_64-rhel62</p>
<p>    其他版本请到进行官网下载。</p>
<h3>1.4.1 安装前准备</h3>
<p>  在安装之前首先确认该版本软件是否支持你的操作系统。</p>
<p>    更多详情查看:https://docs.mongodb.com/manual/installation/&nbsp;</p>
<table class="MsoNormalTable" style="width: 100%; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial" border="0" cellspacing="0" cellpadding="0">
<thead>
<tr style="mso-yfti-irow: 0; mso-yfti-firstrow: yes; height: 5.15pt">
<td style="width: 16.86%; border-width: 1pt; border-color: rgba(245, 246, 247, 1); background: rgba(238, 238, 238, 1); padding: 7.5pt 9pt; height: 5.15pt" width="16%">
<p class="MsoNormal" style="margin: 18pt 0; mso-line-height-alt: 9.0pt; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto"><strong><span style="font-size: 10.5pt; font-family: &quot;Helvetica&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-bidi-font-family: 宋体; color: rgba(127, 127, 127, 1); mso-font-kerning: 0pt" lang="EN-US">Platform</span></strong></p>
</td>
<td style="width: 20.74%; border-width: 1pt 1pt 1pt initial; border-color: rgba(245, 246, 247, 1) rgba(245, 246, 247, 1) rgba(245, 246, 247, 1) initial; border-left-style: none; background: rgba(127, 127, 127, 1); padding: 9pt; height: 5.15pt" width="20%">
<p class="MsoNormal" style="margin: 18pt 0; text-align: center; mso-line-height-alt: 9.0pt; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto" align="center"><strong><span style="font-size: 10.5pt; font-family: &quot;Helvetica&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-bidi-font-family: 宋体; color: rgba(255, 255, 255, 1); mso-font-kerning: 0pt" lang="EN-US">3.6 Community &amp; Enterprise</span></strong></p>
</td>
<td style="width: 20.8%; border-width: 1pt 1pt 1pt initial; border-color: rgba(245, 246, 247, 1) rgba(245, 246, 247, 1) rgba(245, 246, 247, 1) initial; border-left-style: none; background: rgba(127, 127, 127, 1); padding: 9pt; height: 5.15pt" width="20%">
<p class="MsoNormal" style="margin: 18pt 0; text-align: center; mso-line-height-alt: 9.0pt; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto" align="center"><strong><span style="font-size: 10.5pt; font-family: &quot;Helvetica&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-bidi-font-family: 宋体; color: rgba(255, 255, 255, 1); mso-font-kerning: 0pt" lang="EN-US">3.4 Community &amp; Enterprise</span></strong></p>
</td>
<td style="width: 20.8%; border-width: 1pt 1pt 1pt initial; border-color: rgba(245, 246, 247, 1) rgba(245, 246, 247, 1) rgba(245, 246, 247, 1) initial; border-left-style: none; background: rgba(127, 127, 127, 1); padding: 9pt; height: 5.15pt" width="20%">
<p class="MsoNormal" style="margin: 18pt 0; text-align: center; mso-line-height-alt: 9.0pt; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto" align="center"><strong><span style="font-size: 10.5pt; font-family: &quot;Helvetica&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-bidi-font-family: 宋体; color: rgba(255, 255, 255, 1); mso-font-kerning: 0pt" lang="EN-US">3.2 Community &amp; Enterprise</span></strong></p>
</td>
<td style="width: 20.8%; border-width: 1pt 1pt 1pt initial; border-color: rgba(245, 246, 247, 1) rgba(245, 246, 247, 1) rgba(245, 246, 247, 1) initial; border-left-style: none; background: rgba(127, 127, 127, 1); padding: 9pt; height: 5.15pt" width="20%">
<p class="MsoNormal" style="margin: 18pt 0; text-align: center; mso-line-height-alt: 9.0pt; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto" align="center"><strong><span style="font-size: 10.5pt; font-family: &quot;Helvetica&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-bidi-font-family: 宋体; color: rgba(255, 255, 255, 1); mso-font-kerning: 0pt" lang="EN-US">3.0 Community &amp; Enterprise</span></strong></p>
</td>
</tr>
</thead>
<tbody>
<tr>
<td style="width: 16.86%; border-width: initial 1pt 1pt; border-color: initial rgba(245, 246, 247, 1) rgba(245, 246, 247, 1); border-top-style: none; background: rgba(238, 238, 238, 1); padding: 7.5pt 9pt" width="16%">
<p class="MsoNormal" style="margin: 18pt 0; mso-line-height-alt: 9.0pt; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto"><strong><span style="font-size: 10.5pt; font-family: &quot;Helvetica&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-bidi-font-family: 宋体; color: rgba(127, 127, 127, 1); mso-font-kerning: 0pt" lang="EN-US">RHEL/CentOS 6.2 and later</span></strong></p>
</td>
<td style="width: 20.74%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(245, 246, 247, 1); border-right-width: 1pt; border-right-color: rgba(245, 246, 247, 1); padding: 8.25pt 41.25pt 9pt" width="20%">
<p class="MsoNormal" style="margin: 18pt 0; text-align: center; mso-line-height-alt: 9.0pt; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto" align="center"><span style="font-size: 10.5pt; font-family: &quot;Segoe UI Symbol&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-bidi-font-family: 'Segoe UI Symbol'; color: rgba(73, 71, 71, 1); mso-font-kerning: 0pt" lang="EN-US">✓</span></p>
</td>
<td style="width: 20.8%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(245, 246, 247, 1); border-right-width: 1pt; border-right-color: rgba(245, 246, 247, 1); padding: 8.25pt 41.25pt 9pt" width="20%">
<p class="MsoNormal" style="margin: 18pt 0; text-align: center; mso-line-height-alt: 9.0pt; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto" align="center"><span style="font-size: 10.5pt; font-family: &quot;Segoe UI Symbol&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-bidi-font-family: 'Segoe UI Symbol'; color: rgba(73, 71, 71, 1); mso-font-kerning: 0pt" lang="EN-US">✓</span></p>
</td>
<td style="width: 20.8%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(245, 246, 247, 1); border-right-width: 1pt; border-right-color: rgba(245, 246, 247, 1); padding: 8.25pt 41.25pt 9pt" width="20%">
<p class="MsoNormal" style="margin: 18pt 0; text-align: center; mso-line-height-alt: 9.0pt; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto" align="center"><span style="font-size: 10.5pt; font-family: &quot;Segoe UI Symbol&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-bidi-font-family: 'Segoe UI Symbol'; color: rgba(73, 71, 71, 1); mso-font-kerning: 0pt" lang="EN-US">✓</span></p>
</td>
<td style="width: 20.8%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(245, 246, 247, 1); border-right-width: 1pt; border-right-color: rgba(245, 246, 247, 1); padding: 8.25pt 41.25pt 9pt" width="20%">
<p class="MsoNormal" style="margin: 18pt 0; text-align: center; mso-line-height-alt: 9.0pt; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto" align="center"><span style="font-size: 10.5pt; font-family: &quot;Segoe UI Symbol&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-bidi-font-family: 'Segoe UI Symbol'; color: rgba(73, 71, 71, 1); mso-font-kerning: 0pt" lang="EN-US">✓</span></p>
</td>
</tr>
<tr>
<td style="width: 16.86%; border-width: initial 1pt 1pt; border-color: initial rgba(245, 246, 247, 1) rgba(245, 246, 247, 1); border-top-style: none; background: rgba(238, 238, 238, 1); padding: 7.5pt 9pt" width="16%">
<p class="MsoNormal" style="margin: 18pt 0; mso-line-height-alt: 9.0pt; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto"><strong><span style="font-size: 10.5pt; font-family: &quot;Helvetica&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-bidi-font-family: 宋体; color: rgba(127, 127, 127, 1); mso-font-kerning: 0pt" lang="EN-US">RHEL/CentOS 7.0 and later</span></strong></p>
</td>
<td style="width: 20.74%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(245, 246, 247, 1); border-right-width: 1pt; border-right-color: rgba(245, 246, 247, 1); padding: 8.25pt 41.25pt 9pt" width="20%">
<p class="MsoNormal" style="margin: 18pt 0; text-align: center; mso-line-height-alt: 9.0pt; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto" align="center"><span style="font-size: 10.5pt; font-family: &quot;Segoe UI Symbol&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-bidi-font-family: 'Segoe UI Symbol'; color: rgba(73, 71, 71, 1); mso-font-kerning: 0pt" lang="EN-US">✓</span></p>
</td>
<td style="width: 20.8%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(245, 246, 247, 1); border-right-width: 1pt; border-right-color: rgba(245, 246, 247, 1); padding: 8.25pt 41.25pt 9pt" width="20%">
<p class="MsoNormal" style="margin: 18pt 0; text-align: center; mso-line-height-alt: 9.0pt; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto" align="center"><span style="font-size: 10.5pt; font-family: &quot;Segoe UI Symbol&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-bidi-font-family: 'Segoe UI Symbol'; color: rgba(73, 71, 71, 1); mso-font-kerning: 0pt" lang="EN-US">✓</span></p>
</td>
<td style="width: 20.8%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(245, 246, 247, 1); border-right-width: 1pt; border-right-color: rgba(245, 246, 247, 1); padding: 8.25pt 41.25pt 9pt" width="20%">
<p class="MsoNormal" style="margin: 18pt 0; text-align: center; mso-line-height-alt: 9.0pt; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto" align="center"><span style="font-size: 10.5pt; font-family: &quot;Segoe UI Symbol&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-bidi-font-family: 'Segoe UI Symbol'; color: rgba(73, 71, 71, 1); mso-font-kerning: 0pt" lang="EN-US">✓</span></p>
</td>
<td style="width: 20.8%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(245, 246, 247, 1); border-right-width: 1pt; border-right-color: rgba(245, 246, 247, 1); padding: 8.25pt 41.25pt 9pt" width="20%">
<p class="MsoNormal" style="margin: 18pt 0; text-align: center; mso-line-height-alt: 9.0pt; mso-pagination: widow-orphan; layout-grid-mode: both; mso-layout-grid-align: auto" align="center"><span style="font-size: 10.5pt; font-family: &quot;Segoe UI Symbol&quot;, sans-serif; mso-fareast-font-family: 宋体; mso-bidi-font-family: 'Segoe UI Symbol'; color: rgba(73, 71, 71, 1); mso-font-kerning: 0pt" lang="EN-US">✓</span></p>
</td>
</tr>
</tbody>
</table>
<h3>1.4.2 环境说明</h3>
<p><em style="font-size: 14px"><span style="text-decoration: underline">系统环境说明:</span></em></p>
<div>
<div class="cnblogs_code">
<pre># <span style="color: rgba(0, 0, 255, 1)">cat</span> /etc/redhat-<span style="color: rgba(0, 0, 0, 1)">release
CentOS release </span><span style="color: rgba(128, 0, 128, 1)">6.9</span><span style="color: rgba(0, 0, 0, 1)"> (Final)
# <span style="color: rgba(0, 0, 255, 1)">uname</span> -<span style="color: rgba(0, 0, 0, 1)">r
</span><span style="color: rgba(128, 0, 128, 1)">2.6</span>.<span style="color: rgba(128, 0, 128, 1)">32</span>-<span style="color: rgba(128, 0, 128, 1)">696</span><span style="color: rgba(0, 0, 0, 1)">.el6.x86_64
# /etc/init.d/<span style="color: rgba(0, 0, 0, 1)">iptables status
iptables: Firewall is not running.
# getenforce
Disabled
# <span style="color: rgba(0, 0, 255, 1)">hostname</span> -<span style="color: rgba(0, 0, 0, 1)">I
</span><span style="color: rgba(128, 0, 128, 1)">10.0</span>.<span style="color: rgba(128, 0, 128, 1)">0.152</span> <span style="color: rgba(128, 0, 128, 1)">172.16</span>.<span style="color: rgba(128, 0, 128, 1)">1.152</span></pre>
</div>
</div>
<p><strong><em><span style="text-decoration: underline">软件版本说明</span></em></strong></p>
<div>
<div class="cnblogs_code">
<pre>本次使用的mongodb版本为:mongodb-linux-x86_64-<span style="color: rgba(128, 0, 128, 1)">3.2</span>.<span style="color: rgba(128, 0, 128, 1)">8</span>.tgz</pre>
</div>
</div>
<h3>1.4.3 部署MongoDB</h3>
<p>在root用户下操作</p>
<div>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">cat</span> &gt;&gt; /etc/rc.local &lt;&lt;<span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">EOF</span><span style="color: rgba(128, 0, 0, 1)">'</span>
<span style="color: rgba(0, 0, 255, 1)">if</span> test -f /sys/kernel/mm/transparent_hugepage/enabled; <span style="color: rgba(0, 0, 255, 1)">then</span>
<span style="color: rgba(0, 0, 255, 1)">echo</span> never &gt; /sys/kernel/mm/transparent_hugepage/<span style="color: rgba(0, 0, 0, 1)">enabled
</span><span style="color: rgba(0, 0, 255, 1)">fi</span>
<span style="color: rgba(0, 0, 255, 1)">if</span> test -f /sys/kernel/mm/transparent_hugepage/defrag; <span style="color: rgba(0, 0, 255, 1)">then</span>
   <span style="color: rgba(0, 0, 255, 1)">echo</span> never &gt; /sys/kernel/mm/transparent_hugepage/<span style="color: rgba(0, 0, 0, 1)">defrag
</span><span style="color: rgba(0, 0, 255, 1)">fi</span><span style="color: rgba(0, 0, 0, 1)">
EOF</span></pre>
</div>
<p>  该方法仅限与CentOS系统使用,其他系统关闭参照官方文档:&nbsp;&nbsp;       https://docs.mongodb.com/manual/tutorial/transparent-huge-pages/</p>
</div>
<p>  Transparent Huge Pages (THP),通过使用更大的内存页面,可以减少具有大量内存的机器上的缓冲区(TLB)查找的开销。</p>
<p>  但是,数据库工作负载通常对THP表现不佳,因为它们往往具有稀疏而不是连续的内存访问模式。您应该在Linux机器上禁用THP,以确保MongoDB的最佳性能。</p>
<p><span style="background-color: rgba(255, 255, 0, 1)"><strong>创建用户 </strong></span></p>
<div>
<div class="cnblogs_code">
<pre>groupadd -g <span style="color: rgba(128, 0, 128, 1)">800</span><span style="color: rgba(0, 0, 0, 1)"> mongod
useradd</span>-u <span style="color: rgba(128, 0, 128, 1)">801</span> -g mongodmongod</pre>
</div>
</div>
<p>  修改用户密码</p>
<div>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">echo</span> <span style="color: rgba(128, 0, 128, 1)">123456</span> |<span style="color: rgba(0, 0, 255, 1)">passwd</span> --stdinmongod</pre>
</div>
</div>
<p><span style="background-color: rgba(255, 255, 0, 1)"><strong>创建程序目录</strong></span></p>
<div>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">mkdir</span> -p /application/mongodb/   &amp;&amp;<span style="color: rgba(0, 0, 0, 1)">\
cd</span>/application/mongodb/   &amp;&amp;<span style="color: rgba(0, 0, 0, 1)">\
</span><span style="color: rgba(0, 0, 255, 1)">mkdir</span>-pbinconflogdata</pre>
</div>
</div>
<p><span style="background-color: rgba(255, 255, 0, 1)"><strong>下载程序</strong></span></p>
<div>
<div class="cnblogs_code">
<pre>cd/application/mongodb/
<span style="color: rgba(0, 0, 255, 1)">wget</span> http:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">downloads.mongodb.org/linux/mongodb-linux-x86_64-rhel62-3.2.8.tgz</span></pre>
</div>
</div>
<p><span style="background-color: rgba(255, 255, 0, 1)"><strong>解压程序</strong></span></p>
<div>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">tar</span> xfmongodb-linux-x86_64-<span style="color: rgba(128, 0, 128, 1)">3.2</span>.<span style="color: rgba(128, 0, 128, 1)">8</span><span style="color: rgba(0, 0, 0, 1)">.tgz
cd mongodb</span>-linux-x86_64-<span style="color: rgba(128, 0, 128, 1)">3.2</span>.<span style="color: rgba(128, 0, 128, 1)">8</span>/bin/ &amp;&amp;<span style="color: rgba(0, 0, 0, 1)">\
</span><span style="color: rgba(0, 0, 255, 1)">cp</span> * /mongodb/bin</pre>
</div>
</div>
<p><span style="background-color: rgba(255, 255, 0, 1)"><strong>修改程序属主</strong></span></p>
<div>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">chown</span> -R mongod:mongod /application/mongodb</pre>
</div>
</div>
<p>  切换到mongod用户,设置用户环境变量</p>
<div>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">su</span> - mongod</pre>
</div>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">cat</span> &gt;&gt; .bash_profile &lt;&lt;<span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">EOF</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)">
export PATH</span>=/mongodb/<span style="color: rgba(0, 0, 0, 1)">bin:$PATH
EOF
source .bashprofile</span></pre>
</div>
</div>
<p>  &nbsp;<span style="background-color: rgba(0, 255, 0, 1)">&nbsp; <strong>至此,MongoDB</strong><strong>数据库部署完成</strong></span></p>
<h3>1.4.4 管理MongoDB</h3>
<p>  数据库的启动与关闭</p>
<div>
<div class="cnblogs_code">
<pre>启动:mongod --dbpath=/application/mongodb/data --logpath=/application/mongodb/log/mongodb.log --port=<span style="color: rgba(128, 0, 128, 1)">27017</span> --logappend --<span style="color: rgba(0, 0, 0, 1)">fork
关闭:mongod </span>--shutdown--dbpath=/application/mongodb/data --logpath=/application/mongodb/log/mongodb.log --port=<span style="color: rgba(128, 0, 128, 1)">27017</span> --logappend --fork</pre>
</div>
</div>
<p>&nbsp;&nbsp; 参数说明:&nbsp;</p>
<table class="MsoTable15Grid4Accent1" style="width: 100%; border-style: none" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="width: 32.48%; border-width: 1pt initial 1pt 1pt; border-color: rgba(79, 129, 189, 1) initial rgba(79, 129, 189, 1) rgba(79, 129, 189, 1); border-right-style: none; background: rgba(79, 129, 189, 1); padding: 0 5.4pt" valign="top" width="32%">
<p class="MsoNormal"><strong><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; color: rgba(255, 255, 255, 1); mso-themecolor: background1">参数</span></strong></p>
</td>
<td style="width: 67.52%; border-width: 1pt 1pt 1pt initial; border-color: rgba(79, 129, 189, 1) rgba(79, 129, 189, 1) rgba(79, 129, 189, 1) initial; border-left-style: none; background: rgba(79, 129, 189, 1); padding: 0 5.4pt" valign="top" width="67%">
<p class="MsoNormal"><strong><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; color: rgba(255, 255, 255, 1); mso-themecolor: background1">参数说明</span></strong></p>
</td>
</tr>
<tr>
<td style="width: 32.48%; border-width: initial 1pt 1pt; border-color: initial rgba(149, 179, 215, 1) rgba(149, 179, 215, 1); border-top-style: none; background: rgba(219, 229, 241, 1); padding: 0 5.4pt" valign="top" width="32%">
<p class="MsoNormal"><strong><span lang="EN-US">--dbpath&nbsp;&nbsp;&nbsp;&nbsp; </span></strong></p>
</td>
<td style="width: 67.52%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(149, 179, 215, 1); border-right-width: 1pt; border-right-color: rgba(149, 179, 215, 1); background: rgba(219, 229, 241, 1); padding: 0 5.4pt" valign="top" width="67%">
<p class="MsoNormal"><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">数据存放路径</span></p>
</td>
</tr>
<tr>
<td style="width: 32.48%; border-width: initial 1pt 1pt; border-color: initial rgba(149, 179, 215, 1) rgba(149, 179, 215, 1); border-top-style: none; padding: 0 5.4pt" valign="top" width="32%">
<p class="MsoNormal"><strong><span lang="EN-US">--logpath&nbsp;&nbsp;&nbsp; </span></strong></p>
</td>
<td style="width: 67.52%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(149, 179, 215, 1); border-right-width: 1pt; border-right-color: rgba(149, 179, 215, 1); padding: 0 5.4pt" valign="top" width="67%">
<p class="MsoNormal"><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">日志文件路径</span></p>
</td>
</tr>
<tr>
<td style="width: 32.48%; border-width: initial 1pt 1pt; border-color: initial rgba(149, 179, 215, 1) rgba(149, 179, 215, 1); border-top-style: none; background: rgba(219, 229, 241, 1); padding: 0 5.4pt" valign="top" width="32%">
<p class="MsoNormal"><strong><span lang="EN-US">--logappend&nbsp; </span></strong></p>
</td>
<td style="width: 67.52%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(149, 179, 215, 1); border-right-width: 1pt; border-right-color: rgba(149, 179, 215, 1); background: rgba(219, 229, 241, 1); padding: 0 5.4pt" valign="top" width="67%">
<p class="MsoNormal"><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">日志输出方式</span></p>
</td>
</tr>
<tr>
<td style="width: 32.48%; border-width: initial 1pt 1pt; border-color: initial rgba(149, 179, 215, 1) rgba(149, 179, 215, 1); border-top-style: none; padding: 0 5.4pt" valign="top" width="32%">
<p class="MsoNormal"><strong><span lang="EN-US">--port&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></strong></p>
</td>
<td style="width: 67.52%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(149, 179, 215, 1); border-right-width: 1pt; border-right-color: rgba(149, 179, 215, 1); padding: 0 5.4pt" valign="top" width="67%">
<p class="MsoNormal"><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">启用端口号</span></p>
</td>
</tr>
<tr>
<td style="width: 32.48%; border-width: initial 1pt 1pt; border-color: initial rgba(149, 179, 215, 1) rgba(149, 179, 215, 1); border-top-style: none; background: rgba(219, 229, 241, 1); padding: 0 5.4pt" valign="top" width="32%">
<p class="MsoNormal"><strong><span lang="EN-US">--fork&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></strong></p>
</td>
<td style="width: 67.52%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(149, 179, 215, 1); border-right-width: 1pt; border-right-color: rgba(149, 179, 215, 1); background: rgba(219, 229, 241, 1); padding: 0 5.4pt" valign="top" width="67%">
<p class="MsoNormal"><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">在后台运行</span></p>
</td>
</tr>
<tr>
<td style="width: 32.48%; border-width: initial 1pt 1pt; border-color: initial rgba(149, 179, 215, 1) rgba(149, 179, 215, 1); border-top-style: none; padding: 0 5.4pt" valign="top" width="32%">
<p class="MsoNormal"><strong><span lang="EN-US">--auth&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></strong></p>
</td>
<td style="width: 67.52%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(149, 179, 215, 1); border-right-width: 1pt; border-right-color: rgba(149, 179, 215, 1); padding: 0 5.4pt" valign="top" width="67%">
<p class="MsoNormal"><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">是否需要验证权限登录</span><span lang="EN-US">(</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">用户名和密码</span><span lang="EN-US">)</span></p>
</td>
</tr>
<tr>
<td style="width: 32.48%; border-width: initial 1pt 1pt; border-color: initial rgba(149, 179, 215, 1) rgba(149, 179, 215, 1); border-top-style: none; background: rgba(219, 229, 241, 1); padding: 0 5.4pt" valign="top" width="32%">
<p class="MsoNormal"><strong><span lang="EN-US">--bind_ip&nbsp;&nbsp;&nbsp; </span></strong></p>
</td>
<td style="width: 67.52%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(149, 179, 215, 1); border-right-width: 1pt; border-right-color: rgba(149, 179, 215, 1); background: rgba(219, 229, 241, 1); padding: 0 5.4pt" valign="top" width="67%">
<p class="MsoNormal"><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">限制访问的</span><span lang="EN-US">ip</span></p>
</td>
</tr>
<tr>
<td style="width: 32.48%; border-width: initial 1pt 1pt; border-color: initial rgba(149, 179, 215, 1) rgba(149, 179, 215, 1); border-top-style: none; padding: 0 5.4pt" valign="top" width="32%">
<p class="MsoNormal"><strong><span lang="EN-US">--shutdown</span></strong></p>
</td>
<td style="width: 67.52%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(149, 179, 215, 1); border-right-width: 1pt; border-right-color: rgba(149, 179, 215, 1); padding: 0 5.4pt" valign="top" width="67%">
<p class="MsoNormal"><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">关闭数据库</span></p>
</td>
</tr>
</tbody>
</table>
<p>登入数据库</p>
<div>
<div class="cnblogs_code">
<pre>$ mongo
MongoDB shell version: </span><span style="color: rgba(128, 0, 128, 1)">3.2</span>.<span style="color: rgba(128, 0, 128, 1)">8</span><span style="color: rgba(0, 0, 0, 1)">
connecting to: test
</span>&gt;</pre>
</div>
</div>
<p><em><span style="text-decoration: underline">使用配置文件的方式管理数据库:</span></em></p>
<p><strong>  <span style="background-color: rgba(0, 255, 0, 1)">普通格式配置文件</span></strong><span style="background-color: rgba(0, 255, 0, 1)"><strong>:</strong></span></p>
<div>
<div class="cnblogs_code">
<pre>cd /application/mongodb/conf/<span style="color: rgba(0, 0, 0, 1)">
$ vim mongod1.conf
dbpath</span>=/application/mongodb/<span style="color: rgba(0, 0, 0, 1)">data
logpath</span>=/application/mongodb/log/<span style="color: rgba(0, 0, 0, 1)">mongodb.log
port</span>=<span style="color: rgba(128, 0, 128, 1)">27017</span><span style="color: rgba(0, 0, 0, 1)">
logappend</span>=<span style="color: rgba(128, 0, 128, 1)">1</span><span style="color: rgba(0, 0, 0, 1)">
fork</span>=<span style="color: rgba(128, 0, 128, 1)">1</span></pre>
</div>
</div>
<p>&nbsp;&nbsp; 使用配置文件时的启动与关闭:</p>
<div>
<div class="cnblogs_code">
<pre>启动:mongod -<span style="color: rgba(0, 0, 0, 1)">f mongod1.conf
关闭:mongod </span>-f mongod1.conf--shutdown</pre>
</div>
<p> <span style="background-color: rgba(0, 255, 0, 1)"> <strong>YAML</strong><strong>格式配置文件(3.X </strong><strong>版本官方推荐使用)</strong></span></p>
</div>
<div>
<div class="cnblogs_code">
<pre>$ <span style="color: rgba(0, 0, 255, 1)">cat</span><span style="color: rgba(0, 0, 0, 1)">mongod.conf
systemLog:
   destination: </span><span style="color: rgba(0, 0, 255, 1)">file</span><span style="color: rgba(0, 0, 0, 1)">
   path: </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">/application/mongodb/log/mongod.log</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">
   logAppend: </span><span style="color: rgba(0, 0, 255, 1)">true</span><span style="color: rgba(0, 0, 0, 1)">
storage:
   journal:
      enabled: </span><span style="color: rgba(0, 0, 255, 1)">true</span><span style="color: rgba(0, 0, 0, 1)">
   dbPath: </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">/application/mongodb/data</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">
processManagement:
   fork: </span><span style="color: rgba(0, 0, 255, 1)">true</span><span style="color: rgba(0, 0, 0, 1)">
net:
   port: </span><span style="color: rgba(128, 0, 128, 1)">27017</span></pre>
</div>
</div>
<p>在数据库中关闭数据库的方法</p>
<div>
<div class="cnblogs_code">
<pre>shell &gt;<span style="color: rgba(0, 0, 0, 1)"> mongo
$ mongo
MongoDB shell version: </span><span style="color: rgba(128, 0, 128, 1)">3.2</span>.<span style="color: rgba(128, 0, 128, 1)">8</span><span style="color: rgba(0, 0, 0, 1)">
connecting to: test
</span>&gt;<span style="color: rgba(0, 0, 0, 1)"> db.shutdownServer()
shutdown command only works with the admin database; try </span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">use admin</span><span style="color: rgba(128, 0, 0, 1)">'</span>
&gt;<span style="color: rgba(0, 0, 0, 1)"> use admin
</span>&gt;<span style="color: rgba(0, 0, 0, 1)"> db.shutdownServer()
server should be down...</span></pre>
</div>
</div>
<div>
<p class="a3">注:</p>
<blockquote>
<p class="a3" style="color: rgba(0, 0, 0, 1)">mongod进程收到SIGINT信号或者SIGTERM信号,会做一些处理</p>
<p class="a3" style="color: rgba(0, 0, 0, 1)">&gt; 关闭所有打开的连接</p>
<p class="a3" style="color: rgba(0, 0, 0, 1)">&gt; 将内存数据强制刷新到磁盘</p>
<p class="a3" style="color: rgba(0, 0, 0, 1)">&gt; 当前的操作执行完毕</p>
<p class="a3" style="color: rgba(0, 0, 0, 1)">&gt; 安全停止</p>
<p class="a3" style="color: rgba(0, 0, 0, 1)"><strong>  <span style="color: rgba(255, 0, 0, 1)">切忌kill -9</span></strong></p>
<p class="a3">&nbsp;</p>
<p class="a3" style="color: rgba(0, 0, 0, 1)">&nbsp;  数据库直接关闭,数据丢失,数据文件损失,修复数据库(成本高,有风险)</p>
</blockquote>
</div>
<p><strong>&nbsp;&nbsp; </strong><strong>使用kill</strong><strong>命令关闭进程</strong></p>
<div>
<div class="cnblogs_code">
<pre>$ <span style="color: rgba(0, 0, 255, 1)">kill</span> -<span style="color: rgba(128, 0, 128, 1)">2</span><span style="color: rgba(0, 0, 0, 1)"> PID
  原理:</span>-<span style="color: rgba(0, 0, 0, 1)">2表示向mongod进程发送SIGINT信号。

$ </span><span style="color: rgba(0, 0, 255, 1)">kill</span> -<span style="color: rgba(128, 0, 128, 1)">4</span><span style="color: rgba(0, 0, 0, 1)"> PID
  原理:</span>-4表示向mognod进程发送SIGTERM信号。</pre>
</div>
</div>
<p><span style="background-color: rgba(0, 255, 0, 1)"><strong><em><span style="text-decoration: underline">使用脚本管理mongodb</span></em></strong><strong><em><span style="text-decoration: underline">服务</span></em></strong></span></p>
<p>&nbsp;&nbsp; 注:该脚本可以直接在root用户下运行</p>
<div>
<div class="cnblogs_code"><img id="code_img_closed_a536c7f0-5f93-49a1-bde2-20c8eb3f49ad" class="code_img_closed" src="https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif" alt=""><img id="code_img_opened_a536c7f0-5f93-49a1-bde2-20c8eb3f49ad" class="code_img_opened" style="display: none" src="https://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif" alt="">
<div id="cnblogs_code_open_a536c7f0-5f93-49a1-bde2-20c8eb3f49ad" class="cnblogs_code_hide">
<pre><span style="color: rgba(0, 128, 128, 1)"> 1</span> # <span style="color: rgba(0, 0, 255, 1)">cat</span>/etc/init.d/<span style="color: rgba(0, 0, 0, 1)">mongod
</span><span style="color: rgba(0, 128, 128, 1)"> 2</span> #!/bin/<span style="color: rgba(0, 0, 0, 1)">bash
</span><span style="color: rgba(0, 128, 128, 1)"> 3</span> <span style="color: rgba(0, 0, 0, 1)">#
</span><span style="color: rgba(0, 128, 128, 1)"> 4</span> # chkconfig: <span style="color: rgba(128, 0, 128, 1)">2345</span> <span style="color: rgba(128, 0, 128, 1)">80</span> <span style="color: rgba(128, 0, 128, 1)">90</span>
<span style="color: rgba(0, 128, 128, 1)"> 5</span> <span style="color: rgba(0, 0, 0, 1)"># description:mongodb
</span><span style="color: rgba(0, 128, 128, 1)"> 6</span> <span style="color: rgba(0, 0, 0, 1)"># by clsn
</span><span style="color: rgba(0, 128, 128, 1)"> 7</span> # blog_url http:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">blog.nmtui.com</span>
<span style="color: rgba(0, 128, 128, 1)"> 8</span> <span style="color: rgba(0, 0, 0, 1)">#################################
</span><span style="color: rgba(0, 128, 128, 1)"> 9</span>
<span style="color: rgba(0, 128, 128, 1)">10</span> MONGODIR=/application/<span style="color: rgba(0, 0, 0, 1)">mongodb
</span><span style="color: rgba(0, 128, 128, 1)">11</span> MONGOD=$MONGODIR/bin/<span style="color: rgba(0, 0, 0, 1)">mongod
</span><span style="color: rgba(0, 128, 128, 1)">12</span> MONGOCONF=$MONGODIR/conf/<span style="color: rgba(0, 0, 0, 1)">mongod.conf
</span><span style="color: rgba(0, 128, 128, 1)">13</span> InfoFile=/tmp/<span style="color: rgba(0, 0, 0, 1)">start.mongo
</span><span style="color: rgba(0, 128, 128, 1)">14</span>
<span style="color: rgba(0, 128, 128, 1)">15</span> . /etc/init.d/<span style="color: rgba(0, 0, 0, 1)">functions
</span><span style="color: rgba(0, 128, 128, 1)">16</span>
<span style="color: rgba(0, 128, 128, 1)">17</span> <span style="color: rgba(0, 0, 0, 1)">status(){
</span><span style="color: rgba(0, 128, 128, 1)">18</span>   PID=`<span style="color: rgba(0, 0, 255, 1)">awk</span> <span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">NR==2{print $NF}</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)"> $InfoFile`
</span><span style="color: rgba(0, 128, 128, 1)">19</span>   Run_Num=`<span style="color: rgba(0, 0, 255, 1)">ps</span> -p $PID|<span style="color: rgba(0, 0, 255, 1)">wc</span> -<span style="color: rgba(0, 0, 0, 1)">l`
</span><span style="color: rgba(0, 128, 128, 1)">20</span>   <span style="color: rgba(0, 0, 255, 1)">if</span> [ $Run_Num -eq <span style="color: rgba(128, 0, 128, 1)">2</span> ]; <span style="color: rgba(0, 0, 255, 1)">then</span>
<span style="color: rgba(0, 128, 128, 1)">21</span>   <span style="color: rgba(0, 0, 255, 1)">echo</span> <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">MongoDB is running</span><span style="color: rgba(128, 0, 0, 1)">"</span>
<span style="color: rgba(0, 128, 128, 1)">22</span>   <span style="color: rgba(0, 0, 255, 1)">else</span>
<span style="color: rgba(0, 128, 128, 1)">23</span>   <span style="color: rgba(0, 0, 255, 1)">echo</span> <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">MongoDB is shutdown</span><span style="color: rgba(128, 0, 0, 1)">"</span>
<span style="color: rgba(0, 128, 128, 1)">24</span>   return <span style="color: rgba(128, 0, 128, 1)">3</span>
<span style="color: rgba(0, 128, 128, 1)">25</span>   <span style="color: rgba(0, 0, 255, 1)">fi</span>
<span style="color: rgba(0, 128, 128, 1)">26</span> <span style="color: rgba(0, 0, 0, 1)">}
</span><span style="color: rgba(0, 128, 128, 1)">27</span>
<span style="color: rgba(0, 128, 128, 1)">28</span> <span style="color: rgba(0, 0, 0, 1)">start() {
</span><span style="color: rgba(0, 128, 128, 1)">29</span>   status &amp;&gt;/dev/<span style="color: rgba(0, 0, 255, 1)">null</span>
<span style="color: rgba(0, 128, 128, 1)">30</span>   <span style="color: rgba(0, 0, 255, 1)">if</span> [ $? -ne <span style="color: rgba(128, 0, 128, 1)">3</span> ];<span style="color: rgba(0, 0, 255, 1)">then</span>
<span style="color: rgba(0, 128, 128, 1)">31</span>   action <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">启动MongoDB,服务运行中...</span><span style="color: rgba(128, 0, 0, 1)">"</span>/bin/<span style="color: rgba(0, 0, 255, 1)">false</span>
<span style="color: rgba(0, 128, 128, 1)">32</span>   exit <span style="color: rgba(128, 0, 128, 1)">2</span>
<span style="color: rgba(0, 128, 128, 1)">33</span>   <span style="color: rgba(0, 0, 255, 1)">fi</span>
<span style="color: rgba(0, 128, 128, 1)">34</span>   <span style="color: rgba(0, 0, 255, 1)">sudo</span> <span style="color: rgba(0, 0, 255, 1)">su</span> - mongod -c <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">$MONGOD -f $MONGOCONF</span><span style="color: rgba(128, 0, 0, 1)">"</span> &gt;$InfoFile <span style="color: rgba(128, 0, 128, 1)">2</span>&gt;/dev/<span style="color: rgba(0, 0, 255, 1)">null</span>
<span style="color: rgba(0, 128, 128, 1)">35</span>   <span style="color: rgba(0, 0, 255, 1)">if</span> [ $? -eq <span style="color: rgba(128, 0, 128, 1)">0</span> ];<span style="color: rgba(0, 0, 255, 1)">then</span>
<span style="color: rgba(0, 128, 128, 1)">36</span>   action <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">启动MongoDB</span><span style="color: rgba(128, 0, 0, 1)">"</span>/bin/<span style="color: rgba(0, 0, 255, 1)">true</span>
<span style="color: rgba(0, 128, 128, 1)">37</span>   <span style="color: rgba(0, 0, 255, 1)">else</span>
<span style="color: rgba(0, 128, 128, 1)">38</span>   action <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">启动MongoDB</span><span style="color: rgba(128, 0, 0, 1)">"</span>/bin/<span style="color: rgba(0, 0, 255, 1)">false</span>
<span style="color: rgba(0, 128, 128, 1)">39</span>   <span style="color: rgba(0, 0, 255, 1)">fi</span>
<span style="color: rgba(0, 128, 128, 1)">40</span> <span style="color: rgba(0, 0, 0, 1)">}
</span><span style="color: rgba(0, 128, 128, 1)">41</span>
<span style="color: rgba(0, 128, 128, 1)">42</span>
<span style="color: rgba(0, 128, 128, 1)">43</span> <span style="color: rgba(0, 0, 0, 1)">stop() {
</span><span style="color: rgba(0, 128, 128, 1)">44</span>   <span style="color: rgba(0, 0, 255, 1)">sudo</span> <span style="color: rgba(0, 0, 255, 1)">su</span> - mongod -c <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">$MONGOD -f $MONGOCONF --shutdown</span><span style="color: rgba(128, 0, 0, 1)">"</span>&amp;&gt;/dev/<span style="color: rgba(0, 0, 255, 1)">null</span>
<span style="color: rgba(0, 128, 128, 1)">45</span>   <span style="color: rgba(0, 0, 255, 1)">if</span> [ $? -eq <span style="color: rgba(128, 0, 128, 1)">0</span> ];<span style="color: rgba(0, 0, 255, 1)">then</span>
<span style="color: rgba(0, 128, 128, 1)">46</span>   action <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">停止MongoDB</span><span style="color: rgba(128, 0, 0, 1)">"</span>/bin/<span style="color: rgba(0, 0, 255, 1)">true</span>
<span style="color: rgba(0, 128, 128, 1)">47</span>   <span style="color: rgba(0, 0, 255, 1)">else</span>
<span style="color: rgba(0, 128, 128, 1)">48</span>   action <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">停止MongoDB</span><span style="color: rgba(128, 0, 0, 1)">"</span>/bin/<span style="color: rgba(0, 0, 255, 1)">false</span>
<span style="color: rgba(0, 128, 128, 1)">49</span>   <span style="color: rgba(0, 0, 255, 1)">fi</span>
<span style="color: rgba(0, 128, 128, 1)">50</span> <span style="color: rgba(0, 0, 0, 1)">}
</span><span style="color: rgba(0, 128, 128, 1)">51</span>
<span style="color: rgba(0, 128, 128, 1)">52</span>
<span style="color: rgba(0, 128, 128, 1)">53</span> <span style="color: rgba(0, 0, 255, 1)">case</span> <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">$1</span><span style="color: rgba(128, 0, 0, 1)">"</span> <span style="color: rgba(0, 0, 255, 1)">in</span>
<span style="color: rgba(0, 128, 128, 1)">54</span> <span style="color: rgba(0, 0, 0, 1)">start)
</span><span style="color: rgba(0, 128, 128, 1)">55</span> <span style="color: rgba(0, 0, 0, 1)">    start
</span><span style="color: rgba(0, 128, 128, 1)">56</span> <span style="color: rgba(0, 0, 0, 1)">    ;;
</span><span style="color: rgba(0, 128, 128, 1)">57</span> <span style="color: rgba(0, 0, 0, 1)">stop)
</span><span style="color: rgba(0, 128, 128, 1)">58</span> <span style="color: rgba(0, 0, 0, 1)">    stop
</span><span style="color: rgba(0, 128, 128, 1)">59</span> <span style="color: rgba(0, 0, 0, 1)">    ;;
</span><span style="color: rgba(0, 128, 128, 1)">60</span> <span style="color: rgba(0, 0, 0, 1)">restart)
</span><span style="color: rgba(0, 128, 128, 1)">61</span> <span style="color: rgba(0, 0, 0, 1)">    stop
</span><span style="color: rgba(0, 128, 128, 1)">62</span>   <span style="color: rgba(0, 0, 255, 1)">sleep</span> <span style="color: rgba(128, 0, 128, 1)">2</span>
<span style="color: rgba(0, 128, 128, 1)">63</span> <span style="color: rgba(0, 0, 0, 1)">    start
</span><span style="color: rgba(0, 128, 128, 1)">64</span> <span style="color: rgba(0, 0, 0, 1)">    ;;
</span><span style="color: rgba(0, 128, 128, 1)">65</span> <span style="color: rgba(0, 0, 0, 1)">status)
</span><span style="color: rgba(0, 128, 128, 1)">66</span> <span style="color: rgba(0, 0, 0, 1)">    status
</span><span style="color: rgba(0, 128, 128, 1)">67</span> <span style="color: rgba(0, 0, 0, 1)">    ;;
</span><span style="color: rgba(0, 128, 128, 1)">68</span>   *<span style="color: rgba(0, 0, 0, 1)">)
</span><span style="color: rgba(0, 128, 128, 1)">69</span>   <span style="color: rgba(0, 0, 255, 1)">echo</span> $<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">Usage: $0 {start|stop|restart|status}</span><span style="color: rgba(128, 0, 0, 1)">"</span>
<span style="color: rgba(0, 128, 128, 1)">70</span>   exit <span style="color: rgba(128, 0, 128, 1)">1</span>
<span style="color: rgba(0, 128, 128, 1)">71</span> <span style="color: rgba(0, 0, 255, 1)">esac</span></pre>
</div>
<span class="cnblogs_code_collapse">View Code 脚本管理mongodb服务</span><span style="background-color: rgba(255, 255, 255, 1); font-family: &quot;PingFang SC&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-size: 14px">&nbsp;</span></div>
</div>
<h2>1.5 MongoDB的基本操作</h2>
<p>Mongodb中关键字种类:</p>
<div>
<blockquote>
<p class="a3" style="color: rgba(0, 0, 0, 1)">db(数据库实例级别)</p>
<p class="a3" style="color: rgba(0, 0, 0, 1)">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;db本身</p>
<p class="a3" style="color: rgba(0, 0, 0, 1)">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;db.connection 数据库下的集合信息</p>
<p class="a3" style="color: rgba(0, 0, 0, 1)">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;db.collection.xxx(</p>
<p class="a3" style="color: rgba(0, 0, 0, 1)">rs(复制集级别)</p>
<p class="a3">&nbsp;</p>
<p class="a3" style="color: rgba(0, 0, 0, 1)">sh(分片级别)</p>
</blockquote>
</div>
<h3>1.5.1 查询操作</h3>
<p>在客户端指定数据库进行连接:(默认连接本机test数据库)</p>
<div>
<div class="cnblogs_code">
<pre>$ mongo <span style="color: rgba(128, 0, 128, 1)">10.0</span>.<span style="color: rgba(128, 0, 128, 1)">0.152</span>/<span style="color: rgba(0, 0, 0, 1)">admin
MongoDB shell version: </span><span style="color: rgba(128, 0, 128, 1)">3.2</span>.<span style="color: rgba(128, 0, 128, 1)">8</span><span style="color: rgba(0, 0, 0, 1)">
connecting to: </span><span style="color: rgba(128, 0, 128, 1)">10.0</span>.<span style="color: rgba(128, 0, 128, 1)">0.152</span>/<span style="color: rgba(0, 0, 0, 1)">admin
</span>&gt;<span style="color: rgba(0, 0, 0, 1)"> db
admin</span></pre>
</div>
</div>
<p>查看当前数据库版本</p>
<div>
<div class="cnblogs_code">
<pre>&gt;<span style="color: rgba(0, 0, 0, 1)"> db.version()
</span><span style="color: rgba(128, 0, 128, 1)">3.2</span>.<span style="color: rgba(128, 0, 128, 1)">8</span></pre>
</div>
</div>
<p>切换数据库</p>
<div>
<div class="cnblogs_code">
<pre>&gt;<span style="color: rgba(0, 0, 0, 1)"> use test;
switched to db test</span></pre>
</div>
</div>
<p>显示当前数据库</p>
<div>
<div class="cnblogs_code">
<pre>&gt;<span style="color: rgba(0, 0, 0, 1)"> db
test
</span>&gt;<span style="color: rgba(0, 0, 0, 1)"> db.getName()
test</span></pre>
</div>
</div>
<p>查询所有数据库</p>
<div>
<div class="cnblogs_code">
<pre><span style="color: rgba(128, 128, 128, 1)">&gt;</span><span style="color: rgba(0, 0, 0, 1)"> show dbs;
clsn   </span><span style="color: rgba(128, 0, 0, 1); font-weight: bold">0</span><span style="color: rgba(0, 0, 0, 1)">.000GB
local</span><span style="color: rgba(128, 0, 0, 1); font-weight: bold">0</span><span style="color: rgba(0, 0, 0, 1)">.000GB
test   </span><span style="color: rgba(128, 0, 0, 1); font-weight: bold">0</span><span style="color: rgba(0, 0, 0, 1)">.000GB
</span><span style="color: rgba(128, 128, 128, 1)">&gt;</span><span style="color: rgba(0, 0, 0, 1)"> show databases;
clsn   </span><span style="color: rgba(128, 0, 0, 1); font-weight: bold">0</span><span style="color: rgba(0, 0, 0, 1)">.000GB
local</span><span style="color: rgba(128, 0, 0, 1); font-weight: bold">0</span><span style="color: rgba(0, 0, 0, 1)">.000GB
test   </span><span style="color: rgba(128, 0, 0, 1); font-weight: bold">0</span>.000GB</pre>
</div>
</div>
<p>查看clsn数据库当前状态</p>
<div>
<div class="cnblogs_code">
<pre>&gt; <span style="color: rgba(0, 0, 255, 1)">use</span><span style="color: rgba(0, 0, 0, 1)"> clsn;
</span>&gt;<span style="color: rgba(0, 0, 0, 1)"> db.stats()
{
    </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">db</span><span style="color: rgba(128, 0, 0, 1)">"</span> : <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">clsn</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">,
    </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">collections</span><span style="color: rgba(128, 0, 0, 1)">"</span> : <span style="color: rgba(128, 0, 128, 1)">1</span><span style="color: rgba(0, 0, 0, 1)">,
    </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">objects</span><span style="color: rgba(128, 0, 0, 1)">"</span> : <span style="color: rgba(128, 0, 128, 1)">10000</span><span style="color: rgba(0, 0, 0, 1)">,
    </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">avgObjSize</span><span style="color: rgba(128, 0, 0, 1)">"</span> : <span style="color: rgba(128, 0, 128, 1)">80</span><span style="color: rgba(0, 0, 0, 1)">,
    </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">dataSize</span><span style="color: rgba(128, 0, 0, 1)">"</span> : <span style="color: rgba(128, 0, 128, 1)">800000</span><span style="color: rgba(0, 0, 0, 1)">,
    </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">storageSize</span><span style="color: rgba(128, 0, 0, 1)">"</span> : <span style="color: rgba(128, 0, 128, 1)">258048</span><span style="color: rgba(0, 0, 0, 1)">,
    </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">numExtents</span><span style="color: rgba(128, 0, 0, 1)">"</span> : <span style="color: rgba(128, 0, 128, 1)">0</span><span style="color: rgba(0, 0, 0, 1)">,
    </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">indexes</span><span style="color: rgba(128, 0, 0, 1)">"</span> : <span style="color: rgba(128, 0, 128, 1)">1</span><span style="color: rgba(0, 0, 0, 1)">,
    </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">indexSize</span><span style="color: rgba(128, 0, 0, 1)">"</span> : <span style="color: rgba(128, 0, 128, 1)">94208</span><span style="color: rgba(0, 0, 0, 1)">,
    </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">ok</span><span style="color: rgba(128, 0, 0, 1)">"</span> : <span style="color: rgba(128, 0, 128, 1)">1</span><span style="color: rgba(0, 0, 0, 1)">
}</span></pre>
</div>
</div>
<p>查看当前数据库的连接机器地址</p>
<div>
<div class="cnblogs_code">
<pre>&gt;<span style="color: rgba(0, 0, 0, 1)"> db.getMongo()
connection to </span>127.0.0.1</pre>
</div>
</div>
<h3>1.5.2 数据管理</h3>
<p>创建数据库</p>
<div>
<div class="cnblogs_code">
<pre>&gt; use clsn;</pre>
</div>
</div>
<p><strong><em><span style="text-decoration: underline">说明:</span></em></strong></p>
<div>
<blockquote>
<div style="color: rgba(0, 0, 0, 1)">
<p class="a3">创建数据库:</p>
<p class="a3">当use的时候,系统就会自动创建一个数据库。</p>
<p class="a3">如果use之后没有创建任何集合。系统就会删除这个数据库。</p>
</div>
</blockquote>
</div>
<div>
<p class="ac">删除数据库</p>
<div class="cnblogs_code">
<pre>&gt;<span style="color: rgba(0, 0, 0, 1)"> show dbs;
clsn   </span>0<span style="color: rgba(0, 0, 0, 1)">.000GB
local</span>0<span style="color: rgba(0, 0, 0, 1)">.000GB
test   </span>0<span style="color: rgba(0, 0, 0, 1)">.000GB
</span>&gt;<span style="color: rgba(0, 0, 0, 1)"> use clsn
switched to db clsn
</span>&gt;<span style="color: rgba(0, 0, 0, 1)"> db.dropDatabase()
{ </span>"dropped" : "clsn", "ok" : 1 }</pre>
</div>
</div>
<p>说明:</p>
<div>
<blockquote>
<p class="a3" style="color: rgba(0, 0, 0, 1)">删除数据库:</p>
<p class="a3">&nbsp;</p>
<p class="a3" style="color: rgba(0, 0, 0, 1)">  如果没有选择任何数据库,会删除默认的test数据库</p>
</blockquote>
</div>
<p><span style="background-color: rgba(0, 255, 0, 1)"><strong>创建集合</strong></span></p>
<p>&nbsp;&nbsp; 方法一:</p>
<div>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 0, 1)">&gt; use clsn;
switched to db clsn
&gt; db.createCollection('a')
{ "ok" : 1 }
&gt; db.createCollection('b')
{ "ok" : 1 }</span></pre>
</div>
</div>
<p>&nbsp;&nbsp; 查看当前数据下的所有集合</p>
<div>
<div class="cnblogs_code">
<pre>&gt;<span style="color: rgba(0, 0, 0, 1)"> show collections;
a
b
</span>&gt;<span style="color: rgba(0, 0, 0, 1)"> db.getCollectionNames()
[ </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">a</span><span style="color: rgba(128, 0, 0, 1)">"</span>, <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">b</span><span style="color: rgba(128, 0, 0, 1)">"</span> ]</pre>
</div>
</div>
<p>方法二:</p>
<p>  当插入一个文档的时候,一个集合就会自动创建。</p>
<div>
<div class="cnblogs_code">
<pre>&gt; <span style="color: rgba(0, 0, 255, 1)">use</span><span style="color: rgba(0, 0, 0, 1)"> clsn;
switched </span><span style="color: rgba(0, 0, 255, 1)">to</span><span style="color: rgba(0, 0, 0, 1)"> db clsn
</span>&gt; db.c.insert({name:<span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">clsn</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)">});
WriteResult({ </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">nInserted</span><span style="color: rgba(128, 0, 0, 1)">"</span> : <span style="color: rgba(128, 0, 128, 1)">1</span><span style="color: rgba(0, 0, 0, 1)"> })
</span>&gt; db.c.insert({url:<span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">http://blog.nmtui.com</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)">});
WriteResult({ </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">nInserted</span><span style="color: rgba(128, 0, 0, 1)">"</span> : <span style="color: rgba(128, 0, 128, 1)">1</span> })</pre>
</div>
</div>
<p>&nbsp;&nbsp; 查看创建的合集</p>
<div>
<div class="cnblogs_code">
<pre>&gt;<span style="color: rgba(0, 0, 0, 1)"> db.getCollectionNames()
[ </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">a</span><span style="color: rgba(128, 0, 0, 1)">"</span>, <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">b</span><span style="color: rgba(128, 0, 0, 1)">"</span>, <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">c</span><span style="color: rgba(128, 0, 0, 1)">"</span> ]</pre>
</div>
</div>
<p>&nbsp;&nbsp; 查看合集里的内容</p>
<div>
<div class="cnblogs_code">
<pre>&gt;<span style="color: rgba(0, 0, 0, 1)"> db.c.find()
{ </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">_id</span><span style="color: rgba(128, 0, 0, 1)">"</span> : ObjectId(<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">5a4cbcea83ec78b7bea904f8</span><span style="color: rgba(128, 0, 0, 1)">"</span>), <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">name</span><span style="color: rgba(128, 0, 0, 1)">"</span> : <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">clsn</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)"> }
{ </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">_id</span><span style="color: rgba(128, 0, 0, 1)">"</span> : ObjectId(<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">5a4cbcfc83ec78b7bea904f9</span><span style="color: rgba(128, 0, 0, 1)">"</span>), <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">url</span><span style="color: rgba(128, 0, 0, 1)">"</span> : <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">http://blog.nmtui.com</span><span style="color: rgba(128, 0, 0, 1)">"</span> }</pre>
</div>
</div>
<p>重命名集合</p>
<div>
<div class="cnblogs_code">
<pre>&gt; db.c.renameCollection(<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">clsn</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">)
{ </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">ok</span><span style="color: rgba(128, 0, 0, 1)">"</span> : <span style="color: rgba(128, 0, 128, 1)">1</span><span style="color: rgba(0, 0, 0, 1)"> }
</span>&gt;<span style="color: rgba(0, 0, 0, 1)"> db.getCollectionNames()
[ </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">a</span><span style="color: rgba(128, 0, 0, 1)">"</span>, <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">b</span><span style="color: rgba(128, 0, 0, 1)">"</span>, <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">clsn</span><span style="color: rgba(128, 0, 0, 1)">"</span> ]</pre>
</div>
</div>
<p>&nbsp;&nbsp; 删除合集</p>
<div>
<div class="cnblogs_code">
<pre>&gt;<span style="color: rgba(0, 0, 0, 1)"> db.a.drop()
</span><span style="color: rgba(0, 0, 255, 1)">true</span>
&gt;<span style="color: rgba(0, 0, 0, 1)"> db.getCollectionNames()
[ </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">b</span><span style="color: rgba(128, 0, 0, 1)">"</span>, <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">clsn</span><span style="color: rgba(128, 0, 0, 1)">"</span> ]</pre>
</div>
</div>
<p>&nbsp;&nbsp; 插入1w行数据</p>
<div>
<div class="cnblogs_code">
<pre>&gt; <span style="color: rgba(0, 0, 255, 1)">for</span>(i=<span style="color: rgba(128, 0, 128, 1)">0</span>;i&lt;<span style="color: rgba(128, 0, 128, 1)">10000</span>;i++){ db.log.insert({<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">uid</span><span style="color: rgba(128, 0, 0, 1)">"</span>:i,<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">name</span><span style="color: rgba(128, 0, 0, 1)">"</span>:<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">mongodb</span><span style="color: rgba(128, 0, 0, 1)">"</span>,<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">age</span><span style="color: rgba(128, 0, 0, 1)">"</span>:<span style="color: rgba(128, 0, 128, 1)">6</span>,<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">date</span><span style="color: rgba(128, 0, 0, 1)">"</span>:<span style="color: rgba(0, 0, 255, 1)">new</span><span style="color: rgba(0, 0, 0, 1)"> Date()}); }
WriteResult({ </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">nInserted</span><span style="color: rgba(128, 0, 0, 1)">"</span> : <span style="color: rgba(128, 0, 128, 1)">1</span> })</pre>
</div>
</div>
<p>查询集合中的查询所有记录</p>
<div>
<div class="cnblogs_code">
<pre>&gt; db.log.find()</pre>
</div>
</div>
<p>注:默认每页显示20条记录,当显示不下的的情况下,可以用it迭代命令查询下一页数据。</p>
<div>
<div class="cnblogs_code">
<pre>&gt; DBQuery.shellBatchSize=<span style="color: rgba(128, 0, 128, 1)">50</span><span style="color: rgba(0, 0, 0, 1)">;    # 每页显示50条记录
</span><span style="color: rgba(128, 0, 128, 1)">50</span><span style="color: rgba(0, 0, 0, 1)">
app</span>&gt;<span style="color: rgba(0, 0, 0, 1)"> db.log.findOne()            # 查看第1条记录
app</span>&gt;<span style="color: rgba(0, 0, 0, 1)"> db.log.count()            # 查询总的记录数
app</span>&gt; db.log.find({uid:<span style="color: rgba(128, 0, 128, 1)">1000</span>});    # 查询UUID为1000的数据</pre>
</div>
</div>
<p>删除集合中的记录数</p>
<div>
<div class="cnblogs_code">
<pre>&gt;db.log.distinct(<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">name</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">)      #查询去掉当前集合中某列的重复数据
[ </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">mongodb</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)"> ]
</span>&gt;<span style="color: rgba(0, 0, 0, 1)"> db.log.remove({})             #删除集合中所有记录
WriteResult({ </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">nRemoved</span><span style="color: rgba(128, 0, 0, 1)">"</span> : <span style="color: rgba(128, 0, 128, 1)">10000</span><span style="color: rgba(0, 0, 0, 1)"> })
</span>&gt; db.log.distinct(<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">name</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">)
[ ]</span></pre>
</div>
</div>
<p>查看集合存储信息</p>
<div>
<div class="cnblogs_code">
<pre>&gt;<span style="color: rgba(0, 0, 0, 1)"> db.log.stats()          # 查看数据状态
</span>&gt;<span style="color: rgba(0, 0, 0, 1)"> db.log.dataSize()       # 集合中数据的原始大小
</span>&gt;<span style="color: rgba(0, 0, 0, 1)"> db.log.totalIndexSize() # 集合中索引数据的原始大小
</span>&gt; db.log.totalSize()      # 集合中索引+<span style="color: rgba(0, 0, 0, 1)">数据压缩存储之后的大小
</span>&gt; db.log.storageSize()    # 集合中数据压缩存储的大小</pre>
</div>
<p class="ac">pretty()使用</p>
</div>
<div>
<div class="cnblogs_code">
<pre>&gt; db.log.find({uid:<span style="color: rgba(128, 0, 128, 1)">1000</span><span style="color: rgba(0, 0, 0, 1)">}).pretty()
{
    </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">_id</span><span style="color: rgba(128, 0, 0, 1)">"</span> : ObjectId(<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">5a4c5c0bdf067ab57602f7c2</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">),
    </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">uid</span><span style="color: rgba(128, 0, 0, 1)">"</span> : <span style="color: rgba(128, 0, 128, 1)">1000</span><span style="color: rgba(0, 0, 0, 1)">,
    </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">name</span><span style="color: rgba(128, 0, 0, 1)">"</span> : <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">mongodb</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">,
    </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">age</span><span style="color: rgba(128, 0, 0, 1)">"</span> : <span style="color: rgba(128, 0, 128, 1)">6</span><span style="color: rgba(0, 0, 0, 1)">,
    </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">date</span><span style="color: rgba(128, 0, 0, 1)">"</span> : ISODate(<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">2018-01-03T04:28:59.343Z</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">)
}</span></pre>
</div>
</div>
<h2>1.6 MongoDB中用户管理</h2>
<p>  MongoDB数据库默认是没有用户名及密码的,即无权限访问限制。为了方便数据库的管理和安全,需创建数据库用户。</p>
<h3>1.6.1 用户的权限</h3>
<p>  用户中权限的说明&nbsp;</p>
<table class="MsoTable15Grid4Accent3" style="width: 100%; border-style: none" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="width: 31.14%; border-width: 1pt initial 1pt 1pt; border-color: rgba(155, 187, 89, 1) initial rgba(155, 187, 89, 1) rgba(155, 187, 89, 1); border-right-style: none; background: rgba(155, 187, 89, 1); padding: 0 5.4pt" width="31%">
<p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 5" align="center"><strong><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; color: rgba(255, 255, 255, 1); mso-themecolor: background1">权限</span></strong></p>
</td>
<td style="width: 68.86%; border-width: 1pt 1pt 1pt initial; border-color: rgba(155, 187, 89, 1) rgba(155, 187, 89, 1) rgba(155, 187, 89, 1) initial; border-left-style: none; background: rgba(155, 187, 89, 1); padding: 0 5.4pt" width="68%">
<p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 1" align="center"><strong><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; color: rgba(255, 255, 255, 1); mso-themecolor: background1">说明</span></strong></p>
</td>
</tr>
<tr>
<td style="width: 31.14%; border-width: initial 1pt 1pt; border-color: initial rgba(194, 214, 155, 1) rgba(194, 214, 155, 1); border-top-style: none; background: rgba(234, 241, 221, 1); padding: 0 5.4pt" width="31%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 68"><strong><span lang="EN-US">Read&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></strong></p>
</td>
<td style="width: 68.86%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); background: rgba(234, 241, 221, 1); padding: 0 5.4pt" width="68%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">允许用户读取指定数据库</span></p>
</td>
</tr>
<tr>
<td style="width: 31.14%; border-width: initial 1pt 1pt; border-color: initial rgba(194, 214, 155, 1) rgba(194, 214, 155, 1); border-top-style: none; padding: 0 5.4pt" width="31%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 4"><strong><span lang="EN-US">readWrite&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></strong></p>
</td>
<td style="width: 68.86%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); padding: 0 5.4pt" width="68%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">允许用户读写指定数据库</span></p>
</td>
</tr>
<tr>
<td style="width: 31.14%; border-width: initial 1pt 1pt; border-color: initial rgba(194, 214, 155, 1) rgba(194, 214, 155, 1); border-top-style: none; background: rgba(234, 241, 221, 1); padding: 0 5.4pt" width="31%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 68"><strong><span lang="EN-US">dbAdmin&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></strong></p>
</td>
<td style="width: 68.86%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); background: rgba(234, 241, 221, 1); padding: 0 5.4pt" width="68%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">允许用户在指定数据库中执行管理函数,如索引创建、删除,查看统计或访问</span><span lang="EN-US">system.profile</span></p>
</td>
</tr>
<tr>
<td style="width: 31.14%; border-width: initial 1pt 1pt; border-color: initial rgba(194, 214, 155, 1) rgba(194, 214, 155, 1); border-top-style: none; padding: 0 5.4pt" width="31%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 4"><strong><span lang="EN-US">userAdmin&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></strong></p>
</td>
<td style="width: 68.86%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); padding: 0 5.4pt" width="68%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">允许用户向</span><span lang="EN-US">system.users</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">集合写入,可以找指定数据库里创建、删除和管理用户</span></p>
</td>
</tr>
<tr>
<td style="width: 31.14%; border-width: initial 1pt 1pt; border-color: initial rgba(194, 214, 155, 1) rgba(194, 214, 155, 1); border-top-style: none; background: rgba(234, 241, 221, 1); padding: 0 5.4pt" width="31%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 68"><strong><span lang="EN-US">clusterAdmin&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></strong></p>
</td>
<td style="width: 68.86%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); background: rgba(234, 241, 221, 1); padding: 0 5.4pt" width="68%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">只在</span><span lang="EN-US">admin</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">数据库中可用,赋予用户所有分片和复制集相关函数的管理权限。</span></p>
</td>
</tr>
<tr>
<td style="width: 31.14%; border-width: initial 1pt 1pt; border-color: initial rgba(194, 214, 155, 1) rgba(194, 214, 155, 1); border-top-style: none; padding: 0 5.4pt" width="31%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 4"><strong><span lang="EN-US">readAnyDatabase&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></strong></p>
</td>
<td style="width: 68.86%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); padding: 0 5.4pt" width="68%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">只在</span><span lang="EN-US">admin</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">数据库中可用,赋予用户所有数据库的读权限</span></p>
</td>
</tr>
<tr>
<td style="width: 31.14%; border-width: initial 1pt 1pt; border-color: initial rgba(194, 214, 155, 1) rgba(194, 214, 155, 1); border-top-style: none; background: rgba(234, 241, 221, 1); padding: 0 5.4pt" width="31%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 68"><strong><span lang="EN-US">readWriteAnyDatabase </span></strong></p>
</td>
<td style="width: 68.86%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); background: rgba(234, 241, 221, 1); padding: 0 5.4pt" width="68%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">只在</span><span lang="EN-US">admin</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">数据库中可用,赋予用户所有数据库的读写权限</span></p>
</td>
</tr>
<tr>
<td style="width: 31.14%; border-width: initial 1pt 1pt; border-color: initial rgba(194, 214, 155, 1) rgba(194, 214, 155, 1); border-top-style: none; padding: 0 5.4pt" width="31%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 4"><strong><span lang="EN-US">userAdminAnyDatabase </span></strong></p>
</td>
<td style="width: 68.86%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); padding: 0 5.4pt" width="68%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">只在</span><span lang="EN-US">admin</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">数据库中可用,赋予用户所有数据库的</span><span lang="EN-US">userAdmin</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">权限</span></p>
</td>
</tr>
<tr>
<td style="width: 31.14%; border-width: initial 1pt 1pt; border-color: initial rgba(194, 214, 155, 1) rgba(194, 214, 155, 1); border-top-style: none; background: rgba(234, 241, 221, 1); padding: 0 5.4pt" width="31%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 68"><strong><span lang="EN-US">dbAdminAnyDatabase&nbsp;&nbsp; </span></strong></p>
</td>
<td style="width: 68.86%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); background: rgba(234, 241, 221, 1); padding: 0 5.4pt" width="68%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">只在</span><span lang="EN-US">admin</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">数据库中可用,赋予用户所有数据库的</span><span lang="EN-US">dbAdmin</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">权限。</span></p>
</td>
</tr>
<tr>
<td style="width: 31.14%; border-width: initial 1pt 1pt; border-color: initial rgba(194, 214, 155, 1) rgba(194, 214, 155, 1); border-top-style: none; padding: 0 5.4pt" width="31%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 4"><strong><span lang="EN-US">root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></strong></p>
</td>
<td style="width: 68.86%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(194, 214, 155, 1); border-right-width: 1pt; border-right-color: rgba(194, 214, 155, 1); padding: 0 5.4pt" width="68%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">只在</span><span lang="EN-US">admin</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">数据库中可用。超级账号,超级权限</span></p>
</td>
</tr>
</tbody>
</table>
<p>  &nbsp;更多关于用户权限的说明参照:https://docs.mongodb.com/manual/core/security-built-in-roles/</p>
<p><em><span style="text-decoration: underline">用户创建语法</span></em>&nbsp;&nbsp;</p>
<div>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 0, 1)">{
user: </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">&lt;name&gt;</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">,
pwd: </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">&lt;cleartext password&gt;</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">,
customData: { </span>&lt;any information&gt;<span style="color: rgba(0, 0, 0, 1)"> },
roles: [
{ role: </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">&lt;role&gt;</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">,
db: </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">&lt;database&gt;</span><span style="color: rgba(128, 0, 0, 1)">"</span> } | <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">&lt;role&gt;</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">,
...
]
}</span></pre>
</div>
</div>
<p>语法说明:</p>
<div>
<blockquote>
<p class="a3" style="color: rgba(0, 0, 0, 1)">user字段:用户的名字;</p>
<p class="a3" style="color: rgba(0, 0, 0, 1)">pwd字段:用户的密码;</p>
<p class="a3" style="color: rgba(0, 0, 0, 1)">cusomData字段:为任意内容,例如可以为用户全名介绍;</p>
<p class="a3" style="color: rgba(0, 0, 0, 1)">roles字段:指定用户的角色,可以用一个空数组给新用户设定空角色;</p>
<p class="a3">&nbsp;</p>
<p class="a3" style="color: rgba(0, 0, 0, 1)">roles 字段:可以指定内置角色和用户定义的角色。</p>
</blockquote>
</div>
<h3>1.6.2 创建管理员用户</h3>
<p>进入管理数据库</p>
<div>
<div class="cnblogs_code">
<pre>&gt; <span style="color: rgba(0, 0, 255, 1)">use</span> admin</pre>
</div>
</div>
<p>创建管理用户,root权限</p>
<div>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 0, 1)">db.createUser(
{
    user: </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">root</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">,
    pwd: </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">root</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">,
    roles: [ { role: </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">root</span><span style="color: rgba(128, 0, 0, 1)">"</span>, db: <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">admin</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)"> } ]
}
)    </span></pre>
</div>
</div>
<p><span style="color: rgba(255, 0, 0, 1)"><strong>注意:</strong></span></p>
<blockquote>
<p style="color: rgba(0, 0, 0, 1)">&nbsp;&nbsp;&nbsp;  创建管理员角色用户的时候,必须到admin下创建。</p>
<p>&nbsp;</p>
<p style="color: rgba(0, 0, 0, 1)">&nbsp;&nbsp;  &nbsp;删除的时候也要到相应的库下操作。</p>
</blockquote>
<p>查看创建完用户后的collections;</p>
<div>
<div class="cnblogs_code">
<pre> &gt;<span style="color: rgba(0, 0, 0, 1)"> show tables;
system.users# 用户存放位置
system.version</span></pre>
</div>
</div>
<p><strong>查看创建的管理员用户</strong></p>
<div>
<div class="cnblogs_code">
<pre>    &gt;<span style="color: rgba(0, 0, 0, 1)"> show users
    {
      </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">_id</span><span style="color: rgba(128, 0, 0, 1)">"</span> : <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">admin.root</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">,
      </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">user</span><span style="color: rgba(128, 0, 0, 1)">"</span> : <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">root</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">,
      </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">db</span><span style="color: rgba(128, 0, 0, 1)">"</span> : <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">admin</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">,
      </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">roles</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)"> : [
            {
                </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">role</span><span style="color: rgba(128, 0, 0, 1)">"</span> : <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">root</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">,
                </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">db</span><span style="color: rgba(128, 0, 0, 1)">"</span> : <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">admin</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">
            }
      ]
    }</span></pre>
</div>
</div>
<p>验证用户是否能用</p>
<div>
<div class="cnblogs_code">
<pre>&gt; db.auth(<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">root</span><span style="color: rgba(128, 0, 0, 1)">"</span>,<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">root</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">)
</span><span style="color: rgba(128, 0, 128, 1)">1</span># 返回 <span style="color: rgba(128, 0, 128, 1)">1</span> 即为成功</pre>
</div>
</div>
<p>用户创建完成后在配置文件中开启用户验证</p>
<div>
<div class="cnblogs_code">
<pre>cat &gt;&gt;/application/mongodb/conf/mongod.conf&lt;&lt;-<span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">EOF</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)">
security:
authorization: enabled
EOF</span></pre>
</div>
</div>
<p>重启服务</p>
<div>
<div class="cnblogs_code">
<pre>/etc/init.d/mongodrestart</pre>
</div>
<p>  <span style="background-color: rgba(255, 255, 0, 1); color: rgba(255, 0, 0, 1)"><strong>登陆测试,注意登陆时选择admin</strong><strong>数据库</strong></span></p>
</div>
<p>   <span style="color: rgba(255, 0, 0, 1)"> 注意:</span>用户在哪个数据库下创建的,最后加上什么库。</p>
<p>方法一:命令行中进行登陆</p>
<div>
<div class="cnblogs_code">
<pre>$ mongo -uroot -<span style="color: rgba(0, 0, 0, 1)">proot admin
MongoDB shell version: </span><span style="color: rgba(128, 0, 128, 1)">3.2</span>.<span style="color: rgba(128, 0, 128, 1)">8</span><span style="color: rgba(0, 0, 0, 1)">
connecting </span><span style="color: rgba(0, 0, 255, 1)">to</span><span style="color: rgba(0, 0, 0, 1)">: admin
</span>&gt; </pre>
</div>
</div>
<p>方法二:在数据库中进行登陆验证:</p>
<div>
<div class="cnblogs_code">
<pre>$ mongo
MongoDB shell version: </span><span style="color: rgba(128, 0, 128, 1)">3.2</span>.<span style="color: rgba(128, 0, 128, 1)">8</span><span style="color: rgba(0, 0, 0, 1)">
connecting </span><span style="color: rgba(0, 0, 255, 1)">to</span><span style="color: rgba(0, 0, 0, 1)">: test
</span>&gt; <span style="color: rgba(0, 0, 255, 1)">use</span><span style="color: rgba(0, 0, 0, 1)"> admin
switched </span><span style="color: rgba(0, 0, 255, 1)">to</span><span style="color: rgba(0, 0, 0, 1)"> db admin
</span>&gt; db.auth(<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">root</span><span style="color: rgba(128, 0, 0, 1)">"</span>,<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">root</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">)
</span><span style="color: rgba(128, 0, 128, 1)">1</span>
&gt;<span style="color: rgba(0, 0, 0, 1)"> show tables;
system.users
system.version</span></pre>
</div>
</div>
<h3>1.6.3 按生产需求创建应用用户</h3>
<p><span style="background-color: rgba(255, 255, 0, 1)"><strong>创建对某库的只读用户</strong></span></p>
<p>&nbsp;&nbsp; 在test库创建只读用户test</p>
<div>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">use</span><span style="color: rgba(0, 0, 0, 1)"> test
db.createUser(
{
    user: </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">test</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">,
    pwd: </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">test</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">,
    roles: [ { role: </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">read</span><span style="color: rgba(128, 0, 0, 1)">"</span>, db: <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">test</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)"> } ]
}
)</span></pre>
</div>
</div>
<p>&nbsp;&nbsp; 测试用户是否创建成功</p>
<div>
<div class="cnblogs_code">
<pre>db.auth(<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">test</span><span style="color: rgba(128, 0, 0, 1)">"</span>,<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">test</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">)
showusers;</span></pre>
</div>
</div>
<p>登录test用户,并测试是否只读</p>
<div>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 0, 1)">show collections;
db.createCollection(</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">b</span><span style="color: rgba(128, 0, 0, 1)">'</span>)</pre>
</div>
</div>
<p><span style="background-color: rgba(255, 255, 0, 1)"><strong>创建某库的读写用户</strong></span></p>
<p>  创建test1用户,权限为读写</p>
<div>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 0, 1)">db.createUser(
{
    user: </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">test1</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">,
    pwd: </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">test1</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">,
    roles: [ { role: </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">readWrite</span><span style="color: rgba(128, 0, 0, 1)">"</span>, db: <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">test</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)"> } ]
}
)</span></pre>
</div>
</div>
<p>&nbsp;&nbsp; 查看并测试用户</p>
<div>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 0, 1)">show users;
db.auth(</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">test1</span><span style="color: rgba(128, 0, 0, 1)">"</span>,<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">test1</span><span style="color: rgba(128, 0, 0, 1)">"</span>)</pre>
</div>
</div>
<p><span style="background-color: rgba(255, 255, 0, 1)"><strong>创建对多库不同权限的用户</strong></span></p>
<p>&nbsp;&nbsp; 创建对app为读写权限,对test库为只读权限的用户</p>
<div>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">use</span><span style="color: rgba(0, 0, 0, 1)"> app
db.createUser(
{
    user: </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">app</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">,
    pwd: </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">app</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">,
roles: [ { role: </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">readWrite</span><span style="color: rgba(128, 0, 0, 1)">"</span>, db: <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">app</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)"> },
         { role: </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">read</span><span style="color: rgba(128, 0, 0, 1)">"</span>, db: <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">test</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)"> }
]
}
)</span></pre>
</div>
</div>
<p>查看并测试用户</p>
<div>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 0, 1)">show users
db.auth(</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">app</span><span style="color: rgba(128, 0, 0, 1)">"</span>,<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">app</span><span style="color: rgba(128, 0, 0, 1)">"</span>)</pre>
</div>
</div>
<p><strong>删除用户</strong></p>
<p>&nbsp;&nbsp; 删除app用户:先登录到admin数据库</p>
<div>
<div class="cnblogs_code">
<pre>mongo -uroot –proot <span style="color: rgba(128, 0, 128, 1)">127.0</span>.<span style="color: rgba(128, 0, 128, 1)">0.1</span>/admin</pre>
</div>
</div>
<p>&nbsp;&nbsp; 进入app库删除app用户</p>
<div>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">use</span><span style="color: rgba(0, 0, 0, 1)"> app
db.dropUser(</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">app</span><span style="color: rgba(128, 0, 0, 1)">"</span>)</pre>
</div>
</div>
<h3>1.6.4 自定义数据库</h3>
<p>创建app数据库的管理员:先登录到admin数据库</p>
<div>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">use</span><span style="color: rgba(0, 0, 0, 1)"> app
db.createUser(
{
user: </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">admin</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">,
pwd: </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">admin</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">,
roles: [ { role: </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">dbAdmin</span><span style="color: rgba(128, 0, 0, 1)">"</span>, db: <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">app</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)"> } ]
}
)</span></pre>
</div>
</div>
<p>创建app数据库读写权限的用户并具有clusterAdmin权限:</p>
<div>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">use</span><span style="color: rgba(0, 0, 0, 1)"> app
db.createUser(
{
user: </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">app04</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">,
pwd: </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">app04</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">,
roles: [ { role: </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">readWrite</span><span style="color: rgba(128, 0, 0, 1)">"</span>, db: <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">app</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)"> },
{ role: </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">clusterAdmin</span><span style="color: rgba(128, 0, 0, 1)">"</span>, db: <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">admin</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)"> }
]
}
)</span></pre>
</div>
</div>
<h2>1.7 SQL与MongoDB语言对比</h2>
<p><span style="background-color: rgba(0, 255, 0, 1)">SQL语言与CRUD语言对照</span>&nbsp;</p>
<table class="MsoTable15Grid4Accent1" style="width: 100%; border-style: none" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="width: 37.92%; border-width: 1pt initial 1pt 1pt; border-color: rgba(79, 129, 189, 1) initial rgba(79, 129, 189, 1) rgba(79, 129, 189, 1); border-right-style: none; background: rgba(79, 129, 189, 1); padding: 0 5.4pt" width="37%">
<p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 5" align="center"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif; color: rgba(255, 255, 255, 1); mso-themecolor: background1" lang="EN-US">SQL Schema Statements</span></strong></p>
</td>
<td style="width: 62.08%; border-width: 1pt 1pt 1pt initial; border-color: rgba(79, 129, 189, 1) rgba(79, 129, 189, 1) rgba(79, 129, 189, 1) initial; border-left-style: none; background: rgba(79, 129, 189, 1); padding: 0 5.4pt" width="62%">
<p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 1" align="center"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif; color: rgba(255, 255, 255, 1); mso-themecolor: background1" lang="EN-US">MongoDB Schema Statements</span></strong></p>
</td>
</tr>
<tr>
<td style="width: 37.92%; border-width: initial 1pt 1pt; border-color: initial rgba(149, 179, 215, 1) rgba(149, 179, 215, 1); border-top-style: none; background: rgba(219, 229, 241, 1); padding: 0 5.4pt" width="37%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 68"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">CREATE TABLE users (</span></strong></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 68"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">id MEDIUMINT NOT NULL</span></strong></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 68"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">AUTO_INCREMENT,</span></strong></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 68"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">user_id Varchar(30),</span></strong></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 68"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">age Number,</span></strong></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 68"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">status char(1),</span></strong></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 68"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">PRIMARY KEY (id)</span></strong></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 68"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">)</span></strong></p>
</td>
<td style="width: 62.08%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(149, 179, 215, 1); border-right-width: 1pt; border-right-color: rgba(149, 179, 215, 1); background: rgba(219, 229, 241, 1); padding: 0 5.4pt" width="62%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">Implicitly created on first insert() operation. The primary </span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">key _idis automatically added if _id field is not specified.</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">db.users.insert( {</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">user_id: "abc123",</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">age: 55,</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">status: "A"</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">} )</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">However, you can also explicitly create a collection:</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">db.createCollection("users")</span></p>
</td>
</tr>
<tr>
<td style="width: 37.92%; border-width: initial 1pt 1pt; border-color: initial rgba(149, 179, 215, 1) rgba(149, 179, 215, 1); border-top-style: none; padding: 0 5.4pt" width="37%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 4"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">ALTER TABLE users</span></strong></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 4"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">ADD join_date DATETIME</span></strong></p>
</td>
<td style="width: 62.08%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(149, 179, 215, 1); border-right-width: 1pt; border-right-color: rgba(149, 179, 215, 1); padding: 0 5.4pt" width="62%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif">在<span lang="EN-US">Collection </span></span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-bidi-font-family: 微软雅黑">级</span><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif; mso-bidi-font-family: 'Yu Gothic UI Semibold'">没有数据</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-bidi-font-family: 微软雅黑">结</span><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif; mso-bidi-font-family: 'Yu Gothic UI Semibold'">构概念。然而在</span><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US"> document</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-bidi-font-family: 微软雅黑">级</span><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif; mso-bidi-font-family: 'Yu Gothic UI Semibold'">,可以通</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-bidi-font-family: 微软雅黑">过</span><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">$set</span><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif">在</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">update</span><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif">操作添加列到文档中。</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">db.users.update(</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">{ },</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">{ $set: { join_date: new Date() } },</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">{ multi: true }</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">)</span></p>
</td>
</tr>
<tr>
<td style="width: 37.92%; border-width: initial 1pt 1pt; border-color: initial rgba(149, 179, 215, 1) rgba(149, 179, 215, 1); border-top-style: none; background: rgba(219, 229, 241, 1); padding: 0 5.4pt" width="37%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 68"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">ALTER TABLE users</span></strong></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 68"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">DROP COLUMN join_date</span></strong></p>
</td>
<td style="width: 62.08%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(149, 179, 215, 1); border-right-width: 1pt; border-right-color: rgba(149, 179, 215, 1); background: rgba(219, 229, 241, 1); padding: 0 5.4pt" width="62%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif">在<span lang="EN-US">Collection </span></span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-bidi-font-family: 微软雅黑">级</span><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif; mso-bidi-font-family: 'Yu Gothic UI Semibold'">没有数据</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-bidi-font-family: 微软雅黑">结</span><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif; mso-bidi-font-family: 'Yu Gothic UI Semibold'">构概念。然而在</span><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US"> document</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-bidi-font-family: 微软雅黑">级</span><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif; mso-bidi-font-family: 'Yu Gothic UI Semibold'">,可以通</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-bidi-font-family: 微软雅黑">过</span><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">$unset</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif">在<span lang="EN-US">update</span>操作从文档中</span><span style="font-family: &quot;微软雅黑&quot;, sans-serif; mso-bidi-font-family: 微软雅黑">删</span><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif; mso-bidi-font-family: 'Yu Gothic UI Semibold'">除列。</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">db.users.update(</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">{ },</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">{ $unset: { join_date: "" } },</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">{ multi: true }</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">)</span></p>
</td>
</tr>
<tr>
<td style="width: 37.92%; border-width: initial 1pt 1pt; border-color: initial rgba(149, 179, 215, 1) rgba(149, 179, 215, 1); border-top-style: none; padding: 0 5.4pt" width="37%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 4"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">CREATE INDEX idx_user_id_asc</span></strong></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 4"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">ON users(user_id)</span></strong></p>
</td>
<td style="width: 62.08%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(149, 179, 215, 1); border-right-width: 1pt; border-right-color: rgba(149, 179, 215, 1); padding: 0 5.4pt" width="62%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">db.users.createIndex( { user_id: 1 } )</span></p>
</td>
</tr>
<tr>
<td style="width: 37.92%; border-width: initial 1pt 1pt; border-color: initial rgba(149, 179, 215, 1) rgba(149, 179, 215, 1); border-top-style: none; background: rgba(219, 229, 241, 1); padding: 0 5.4pt" width="37%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 68"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">CREATE INDEX</span></strong></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 68"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">idx_user_id_asc_age_desc</span></strong></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 68"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">ON users(user_id, age DESC)</span></strong></p>
</td>
<td style="width: 62.08%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(149, 179, 215, 1); border-right-width: 1pt; border-right-color: rgba(149, 179, 215, 1); background: rgba(219, 229, 241, 1); padding: 0 5.4pt" width="62%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">db.users.createIndex( { user_id: 1, age: -1 } )</span></p>
</td>
</tr>
<tr>
<td style="width: 37.92%; border-width: initial 1pt 1pt; border-color: initial rgba(149, 179, 215, 1) rgba(149, 179, 215, 1); border-top-style: none; padding: 0 5.4pt" width="37%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 4"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">DROP TABLE users</span></strong></p>
</td>
<td style="width: 62.08%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(149, 179, 215, 1); border-right-width: 1pt; border-right-color: rgba(149, 179, 215, 1); padding: 0 5.4pt" width="62%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">db.users.drop()</span></p>
</td>
</tr>
</tbody>
</table>
<p><span style="background-color: rgba(0, 255, 0, 1)">插入/删除/更新 语句对比</span></p>
<table class="MsoTable15Grid4Accent1" style="width: 100%; border-style: none" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="width: 39.26%; border-width: 1pt initial 1pt 1pt; border-color: rgba(79, 129, 189, 1) initial rgba(79, 129, 189, 1) rgba(79, 129, 189, 1); border-right-style: none; background: rgba(79, 129, 189, 1); padding: 0 5.4pt" width="39%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 5"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif; color: rgba(255, 255, 255, 1); mso-themecolor: background1" lang="EN-US">SQL &nbsp;Statements</span></strong></p>
</td>
<td style="width: 60.74%; border-width: 1pt 1pt 1pt initial; border-color: rgba(79, 129, 189, 1) rgba(79, 129, 189, 1) rgba(79, 129, 189, 1) initial; border-left-style: none; background: rgba(79, 129, 189, 1); padding: 0 5.4pt" width="60%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 1"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif; color: rgba(255, 255, 255, 1); mso-themecolor: background1" lang="EN-US">MongoDB &nbsp;Statements</span></strong></p>
</td>
</tr>
<tr>
<td style="width: 39.26%; border-width: initial 1pt 1pt; border-color: initial rgba(149, 179, 215, 1) rgba(149, 179, 215, 1); border-top-style: none; background: rgba(219, 229, 241, 1); padding: 0 5.4pt" width="39%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 68"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">INSERT INTO</span></strong></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 68"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">users(user_id,</span></strong></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 68"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">age</span></strong></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 68"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">status)</span></strong></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 68"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">VALUES ("bcd001",</span></strong></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 68"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">45,</span></strong></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 68"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">"A")</span></strong></p>
</td>
<td style="width: 60.74%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(149, 179, 215, 1); border-right-width: 1pt; border-right-color: rgba(149, 179, 215, 1); background: rgba(219, 229, 241, 1); padding: 0 5.4pt" width="60%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">db.users.insert(</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">{ user_id: "bcd001", age:</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">45, status: "A" }</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">)</span></p>
</td>
</tr>
<tr>
<td style="width: 39.26%; border-width: initial 1pt 1pt; border-color: initial rgba(149, 179, 215, 1) rgba(149, 179, 215, 1); border-top-style: none; padding: 0 5.4pt" width="39%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 4"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">DELETE FROM users</span></strong></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 4"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">WHERE status = "D"</span></strong></p>
</td>
<td style="width: 60.74%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(149, 179, 215, 1); border-right-width: 1pt; border-right-color: rgba(149, 179, 215, 1); padding: 0 5.4pt" width="60%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">db.users.remove( { status: "D" } )</span></p>
</td>
</tr>
<tr>
<td style="width: 39.26%; border-width: initial 1pt 1pt; border-color: initial rgba(149, 179, 215, 1) rgba(149, 179, 215, 1); border-top-style: none; background: rgba(219, 229, 241, 1); padding: 0 5.4pt" width="39%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 68"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">DELETE FROM users</span></strong></p>
</td>
<td style="width: 60.74%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(149, 179, 215, 1); border-right-width: 1pt; border-right-color: rgba(149, 179, 215, 1); background: rgba(219, 229, 241, 1); padding: 0 5.4pt" width="60%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">db.users.remove({})</span></p>
</td>
</tr>
<tr>
<td style="width: 39.26%; border-width: initial 1pt 1pt; border-color: initial rgba(149, 179, 215, 1) rgba(149, 179, 215, 1); border-top-style: none; padding: 0 5.4pt" width="39%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 4"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">UPDATE users</span></strong></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 4"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">SET status = "C"</span></strong></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 4"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">WHERE age &gt; 25</span></strong></p>
</td>
<td style="width: 60.74%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(149, 179, 215, 1); border-right-width: 1pt; border-right-color: rgba(149, 179, 215, 1); padding: 0 5.4pt" width="60%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">db.users.update(</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">{ age: { $gt: 25 } },</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">{ $set: { status: "C" } },</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">{ multi: true }</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">)</span></p>
</td>
</tr>
<tr>
<td style="width: 39.26%; border-width: initial 1pt 1pt; border-color: initial rgba(149, 179, 215, 1) rgba(149, 179, 215, 1); border-top-style: none; background: rgba(219, 229, 241, 1); padding: 0 5.4pt" width="39%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 68"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">UPDATE users</span></strong></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 68"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">SET age = age + 3</span></strong></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 68"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">WHERE status = "A"</span></strong></p>
</td>
<td style="width: 60.74%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(149, 179, 215, 1); border-right-width: 1pt; border-right-color: rgba(149, 179, 215, 1); background: rgba(219, 229, 241, 1); padding: 0 5.4pt" width="60%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">db.users.update(</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">{ status: "A" } ,</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">{ $inc: { age: 3 } },</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">{ multi: true }</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">)</span></p>
</td>
</tr>
</tbody>
</table>
<p><span style="background-color: rgba(0, 255, 0, 1)">查询类操作对比&nbsp;</span></p>
<table class="MsoTable15Grid4Accent1" style="width: 100%; border-style: none" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="width: 39.26%; border-width: 1pt initial 1pt 1pt; border-color: rgba(79, 129, 189, 1) initial rgba(79, 129, 189, 1) rgba(79, 129, 189, 1); border-right-style: none; background: rgba(79, 129, 189, 1); padding: 0 5.4pt" valign="top" width="39%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 5"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif; color: rgba(255, 255, 255, 1); mso-themecolor: background1" lang="EN-US">SQL SELECT Statements</span></strong></p>
</td>
<td style="width: 60.74%; border-width: 1pt 1pt 1pt initial; border-color: rgba(79, 129, 189, 1) rgba(79, 129, 189, 1) rgba(79, 129, 189, 1) initial; border-left-style: none; background: rgba(79, 129, 189, 1); padding: 0 5.4pt" valign="top" width="60%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 1"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif; color: rgba(255, 255, 255, 1); mso-themecolor: background1" lang="EN-US">MongoDB find() Statements</span></strong></p>
</td>
</tr>
<tr>
<td style="width: 39.26%; border-width: initial 1pt 1pt; border-color: initial rgba(149, 179, 215, 1) rgba(149, 179, 215, 1); border-top-style: none; background: rgba(219, 229, 241, 1); padding: 0 5.4pt" valign="top" width="39%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 68"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">SELECT *</span></strong></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 68"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">FROM users</span></strong></p>
</td>
<td style="width: 60.74%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(149, 179, 215, 1); border-right-width: 1pt; border-right-color: rgba(149, 179, 215, 1); background: rgba(219, 229, 241, 1); padding: 0 5.4pt" valign="top" width="60%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">db.users.find()</span></p>
</td>
</tr>
<tr>
<td style="width: 39.26%; border-width: initial 1pt 1pt; border-color: initial rgba(149, 179, 215, 1) rgba(149, 179, 215, 1); border-top-style: none; padding: 0 5.4pt" valign="top" width="39%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 4"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">SELECT id,</span></strong></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 4"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">user_id,</span></strong></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 4"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">status</span></strong></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 4"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">FROM users</span></strong></p>
</td>
<td style="width: 60.74%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(149, 179, 215, 1); border-right-width: 1pt; border-right-color: rgba(149, 179, 215, 1); padding: 0 5.4pt" valign="top" width="60%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">db.users.find(</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">{ },</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">{ user_id: 1, status: 1, _id: 0 }</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">)</span></p>
</td>
</tr>
<tr>
<td style="width: 39.26%; border-width: initial 1pt 1pt; border-color: initial rgba(149, 179, 215, 1) rgba(149, 179, 215, 1); border-top-style: none; background: rgba(219, 229, 241, 1); padding: 0 5.4pt" valign="top" width="39%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 68"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">SELECT user_id, status</span></strong></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 68"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">FROM users</span></strong></p>
</td>
<td style="width: 60.74%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(149, 179, 215, 1); border-right-width: 1pt; border-right-color: rgba(149, 179, 215, 1); background: rgba(219, 229, 241, 1); padding: 0 5.4pt" valign="top" width="60%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">db.users.find(</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">{ },</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">{ user_id: 1, status: 1 }</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">)</span></p>
</td>
</tr>
<tr>
<td style="width: 39.26%; border-width: initial 1pt 1pt; border-color: initial rgba(149, 179, 215, 1) rgba(149, 179, 215, 1); border-top-style: none; padding: 0 5.4pt" valign="top" width="39%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 4"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">SELECT *</span></strong></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 4"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">FROM users</span></strong></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 4"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">WHERE status = "A"</span></strong></p>
</td>
<td style="width: 60.74%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(149, 179, 215, 1); border-right-width: 1pt; border-right-color: rgba(149, 179, 215, 1); padding: 0 5.4pt" valign="top" width="60%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">db.users.find(</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">{ status: "A" }</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">)</span></p>
</td>
</tr>
<tr>
<td style="width: 39.26%; border-width: initial 1pt 1pt; border-color: initial rgba(149, 179, 215, 1) rgba(149, 179, 215, 1); border-top-style: none; background: rgba(219, 229, 241, 1); padding: 0 5.4pt" valign="top" width="39%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 68"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">SELECT user_id, status</span></strong></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 68"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">FROM users</span></strong></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 68"><strong><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">WHERE status = "A"</span></strong></p>
</td>
<td style="width: 60.74%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: rgba(149, 179, 215, 1); border-right-width: 1pt; border-right-color: rgba(149, 179, 215, 1); background: rgba(219, 229, 241, 1); padding: 0 5.4pt" valign="top" width="60%">
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">db.users.find(</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">{ status: "A" },</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">{ user_id: 1, status: 1, _id: 0 }</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 64"><span style="font-family: &quot;Yu Gothic UI Semibold&quot;, sans-serif" lang="EN-US">)</span></p>
</td>
</tr>
</tbody>
</table>
<h2>1.8 错误解决</h2>
<h6><span style="font-size: 14px">  在登陆数据库的时候,发现会由描述文件相关的报错。</span></h6>
<div>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 0, 1)">$ mongo
MongoDB shell version: </span><span style="color: rgba(128, 0, 128, 1)">3.2</span>.<span style="color: rgba(128, 0, 128, 1)">8</span><span style="color: rgba(0, 0, 0, 1)">
connecting to: test
Server has startup warnings:
</span><span style="color: rgba(128, 0, 128, 1)">2018</span>-<span style="color: rgba(128, 0, 128, 1)">01</span>-03T11:<span style="color: rgba(128, 0, 128, 1)">08</span>:<span style="color: rgba(128, 0, 128, 1)">55.526</span>+<span style="color: rgba(128, 0, 128, 1)">0800</span><span style="color: rgba(0, 0, 0, 1)"> I CONTROL
</span><span style="color: rgba(128, 0, 128, 1)">2018</span>-<span style="color: rgba(128, 0, 128, 1)">01</span>-03T11:<span style="color: rgba(128, 0, 128, 1)">08</span>:<span style="color: rgba(128, 0, 128, 1)">55.526</span>+<span style="color: rgba(128, 0, 128, 1)">0800</span> I CONTROL ** WARNING: soft rlimits too low. rlimits set to <span style="color: rgba(128, 0, 128, 1)">19193</span> processes, <span style="color: rgba(128, 0, 128, 1)">65535</span> files. Number of processes should be at least <span style="color: rgba(128, 0, 128, 1)">32767.5</span> : <span style="color: rgba(128, 0, 128, 1)">0.5</span> times number of files.</pre>
</div>
</div>
<p>解决办法:</p>
<div>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">cat</span> &gt;&gt; /etc/security/limits.conf &lt;&lt;<span style="color: rgba(0, 0, 0, 1)">EOF
mongod   soft   nofile   </span><span style="color: rgba(128, 0, 128, 1)">32767.5</span><span style="color: rgba(0, 0, 0, 1)">
mongod   soft   nproc      </span><span style="color: rgba(128, 0, 128, 1)">32767.5</span><span style="color: rgba(0, 0, 0, 1)">
EOF</span></pre>
</div>
</div>
<p>&nbsp;&nbsp; 修改后,重启服务器,即可解决该问题。</p>
<h2>1.9 参考文献</h2>
<div>
<blockquote>
<p class="a3" style="color: rgba(0, 0, 0, 1)">&nbsp;&nbsp;https://docs.mongodb.com/manual/introduction/</p>
<p class="a3" style="color: rgba(0, 0, 0, 1)">&nbsp;&nbsp;http://www.mongoing.com/docs/introduction.html</p>
<p class="a3" style="color: rgba(0, 0, 0, 1)">&nbsp;&nbsp;https://zh.wikipedia.org/</p>
<p class="a3" style="color: rgba(0, 0, 0, 1)">&nbsp;&nbsp;https://docs.mongodb.com/manual/core/security-built-in-roles/</p>
</blockquote>
</div>
<p>&nbsp;</p>

</div>
<div id="MySignature" role="contentinfo">
    <div style="padding: 5px; background: #ff9; border: solid 1px #ccc">
作者:惨绿少年
<br>
出处:http://clsn.io
<br>
本文版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
<br>
</div><br><br>
来源:https://www.cnblogs.com/clsn/p/8214194.html
頁: [1]
查看完整版本: MongoDB 入门篇