<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>BLOG</title>
        <link>https://blog.yayh.life/</link>
        <description></description>
        <lastBuildDate>Sat, 16 Nov 2024 04:20:36 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>zh-CN</language>
        <copyright>All rights reserved 2024, guozichun</copyright>
        <item>
            <title><![CDATA[B-Money]]></title>
            <link>https://blog.yayh.life/article/6b509ef9-09ec-4879-8520-c76dfa6911de</link>
            <guid>https://blog.yayh.life/article/6b509ef9-09ec-4879-8520-c76dfa6911de</guid>
            <pubDate>Thu, 13 Jun 2024 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-6b509ef909ec48798520c76dfa6911de"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-callout notion-gray_background_co notion-block-502fc42580e14234aecaa39cd865f2b1"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="😆">😆</span></div><div class="notion-callout-text"><span class="notion-pink"><b>Arise, you have nothing to lose but your barbed wire fences! </b></span><span class="notion-pink">                             </span></div></div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-8e0938989bae40eca633b0a87164e289" data-id="8e0938989bae40eca633b0a87164e289"><span><div id="8e0938989bae40eca633b0a87164e289" class="notion-header-anchor"></div><a class="notion-hash-link" href="#8e0938989bae40eca633b0a87164e289" title="💰B-Money "><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">💰B-Money </span></span></h2><div class="notion-text notion-block-b243561e895d4523b2a75453ff65afc1"> 戴维的梦想。是他从 Tim May’s的”The Crypto Anarchist Manifesto’的设想而落地的一个提议，加密货币的早期版本是由这篇论文的概念衍生而来，但是戴维发布的是一个<b><em>Proposal</em></b>，而没有具体的代码或相关实现。</div><blockquote class="notion-quote notion-block-920f1f3a02114dc98a636089d32a8e5e"><div><em>  </em><span class="notion-gray">谁有多少钱的账户由一部分参与者（从现在开始称为服务器）而不是所有人保存。这些服务器通过</span><b><em><span class="notion-gray">Usenet</span></em></b><span class="notion-gray">样式的广播信道链接。在此信道上广播的事务消息的格式与第一个协议中的格式相同，但每个事务的受影响参与者应验证该消息是否已被随机选择的服务器子集接收并成功处理</span>。</div></blockquote><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-cf41684d54e04f77b75c4bfde31d69b5" data-id="cf41684d54e04f77b75c4bfde31d69b5"><span><div id="cf41684d54e04f77b75c4bfde31d69b5" class="notion-header-anchor"></div><a class="notion-hash-link" href="#cf41684d54e04f77b75c4bfde31d69b5" title="Tim-May"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Tim-May</span></span></h3><blockquote class="notion-quote notion-block-8b76ecf9084847498ba74204a5248062"><div>加密无政府主义 ——— <b><em><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://groups.csail.mit.edu/mac/classes/6.805/articles/crypto/cypherpunks/may-crypto-manifesto.html?ref=hackernoon.com">The Crypto Anarchist Manifesto</a></em></b></div></blockquote><div class="notion-text notion-block-a761fdd60b464b97a9d96b2074a9f41d"><em><span class="notion-orange">暴力将会被避免，因为你根本找不到参与者的真实姓名和肉身位置。</span></em></div><div class="notion-blank notion-block-90bc2990bb5e4cf89f022d4397bebb95"> </div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-8c125e7cd3004604acf3d770bd6168cf" data-id="8c125e7cd3004604acf3d770bd6168cf"><span><div id="8c125e7cd3004604acf3d770bd6168cf" class="notion-header-anchor"></div><a class="notion-hash-link" href="#8c125e7cd3004604acf3d770bd6168cf" title="PoW"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">PoW</span></span></h3><blockquote class="notion-quote notion-block-9bd29dd59ff34c5d8a07825f92a7ca42"><div>Proof-work 工作量证明</div></blockquote><div class="notion-text notion-block-9fd075277bbd4a7b87ebc3f721955af5">  PoW造币是通过消耗对应的计算量来产生同等价值的奖励（基本都是货币），但是需要计算的内容并不具备实际量化的意义，而是纯粹的消耗。

<b>举个🌰</b></div><div class="notion-text notion-block-50eaebc2409f4f47bb8088cfcdd55f6e">  以<b>BTC</b>为例子，算出对应的数学题后就拥有当前区块的记账权，同时也会获得分配给自己的奖励。每2016会调整一次计算难度，假设当前的计算是一个18位长度的Hash值,并没有任何算法能进行对应的解密，只能通过类似暴力的方式一次次进行对称重试直到找到答案，而每个矿工去计算的时候可以自由的选择方式从哪里开始进行，这里对于高算力的矿工来说提升的只是几率而不是靠速度快就能百分之百的完成计算，低算力的也同样会有机会。</div><div class="notion-blank notion-block-19a5ecf4148b4059b3a546e92ada94cc"> </div><div class="notion-text notion-block-30da616fa7464c9d94f889db69a365e2"><b>优劣点分析：</b></div><ol start="1" class="notion-list notion-list-numbered notion-block-c6d9d097bb09402aa3695bd1c47c3fd9"><li>去中心化程度高，但是为了确保区块的共识的确认、时间无法缩短又导致非常的不环保。</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-5b46dbb447e14da0a3bd91641b71c10e"><li>计算成本过高导致常见的攻击无效、例如双花攻击、篡改数据，但一旦攻击程度到达51%，而区块算力不够时就无法承受。</li></ol><div class="notion-blank notion-block-337919234f6b4f83aea66df11fdc9a6f"> </div><div class="notion-text notion-block-a31f452ee2404f9d8648cfbab3a0407a"><b>流程</b></div><div class="notion-blank notion-block-9899996014e846bc9f542c11c33bf43e"> </div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-6eec2141f91049b0ac1a9595811d21a7" data-id="6eec2141f91049b0ac1a9595811d21a7"><span><div id="6eec2141f91049b0ac1a9595811d21a7" class="notion-header-anchor"></div><a class="notion-hash-link" href="#6eec2141f91049b0ac1a9595811d21a7" title="双花问题"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">双花问题</span></span></h4><blockquote class="notion-quote notion-block-5d0b9b2d2f39486fae0f521365c909e1"><div><em>BMoney无法解决双花问题、因为没有共识机制来证明，只能确保PoW的工作量证明，但不能保证工作产生的值被多次使用。</em></div></blockquote><div class="notion-text notion-block-ba7f713033154823ae19fdd50242aeaa">因为没有中央账本来进行管理，BMoney没有提供解决类似拜占庭将军的类似问题，而<b>Btc</b>的出现就弥补了<code class="notion-inline-code">BMoney</code> 带来的共识机制问题，通过在分布式的各个参与者记录账本来保证区块的连续性和真实性。</div><div class="notion-text notion-block-d6bade5e255949e1bc4534d21b832030">通过区块链、共识机制、时间戳服务器来实现<code class="notion-inline-code">BMoney</code> 没有做到的那部分。</div><blockquote class="notion-quote notion-block-b173a2b8a45a4bf98050f6692280a9b8"><div><em><span class="notion-gray">比特币通过链，让后来区块的安全去累加加固以前区块的安全，是非常厉害的安全思路。</span></em></div></blockquote><div class="notion-blank notion-block-a6de140ce6ea420bb46ad348334052df"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-e53f1c4e001244e2a657117309e5d1ce"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F321b9db5-2572-4ed3-a141-dcbea6d92a4c%2Fd8ef290a-7ab5-4722-b59f-110b153b8e87%2FUntitled.png?table=block&amp;id=e53f1c4e-0012-44e2-a657-117309e5d1ce&amp;t=e53f1c4e-0012-44e2-a657-117309e5d1ce&amp;width=720&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-2f741f99897f42d9a7ed9561123f5560"> </div><div class="notion-blank notion-block-a93e44dd05ea4bc184711f4c3ad86ea4"> </div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-90e5cd5734bb4119ac32e210b01b5107" data-id="90e5cd5734bb4119ac32e210b01b5107"><span><div id="90e5cd5734bb4119ac32e210b01b5107" class="notion-header-anchor"></div><a class="notion-hash-link" href="#90e5cd5734bb4119ac32e210b01b5107" title="拜占庭将军问题"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">拜占庭将军问题</span></span></h4><blockquote class="notion-quote notion-block-bda8d91c4961405da51224440f7fd993"><div>当 n &gt; 3t 时，可以冗余出现问题的情况。</div></blockquote><div class="notion-blank notion-block-78d8f661fd504c5bbff84bc912a3b10e"> </div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-f3cc7c64e5264a468c62f4be67990b06" data-id="f3cc7c64e5264a468c62f4be67990b06"><span><div id="f3cc7c64e5264a468c62f4be67990b06" class="notion-header-anchor"></div><a class="notion-hash-link" href="#f3cc7c64e5264a468c62f4be67990b06" title="PoS "><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">PoS </span></span></h3><blockquote class="notion-quote notion-block-176026fcc3404fcaa1bef17e3f2dbfc2"><div><em>Proof of Stake </em><span class="notion-gray">权益共识，解决资源大量浪费的情况，当持有占总币数量、时间决定是否拥有记账权的概率越大。</span></div></blockquote><div class="notion-blank notion-block-e21038f1c4374367b053261ed72817e3"> </div><div class="notion-text notion-block-a78b0b0458434968b52aed1d725f9774">PoW机制中工作机制需要耗费大量的计算量得到 <code class="notion-inline-code">nonce</code> , <code class="notion-inline-code">Pos</code>机制则采取更快速的算法。</div><div class="notion-text notion-block-afe33fa48555424aa717d05cd2f86fc2"><code class="notion-inline-code">H</code> = 哈希函数</div><div class="notion-text notion-block-a106408f9dc7421dbad5f33290e41411"><code class="notion-inline-code">t</code> = UTC时间戳</div><div class="notion-text notion-block-5f7a8b163b944c97a26ec5ce6f9b4868"><code class="notion-inline-code">Bprev</code> = 上个区块</div><div class="notion-text notion-block-1cf2ace9c07b4703af73ef7f60e79422"><code class="notion-inline-code">balance(A)</code> = 账户余额</div><div class="notion-text notion-block-183d42eb1ae54b6b9f6db4b7b1200bef">当<code class="notion-inline-code">balance(A)</code>足够大的时候，数值越大同等算力的情况下越容易找到符合的<code class="notion-inline-code">t</code> </div><div class="notion-blank notion-block-a51df886847c4e55ba2a87877dc435be"> </div><blockquote class="notion-quote notion-block-b1d728c04707418d949a9f063c14d4d4"><div><em><b> </b></em><b><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://zhuanlan.zhihu.com/p/31588809">引用知乎的一个例子总结:</a></b><b> 
 
</b><em><span class="notion-gray"><b>你上学的时候，班级里发生的行为需要被记在班级的一个大家公用的账本（区块链）上。</b></span></em></div><div class="notion-text notion-block-2f76c2b330ae4328bbc051eb7984d18a"><em><span class="notion-gray"><b>老师或者同学们用这个公用的账本进行记录，并且有一种专门用来支付这个账本上大家记录的、需要支付的代币，我们暂且把它叫做Good币。</b></span></em></div><div class="notion-text notion-block-833ca793cb7b4c0ab5923d4438d4e41c"><em><span class="notion-gray"><b>这些币可以兑换成钱。你们班级的公共账本不是一个大本子，而是由很多个小本子中间连接一条线组合成的。</b></span></em></div><div class="notion-text notion-block-3353bd1ceade43308fd6b7d9b54ff6a4"><em>在PoW机制下，老师是用一道特别难的数学题来让第一个算出来的同学获得记账权，在这个机制下会导致大部分的同学计算题目导致的时间资源浪费，目前重新推举了PoS的共识机制.</em></div><div class="notion-text notion-block-bd599236accc4c97a755c609cf434d36">调整区别如下</div><ol start="1" class="notion-list notion-list-numbered notion-block-e8cc6e5b62fd4bbcb6a69ac82cc9a943"><li>不再计算数学题。</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-a2f0b59b53df4645af341187fbe22fb4"><li>增加币龄的概念(持有币的时间,例: 每个币每天产生1币龄)</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-18b8e1000cd641e1bcce05168149928a"><li>增加持有币的统计 （持有的币越多几率越高）</li></ol><ol start="4" class="notion-list notion-list-numbered notion-block-b119ed3d93f84672b3124d725926e3ee"><li>增加币的年利率（假设5%）</li></ol><ol start="5" class="notion-list notion-list-numbered notion-block-36a516dae12c4216b1cbb9075caaab8e"><li>每次新区块产生之前会清空币龄</li></ol><ol start="6" class="notion-list notion-list-numbered notion-block-b8ac79f05c8c4d109ccc563655a884d7"><li>每清空365个币龄就会产生5%的年化利息</li></ol><div class="notion-blank notion-block-eba856594b6642f898192e06e16dbaa4"> </div><div class="notion-text notion-block-f3abdf7b23374aa29e9fa6819c39c888"><em><b>现在，如果 A 持有 30天 100个 Good币，则 30 * 100 * 0.05 / 365 = 0.4109589041 Good币</b></em></div><div class="notion-blank notion-block-6b5f1633633847059a257b1f084a597f"> </div></blockquote><div class="notion-blank notion-block-884c27fcaadb43438b499b1925401957"> </div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-11dffbaf77904f5799e9787ab901e5b4" data-id="11dffbaf77904f5799e9787ab901e5b4"><span><div id="11dffbaf77904f5799e9787ab901e5b4" class="notion-header-anchor"></div><a class="notion-hash-link" href="#11dffbaf77904f5799e9787ab901e5b4" title="总结"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">总结</span></span></h2><div class="notion-text notion-block-c634b4de6c17481b809f9b9191fd0627"><em>根据PoW和PoS来看，在去中心化的区块技术下没有最好的机制只有更好的机制, 每种机制都有取舍、包括还有新推出的PoA机制，多多少少都有对应的优劣。</em></div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-121cf79a946643d28876eac381dbac49" data-id="121cf79a946643d28876eac381dbac49"><span><div id="121cf79a946643d28876eac381dbac49" class="notion-header-anchor"></div><a class="notion-hash-link" href="#121cf79a946643d28876eac381dbac49" title="📎 参考文章"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">📎 参考文章</span></span></h2><ul class="notion-list notion-list-disc notion-block-ed52acb3288c4468b3316de8669e173d"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="http://www.weidai.com/bmoney.txt">BMoney - WeiDai</a></li></ul><div class="notion-blank notion-block-89145388978643f1ac400511ef41e2d0"> </div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[从对腾讯云COS加密的需求开始的轮子]]></title>
            <link>https://blog.yayh.life/article/dc112037-fd4b-4843-9339-ab04c24d039a</link>
            <guid>https://blog.yayh.life/article/dc112037-fd4b-4843-9339-ab04c24d039a</guid>
            <pubDate>Thu, 25 Apr 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[轮子、腾讯云、SDK]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-dc112037fd4b48439339ab04c24d039a"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-callout notion-gray_background_co notion-block-7d3aae04c15a46b1911440466076c2b3"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="😀">😀</span></div><div class="notion-callout-text">一句话需求：
返回给前端通过腾讯云COS存储的图片预签名URL，简单来说。出于安全考虑（这个方式存疑！）就是要把存储在COS里的某些文件数据进行签名加密之后进行可控的访问，可以添加的参数包括不限于 Query\Headr
可以设置签名的有效时间在一定范围时间内可以用签名好的链接进行访问，如果超出时长就失效。</div></div><div class="notion-blank notion-block-ee71a0b65f09449ebca410beb024ef22"> </div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-f40f3a75d4f84502a2853f99d3d785c8" data-id="f40f3a75d4f84502a2853f99d3d785c8"><span><div id="f40f3a75d4f84502a2853f99d3d785c8" class="notion-header-anchor"></div><a class="notion-hash-link" href="#f40f3a75d4f84502a2853f99d3d785c8" title="📝 签名步骤"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">📝 签名步骤</span></span></h2><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-7903223a5f0643b294f787b948a65170" data-id="7903223a5f0643b294f787b948a65170"><span><div id="7903223a5f0643b294f787b948a65170" class="notion-header-anchor"></div><a class="notion-hash-link" href="#7903223a5f0643b294f787b948a65170" title="通过对应的APPID + Bucket + KEY 等参数通过腾讯云COS鉴权之后后进行对某个文件Key的预签名或者直接获取签名后的Download URL"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">通过对应的APPID + Bucket + KEY 等参数通过腾讯云COS鉴权之后后进行对某个文件Key的预签名或者直接获取签名后的Download URL</span></span></h3><figure class="notion-asset-wrapper notion-asset-wrapper-embed notion-block-f785998bae544d2a9d2564a601df3607"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:320px"><iframe class="notion-asset-object-fit" src="https://cloud.tencent.com/document/product/436/35217" title="iframe embed" frameBorder="0" allowfullscreen="" loading="lazy" scrolling="auto"></iframe></div></figure><div class="notion-blank notion-block-3838e3a39b174d4984861868d9eb9676"> </div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-fc5a9fa4fffd4b219f03068ae5d93da0" data-id="fc5a9fa4fffd4b219f03068ae5d93da0"><span><div id="fc5a9fa4fffd4b219f03068ae5d93da0" class="notion-header-anchor"></div><a class="notion-hash-link" href="#fc5a9fa4fffd4b219f03068ae5d93da0" title="但是没有好用的NestJS的腾讯云包"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">但是没有好用的NestJS的腾讯云包</span></span></h3><blockquote class="notion-quote notion-block-7ca283e29b134a1e94e5db6821712497"><div>腾讯云的SDK小版本比较频繁、问题也比较多 依赖更新也很草率。
COS和CLOUD的两个SDK是分了两个项目包
导致打包的问题（+2小时）目前最新的在16小时前发布的 <b>4.0.842 </b>有和目前开发项目的sub-modules包的依赖冲突，目前比较稳定的是 <b>4.0.837
目前实现的是 OCR、SMS、COS</b></div></blockquote><div class="notion-text notion-block-b676ff4098144a32ad0bddf83001af98">索性就写了个包，将来项目上也可以复用和慢慢升级改造。</div><div class="notion-text notion-block-86359fa755f44baa8cd000e8ff6515dc">
<b>@cardbrother/nestjs-tencent-cloud-sdk</b></div><div class="notion-text notion-block-49cf1664d3984a37b3292f93a697622c"><b>因为底层冲突问题 目前version发布的比较混乱（回头会抽空整理下）
</b></div><div class="notion-row"><a target="_blank" rel="noopener noreferrer" class="notion-bookmark notion-block-8e6d523d371e4a7fa2be58d64c306e5c" href="https://www.npmjs.com/package/@cardbrother/nestjs-tencent-cloud-sdk?activeTab=readme"><div><div class="notion-bookmark-title">npm: @cardbrother/nestjs-tencent-cloud-sdk</div><div class="notion-bookmark-description">nestjs tencent cloud sdk. Latest version: 1.0.11, last published: 3 hours ago. Start using @cardbrother/nestjs-tencent-cloud-sdk in your project by running `npm i @cardbrother/nestjs-tencent-cloud-sdk`. There are no other projects in the npm registry using @cardbrother/nestjs-tencent-cloud-sdk.</div><div class="notion-bookmark-link"><div class="notion-bookmark-link-icon"><img src="https://static-production.npmjs.com/1996fcfdf7ca81ea795f67f093d7f449.png?t=8e6d523d-371e-4a7f-a2be-58d64c306e5c" alt="npm: @cardbrother/nestjs-tencent-cloud-sdk" loading="lazy" decoding="async"/></div><div class="notion-bookmark-link-text">https://www.npmjs.com/package/@cardbrother/nestjs-tencent-cloud-sdk?activeTab=readme</div></div></div><div class="notion-bookmark-image"><img style="object-fit:cover" src="https://static-production.npmjs.com/338e4905a2684ca96e08c7780fc68412.png?t=8e6d523d-371e-4a7f-a2be-58d64c306e5c" alt="npm: @cardbrother/nestjs-tencent-cloud-sdk" loading="lazy" decoding="async"/></div></a></div><div class="notion-blank notion-block-e229a92ea2444cc2b5214a7bd272f38a"> </div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-5b44744e39614ef8ba0565e794f9b7a0" data-id="5b44744e39614ef8ba0565e794f9b7a0"><span><div id="5b44744e39614ef8ba0565e794f9b7a0" class="notion-header-anchor"></div><a class="notion-hash-link" href="#5b44744e39614ef8ba0565e794f9b7a0" title="回到加密需求本身"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">回到加密需求本身</span></span></h3><div class="notion-text notion-block-60d09f6f1c6d4a0e97d176f67ca0fb9e">考虑以后难免需要签名加密的图片或者文件可能会有，业务实现的方式变成拦截器来实现并不是在业务中固定


<em><b>核心代码</b></em></div><div class="notion-blank notion-block-571fe63d3d9b4b498ec538d0ebea57cc"> </div><div class="notion-text notion-block-d8bea0c6f1bc4708a0f5b5bdb10151b9"><b>调用方式</b></div><div class="notion-blank notion-block-73e942aa95dd4e3785e0c0d004ea0ec2"> </div><div class="notion-blank notion-block-e4449466a8d748aa9aa578459ae9e0a0"> </div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-7c5f35df2c2f42fdbbd60037ea4e42ec" data-id="7c5f35df2c2f42fdbbd60037ea4e42ec"><span><div id="7c5f35df2c2f42fdbbd60037ea4e42ec" class="notion-header-anchor"></div><a class="notion-hash-link" href="#7c5f35df2c2f42fdbbd60037ea4e42ec" title="结论"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">结论</span></span></h3><div class="notion-text notion-block-55653c8dc962491fb558660f1033f0bb"><b>综上，所以实际工作量超出预期（顺便提了个PR给changeset/action 🍉)</b>

</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-94fa3133c98c4e92aaa26db581b91bb5"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:499px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F321b9db5-2572-4ed3-a141-dcbea6d92a4c%2F03f2d3d3-2b3c-4d36-ab09-35f5450fffa7%2FUntitled.png?table=block&amp;id=94fa3133-c98c-4e92-aaa2-6db581b91bb5&amp;t=94fa3133-c98c-4e92-aaa2-6db581b91bb5&amp;width=499&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-3cf0d70d9de34941b09602034c275d30"> </div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[从西门开始一路向东-岳麓山西门徒步]]></title>
            <link>https://blog.yayh.life/article/2da19215-3d61-43f7-ae06-aeb4101e83ff</link>
            <guid>https://blog.yayh.life/article/2da19215-3d61-43f7-ae06-aeb4101e83ff</guid>
            <pubDate>Mon, 29 Apr 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[徒步、长沙、旅游]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-2da192153d6143f7ae06aeb4101e83ff"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-callout notion-gray_background_co notion-block-4bda71ec781e43159e7d6934e783aac1"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="😀">😀</span></div><div class="notion-callout-text">“没人疼就去爬山吧，爬完浑身疼。”  那天也不知道为什么，珩坨妈妈导航到了西门。</div></div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-43367acacdfb4b139e891d29e9b84a8d"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:192px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F321b9db5-2572-4ed3-a141-dcbea6d92a4c%2F76831961-e1be-40f3-a16d-0188f70df636%2FUntitled.png?table=block&amp;id=43367aca-cdfb-4b13-9e89-1d29e9b84a8d&amp;t=43367aca-cdfb-4b13-9e89-1d29e9b84a8d&amp;width=192&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-0fd6e83b38cd42ab88e50d8215a35c3f" data-id="0fd6e83b38cd42ab88e50d8215a35c3f"><span><div id="0fd6e83b38cd42ab88e50d8215a35c3f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#0fd6e83b38cd42ab88e50d8215a35c3f" title="🚗 出发"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">🚗 出发</span></span></h2><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-7068ca2ede2642e08c820f8140d0a716" data-id="7068ca2ede2642e08c820f8140d0a716"><span><div id="7068ca2ede2642e08c820f8140d0a716" class="notion-header-anchor"></div><a class="notion-hash-link" href="#7068ca2ede2642e08c820f8140d0a716" title="π崽近日一直跟我念叨想去爬山"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">π崽近日一直跟我念叨想去爬山</span></span></h3><blockquote class="notion-quote notion-block-346423c6484f49918d63df5b1d8a8f2d"><div>我说 游乐场和爬山你二选一，他居然毫不犹豫的选择了爬山。</div></blockquote><div class="notion-blank notion-block-c5b76dfe4ab74f4bacb15024d27cc951"> </div><div class="notion-text notion-block-d7055cbfb8b04b8e8b4451c5df148b0f">正好近日我调休还剩余几天，五一前夕。趁着假期人流高峰来临之前夜。索性休假带着π崽珩坨去岳麓山</div><div class="notion-blank notion-block-ef78282f760c4caaa6d3b9180e970090"> </div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-886b6cfe86b44fac9f1546877b3a89b2" data-id="886b6cfe86b44fac9f1546877b3a89b2"><span><div id="886b6cfe86b44fac9f1546877b3a89b2" class="notion-header-anchor"></div><a class="notion-hash-link" href="#886b6cfe86b44fac9f1546877b3a89b2" title="海尔兄弟👬 不畏困难"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">海尔兄弟👬 不畏困难</span></span></h3><blockquote class="notion-quote notion-block-8f5b162612164fa180fb5735ee91f1ae"><div>居然没想到，几乎99%完全独立走完全程的哥哥。一路上不哭也不闹尽量自己向上攀爬台阶的弟弟，共同愉快的完成了登顶。</div></blockquote><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-7e15eb93f33a4b67930ecbf6101efeb5" data-id="7e15eb93f33a4b67930ecbf6101efeb5"><span><div id="7e15eb93f33a4b67930ecbf6101efeb5" class="notion-header-anchor"></div><a class="notion-hash-link" href="#7e15eb93f33a4b67930ecbf6101efeb5" title="🤗 沿路都在享受过程 没有拍很多照片"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">🤗 沿路都在享受过程 没有拍很多照片</span></span></h2><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-97913c37b89a4475824928ccd4fd7297"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:480px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F321b9db5-2572-4ed3-a141-dcbea6d92a4c%2F56cc5a90-0ce1-4d81-bc12-e61275f09f9a%2FUntitled.jpeg?table=block&amp;id=97913c37-b89a-4475-8249-28ccd4fd7297&amp;t=97913c37-b89a-4475-8249-28ccd4fd7297&amp;width=480&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-4600b90294b04796a71862b79c1ade01"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:480px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F321b9db5-2572-4ed3-a141-dcbea6d92a4c%2Fcc524cf5-4608-433f-bc52-099e8e2995b6%2FUntitled.jpeg?table=block&amp;id=4600b902-94b0-4796-a718-62b79c1ade01&amp;t=4600b902-94b0-4796-a718-62b79c1ade01&amp;width=480&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-cad2e3c629224d3f92774288ad097527"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:480px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F321b9db5-2572-4ed3-a141-dcbea6d92a4c%2F685a9bb0-cfc7-43f5-9563-01466c0e8db8%2FUntitled.jpeg?table=block&amp;id=cad2e3c6-2922-4d3f-9277-4288ad097527&amp;t=cad2e3c6-2922-4d3f-9277-4288ad097527&amp;width=480&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-8cd32245886e4550b2e230485d27a41b"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:480px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F321b9db5-2572-4ed3-a141-dcbea6d92a4c%2F7c9f4ebb-9518-440a-a4d0-32ed95a127cc%2FUntitled.jpeg?table=block&amp;id=8cd32245-886e-4550-b2e2-30485d27a41b&amp;t=8cd32245-886e-4550-b2e2-30485d27a41b&amp;width=480&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-cc385155dff3419497529f306740c93d"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:480px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F321b9db5-2572-4ed3-a141-dcbea6d92a4c%2F0cecbac3-1944-474a-b8f3-182105aa9f56%2FUntitled.jpeg?table=block&amp;id=cc385155-dff3-4194-9752-9f306740c93d&amp;t=cc385155-dff3-4194-9752-9f306740c93d&amp;width=480&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-23dce65ec7e0423487f206c4dad8739e"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:480px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F321b9db5-2572-4ed3-a141-dcbea6d92a4c%2F80909bf8-9fd9-4918-8c49-3467f885344e%2FUntitled.jpeg?table=block&amp;id=23dce65e-c7e0-4234-87f2-06c4dad8739e&amp;t=23dce65e-c7e0-4234-87f2-06c4dad8739e&amp;width=480&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-c8093610dbe54ed0bc1e42243446034c"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:480px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F321b9db5-2572-4ed3-a141-dcbea6d92a4c%2Fd4117adf-42c4-4f9e-898a-621bf958a1fd%2FUntitled.jpeg?table=block&amp;id=c8093610-dbe5-4ed0-bc1e-42243446034c&amp;t=c8093610-dbe5-4ed0-bc1e-42243446034c&amp;width=480&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-7541dfcb893c4815ad4a467087629b68"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:480px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F321b9db5-2572-4ed3-a141-dcbea6d92a4c%2Fbe28f76e-9b67-4820-94b3-22fb1118f95f%2FUntitled.jpeg?table=block&amp;id=7541dfcb-893c-4815-ad4a-467087629b68&amp;t=7541dfcb-893c-4815-ad4a-467087629b68&amp;width=480&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-13c0bc8ac46245c1aaff1ed1c4ceb4e0"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:480px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F321b9db5-2572-4ed3-a141-dcbea6d92a4c%2Fb0fdc3bc-6cb5-41f1-aec7-a451f462d3f8%2FUntitled.jpeg?table=block&amp;id=13c0bc8a-c462-45c1-aaff-1ed1c4ceb4e0&amp;t=13c0bc8a-c462-45c1-aaff-1ed1c4ceb4e0&amp;width=480&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-2d5ad560ca184868ad965a4d3785f12c"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:480px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F321b9db5-2572-4ed3-a141-dcbea6d92a4c%2F676dc39d-10c8-4bef-9a9a-b11fa4f5697d%2FUntitled.jpeg?table=block&amp;id=2d5ad560-ca18-4868-ad96-5a4d3785f12c&amp;t=2d5ad560-ca18-4868-ad96-5a4d3785f12c&amp;width=480&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-c690bd4b8dce4c06b9f6532d01902d98"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:384px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F321b9db5-2572-4ed3-a141-dcbea6d92a4c%2F2bd9e8a6-bf99-4eea-a4f0-a75c7864e825%2FUntitled.jpeg?table=block&amp;id=c690bd4b-8dce-4c06-b9f6-532d01902d98&amp;t=c690bd4b-8dce-4c06-b9f6-532d01902d98&amp;width=384&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-516c279c2f1843ca9ccbf7f3360b4409"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:384px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F321b9db5-2572-4ed3-a141-dcbea6d92a4c%2Fc6a881a8-36c1-43cb-aff5-868ed41203e5%2FUntitled.jpeg?table=block&amp;id=516c279c-2f18-43ca-9ccb-f7f3360b4409&amp;t=516c279c-2f18-43ca-9ccb-f7f3360b4409&amp;width=384&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-e256c17cde0d49cc8477c289234d64bd"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:384px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F321b9db5-2572-4ed3-a141-dcbea6d92a4c%2F6f4b844d-439d-4e0e-8f72-65890324a4b8%2FUntitled.jpeg?table=block&amp;id=e256c17c-de0d-49cc-8477-c289234d64bd&amp;t=e256c17c-de0d-49cc-8477-c289234d64bd&amp;width=384&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[使用Rollup构建React项目]]></title>
            <link>https://blog.yayh.life/article/8ce7ef45-3263-476d-94e1-48da9a75561c</link>
            <guid>https://blog.yayh.life/article/8ce7ef45-3263-476d-94e1-48da9a75561c</guid>
            <pubDate>Fri, 29 Mar 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[Rollup打包前端应用]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-8ce7ef453263476d94e148da9a75561c"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-callout notion-gray_background_co notion-block-4162f284d9d44b09b5d91e33e51619a8"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="💡">💡</span></div><div class="notion-callout-text">最近参加了北京大学计算与数字经济研究院下的工业智能的面试，一面之后二面需要在复试之前做2个小Quize，因为是全栈岗，所以考核中也包括了一个前端组件的实现，实现要求很自由并没有任何限制。
不想用太重的框架或成熟生态技术脚手架来做这个实现，正好对比了目前生态各个毕竟流行的打包方式，Webpack、Vite、esbuild等等，看到目前比较火的Vite其实内部打包也是利用的Rollup来做的处理只是非显性的配置，联想起多年前在Ant做过的统一认证认证的Sdk，当时也是选用的Roullup早期版本方案来做的打包输出，那时还没有很完善的生态周边插件，现在朝花夕拾了</div></div><div class="notion-blank notion-block-a33cf1e9ed754040ab9edd6818211abc"> </div><div class="notion-blank notion-block-5f6e289c9ef0489b935c260cc6277724"> </div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-2a37a71e9a0e4563a6411699b5c65e49" data-id="2a37a71e9a0e4563a6411699b5c65e49"><span><div id="2a37a71e9a0e4563a6411699b5c65e49" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2a37a71e9a0e4563a6411699b5c65e49" title="准备"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">准备</span></span></h2><div class="notion-blank notion-block-eb4d59b1577b42628b5f4ebf98c83dbf"> </div><blockquote class="notion-quote notion-block-f532898e35364f1c8b07e6fa601669d9"><div>使用的包管理器是 <code class="notion-inline-code">yarn@4.1.1 </code></div></blockquote><div class="notion-blank notion-block-b6bd30a0b6f0488abe8f1e9256284b28"> </div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-d09be0a248e64f9a981182ea29e44fb0" data-id="d09be0a248e64f9a981182ea29e44fb0"><span><div id="d09be0a248e64f9a981182ea29e44fb0" class="notion-header-anchor"></div><a class="notion-hash-link" href="#d09be0a248e64f9a981182ea29e44fb0" title="安装依赖"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">安装依赖</span></span></h4><div class="notion-blank notion-block-0c87e7cc6e9b4de9a599bc1ddd48cb42"> </div><blockquote class="notion-quote notion-block-eb1e438dce224e31a11c8854008e64cb"><div>首先按照rollup对React项目中所需要用的包<b>开发依赖</b>进行安装</div></blockquote><div class="notion-blank notion-block-4e5dbdb7317d46f58219bbddd5a134c4"> </div><blockquote class="notion-quote notion-block-d51efa95cdf2418e80e17c345e25d6e3"><div>关键开发依赖库的用途</div></blockquote><ul class="notion-list notion-list-disc notion-block-efad7c108d5740bbb46014f472404d82"><li><code class="notion-inline-code">rollup-plugin-commonjs </code> 将CommonJS模块转换为ESM</li></ul><ul class="notion-list notion-list-disc notion-block-657896eb5a8847acb3e9fed8d521e527"><li><code class="notion-inline-code">rollup-plugion-node-resolve</code> 帮助Rollup直接查找并使用第三方库 node_modules模块</li></ul><ul class="notion-list notion-list-disc notion-block-bddab6ae363a4ae8946fdc53f10470da"><li><code class="notion-inline-code">rollup-plugin-clear</code>  清空输出目录</li></ul><ul class="notion-list notion-list-disc notion-block-004bf5ba9f1d4ffeb6782da382551ff5"><li><code class="notion-inline-code">rollup-plugin-terser</code> 压缩</li></ul><ul class="notion-list notion-list-disc notion-block-95b00155becb4f0ea6f7b326e740dbbd"><li><code class="notion-inline-code">@rollup/plugin-typescript</code> rollup编译解析typescript</li></ul><ul class="notion-list notion-list-disc notion-block-9b9f58e0b4d1451bb2ea049284299c05"><li><code class="notion-inline-code">rollup-plugin-serve</code> 开发服务启动（热更新）</li></ul><div class="notion-blank notion-block-8e371d085a9a40deae946f8fe0cd1afe"> </div><div class="notion-blank notion-block-2869d5038fc9484eba69df800779f11f"> </div><div class="notion-blank notion-block-02bed903b2984ee691f936d52451dd09"> </div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-04a9a793df344843abaf20fbb9470ba2" data-id="04a9a793df344843abaf20fbb9470ba2"><span><div id="04a9a793df344843abaf20fbb9470ba2" class="notion-header-anchor"></div><a class="notion-hash-link" href="#04a9a793df344843abaf20fbb9470ba2" title="配置"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">配置</span></span></h2><div class="notion-blank notion-block-46e93831b2024883a818a704736918bf"> </div><blockquote class="notion-quote notion-block-196397bb1d23490b8d88b2d669b870a3"><div>初始化配置</div></blockquote><div class="notion-blank notion-block-d380842f056f496ab395754266379fc9"> </div><div class="notion-text notion-block-db4249579ec34896b0cea0636c023385"><code class="notion-inline-code">yarn dlx tsc —init</code> or <code class="notion-inline-code">tsc --init</code></div><div class="notion-text notion-block-8f4bcc1c0130485892df3799e3608090"><code class="notion-inline-code">yarn dlx @yarnpkg/sdks vscode  </code></div><div class="notion-text notion-block-ede9f91e00ec41939e5890ccafa98db4"><em><b>Then, In </b></em><span class="notion-blue"><em><b>VSCode</b></em></span></div><blockquote class="notion-quote notion-block-07c5c7c6de464a6c8524537935ecefe9"><div>CMD + SHIFT + P   → Select  Typescript Version </div></blockquote><blockquote class="notion-quote notion-block-44202f5058994a768ce2948aaf397365"><div>Use <code class="notion-inline-code">.yarn/sdk/typescript/lib</code></div></blockquote><div class="notion-blank notion-block-0fbcdb1a9c594df8bdafddcbb0f0e60c"> </div><div class="notion-text notion-block-f43618a5821641fd95e9209e98bbdd44"><b>Rollup配置</b></div><div class="notion-blank notion-block-02b313ac6c00402980f4aed289760ebd"> </div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-b738709adb0c401997107da6ad4b2445" data-id="b738709adb0c401997107da6ad4b2445"><span><div id="b738709adb0c401997107da6ad4b2445" class="notion-header-anchor"></div><a class="notion-hash-link" href="#b738709adb0c401997107da6ad4b2445" title="Rollup相关回顾"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Rollup相关回顾</span></span></h3><div class="notion-blank notion-block-0df1f322c69c42128561b36e4c10f31b"> </div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-a1d017f278064a838532452edafdc1c9" data-id="a1d017f278064a838532452edafdc1c9"><span><div id="a1d017f278064a838532452edafdc1c9" class="notion-header-anchor"></div><a class="notion-hash-link" href="#a1d017f278064a838532452edafdc1c9" title="ES6 Module"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">ES6 Module</span></span></h4><div class="notion-blank notion-block-894e1dfe15374e1598624a43bf4e7e3e"> </div><div class="notion-blank notion-block-d246b966e38f47c6b867fccf1d521682"> </div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-b7d66d20a9304caca83d771f2c0c2c1f" data-id="b7d66d20a9304caca83d771f2c0c2c1f"><span><div id="b7d66d20a9304caca83d771f2c0c2c1f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#b7d66d20a9304caca83d771f2c0c2c1f" title="导入第三方模块"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">导入第三方模块</span></span></h4><div class="notion-blank notion-block-8a2b1204e28942fe80d05f52479cd744"> </div><div class="notion-text notion-block-c851fbe25f614779b0bfca3f8c5f919e">在<code class="notion-inline-code">rollup</code>中需要引入第三方模块时，需要引入插件 <code class="notion-inline-code">rollup-plugin-node-resolve</code> 来实现，因为默认<code class="notion-inline-code">rollup</code>本身只能通过本地文件路径来引入模块，并不能通过包的名称来引入node_modules中安装的第三方类库。</div><div class="notion-blank notion-block-04c1b7782ebf4dbba3fbaf9da04be560"> </div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-3111fda028bc443ebafda888afadf120" data-id="3111fda028bc443ebafda888afadf120"><span><div id="3111fda028bc443ebafda888afadf120" class="notion-header-anchor"></div><a class="notion-hash-link" href="#3111fda028bc443ebafda888afadf120" title="Tree Shaking 树状摇曳"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>Tree Shaking </b>树状摇曳</span></span></h4><div class="notion-blank notion-block-5ddcbacd8e3d41e79cb82b814aade4fc"> </div><blockquote class="notion-quote notion-block-7966bd692bc148faa73770e231a9b2f7"><div>Rollup 提供Tree-Shaking功能，这个形象的名词描述了功能就像是摇晃树，那些不再被需要的树枝叶子会掉落下来，这里指的是那些不需要被打包进去的代码。</div></blockquote><div class="notion-blank notion-block-2c3727a3d3fd4328880f5b4e5dabd520"> </div><div class="notion-text notion-block-b30662a9e6954d11b1de12504e45a37d">这个功能在Webpack中可以通过 <code class="notion-inline-code">babel-plugin-import</code>  可实现按需加载减少打包体积</div><div class="notion-blank notion-block-75cd142d023448f2ab71073ec9a76a30"> </div><div class="notion-blank notion-block-9e57d9c614a24928a66a6b96452a1f09"> </div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-2c391701d92942008e22f86d87ee9189" data-id="2c391701d92942008e22f86d87ee9189"><span><div id="2c391701d92942008e22f86d87ee9189" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2c391701d92942008e22f86d87ee9189" title="CommonJS 和 ESM"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">CommonJS 和 ESM</span></span></h4><div class="notion-blank notion-block-c4c1bc0cdd51427cb9324a6b95864b15"> </div><blockquote class="notion-quote notion-block-1c539e880d4746e99d9ba42b0a3780a7"><div>为了确保你的 ES 模块可以立即被处理 CommonJS 的工具，例如 Node.js 和 webpack 使用，你可以使用 Rollup 编译成 UMD 或 CommonJS 格式，然后在 <code class="notion-inline-code">package.json</code> 文件中使用 <code class="notion-inline-code">main</code> 属性指向编译后的版本。如果你的 <code class="notion-inline-code">package.json</code> 文件还有一个 <code class="notion-inline-code">module</code> 字段，那么像 Rollup 和 <a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://webpack.js.org/">webpack 2+</a> 这样的可感知 ES 模块的工具将直接 <a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://github.com/rollup/rollup/wiki/pkg.module">导入 ES 模块版本</a>。</div></blockquote><div class="notion-blank notion-block-67929da213714ed09684d20c62590cfa"> </div><div class="notion-text notion-block-c5f78843480f43089ab506c49307f85f">默认<code class="notion-inline-code">rollup</code> 是不支持CommonJS打包的，默认输出的为ESM，更偏向于前端类库支持。如果需要想在Rollup中实现<code class="notion-inline-code">CJS</code> 输出的话，需要引用 <code class="notion-inline-code">rollup-plugins-commonjs</code> 来实现。</div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-1527559e6f454c32b3c33329a5cdcb77" data-id="1527559e6f454c32b3c33329a5cdcb77"><span><div id="1527559e6f454c32b3c33329a5cdcb77" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1527559e6f454c32b3c33329a5cdcb77" title="🤗 总结归纳"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">🤗 总结归纳</span></span></h2><div class="notion-text notion-block-75fe9c19d6e84a25aae5e04103030156"> 当需要使用一种简单有效的对类库的打包当时<code class="notion-inline-code">Rollup</code> 还是非常适用的，但是如果开发一个复杂度更高项目而不是单一功能或表现的库，还是需要webpack或Vite等更加丰富完善的打包工具。</div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-3b1fb1b5d2c34b83be5c5e2f307c8ac0" data-id="3b1fb1b5d2c34b83be5c5e2f307c8ac0"><span><div id="3b1fb1b5d2c34b83be5c5e2f307c8ac0" class="notion-header-anchor"></div><a class="notion-hash-link" href="#3b1fb1b5d2c34b83be5c5e2f307c8ac0" title="📎 参考文章"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">📎 参考文章</span></span></h2><ul class="notion-list notion-list-disc notion-block-c5507be7567c4dddaddc80fb32e94c2e"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://cn.rollupjs.org">rollup 官网</a></li></ul></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Prometheus 监控预警]]></title>
            <link>https://blog.yayh.life/article/806529b1-70c5-45a7-8582-28f778b4634c</link>
            <guid>https://blog.yayh.life/article/806529b1-70c5-45a7-8582-28f778b4634c</guid>
            <pubDate>Wed, 27 Mar 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[Prometheus 技术调研]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-full-width notion-block-806529b170c545a7858228f778b4634c"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-a5049e193c9f4127b0cfabad6ef82642" data-id="a5049e193c9f4127b0cfabad6ef82642"><span><div id="a5049e193c9f4127b0cfabad6ef82642" class="notion-header-anchor"></div><a class="notion-hash-link" href="#a5049e193c9f4127b0cfabad6ef82642" title="💡Prometheus能做什么？"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">💡Prometheus能做什么？</span></span></h2><div class="notion-blank notion-block-5af99006131347b8912a63c00aebb154"> </div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-7c9b635f19be4807abdb418a1318f8b3" data-id="7c9b635f19be4807abdb418a1318f8b3"><span><div id="7c9b635f19be4807abdb418a1318f8b3" class="notion-header-anchor"></div><a class="notion-hash-link" href="#7c9b635f19be4807abdb418a1318f8b3" title="Google SRE的运维理念"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Google SRE的运维理念</span></span></h4><blockquote class="notion-quote notion-block-98a0c8ee7aa54f859358d0630db0b26e"><div>SRE是一种运维的标准、亦或者是一种岗位职责制度，SRE制度里有一条红线，运维的人只能把一半的时间花在运维上，另外一半的时间必须搞工程上、研发上的东西。研发可以是写工具，可以是参与系统设计，参与可靠性的提高，但是要保证运维不能只干运维</div></blockquote><div class="notion-blank notion-block-3391e058b5394cc3b6816eaf377ba1d5"> </div><div class="notion-text notion-block-9995dde7df7e43d8bf025245479c6e58"><em>主要定位作为企业服务监控告警解决方案</em></div><div class="notion-blank notion-block-1737386d4e364c61bb75f7a1c0672a24"> </div><hr class="notion-hr notion-block-b97c8c9c633d4d0cb748962ff5040a9c"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-b7c429f46891448d92c44efb331c4497" data-id="b7c429f46891448d92c44efb331c4497"><span><div id="b7c429f46891448d92c44efb331c4497" class="notion-header-anchor"></div><a class="notion-hash-link" href="#b7c429f46891448d92c44efb331c4497" title="核心组件"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b><b>核心组件</b></b></span></span></h3><div class="notion-blank notion-block-28d0ea7704cc46f6939310dad2efbd0d"> </div><ol start="1" class="notion-list notion-list-numbered notion-block-1121b7847eda42a4a6ae2403edcb2af2"><li><b>Prometheus Server
</b>主要用于抓取数据和存储时序数据，另外还提供查询和 Alert Rule 配置管理。</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-3dbb017828754c0e88cd94bef1b17c98"><li><b>Client libraries</b>
用于对接 Prometheus Server, 可以查询和上报数据</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-86f41669989e4a66bb11aacf3a9468fd"><li><b>Push Gateway
</b><em>用于批量，短期的监控数据的汇总节点，主要用于业务数据汇报等。</em></li></ol><ol start="4" class="notion-list notion-list-numbered notion-block-b47149a8cb8240c8957a6c74ba258068"><li><b>Exports
</b><em>各种汇报数据的 exporters ，例如汇报机器数据的 node_exporter, 汇报 MongoDB 信息的 MongoDB exporter 等等</em></li></ol><ol start="5" class="notion-list notion-list-numbered notion-block-930f0ad4eea14c1f96d7ae74c54efdae"><li><b>AlertManage</b></li><ol class="notion-list notion-list-numbered notion-block-930f0ad4eea14c1f96d7ae74c54efdae"><div class="notion-text notion-block-fb747674423749e48c1fdfdfe57a541f"><em>用于告警通知管理的 alertmanager 。</em></div><div class="notion-blank notion-block-817ccc571f0e45af829546226367043b"> </div><div class="notion-blank notion-block-22a3df25e4fb4a1c99107aa63ecad628"> </div></ol></ol><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-6a4a2f8be46a40b0b61c4623d29c5336"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://prometheus.io/assets/architecture.svg?t=6a4a2f8b-e46a-40b0-b61c-4623d29c5336" alt="服务架构图" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption"><em><b>服务架构图</b></em></figcaption></div></figure><div class="notion-blank notion-block-a245bd8bee0b4ed7a4a1b4fbfec8a1cb"> </div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-1429725e987f4f1b8ca1ff5806e89f6e" data-id="1429725e987f4f1b8ca1ff5806e89f6e"><span><div id="1429725e987f4f1b8ca1ff5806e89f6e" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1429725e987f4f1b8ca1ff5806e89f6e" title="服务流程简述"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">服务流程简述</span></span></h3><div class="notion-blank notion-block-7f772d28cf5c443c88eb03c82f2ca7a7"> </div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-a001b0dc47d948598cc39d9efc1e25dd" data-id="a001b0dc47d948598cc39d9efc1e25dd"><span><div id="a001b0dc47d948598cc39d9efc1e25dd" class="notion-header-anchor"></div><a class="notion-hash-link" href="#a001b0dc47d948598cc39d9efc1e25dd" title="TIPS:"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b><em>TIPS:</em></b></span></span></h4><blockquote class="notion-quote notion-block-5d9c81789fbf45ada43c8c02489d2497"><div>Prometheus 的数据是基于时序的 float64 的值，如果你的数据值有更多类型，无法满足。</div></blockquote><blockquote class="notion-quote notion-block-ea894e95f6b24282acdcd42661e07714"><div>Prometheus 不适合做审计计费，因为它的数据是按一定时间采集的，关注的更多是系统的运行瞬时状态以及趋势，即使有少量数据没有采集也能容忍，但是审计计费需要记录每个请求，并且数据长期存储，这个 Prometheus 无法满足，可能需要采用专门的审计系统。</div></blockquote><blockquote class="notion-quote notion-block-08b97b98952249e3aa0b30360c8ca38a"><div>OpenTSDB的表示法是一致的</div></blockquote><blockquote class="notion-quote notion-block-eb6998fd79e540bb902306eae3f71ce5"><div><em>时序数据库 </em><em><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://blog.yayh.life/article/e5afa554-4564-41ea-a099-50c922dea5a3">OpenTSDB</a></em></div></blockquote><div class="notion-blank notion-block-dc92cc5d8dcf495e9204b3c4b6944e91"> </div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-b75f7c9efb5c4de4b3707e5668008501" data-id="b75f7c9efb5c4de4b3707e5668008501"><span><div id="b75f7c9efb5c4de4b3707e5668008501" class="notion-header-anchor"></div><a class="notion-hash-link" href="#b75f7c9efb5c4de4b3707e5668008501" title="数据模型"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">数据模型</span></span></h2><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-1b6439c58724495fbdf97c786383de5b" data-id="1b6439c58724495fbdf97c786383de5b"><span><div id="1b6439c58724495fbdf97c786383de5b" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1b6439c58724495fbdf97c786383de5b" title="索引"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>索引</b></span></span></h4><div class="notion-text notion-block-cc6341fbb4e5409ebf82104264d4b984">Prometheus存储的是<a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://en.wikipedia.org/wiki/Time_series">时序数据</a>, 即按照相同时序(相同的名字和标签)，以时间维度存储连续的数据的集合，（但不保证连续不中断)</div><div class="notion-blank notion-block-f84dec9a4dcb42b5af8ef3fe559bc692"> </div><div class="notion-text notion-block-2a47ba603e3c4c648cd752faa0d5347d">时序由<code class="notion-inline-code">time series</code>，<code class="notion-inline-code">&lt;metric [name]&gt;{&lt;label name=[values…]&gt;, ...}</code> 一组 K/V标签格式定义的具有相同的名字以及标签属于相同时序。</div><div class="notion-blank notion-block-9112a8a58b614b49b1571e2507c297f1"> </div><div class="notion-text notion-block-5f689572bdec486f8806e7c8b859dd37"><span class="notion-gray_background"><b>名称规则</b></span></div><ul class="notion-list notion-list-disc notion-block-06d61c901f93475682b9871ac716333e"><li>时序的名字可以使用规则为 ASCII字符，数字，下划线，以及冒号组成，它必须满足正则表达式[a-zA-Z_:][a-zA-Z0-9_:]* 其名字应该具有语义化，一般表示一个可以度量的指标，例如 <code class="notion-inline-code">http_request_total</code></li></ul><ul class="notion-list notion-list-disc notion-block-d203747d2c594ae2b33b834dc26326e4"><li><code class="notion-inline-code">__</code>开头属于Prometheus保留</li></ul><ul class="notion-list notion-list-disc notion-block-9208a526d50c4ba2a18dc38fb3429e48"><li>支持中文</li></ul><div class="notion-blank notion-block-9c8f0ffc930444239b001684bb14d7ec"> </div><div class="notion-blank notion-block-841792ad36734f4098c105d083dbd971"> </div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-bfa7cf00c6884c5592725417c7745a98" data-id="bfa7cf00c6884c5592725417c7745a98"><span><div id="bfa7cf00c6884c5592725417c7745a98" class="notion-header-anchor"></div><a class="notion-hash-link" href="#bfa7cf00c6884c5592725417c7745a98" title="时序样本"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">时序样本</span></span></h4><ul class="notion-list notion-list-disc notion-block-0ded22ca358c4ec281d2679b1999f468"><li>float64</li></ul><ul class="notion-list notion-list-disc notion-block-3c41fe982f44404dba8ded291ab88ce8"><li>unix时间戳</li></ul><div class="notion-blank notion-block-1d9ce33e5e924927965851e6bd815a3b"> </div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-4645dbcc8a5a4f62b14fc84b7c8d293b" data-id="4645dbcc8a5a4f62b14fc84b7c8d293b"><span><div id="4645dbcc8a5a4f62b14fc84b7c8d293b" class="notion-header-anchor"></div><a class="notion-hash-link" href="#4645dbcc8a5a4f62b14fc84b7c8d293b" title="格式"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">格式</span></span></h4><div class="notion-blank notion-block-8d846e73f7e449edbe5ea369c345cbcf"> </div><div class="notion-blank notion-block-3c6530af8f1b4af1a99fb6e5e0f36850"> </div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-144caeef1ddc467082d60a809b63e114" data-id="144caeef1ddc467082d60a809b63e114"><span><div id="144caeef1ddc467082d60a809b63e114" class="notion-header-anchor"></div><a class="notion-hash-link" href="#144caeef1ddc467082d60a809b63e114" title="Metric时序的4种类型"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Metric时序的4种类型</span></span></h4><div class="notion-blank notion-block-28d5fdfe779c49e4979d4e7cb0ec56a5"> </div><ul class="notion-list notion-list-disc notion-block-99445f13211d40dc92165b58b25bab56"><li>Counter 表示数据收集指标用于趋势变化的，例如增长的请求数、异常等统计值</li></ul><ul class="notion-list notion-list-disc notion-block-e402834bb968482caa0e15ab96a9a1bb"><li>Gauge 表示数据瞬时值，服务器压力等指标，磁盘、内存、网络吞吐、CPU占用率等</li></ul><ul class="notion-list notion-list-disc notion-block-99cc7c2549ee479684bcf6df0d5671eb"><li>Histogram 主要用于表示一段时间范围内对数据进行采样（通常是请求持续时间或响应大小），并能够对其指定区间以及总数进行统计，通常它采集的数据展示为直方图。</li></ul><ul class="notion-list notion-list-disc notion-block-323be844cca34308827600fc13fdf353"><li>Summary 由 <code class="notion-inline-code">&lt;basename&gt;{quantile=&quot;&lt;φ&gt;&quot;}</code>，<code class="notion-inline-code">&lt;basename&gt;_sum</code>，<code class="notion-inline-code">&lt;basename&gt;_count</code> 组成，主要用于表示一段时间内数据采样结果（通常是请求持续时间或响应大小），它直接存储了 quantile 数据，而不是根据统计区间计算出来的。</li></ul><ul class="notion-list notion-list-disc notion-block-82a2537962844befbcfdbdc2cda21710"><li>Histogram vs Summary </li></ul><div class="notion-blank notion-block-c0a2e2eb88a54aeeb84f37ac7be50232"> </div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-7d713e278f2a41959381dc99be1215a5" data-id="7d713e278f2a41959381dc99be1215a5"><span><div id="7d713e278f2a41959381dc99be1215a5" class="notion-header-anchor"></div><a class="notion-hash-link" href="#7d713e278f2a41959381dc99be1215a5" title="作业和实例"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>作业和实例</b></span></span></h4><div class="notion-blank notion-block-37c62df0c8264d57a155a6940722ae4c"> </div><div class="notion-blank notion-block-d87795d3ddff4d7a8bd36c247f7104a3"> </div><div class="notion-text notion-block-2859f7d2690440d6acac0caa5709ffb0"><b>Tips: </b></div><div class="notion-text notion-block-f0f4f99aacf84f89b2e08f3c63313b22">独立的数据源（target) 在Prometheus中称为 <b><em>Instance </em></b>包含当前相同类型实例的集合叫做 <em><b>Job</b></em></div><div class="notion-blank notion-block-261359a948c14312aeb66f494f25fec9"> </div><div class="notion-blank notion-block-77711f99ad1c4e299e4b082c5074f0b1"> </div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-20d726b201fd47f1b89c5b73a58c4d97" data-id="20d726b201fd47f1b89c5b73a58c4d97"><span><div id="20d726b201fd47f1b89c5b73a58c4d97" class="notion-header-anchor"></div><a class="notion-hash-link" href="#20d726b201fd47f1b89c5b73a58c4d97" title="自动生成标签和时序"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">自动生成标签和时序</span></span></h4><div class="notion-text notion-block-ab5b783d9ac6402087faab0169c51eca"><em>如果其中任一标签已经在此前采集的数据中存在，那么将会根据 </em><em><code class="notion-inline-code">honor_labels</code></em><em> 设置选项来决定新标签。</em></div><div class="notion-blank notion-block-e96bc18db23740468442ccb22f883941"> </div><div class="notion-text notion-block-838123bd7a8948739defd188ca059bd2">对每一个实例而言，Prometheus 按照以下时序来存储所采集的数据样本：</div><div class="notion-blank notion-block-c599053457f94da1836c87eedbb0e626"> </div><div class="notion-blank notion-block-fd90b0ff582443ccad5a14483f52c1a7"> </div><div class="notion-blank notion-block-1b491b53203c4864adc5edaa3d43326a"> </div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-c2d6b240e60a4c30b71b12fd9984ad8b" data-id="c2d6b240e60a4c30b71b12fd9984ad8b"><span><div id="c2d6b240e60a4c30b71b12fd9984ad8b" class="notion-header-anchor"></div><a class="notion-hash-link" href="#c2d6b240e60a4c30b71b12fd9984ad8b" title="功能模块"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">功能模块</span></span></h2><div class="notion-blank notion-block-e8f80a6c0ebe41c39057b1695f6b7fcb"> </div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-7b75c7cc9e58446c98d3af29b7075209" data-id="7b75c7cc9e58446c98d3af29b7075209"><span><div id="7b75c7cc9e58446c98d3af29b7075209" class="notion-header-anchor"></div><a class="notion-hash-link" href="#7b75c7cc9e58446c98d3af29b7075209" title="Server"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Server</span></span></h4><div class="notion-blank notion-block-29c2e3bd43e544428216218a131ecece"> </div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-dbe3f001e33b419080f99ee9aebe4075" data-id="dbe3f001e33b419080f99ee9aebe4075"><span><div id="dbe3f001e33b419080f99ee9aebe4075" class="notion-header-anchor"></div><a class="notion-hash-link" href="#dbe3f001e33b419080f99ee9aebe4075" title="Exporter"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Exporter</span></span></h4><div class="notion-blank notion-block-1a97d80456204485bbdfeab7b861b34a"> </div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-22e253b2ce244cac8dd534d7b3d240d8" data-id="22e253b2ce244cac8dd534d7b3d240d8"><span><div id="22e253b2ce244cac8dd534d7b3d240d8" class="notion-header-anchor"></div><a class="notion-hash-link" href="#22e253b2ce244cac8dd534d7b3d240d8" title="PushGateway"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">PushGateway</span></span></h4><div class="notion-blank notion-block-8e30084bf5074ebb93f9d6cb4d8b6ae9"> </div><div class="notion-blank notion-block-6daed4f1f6054664b3ff25665cfeb382"> </div><div class="notion-blank notion-block-1213154eadd44e19bde056e9c8df2d78"> </div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-3112138a7d614953a77a0a7b173ee791" data-id="3112138a7d614953a77a0a7b173ee791"><span><div id="3112138a7d614953a77a0a7b173ee791" class="notion-header-anchor"></div><a class="notion-hash-link" href="#3112138a7d614953a77a0a7b173ee791" title="配置"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">配置</span></span></h2><div class="notion-blank notion-block-85ae87e3af8c47038d159ca9180bc996"> </div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-873717807aaf41f589e46dad19ec9dca" data-id="873717807aaf41f589e46dad19ec9dca"><span><div id="873717807aaf41f589e46dad19ec9dca" class="notion-header-anchor"></div><a class="notion-hash-link" href="#873717807aaf41f589e46dad19ec9dca" title="全局配置 - Global"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">全局配置 - Global</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-2dbc517395cb4bffa8a73d9fe2632635" data-id="2dbc517395cb4bffa8a73d9fe2632635"><span><div id="2dbc517395cb4bffa8a73d9fe2632635" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2dbc517395cb4bffa8a73d9fe2632635" title="告警配置 - alerting"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">告警配置 - alerting</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-cf0e9cf1368340e698e937a1d4fe253b" data-id="cf0e9cf1368340e698e937a1d4fe253b"><span><div id="cf0e9cf1368340e698e937a1d4fe253b" class="notion-header-anchor"></div><a class="notion-hash-link" href="#cf0e9cf1368340e698e937a1d4fe253b" title="规则文件配置 - rule_files"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">规则文件配置 - rule_files</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-6de3afcea7044814acb5bc2f442a1b6e" data-id="6de3afcea7044814acb5bc2f442a1b6e"><span><div id="6de3afcea7044814acb5bc2f442a1b6e" class="notion-header-anchor"></div><a class="notion-hash-link" href="#6de3afcea7044814acb5bc2f442a1b6e" title="拉取配置 - scrape_configs"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">拉取配置 - scrape_configs</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-4de33872486b4189a12d9e80851e2cae" data-id="4de33872486b4189a12d9e80851e2cae"><span><div id="4de33872486b4189a12d9e80851e2cae" class="notion-header-anchor"></div><a class="notion-hash-link" href="#4de33872486b4189a12d9e80851e2cae" title="远程读写配置 - remote_read remote_write"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">远程读写配置 - remote_read remote_write</span></span></h4><div class="notion-blank notion-block-1ebb26ca9e224c6eaf9cf4bbaafc7490"> </div><div class="notion-blank notion-block-acb3e16d04e143e993e23043bddcc0fd"> </div><div class="notion-blank notion-block-6242503d24f34fe59c53529caa43cb97"> </div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-1739863b379b4e608f8637ebc498f838" data-id="1739863b379b4e608f8637ebc498f838"><span><div id="1739863b379b4e608f8637ebc498f838" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1739863b379b4e608f8637ebc498f838" title="围绕网关服务健康度检测"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">围绕网关服务健康度检测</span></span></h3><div class="notion-blank notion-block-fb757480e5ed48a1a5fd5243c8c09722"> </div><div class="notion-blank notion-block-303fcbbc1de6404a8da1a911e71df51b"> </div><div class="notion-blank notion-block-f7c6b4bdfdf04906a57a474636e17b11"> </div><div class="notion-text notion-block-bc957dab73934a0db4ce42acaf5580a8">部署一台mysql服务</div><div class="notion-text notion-block-59cfcf8b7591477bb7596ad8d9bc26fd">企业微信推送消息测试</div><div class="notion-blank notion-block-040f6a43815b4dde9fc73282f6273e48"> </div><div class="notion-blank notion-block-d5041317116c497a8ffde59b2422604d"> </div><div class="notion-blank notion-block-2014d2907c7e446a94ad64e25073f502"> </div><div class="notion-blank notion-block-ee228c8249bf46ba8c51bed1859cd6fa"> </div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-85f53fe72cd04f7daed1f706425a609f" data-id="85f53fe72cd04f7daed1f706425a609f"><span><div id="85f53fe72cd04f7daed1f706425a609f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#85f53fe72cd04f7daed1f706425a609f" title="🤗 总结归纳"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">🤗 总结归纳</span></span></h2><div class="notion-blank notion-block-2d0a961ac98447c5aac199d6f8b47b22"> </div><ul class="notion-list notion-list-disc notion-block-2dde16175e174bf19621e591b9847ae8"><li>Prometheus 需要手动修改文件配置。</li></ul><ul class="notion-list notion-list-disc notion-block-4c55274a97ba47799493a8a818de2685"><li>Prometheus 适用于主机监控，还适用于 Cloud, SaaS, Openstack，Container 等监控。</li></ul><ul class="notion-list notion-list-disc notion-block-cf00f745ca4b4b20a7165dbb3b01f885"><li>Prometheus 属于一站式监控告警平台，依赖少，功能齐全。</li></ul><ul class="notion-list notion-list-disc notion-block-6a7a1851cc01411e85808bf42f50f31e"><li>Prometheus 支持对云或容器的监控，其他系统主要对主机监控。</li></ul><ul class="notion-list notion-list-disc notion-block-7ca9fa24454d4ee9bc9671b63bcc24fe"><li>Prometheus 数据查询语句表现力更强大，内置更强大的统计函数。</li></ul><ul class="notion-list notion-list-disc notion-block-d9f0fe54f8c446418d3fe6f645049887"><li>Prometheus 在数据存储扩展性以及持久性上没有 InfluxDB，OpenTSDB，Sensu 好。</li></ul><div class="notion-blank notion-block-64ec2607a9c749b2baaa2885500dcdb8"> </div><div class="notion-blank notion-block-4170145b93764c9cba0a445f3769f2af"> </div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-1f46db2a86994564bfdbd4f7f1f505c5" data-id="1f46db2a86994564bfdbd4f7f1f505c5"><span><div id="1f46db2a86994564bfdbd4f7f1f505c5" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1f46db2a86994564bfdbd4f7f1f505c5" title="📎 参考文章"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">📎 参考文章</span></span></h2><ul class="notion-list notion-list-disc notion-block-9fcfeeb26cbb4def9ae501c9935fedce"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://songjiayang.gitbooks.io/prometheus/content/alertmanager/wechat.html"><b>Prometheus 实战</b></a></li></ul><ul class="notion-list notion-list-disc notion-block-4b1ce3311b7c46f190fecfda2666986e"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://prometheus.io/docs/"><b>Prometheus Documents</b></a></li></ul></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OpenTSDB]]></title>
            <link>https://blog.yayh.life/article/e5afa554-4564-41ea-a099-50c922dea5a3</link>
            <guid>https://blog.yayh.life/article/e5afa554-4564-41ea-a099-50c922dea5a3</guid>
            <pubDate>Wed, 10 Apr 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[TSDB 时序存储]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-e5afa554456441eaa09950c922dea5a3"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-callout notion-gray_background_co notion-block-64d075cbdb954761afec6d344ef16eea"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="😀">😀</span></div><div class="notion-callout-text">本文由之前写的 《<a class="notion-link" href="/806529b170c545a7858228f778b4634c">Prometheus</a>》 衍生而来</div></div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-79e7bf6e8120442bafd0a16a75af5567" data-id="79e7bf6e8120442bafd0a16a75af5567"><span><div id="79e7bf6e8120442bafd0a16a75af5567" class="notion-header-anchor"></div><a class="notion-hash-link" href="#79e7bf6e8120442bafd0a16a75af5567" title="🕰 基于时间"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">🕰 基于时间</span></span></h2><div class="notion-text notion-block-bd1092c6cb8f4ba286c99b0aeff7d8e6">对于采集频率快、采集依赖时间维度、测量点庞大的数据存储结构有一种比较成熟的解决方案，对于这系列的数据格式称为 基于时间序列数据。</div><div class="notion-blank notion-block-ca31405af5cf49479ac2883f75161998"> </div><div class="notion-text notion-block-0c18e1a2072c4e84a098fdfa872ac858">而针对这部分数据特性，关系型数据库又不再满足，转而出现了针对性时间序列数据存储的数据库。</div><div class="notion-blank notion-block-398919b826824d5e8c8e1566c902ee21"> </div><div class="notion-text notion-block-db10df17e6d94c58a4b7ac7a2e5d8157"><b>基本需要满足的特点有:</b></div><ul class="notion-list notion-list-disc notion-block-ba8bc2651e5448938816bf0dbc7fe150"><li>根据时间序列快速写入</li></ul><ul class="notion-list notion-list-disc notion-block-0d490e9755af4c0fa3ca012801cd1ce3"><li>持久化</li></ul><ul class="notion-list notion-list-disc notion-block-31b237cd87154522a13b140e42973c0c"><li>多维度聚合查询</li></ul><ul class="notion-list notion-list-disc notion-block-e1699c64b9ef4bf2996585a1a5fa8bed"><li>精确到毫秒</li></ul><ul class="notion-list notion-list-disc notion-block-d910f109584c41419032c625c30820cf"><li>不需要转换步骤存储数据和写入一致</li></ul><ul class="notion-list notion-list-disc notion-block-8729936489c947eea74c4fd4cbe2437f"><li>永久保留原始数据</li></ul><div class="notion-blank notion-block-f0875dfa73654b40ad45dda0a9836b46"> </div><div class="notion-blank notion-block-94ee61951a484b67931eb2398e1b1aa0"> </div><div class="notion-text notion-block-abd7109968d342b2a3543b5f8eab2257">OpenTSDB是TSD和实用命令组成的，独立且没有master、不共享状态。</div><div class="notion-text notion-block-84e00b991c104cc5a0a160a93693b830">底层是通过HBase在存储数据，必须先有HBase环境</div><div class="notion-blank notion-block-c151e4bdd15e490bb1512e592f6fb855"> </div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-ce9826a3a04c4ba6a8f0a5aed94236ee" data-id="ce9826a3a04c4ba6a8f0a5aed94236ee"><span><div id="ce9826a3a04c4ba6a8f0a5aed94236ee" class="notion-header-anchor"></div><a class="notion-hash-link" href="#ce9826a3a04c4ba6a8f0a5aed94236ee" title="💡核心概念"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">💡核心概念</span></span></h2><div class="notion-blank notion-block-81759c5ea7034a3dae4d94d6445ee663"> </div><ul class="notion-list notion-list-disc notion-block-8592a4f95b8940769fcd901953a69c99"><li>Metric 监控项/指标</li></ul><ul class="notion-list notion-list-disc notion-block-8d7e54e39e0a40d89cc9a446b1fdbf02"><li>Tags 维度/标签</li></ul><ul class="notion-list notion-list-disc notion-block-017a731821e24b6f8ad870c57a102030"><li>Value 值</li></ul><ul class="notion-list notion-list-disc notion-block-4d4df362786b429f900f7a8407857403"><li>Timestamp 时间戳</li></ul><ul class="notion-list notion-list-disc notion-block-078a8076ab6e40b6b8f3bfc247cdba03"><li>DataPoint 某个Metric在某个时间点的数值</li><ul class="notion-list notion-list-disc notion-block-078a8076ab6e40b6b8f3bfc247cdba03"><li>格式例如： Timestamp-Tags-Metric-Value</li></ul></ul><div class="notion-blank notion-block-0b207350b2c24d1dba33aa725ff8df46"> </div><div class="notion-blank notion-block-f926ebacbebf40c39cd0f77e446c910f"> </div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-3a38a89f1ae14ec88aa5f0458377c7e8" data-id="3a38a89f1ae14ec88aa5f0458377c7e8"><span><div id="3a38a89f1ae14ec88aa5f0458377c7e8" class="notion-header-anchor"></div><a class="notion-hash-link" href="#3a38a89f1ae14ec88aa5f0458377c7e8" title="🤗 总结归纳"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">🤗 总结归纳</span></span></h2><blockquote class="notion-quote notion-block-ced7759e933446f5b137dff9665e4964"><div>OpenTSDB不适合超大数据量，在千万级、亿级中提取几万条数据，比如某个指标半年内的5分钟级别的数据，还是很快响应的。但如果再提取多点数据，几十万，百万这样的量级，又或者提取后再做个聚合运算，OpenTSDB 就勉为其难，实际使用的时候用作服务端机器的监控无任何问题，如果作为客户端APP监控，响应就比较迟缓。</div></blockquote><div class="notion-blank notion-block-69c75613a27a4626b4278d004eb2546c"> </div><div class="notion-text notion-block-716bd96a2da84451b1c965eadf8bdf63">TIPS: <b>如果需要支持特大批量时序数据，建议使用Druid或InfluxDB，其中InfluxDB是最易用的时序数据库。</b></div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-9669fc2226ad4cfd81d71f70d525e295" data-id="9669fc2226ad4cfd81d71f70d525e295"><span><div id="9669fc2226ad4cfd81d71f70d525e295" class="notion-header-anchor"></div><a class="notion-hash-link" href="#9669fc2226ad4cfd81d71f70d525e295" title="📎 参考文章"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">📎 参考文章</span></span></h2><ul class="notion-list notion-list-disc notion-block-17b4735296734312b2b4e4b9b1c9aa94"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://zhuanlan.zhihu.com/p/158143689">OpenTSDB数据存储详解</a></li></ul><div class="notion-blank notion-block-f3ee8f75871c44d28c862b8e2b2fd43c"> </div></main></div>]]></content:encoded>
        </item>
    </channel>
</rss>