<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>qxp</title>
    <description>本人致力于研究运筹学优化问题、深度学习算法、c++后端开发，欢迎一同交流~</description>
    <link>http://qiuxiaopeng2000.github.io/</link>
    <atom:link href="http://qiuxiaopeng2000.github.io/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Wed, 12 Apr 2023 03:00:39 +0000</pubDate>
    <lastBuildDate>Wed, 12 Apr 2023 03:00:39 +0000</lastBuildDate>
    <generator>Jekyll v3.9.3</generator>
    
      <item>
        <title>Linux操作系统内核Lab1</title>
        <description>&lt;h2 id=&quot;实验11&quot;&gt;实验1.1&lt;/h2&gt;

&lt;h3 id=&quot;实验要求&quot;&gt;实验要求&lt;/h3&gt;
&lt;p&gt;将一个简单的C程序汇编成LoongArch或RISC-V汇编代码，并逐步分析程序的执行过程，深入理解存储程序计算机和函数调用堆栈框架在执行过程中所起的作用。&lt;/p&gt;

&lt;h3 id=&quot;实验背景&quot;&gt;实验背景&lt;/h3&gt;
&lt;p&gt;gcc对c程序的编译分为四个步骤&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;预处理：对头文件、注释、宏等进行预处理，使用命令&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt; gcc -E hello.c -o hello.i&lt;/code&gt;生成.i/.ii文件&lt;/li&gt;
  &lt;li&gt;编译：将经过预处理的文件生成汇编代码，使用命令&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gcc -S hello.i -o hello.s&lt;/code&gt;生成.s文件&lt;/li&gt;
  &lt;li&gt;汇编：将汇编代码转换位二进制文件，使用命令&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gcc -c hello.s -o hello.o&lt;/code&gt;生成.o文件&lt;/li&gt;
  &lt;li&gt;链接：将目标文件最终链接成可执行文件，使用命令&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gcc hello.o -o hello&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;实验过程&quot;&gt;实验过程&lt;/h3&gt;
&lt;p&gt;本次实验中使用的c程序为：&lt;/p&gt;
&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;#include &amp;lt;stdio.h&amp;gt;
&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;add_a_and_b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;sub_a_and_b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sub_a_and_b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;add_a_and_b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;最终生成的汇编代码及解读如下：&lt;/p&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;file&lt;/span&gt;   &lt;span class=&quot;s&quot;&gt;&quot;lab1.c&quot;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;text&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;globl&lt;/span&gt;  &lt;span class=&quot;n&quot;&gt;add_a_and_b&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;type&lt;/span&gt;   &lt;span class=&quot;n&quot;&gt;add_a_and_b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;function&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;add_a_and_b&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;LFB0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cfi_startproc&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;pushq&lt;/span&gt;   &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rbp&lt;/span&gt;    &lt;span class=&quot;c1&quot;&gt;// rbp入栈保存当前待执行的指令，下面开始执行当前函数体中的指令&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cfi_def_cfa_offset&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;16&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cfi_offset&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;16&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;movq&lt;/span&gt;    &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rsp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rbp&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;// rbp = rsp，生成新的堆栈空间，rsp是64位&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cfi_def_cfa_register&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;movl&lt;/span&gt;    &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;edi&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rbp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;// edi直接寻址、rbp间接寻址，将edi的值存入rbp中保存的地址-4后所指向的内存，32位&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;movl&lt;/span&gt;    &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;esi&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rbp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;// esi直接寻址、rbp间接寻址，将esi的值存入rbp中保存的地址-8后所指向的内存，32位&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;movl&lt;/span&gt;    &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rbp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;eax&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;// rdp间接寻址、eax直接寻址，将rbp中保存的地址-8后所指向的值存入eax中，32位&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;movl&lt;/span&gt;    &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rbp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;edx&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;// rbp间接寻址、edx直接寻址，将rbp中保存的地址-4后所指向的值存入edx中，32位&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;addl&lt;/span&gt;    &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;edx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;eax&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;// eax = eax + edx&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;popq&lt;/span&gt;    &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rbp&lt;/span&gt;    &lt;span class=&quot;c1&quot;&gt;// 将之前保存的栈顶值弹出，并赋给rbp&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cfi_def_cfa&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;ret&lt;/span&gt;     &lt;span class=&quot;c1&quot;&gt;// 函数指令执行完毕，返回并执行下一条指令&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cfi_endproc&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;LFE0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;size&lt;/span&gt;   &lt;span class=&quot;n&quot;&gt;add_a_and_b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;add_a_and_b&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;globl&lt;/span&gt;  &lt;span class=&quot;n&quot;&gt;sub_a_and_b&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;type&lt;/span&gt;   &lt;span class=&quot;n&quot;&gt;sub_a_and_b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;function&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;sub_a_and_b&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;LFB1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cfi_startproc&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;pushq&lt;/span&gt;   &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rbp&lt;/span&gt;    &lt;span class=&quot;c1&quot;&gt;// rbp入栈保存当前待执行的指令，下面开始执行当前函数体中的指令&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cfi_def_cfa_offset&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;16&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cfi_offset&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;16&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;movq&lt;/span&gt;    &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rsp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rbp&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;// 直接寻址，将rsp中的值存入rbp中， 64位&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cfi_def_cfa_register&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;movl&lt;/span&gt;    &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;edi&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rbp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;// edi直接寻址、rbp间接寻址，将edi的值存入rbp中保存的地址-4后所指向的内存，32位&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;movl&lt;/span&gt;    &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;esi&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rbp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;// esi直接寻址、rbp间接寻址，将esi的值存入rbp中保存的地址-8后所指向的内存，32位&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;movl&lt;/span&gt;    &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rbp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;eax&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;// rdp间接寻址、eax直接寻址，将rbp中保存的地址-8后所指向的值存入eax中，32位&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;movl&lt;/span&gt;    &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rbp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;edx&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;// rbp间接寻址、edx直接寻址，将rbp中保存的地址-4后所指向的值存入edx中，32位&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;subl&lt;/span&gt;    &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;eax&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;edx&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;// edx = edx - eax&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;movl&lt;/span&gt;    &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;edx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;eax&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;// 直接寻址，将edx的值赋给eax&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;popq&lt;/span&gt;    &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rbp&lt;/span&gt;    &lt;span class=&quot;c1&quot;&gt;// 将之前保存的栈顶值弹出，并赋给rbp&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cfi_def_cfa&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;   
    &lt;span class=&quot;n&quot;&gt;ret&lt;/span&gt;     &lt;span class=&quot;c1&quot;&gt;// 函数指令执行完毕，返回并执行下一条指令&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cfi_endproc&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;LFE1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;size&lt;/span&gt;   &lt;span class=&quot;n&quot;&gt;sub_a_and_b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sub_a_and_b&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;globl&lt;/span&gt;  &lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;type&lt;/span&gt;   &lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;function&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;LFB2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cfi_startproc&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;pushq&lt;/span&gt;   &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rbp&lt;/span&gt;    &lt;span class=&quot;c1&quot;&gt;// rbp入栈保存当前待执行的指令，下面开始执行当前函数体中的指令&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cfi_def_cfa_offset&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;16&lt;/span&gt;  
    &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cfi_offset&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;16&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;movq&lt;/span&gt;    &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rsp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rbp&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;// 直接寻址，将rsp的值存入rbp中&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cfi_def_cfa_register&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;movl&lt;/span&gt;    &lt;span class=&quot;err&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;esi&lt;/span&gt;    &lt;span class=&quot;c1&quot;&gt;// 立即寻址，将3存入esi中&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;movl&lt;/span&gt;    &lt;span class=&quot;err&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;edi&lt;/span&gt;    &lt;span class=&quot;c1&quot;&gt;// 立即寻址， 将2存入edi中&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;call&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;add_a_and_b&lt;/span&gt;     &lt;span class=&quot;c1&quot;&gt;// 调用add_a_and_b函数，此时eax中保存了add_a_and_b(3,2)计算得到的值&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;movl&lt;/span&gt;    &lt;span class=&quot;err&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;esi&lt;/span&gt;    &lt;span class=&quot;c1&quot;&gt;// 立即寻址，将1存入esi中&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;movl&lt;/span&gt;    &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;eax&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;edi&lt;/span&gt;      &lt;span class=&quot;c1&quot;&gt;// 直接寻址，将eax中的值存入edi中&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;call&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;sub_a_and_b&lt;/span&gt;     &lt;span class=&quot;c1&quot;&gt;// 调用sub_a_and_b函数，此时eax中保存了最终计算得到的值&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;popq&lt;/span&gt;    &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rbp&lt;/span&gt;        &lt;span class=&quot;c1&quot;&gt;// 将栈顶元素出栈并存入rbp中&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cfi_def_cfa&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;ret&lt;/span&gt;     &lt;span class=&quot;c1&quot;&gt;// 返回，退出main&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cfi_endproc&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;LFE2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;size&lt;/span&gt;   &lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ident&lt;/span&gt;  &lt;span class=&quot;s&quot;&gt;&quot;GCC: (GNU) 4.8.5 20150623 (Red Hat 4.8.5-44)&quot;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;section&lt;/span&gt;    &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;note&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;GNU&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stack&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;progbits&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;实验12&quot;&gt;实验1.2&lt;/h2&gt;

&lt;h2 id=&quot;实验要求-1&quot;&gt;实验要求&lt;/h2&gt;
&lt;p&gt;构造一个Linux系统并跟踪分析Linux内核启动过程&lt;/p&gt;

&lt;h3 id=&quot;调试&quot;&gt;调试&lt;/h3&gt;
&lt;p&gt;本次实验搭建在腾讯云上，使用vscode通过ssh远程连接完成实验，使用xshell辅助执行mykernel的启动，使用xmanager查看可视化页面&lt;/p&gt;

&lt;p&gt;配置好环境后，使用命令 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;qemu-system-x86_64 -kernel linux-5.4.34/arch/x86/boot/bzImage -initrd rootfs.cpio.gz&lt;/code&gt;启动Linux内核，Linux正常启动&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;../images/Linux/mykernel-start.png&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;退出程序，再使用&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;qemu-system-x86_64 -kernel linux-5.4.34/arch/x86/boot/bzImage -initrd rootfs.cpio.gz -S -s&lt;/code&gt;进行debug状态，程序一启动就会马上暂停
&lt;a href=&quot;../images/Linux/mykernel-start-pause.png&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;使用vscode远程连接，使用命令&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gdb vmlinux&lt;/code&gt;进入gdb调试模式，执行命令&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;b start_kernel&lt;/code&gt;在内核开始处打断点，程序运行到断点就会自动中断&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;../images/Linux/start_kernel.png&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;使用list查看断点处的上下文
&lt;a href=&quot;../images/Linux/list.png&quot;&gt;&lt;/a&gt;&lt;/p&gt;
</description>
        <pubDate>Fri, 10 Mar 2023 00:00:00 +0000</pubDate>
        <link>http://qiuxiaopeng2000.github.io/2023/03/Linux%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F%E5%88%86%E6%9E%90%E5%AE%9E%E9%AA%8C1/</link>
        <guid isPermaLink="true">http://qiuxiaopeng2000.github.io/2023/03/Linux%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F%E5%88%86%E6%9E%90%E5%AE%9E%E9%AA%8C1/</guid>
        
        <category>Linux</category>
        
        
      </item>
    
      <item>
        <title>配置docker环境与git环境</title>
        <description>&lt;p&gt;以下操作均在Linux虚拟机中进行，作者使用的服务器是腾讯云的轻量应用服务器。&lt;/p&gt;

&lt;h2 id=&quot;前置操作&quot;&gt;前置操作&lt;/h2&gt;

&lt;h3 id=&quot;免密远程登录服务器&quot;&gt;免密远程登录服务器&lt;/h3&gt;

&lt;p&gt;我们首先要租一台云服务器。&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;在本地Linux虚拟机中使用命令&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ssh-keygen&lt;/code&gt;生成ssh公钥和私钥，让服务器能识别你本地虚拟机的身份，使用&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cd ~/.ssh&lt;/code&gt;可以进入ssh文件夹查看生成的密钥。&lt;/li&gt;
  &lt;li&gt;使用ssh远程登录你的服务器。使用&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ssh name@ip&lt;/code&gt;进行远程登录，其中name是你的服务器的名字即hostname，ip是你服务器的公有ip。一般租用的服务器都有初始的hostname，阿里云的默认是root，腾讯云的默认是ubuntu，也可自行修改hostname文件修改hostname&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vim /etc/hostname&lt;/code&gt;。比如作者将服务器的hostname设置成qxp，服务器的ip是1.15.93.63，则使用命令&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ssh qxp@1.15.93.63&lt;/code&gt;远程登录服务器。&lt;/li&gt;
  &lt;li&gt;root的权限过高，为了避免错误使用服务器而造成不可挽回后果，应当新建一个用户赋予部分权限，避免菜鸟因权限过高而造成损失。使用&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;usradd test&lt;/code&gt;新建命名为test的用户，然后使用&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;passwd test&lt;/code&gt;为用户设置密码。一般创建了用户后会在usr目录下为该用户建立一个文件夹，进入usr目录&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cd /usr&lt;/code&gt;，为test用户分配权限&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;chmod 777 -R test&lt;/code&gt;。
    &lt;blockquote&gt;
      &lt;p&gt;用户权限用三位bit位表示，第一位表示读，第二位表示行，第三位表示可执行，若可读则为100，转化为十进制就是4，7就表示该文件的权限为可读、可写、可执行。上述命令使用了三个7，第一个7是文件所有者的权限，第二个7是文件所属组的权限（同组成员的访问权限），第三个7表示其他用户的权限（游客的权限，一般游客只允许读，设置为4即可，这里为了方便都设置为7）。若需要更高的权限比如root权限，修改/etc/passwd即可，把用户名的ID和ID组修改成0（不建议）如需root权限自行百度
给用户赋予root最高权限：直接修改/etc/passwd文件，将第三列的数字设置为0（可以参考root的值）即可&lt;/p&gt;
    &lt;/blockquote&gt;
  &lt;/li&gt;
  &lt;li&gt;配置config。使用&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vim .ssh/config&lt;/code&gt;命令新建config文件，写入配置如下：
    &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; Host qxp &lt;span class=&quot;c&quot;&gt;# Host后写上你要登陆的服务器的hostname&lt;/span&gt;
     Hostname 1.15.93.63 &lt;span class=&quot;c&quot;&gt;# 写上要登陆的服务器的ip&lt;/span&gt;
     User &lt;span class=&quot;nb&quot;&gt;test&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# 写上你要登录的用户身份，即上文创建的用户test&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;使用命令&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ssh-copy-id qxp&lt;/code&gt;命令并通过密码验证即可成功设置免密登录，登录的用户身份及权限是User中填写的用户名，ssh-copy-id后填入的是你要免密登录的服务器的hostname。&lt;/li&gt;
  &lt;li&gt;直接通过ssh登录到服务器中的容器：通过容器的端口进行映射
    &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; Host qxp &lt;span class=&quot;c&quot;&gt;# Host后写上你要登陆的服务器的hostname&lt;/span&gt;
     Hostname 1.15.93.63 &lt;span class=&quot;c&quot;&gt;# 写上要登陆的服务器的ip&lt;/span&gt;
     User &lt;span class=&quot;nb&quot;&gt;test&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# 写上你要登录的用户身份，即上文创建的用户test&lt;/span&gt;
     Port 20000
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;上传文件至服务器&quot;&gt;上传文件至服务器&lt;/h3&gt;
&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;scp 文件名 qxp:&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;scp后第一个变量为需要上传到服务器的本地文件，第二个变量为要上传到的服务器的hostname，由于已经配置了免密登录，可以直接传输文件，命令末尾不要忘记加&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;:&lt;/code&gt;&lt;/p&gt;

&lt;h2 id=&quot;配置docker环境&quot;&gt;配置docker环境&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;启动dockers服务：&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;systemctl start docker&lt;/code&gt;。启动docker命令需要root权限，最好是先使用root用户登录服务器并启动docker。&lt;/li&gt;
  &lt;li&gt;为项目创建docker镜像：&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;docker load -i filename&lt;/code&gt;，-i的含义是指定导入的文件，filename即要创建docker镜像的文件名。&lt;/li&gt;
  &lt;li&gt;生成容器及端口映射：将dockers容器中的端口映射到服务器中，即连通docker容器与服务器 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;docker run -p 20000:22 -p 8000:8000 --name django_server -itd django_lesson&lt;/code&gt; 前面的端口是服务器的端口，后面的是容器的端口。22号端口是ssh应用端口，用于ssh登录容器，8000号端口用于测试用途，无特殊含义；name是为此次映射形成的容器的名称；-itd是一些配置参数，可自行百度；最后填上映射的docker镜像image。注意：容器一旦生成无法再修改容器映射。
    &lt;blockquote&gt;
      &lt;p&gt;记得在云服务器上开放相应的端口。
本人在使用腾讯云轻量应用服务器期间遇到过在控制台中打开端口仍然无法访问的情况，可以使用Linux命令手动打开端口。
首先执行&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;systemctl status firewall&lt;/code&gt;查看防火墙是否打开，若防火墙关闭了可以使用&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;systemctl start firewall&lt;/code&gt;打开防火墙，然后使用命令&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;firewall-cmd --zone=public --add-port=20000/tcp --permanent&lt;/code&gt;打开端口，再使用&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;firewall-cmd --reload&lt;/code&gt;加载设置，最终实现手动端口放行。可以使用命令&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;firewall-cmd --zone=public --list-ports&lt;/code&gt;查看已经放行的端口，检查端口是否放行成功。&lt;/p&gt;
    &lt;/blockquote&gt;
  &lt;/li&gt;
  &lt;li&gt;进入容器命令：&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;docker attach image_name(container_name)&lt;/code&gt;。关闭容器：Ctrl + D，挂起容器：先按Ctrl + P, 再按 Ctrl + Q&lt;/li&gt;
  &lt;li&gt;使用ssh通过开放的端口直接登录容器，通过修改config配置，具体步骤参考&lt;a href=&quot;#免密远程登录服务器&quot;&gt;免密登录服务器&lt;/a&gt;第6小节。&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;使用git维护项目&quot;&gt;使用git维护项目&lt;/h2&gt;
&lt;p&gt;任意找一个代码托管平台如&lt;a href=&quot;https://github.com/&quot;&gt;GitHub&lt;/a&gt;&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;使用&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git init&lt;/code&gt;生成.git文件并初始化&lt;/li&gt;
  &lt;li&gt;使用&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git config --global user.name &quot;用户名&quot;&lt;/code&gt;和&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git config --global user.email &quot;邮箱地址&quot;&lt;/code&gt;配置身份信息，只有配置了身份信息才能正常使用git&lt;/li&gt;
  &lt;li&gt;使用&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git remote add origin git@github.com:yourName/repositoryname.git&lt;/code&gt;连接到远程仓库（初次连接时使用，下一次不需要重新建立连接）。
    &lt;blockquote&gt;
      &lt;p&gt;以上三步可以使用另一种方法代替。先在代码托管平台上建立一个代码仓库，再把该仓库克隆&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git clone git@github.com:yourName/repositoryname.git&lt;/code&gt;到本地，之后在本地项目上修改代码内容，使用下述方法进行提交、更新等管理。&lt;/p&gt;
    &lt;/blockquote&gt;
  &lt;/li&gt;
  &lt;li&gt;使用&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git add .&lt;/code&gt;把全部文件添加到暂存区，注意add后有一个空格。&lt;/li&gt;
  &lt;li&gt;使用&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git commit&lt;/code&gt;将暂存区内容添加到仓库中，此时内容只记录在了.git文件中，还未正式提交。&lt;/li&gt;
  &lt;li&gt;使用&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git push&lt;/code&gt;把要提交的内容正式提交到远程仓库&lt;/li&gt;
  &lt;li&gt;使用&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git pull&lt;/code&gt;把远程仓库的内容更新到本地&lt;/li&gt;
&lt;/ol&gt;

</description>
        <pubDate>Mon, 27 Feb 2023 00:00:00 +0000</pubDate>
        <link>http://qiuxiaopeng2000.github.io/2023/02/%E9%85%8D%E7%BD%AEdocker%E7%8E%AF%E5%A2%83-git%E7%8E%AF%E5%A2%83%E4%B8%8E%E9%A1%B9%E7%9B%AE%E5%88%9B%E5%BB%BA/</link>
        <guid isPermaLink="true">http://qiuxiaopeng2000.github.io/2023/02/%E9%85%8D%E7%BD%AEdocker%E7%8E%AF%E5%A2%83-git%E7%8E%AF%E5%A2%83%E4%B8%8E%E9%A1%B9%E7%9B%AE%E5%88%9B%E5%BB%BA/</guid>
        
        <category>Docker</category>
        
        <category>Git</category>
        
        
      </item>
    
      <item>
        <title>Linux下执行python文件出现找不到自定义模块的问题</title>
        <description>&lt;p&gt;若在一个python文件中引用了自定义的其它目录下的文件，在pycharm中可以顺利通过编译，而在Linux或命令行下会出现 ModuleNotFoundError: No module named ‘xxx‘ 的报错信息，其根本原因是python的&lt;strong&gt;搜索包机制&lt;/strong&gt;。&lt;/p&gt;

&lt;p&gt;python没有在IDE环境下时，是从要执行的.py文件开始向下搜索包，因此对于其它目录下的文件，在Linux或命令行环境下无法被搜索。可以使用os包来引入项目的根目录，使得python编译器从根目录往下搜索文件。&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;sys&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;os&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;curPath&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;os&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;abspath&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;os&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dirname&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;__file__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;rootPath&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;os&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;curPath&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;sys&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rootPath&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;其中&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;os.path.dirname(__file__)&lt;/code&gt;获取当前文件所在目录的目录名，&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;os.path.abspath&lt;/code&gt;获取当前文件的绝对路径，&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;os.path.split&lt;/code&gt;将最后一个/进行拆分，将索引为0的视为目录（路径），将索引为1的视为文件名。&lt;/p&gt;

&lt;p&gt;在文件头加入上述代码即可解决问题。&lt;/p&gt;
</description>
        <pubDate>Fri, 24 Feb 2023 00:00:00 +0000</pubDate>
        <link>http://qiuxiaopeng2000.github.io/2023/02/Linux%E4%B8%8B%E6%89%A7%E8%A1%8Cpython%E6%96%87%E4%BB%B6%E5%87%BA%E7%8E%B0%E6%89%BE%E4%B8%8D%E5%88%B0%E8%87%AA%E5%AE%9A%E4%B9%89%E6%A8%A1%E5%9D%97%E7%9A%84%E9%97%AE%E9%A2%98/</link>
        <guid isPermaLink="true">http://qiuxiaopeng2000.github.io/2023/02/Linux%E4%B8%8B%E6%89%A7%E8%A1%8Cpython%E6%96%87%E4%BB%B6%E5%87%BA%E7%8E%B0%E6%89%BE%E4%B8%8D%E5%88%B0%E8%87%AA%E5%AE%9A%E4%B9%89%E6%A8%A1%E5%9D%97%E7%9A%84%E9%97%AE%E9%A2%98/</guid>
        
        <category>python</category>
        
        
      </item>
    
      <item>
        <title>在GitHub Pages中渲染LaTex 公式</title>
        <description>&lt;p&gt;　　昨天在写学习笔记的时候，在书写公式时使用的是 Markdown 自带的 LaTex 语法，但是在网页实际预览的时候发现公式的显示并不正常😢，出现了 LaTex 的源码，影响了阅读效果，为了解决这个问题，进行了一番搜索，成功解决问题。😊&lt;/p&gt;

&lt;p&gt;解决的方法是在静态页面中挂载 Javascript 代码，我用到的是&lt;a href=&quot;https://www.mathjax.org/&quot;&gt;MathJax&lt;/a&gt; 。 官网的介绍是：&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;&lt;em&gt;Beautiful math in all browsers A JavaScript display engine for mathematics that works in all browsers. No more setup for readers. It just works.&lt;/em&gt;&lt;/p&gt;

&lt;/blockquote&gt;

&lt;p&gt;下面介绍步骤&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;首先找到博客的目录下的head.html&lt;/li&gt;
&lt;/ol&gt;
&lt;div align=&quot;center&quot;&gt;&lt;img src=&quot;http://qiuxiaopeng2000.github.io//images/posts/article/在GitHub-Pages中渲染LaTex公式.png&quot; /&gt; &lt;/div&gt;

&lt;!-- ![在GitHub Pages中渲染 LaTex 公式](http://qiuxiaopeng2000.github.io//images/posts/article/在GitHub-Pages中渲染LaTex公式.png) --&gt;

&lt;ol&gt;
  &lt;li&gt;编辑_includes 目录下的 head.html 文件，在 &amp;lt;head&amp;gt; 和 &amp;lt;/head&amp;gt; 中间的任意位置加上官方提供的脚本链接：&lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&quot;language-html highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;script &lt;/span&gt;&lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;text/x-mathjax-config&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;MathJax&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Hub&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Config&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;TeX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;equationNumbers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;autoNumber&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;all&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;

    &lt;span class=&quot;nt&quot;&gt;&amp;lt;script &lt;/span&gt;&lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;text/x-mathjax-config&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;MathJax&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Hub&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Config&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;tex2jax&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
             &lt;span class=&quot;na&quot;&gt;inlineMath&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\\&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\\&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
             &lt;span class=&quot;na&quot;&gt;processEscapes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;
           &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
         &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;

    &lt;span class=&quot;nt&quot;&gt;&amp;lt;script &lt;/span&gt;&lt;span class=&quot;na&quot;&gt;src=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;text/javascript&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;上面的三个脚本分别实现了：&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;整行公式自动编号&lt;/li&gt;
  &lt;li&gt;将两个单美元符号 $ 中间的内容看作行内数学公式（若文本内容中美元符号出现频率较高，建议禁用这一脚本)&lt;/li&gt;
  &lt;li&gt;从 mathjax 官网挂载脚本&lt;/li&gt;
&lt;/ol&gt;

</description>
        <pubDate>Mon, 13 Feb 2023 00:00:00 +0000</pubDate>
        <link>http://qiuxiaopeng2000.github.io/2023/02/%E5%9C%A8GitHub-Pages%E4%B8%AD%E6%B8%B2%E6%9F%93LaTex-%E5%85%AC%E5%BC%8F/</link>
        <guid isPermaLink="true">http://qiuxiaopeng2000.github.io/2023/02/%E5%9C%A8GitHub-Pages%E4%B8%AD%E6%B8%B2%E6%9F%93LaTex-%E5%85%AC%E5%BC%8F/</guid>
        
        <category>Latex</category>
        
        <category>Github</category>
        
        <category>Markdown</category>
        
        
      </item>
    
      <item>
        <title>科软高级数据库期末复习总结</title>
        <description>&lt;h2 id=&quot;关系数据库相关概念&quot;&gt;关系数据库相关概念&lt;/h2&gt;

&lt;h3 id=&quot;三级模式结构与二级映射&quot;&gt;三级模式结构与二级映射&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;概念模式：全体数据的逻辑结构和特征描述。一个数据库只能有一个概念模式，一般是指数据库形成的表。&lt;/li&gt;
  &lt;li&gt;外模式：用户所能看到的部分数据的逻辑结构合特征描述。一个数据库科研有多个外模式，一般是概念模式经过数据库对用户形成的接口映射后的内容，外模式的属性可能由模式中的多个属性运算而成。&lt;/li&gt;
  &lt;li&gt;内模式：数据的物理结构和存储方式。一个数据库只有一个内模式，一般是指数据库的&lt;a href=&quot;#数据库索引&quot;&gt;索引结构&lt;/a&gt;。&lt;/li&gt;
  &lt;li&gt;外模式/模式映像：保证了数据库的逻辑独立性。&lt;/li&gt;
  &lt;li&gt;模式/内模式映像：保证了数据库的物理独立性。&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;举例：&lt;/p&gt;
&lt;div class=&quot;language-sql highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;select&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;E&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;#&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;EMP&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;D&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;#&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;DEPT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Employee&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;EMP&lt;/code&gt;属于外模式，&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Employee&lt;/code&gt;属于模式，&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Employee&lt;/code&gt;表的索引结构属于内模式。&lt;/p&gt;

&lt;h3 id=&quot;关系数据库的几个术语&quot;&gt;关系数据库的几个术语&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;超码：能唯一标识一个元组的属性集叫超码，超码中可能存在冗余属性。&lt;/li&gt;
  &lt;li&gt;候选码：不含冗余属性的超码叫候选码。位于候选码中的叫主属性，不在候选码中的叫非主属性。&lt;/li&gt;
  &lt;li&gt;主码：用户选定的一个候选码作为主码，其它的候选码叫替换码。&lt;/li&gt;
  &lt;li&gt;关系模式：数据之间关系的逻辑结构和特征描述，一般用二维表来表示。&lt;/li&gt;
  &lt;li&gt;关系：关系模式的一个实例，即一张具体的二维表。&lt;/li&gt;
  &lt;li&gt;关系数据库模式：关系模式的集合。&lt;/li&gt;
  &lt;li&gt;关系数据库：关系数据库模式的实例。&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;关系数据库的形式化定义&quot;&gt;关系数据库的形式化定义&lt;/h3&gt;
&lt;p&gt;关系数据库的形式化定义表示为：&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;R(U, D, Dom, F)&lt;/code&gt;。&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;R为关系模式名。&lt;/li&gt;
  &lt;li&gt;U表示属性集。&lt;/li&gt;
  &lt;li&gt;D为U中属性的值所来自的域，一般指属性集中出现过的数据类型，如char、int。&lt;/li&gt;
  &lt;li&gt;Dom代表U中属性向D中值域的映射的集合，一般指每个属性的数据类型。&lt;/li&gt;
  &lt;li&gt;F表示属性间的依赖，一般只考虑函数依赖FD（Function Dependency）。&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;函数依赖&quot;&gt;函数依赖&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;函数依赖集&lt;/strong&gt;的闭包：被函数依赖集F所能推出的全部函数依赖所构成的集合叫函数依赖集的闭包，记作$F^+$.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;属性集&lt;/strong&gt;的闭包：属性集X是属性集U的一个子属性集，X经过函数依赖集F所能推出来的全部属性集，记作$X^+$.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
  &lt;p&gt;设属性集X的闭包为Y，则属性集闭包的求法：&lt;/p&gt;
  &lt;ol&gt;
    &lt;li&gt;将Y初始化为X，即令$Y=X$。&lt;/li&gt;
    &lt;li&gt;遍历函数依赖集F，若F中的函数依赖项的左项全部位于Y中，则将该函数依赖项的右项属性加入属性集Y。&lt;/li&gt;
    &lt;li&gt;重复1、2项直至遍历完函数依赖集F，最终得到$Y=X^+$.&lt;/li&gt;
  &lt;/ol&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
  &lt;li&gt;最小函数依赖集：1.每个函数依赖右边只有一个属性。2.F不可约，即去掉任何一个函数依赖，则函数依赖集F的闭包会改变。3.每个函数依赖的左部不可约，即删除函数依赖左部任何一个元素都会改变F的闭包结果。
    &lt;blockquote&gt;
      &lt;p&gt;最小函数依赖集的求法：&lt;/p&gt;

      &lt;ol&gt;
        &lt;li&gt;先将函数依赖的右部分解，将FD右部分解为单一元素。如：&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;A-&amp;gt;BC&lt;/code&gt;分解为&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;A-&amp;gt;B, A-&amp;gt;C&lt;/code&gt;.&lt;/li&gt;
        &lt;li&gt;去掉左部冗余属性。如：&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ABC-&amp;gt;D&lt;/code&gt;，若$(AB)^+$包含D，则C冗余，可以去掉。&lt;/li&gt;
        &lt;li&gt;去掉F集合中的冗余FD。若在F集合中去掉&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;X-&amp;gt;Y&lt;/code&gt;，在$X^+$中仍然包含Y，则&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;X-&amp;gt;Y&lt;/code&gt;冗余，可以去掉。&lt;/li&gt;
        &lt;li&gt;实现1、2、3步，最终得到最小函数依赖集。&lt;/li&gt;
      &lt;/ol&gt;
    &lt;/blockquote&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;关系代数&quot;&gt;关系代数&lt;/h3&gt;
&lt;p&gt;交 $\cap$, 并 $\cup$, 差 -, 笛卡尔积 $\times$, 选择 $\sigma$, 投影 $\pi$, 连接 $\Join$。&lt;/p&gt;
&lt;blockquote&gt;
  &lt;ol&gt;
    &lt;li&gt;选择 $\sigma$ 对应sql语句中的where.&lt;/li&gt;
    &lt;li&gt;投影 $\pi$ 对应sql语句中的select.&lt;/li&gt;
    &lt;li&gt;连接 $\Join$ 不加限制条件默认为自然连接，会消去重复列；若加上限制条件则不会消去重复列。&lt;/li&gt;
    &lt;li&gt;重命名 $\rho_x(E)$&lt;/li&gt;
  &lt;/ol&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;三类完整性&quot;&gt;三类完整性&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;实体完整性：主码不得为空值。&lt;/li&gt;
  &lt;li&gt;参照完整性：任何一个非空的外键都存在一个候选码与其对应。&lt;/li&gt;
  &lt;li&gt;用户自定义完整性：用户自定义的约束条件。&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;sql语句&quot;&gt;SQL语句&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;DDL：create&lt;/li&gt;
  &lt;li&gt;DML：insert、delete、update、select&lt;/li&gt;
  &lt;li&gt;DCL：grant、revoke、deny&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;数据库设计&quot;&gt;数据库设计&lt;/h2&gt;

&lt;h3 id=&quot;数据库设计的相关概念&quot;&gt;数据库设计的相关概念&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;无损连接：一张关系表分解成的多个表，再通过自然连接能完全恢复成原来的表，数据量不能多也不能少。
    &lt;blockquote&gt;
      &lt;p&gt;$p={R_1,R_2}$是无损连接的条件是：$（R_1\cap R_2）-&amp;gt; (R_1-R_2)$或$（R_1\cap R_2）-&amp;gt; (R_2-R_1)$&lt;/p&gt;
    &lt;/blockquote&gt;
  &lt;/li&gt;
  &lt;li&gt;保持函数依赖：分解之后的各个函数依赖集$F_i$的并集的闭包等于原函数依赖集的闭包。&lt;/li&gt;
  &lt;li&gt;完全函数依赖：$X-&amp;gt;Y$，Y依赖于X中的全部属性值，X中不存在冗余属性。&lt;/li&gt;
  &lt;li&gt;部分函数依赖：Y只依赖于X中的部分属性值。&lt;/li&gt;
  &lt;li&gt;传递函数依赖：$X-&amp;gt;Y, Y-&amp;gt;Z$, 则$X-&amp;gt;Z$称为传递函数依赖。&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;关系模式的范式&quot;&gt;关系模式的范式&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;1NF：对于每个元组的每一个属性值都只含有一个值。每一个关系模式都满足1NF。&lt;/li&gt;
  &lt;li&gt;2NF：非主属性都完全函数依赖与主码。&lt;/li&gt;
  &lt;li&gt;3NF：非主属性不传递函数依赖于主码。&lt;/li&gt;
  &lt;li&gt;BCNF：所有不平凡的、完全的函数依赖的决定因素（左边的属性集）都是候选码。&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;模式分解的算法&quot;&gt;模式分解的算法&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;保持函数依赖地分解到3NF的算法
    &lt;blockquote&gt;
      &lt;ol&gt;
        &lt;li&gt;把不在函数依赖集F中出现地属性分为一类。&lt;/li&gt;
        &lt;li&gt;把F中左部相同地所有函数依赖所涉及地属性分为一类。&lt;/li&gt;
        &lt;li&gt;最终得到的分解保持函数依赖，且满足3NF。&lt;/li&gt;
      &lt;/ol&gt;
    &lt;/blockquote&gt;
  &lt;/li&gt;
  &lt;li&gt;无损连接且保持函数依赖地分解到3NF的算法
    &lt;blockquote&gt;
      &lt;ol&gt;
        &lt;li&gt;先使用保持函数依赖分解到的3NF算法进行分解，得到$q={R_1,R_2,…,R_k}$。&lt;/li&gt;
        &lt;li&gt;将R的所有候选码X作为分解后得到的属性集，若某个候选码构成的属性集R是q中的一个子集，则去掉该属性集R。&lt;/li&gt;
        &lt;li&gt;最终得到无损连接且保持函数依赖地分解到3NF的结果。&lt;/li&gt;
      &lt;/ol&gt;
    &lt;/blockquote&gt;
  &lt;/li&gt;
  &lt;li&gt;求候选码的算法
    &lt;blockquote&gt;
      &lt;ol&gt;
        &lt;li&gt;将函数依赖集F中出现的属性分为四种：只出现在左端的L类、只出现在右端的R类、同时出现在左右两端的LR类、未在F中出现的N类。&lt;/li&gt;
        &lt;li&gt;L类和N类一定属于候选码，R类一定不是候选码，LR类可能是候选码也可能不是。&lt;/li&gt;
        &lt;li&gt;判断LR类是不是候选码。求出第一步中得到的一定属于候选码的属性集的闭集$R^+$，若$R^+=U$，则得到最终结果，若不等于，则执行第4步。&lt;/li&gt;
        &lt;li&gt;从LR类中分别取出属性加入候选码中，分别计算此时得到的闭集是否满足$R^+=U$，若满足则R即为候选码。&lt;strong&gt;注意&lt;/strong&gt;：可能求得多个属性集R都是候选码，候选码可能存在多个。&lt;/li&gt;
      &lt;/ol&gt;
    &lt;/blockquote&gt;
  &lt;/li&gt;
  &lt;li&gt;无损连接地分解到BCNF
    &lt;blockquote&gt;
      &lt;ol&gt;
        &lt;li&gt;先检查各关系模式是否都属于BCNF，若都是，则算法终止。&lt;/li&gt;
        &lt;li&gt;若存在不满足BCNF地关系模式，则必定存在关系模式$R_k$，其中有$X-&amp;gt;A$，X不是候选码，则将$R_k$分解为$R_k1={X, A}$和$R_k2={R_k-A}$.&lt;/li&gt;
        &lt;li&gt;重复1、2步，直到都满足BCNF。&lt;/li&gt;
      &lt;/ol&gt;
    &lt;/blockquote&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;数据库设计的步骤&quot;&gt;数据库设计的步骤&lt;/h3&gt;
&lt;ol&gt;
  &lt;li&gt;先完成&lt;strong&gt;需求分析&lt;/strong&gt;，设计出E-R图。&lt;/li&gt;
  &lt;li&gt;再完成&lt;strong&gt;逻辑设计&lt;/strong&gt;，形成数据库表，并进行修正和优化（范式分解）。
逻辑设计中的步骤：
    &lt;blockquote&gt;
      &lt;ol&gt;
        &lt;li&gt;1：1的关系：将任意一个实体的主键加入另一实体，两个实体的主键保持不变，只有一个实体增加了一个属性。&lt;/li&gt;
        &lt;li&gt;1：N的关系：将1端的实体主键加入N端的实体，两个实体的主键保持不变。&lt;/li&gt;
        &lt;li&gt;M：N的关系：新建一个关系模式，将两端的实体主键与两端的联系属性一起组成新关系模式，该关系模式的主码为两端属性的主码的组合。&lt;/li&gt;
        &lt;li&gt;弱实体关系：将强实体的主键加入弱实体，与弱实体原本的主键一起形成新的主键。&lt;/li&gt;
        &lt;li&gt;子类（继承关系）：将父类的主键加入子类中，并将父类的主键作为子类的主键。&lt;/li&gt;
        &lt;li&gt;对最终形成的关系模式进行模式分解以及规范化处理。&lt;/li&gt;
      &lt;/ol&gt;
    &lt;/blockquote&gt;
  &lt;/li&gt;
  &lt;li&gt;最后实现&lt;strong&gt;物理设计&lt;/strong&gt;，选择存储结构、存取方法以及&lt;a href=&quot;#数据库索引&quot;&gt;索引设计&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;数据存储&quot;&gt;数据存储&lt;/h2&gt;
&lt;h3 id=&quot;磁盘存取优化&quot;&gt;磁盘存取优化&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;减少寻道时间：将随机I/O变为有序I/O: 缓冲机制，先将I/O命令不执行放入缓冲中，再在缓冲中进行排序变成局部有序I/O。主要有单缓冲、双缓冲&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;磁盘调度算法：先来先服务算法、最短寻道时间优先算法、扫描算法、循环扫描算法…&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;数据组织方式&quot;&gt;数据组织方式&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;定长vs不定长&lt;/li&gt;
  &lt;li&gt;跨块vs不跨块：跨块块利用率高，但访问速度慢（取一次数据可能需要访问多个块，多次I/O），耗费空间存储地址。&lt;/li&gt;
  &lt;li&gt;数据聚簇：把经常访问的数据尽量放在一个块中，不同类型的数据聚簇通常与跨块搭配，只对局部数据访问如&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;select student.name from table&lt;/code&gt;效率可能会提高，但对于&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;select * from table&lt;/code&gt;总体访问效率降低。&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;缓冲区管理&quot;&gt;缓冲区管理&lt;/h2&gt;

&lt;h3 id=&quot;缓冲区替换策略&quot;&gt;缓冲区替换策略&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;最佳置换算法OPT：把理论上最不可能使用的缓冲块进行置换，理论上的最优算法。&lt;/li&gt;
  &lt;li&gt;LRU算法：维护一个链表，访问后的块移动到链尾，每次从链头取出frame进行置换。LRU算法没有考虑访问频率。&lt;/li&gt;
  &lt;li&gt;LRU-K算法：优先使用LRU算法置换访问次数小于K次的块，访问次数大于K次的块尽量不置换。缺点：记录frame的被访问次数需要额外开销。&lt;/li&gt;
  &lt;li&gt;2Q算法：与LUR-2类似，&lt;strong&gt;访问次数&lt;/strong&gt;为1次的frame用FIFO队列维护进行置换，访问次数大于1次的frame块用LRU队列进行维护置换。&lt;/li&gt;
  &lt;li&gt;Second-Chance FIFO算法：所有的frame块用FIFO队列进行维护，给了每个frame两次机会，当一个frame块第一次位于队列头时（&lt;strong&gt;选择替换出去的次数&lt;/strong&gt;），移到队尾并用一个bit标记，只有当第二次位于队列头时才被换出并清空bit位标记。缺点：置换时需要移动多个元素，且需要额外的bit位，理论性能比LRU性能差。&lt;/li&gt;
  &lt;li&gt;CLOCK算法：将Second-Chance FIFO算法中的队列改造成环形，只需要移动头指针而不需要移动队列元素，减小了移动开销。&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;闪存ssd置换算法&quot;&gt;闪存SSD置换算法&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;CFLRU算法：Clean-first算法，将一个LRU队列分为两部分，相当于维护两个LRU队列，一个由dirty块组成，一个由未修改过的Clean块组成，优先将Clean-LRU队列中的块置换出去，若不存在未修改过的块，再从Dirty-LRU队列中执行LRU算法。&lt;/li&gt;
  &lt;li&gt;LRU-WSR算法：在CFLRU算法的基础上，将Dirty队列执行Second-Chance算法，Clean-LRU队列任然执行LRU算法。&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;数据库索引&quot;&gt;数据库索引&lt;/h2&gt;

&lt;h3 id=&quot;顺序文件上的索引&quot;&gt;顺序文件上的索引&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;密集索引：适用于记录大小远大于索引的时候。缺点：索引空间占用过大。&lt;/li&gt;
  &lt;li&gt;稀疏索引：稀疏索引仅适用于顺序文件，仅部分记录有索引，一般为每个数据块的第一个记录建立索引。&lt;/li&gt;
  &lt;li&gt;多级索引：索引上再建索引。二级索引空间更小，可以常驻内存。二级索引仅为稀疏索引，若二级索引为密集索引则无意义。&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;无序文件上的索引&quot;&gt;无序文件上的索引&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;辅助索引：辅助索引只能是&lt;strong&gt;密集索引&lt;/strong&gt;。在记录无序的情况下建立密集索引，并对索引进行排序。缺点：若记录存在重复键值，则使用密集索的基础上进一步建立二级索引也不方便。&lt;/li&gt;
  &lt;li&gt;间接桶：对于重复的记录建立一个间接桶，辅助索引只记录非重复值，辅助索引指向间接桶，间接桶才指向最终数据，这样可以在辅助索引上建立多级索引。&lt;/li&gt;
  &lt;li&gt;倒排索引：应用于文档搜索的间接桶，为每个检索词建立一个间接桶，桶的指针指向检索词出现的文档。&lt;/li&gt;
  &lt;li&gt;B+树：
    &lt;blockquote&gt;
      &lt;ol&gt;
        &lt;li&gt;根节点的指针数$2$~$n+1$.&lt;/li&gt;
        &lt;li&gt;中间节点的指针数范围为$\lceil \frac{n+1}{2} \rceil$~$n+1$.&lt;/li&gt;
        &lt;li&gt;叶节点中$\lfloor \frac{n+1}{2} \rfloor$~$n$个指针指向键值，再加上最后一个节点指向兄弟节点。&lt;/li&gt;
        &lt;li&gt;所有非叶子节点只有索引作用，不指向真实值，叶节点才指向真实值。&lt;/li&gt;
        &lt;li&gt;B+树的插入：先插入叶节点对应的位置，若超过一个节点所能容纳的最大元素范围，则第$\lceil \frac{k+1}{2} \rceil$个元素向上分裂（从1开始计数），k表示该节点容纳的元素数目；若分裂后导致上一层非叶子节点超出容纳范围，则该非叶子节点分裂，直到全都满足B+树的限制。&lt;/li&gt;
        &lt;li&gt;B+树的删除：先插入叶节点对应的值，若低于B+树最低容纳量，优先向左右兄弟节点借，若不够借则合并。
B+树的插入删除可以参考&lt;a href=&quot;#https://www.cs.usfca.edu/~galles/visualization/BPlusTree.html&quot;&gt;B+树演示网站&lt;/a&gt;&lt;/li&gt;
      &lt;/ol&gt;
    &lt;/blockquote&gt;
  &lt;/li&gt;
  &lt;li&gt;散列索引：散列表删除数据一般不直接删除，而是用符号标记进行逻辑删除。&lt;/li&gt;
  &lt;li&gt;可扩展散列表：散列函数是一个二进制序列，用前（左）i 位区分桶，桶的数量始终等于$2^i$。当其中一个桶的容量已满时，则将i加1，即将桶数量翻倍。&lt;strong&gt;优点&lt;/strong&gt;：当查找记录时，可以根据二进制序列的前i位查找，只需访问一个存储块。&lt;strong&gt;缺点&lt;/strong&gt;：桶是成倍增长的，增长速度过快，且可能存在大量空闲桶，利用率低。&lt;/li&gt;
  &lt;li&gt;线性散列表：使用二进制序列的后（右）i 位区分桶，桶的数量不一定等于$2^i$。
    &lt;blockquote&gt;
      &lt;p&gt;设桶的数量位n，当前i位区分桶，后i位表示的十进制值位m。&lt;/p&gt;
      &lt;ol&gt;
        &lt;li&gt;若 m&amp;lt;=n , 则记录位于第m个桶。&lt;/li&gt;
        &lt;li&gt;若 n&amp;lt; m &amp;lt; $2^i$，则记录位于$m-2^{i-1}$个桶。&lt;/li&gt;
        &lt;li&gt;只有桶的填充度超过某个比例时才增加1个&lt;strong&gt;新桶&lt;/strong&gt;，若所有桶总的填充度未达到该比例，但当前桶已经塞满的情况下，使用溢出块，当达到增加新桶的标准时，才将溢出块中的数据移入对应的桶中。&lt;/li&gt;
        &lt;li&gt;当桶的数量n &amp;gt; $2^i$时，才将i加1，增加一位&lt;strong&gt;数位&lt;/strong&gt;来区分桶。&lt;/li&gt;
      &lt;/ol&gt;
    &lt;/blockquote&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;查询优化&quot;&gt;查询优化&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;语法分析：构造基于sql语句的语法分析树&lt;/li&gt;
  &lt;li&gt;初始逻辑查询计划生成：将语法分析树转化为关系代数&lt;/li&gt;
  &lt;li&gt;生成逻辑查询计划：构造基于关系代数的语法分析树&lt;/li&gt;
  &lt;li&gt;查询重写：基于代数转换规则优化逻辑查询。
    &lt;blockquote&gt;
      &lt;p&gt;转换规则：&lt;/p&gt;
      &lt;ol&gt;
        &lt;li&gt;连接的转换规则：让生成的中间数据较少的两张表优先连接。&lt;/li&gt;
        &lt;li&gt;选择上的转换规则：$\sigma_{C1\cap C2}(R)=\sigma_{C1}(\sigma_{C2}(R))$, $\sigma_{C1\cup C2}(R)=\sigma_{C1}(R)\cup \sigma_{C2}(R)$&lt;/li&gt;
        &lt;li&gt;选择+自然连接转换规则：$\sigma_{C1}(R\Join S)= [\sigma_{C1}(R)]\Join S = [\sigma_{C1}(S)]\Join R$，$\sigma_{C1\cap C2}(R\Join S)= [\sigma_{C1}(R)]\Join [\sigma_{C2}(S)]$，$\sigma_{C1\cup C2}(R\Join S)= [\sigma_{C1}(R\Join S)]\cup [\sigma_{C2}(R\Join S)]$&lt;/li&gt;
        &lt;li&gt;投影+自然连接的转换规则：$\pi_{xy}(R\Join S) = \pi_{xy}(\pi_{xz}(R)\Join \pi_{yz}(S))$&lt;/li&gt;
      &lt;/ol&gt;
    &lt;/blockquote&gt;
  &lt;/li&gt;
  &lt;li&gt;查询代价估计：&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;相关参数：&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;T(R)：R的元组数&lt;/p&gt;

  &lt;p&gt;S(R)：R中每个元组的大小&lt;/p&gt;

  &lt;p&gt;V(R, A)：R中属性A上的不同值数&lt;/p&gt;

  &lt;p&gt;B(R)：容纳R中所有元组所需的块数&lt;/p&gt;

&lt;/blockquote&gt;

&lt;ol&gt;
  &lt;li&gt;$W = R1 * R2$:
    &lt;blockquote&gt;
      &lt;p&gt;T(W) = T(R1) * T(R2)&lt;/p&gt;

      &lt;p&gt;S(W) = S(R1) + S(R2)&lt;/p&gt;

    &lt;/blockquote&gt;
  &lt;/li&gt;
  &lt;li&gt;$W = \sigma_{A=a}(R)$:
    &lt;blockquote&gt;
      &lt;p&gt;S(W) = S(R)&lt;/p&gt;

      &lt;p&gt;$T(W) = \frac{T(R)}{V(R,A)}$&lt;/p&gt;

    &lt;/blockquote&gt;
  &lt;/li&gt;
  &lt;li&gt;$W = \sigma_{A&amp;gt;a}(R)$:
    &lt;blockquote&gt;
      &lt;p&gt;S(W) = S(R)&lt;/p&gt;

      &lt;p&gt;$T(W) = \frac{T(R)}{2}$ 或 $\frac{T(R)}{3}$ 或范围命中率$f$&lt;/p&gt;

    &lt;/blockquote&gt;
  &lt;/li&gt;
  &lt;li&gt;$W = \sigma_{A!=a}(R)$:
    &lt;blockquote&gt;
      &lt;p&gt;S(W) = S(R)&lt;/p&gt;

      &lt;p&gt;$T(W) = T(R) -\frac{T(R)}{V(R,A)}$&lt;/p&gt;

    &lt;/blockquote&gt;
  &lt;/li&gt;
  &lt;li&gt;W = $R_1\Join R_2$:
    &lt;blockquote&gt;
      &lt;p&gt;S(W) = $S(R_1) + S(R_2) - S(A)$，其中A表示两个表在属性A上建立自然连接&lt;/p&gt;

      &lt;p&gt;$T(W) = \frac{T(R_1)\bullet T(R_2)}{max{V(R_1, A),V(R_2,A)}}$&lt;/p&gt;

      &lt;p&gt;$V(W,A) = min{V(R_1,A),V(R_2,A)}$，其余属性集在W上的V与在原属性集上的V保持一致&lt;/p&gt;

    &lt;/blockquote&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;#查询执行&quot;&gt;物理查询计划选择&lt;/a&gt;
    &lt;blockquote&gt;
      &lt;p&gt;参考查询执行章节&lt;/p&gt;
    &lt;/blockquote&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;查询执行&quot;&gt;查询执行&lt;/h2&gt;

&lt;p&gt;若数据存放不连续则一次I/O只能读取一个块，若连续存放一次I/O能读取多个块。&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;嵌套循环连接&lt;/li&gt;
  &lt;li&gt;基于排序的算法：归并连接：两阶段多路连接归并算法。代价：每个块4次I/O，最少需要块$\sqrt{R}$个。&lt;strong&gt;归并连接算法 = 归并排序算法 + 连接&lt;/strong&gt;，若连接后不需要写回disk直接传给用户，则每个块多一次I/O，总共5次I/O。&lt;/li&gt;
  &lt;li&gt;基于散列的算法：散列连接：一次read + write完成哈希映射的建立，再来一次read实现连接，总共3次I/O。&lt;/li&gt;
  &lt;li&gt;基于索引的算法：索引连接&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;事务进程&quot;&gt;事务进程&lt;/h2&gt;
&lt;ol&gt;
  &lt;li&gt;事物的四大性质：原子性、一致性、隔离性、持久性&lt;/li&gt;
  &lt;li&gt;串行调度：穿行执行事务，而不是并发执行。如果一个调度的结果与某串行调度的结果相同，则称该调度是&lt;strong&gt;可串化调度&lt;/strong&gt;&lt;/li&gt;
  &lt;li&gt;事务冲突：如果两个属于不同事务操作（事务并行执行过程中的一部分）是冲突的，那么交换这两个操作的执行顺序至少会改变其中一个事务的结果；若两个操作不冲突，在这两个操作的执行顺序可交换（同一事务的不同操作顺序不可交换）。&lt;/li&gt;
  &lt;li&gt;冲突等价：一个冲突若能通过一系列不冲突的操作顺序交换成另一个冲突，则陈这两个冲突等价。&lt;/li&gt;
  &lt;li&gt;冲突可串性：一个冲突若等价于一个串行序列的冲突，在称该冲突具有可串性。&lt;/li&gt;
  &lt;li&gt;优先图：专用于冲突可串性的判断，节点表示事务，用有向边连接可能发生冲突的事务，有向边的方向记录事务的时间顺序。若优先图中&lt;strong&gt;无环&lt;/strong&gt;，则该调度满足冲突可串性。若具有冲突可串性，则优先图的&lt;strong&gt;拓扑排序&lt;/strong&gt;即为一组等价串行调度序列。&lt;/li&gt;
  &lt;li&gt;视图等价：若不同的调度方式对同一个数据的操作及先后顺序都一致，则称该两个调度方式视图等价。&lt;/li&gt;
  &lt;li&gt;视图可串性：某个调度与某一个串行调度视图等价，则称该调度具有视图可串性。具有冲突可串性的所有调度都具有冲突可串性。&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;锁&quot;&gt;锁&lt;/h3&gt;
&lt;h4 id=&quot;2pl锁&quot;&gt;2PL锁&lt;/h4&gt;
&lt;p&gt;2PL两阶段锁：一个阶段加锁，然后对数据进行操作，在另一个阶段解锁。若所有事务都遵循2PL，则该调度是可串化调度。2PL锁影响了事务的并发性。&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;X锁：排它锁&lt;/li&gt;
  &lt;li&gt;S锁：共享锁，允许其它事务读，但不允许写。加了S锁的数据不允许再加X锁，但允许其它事务加S锁，即允许其它事务读。
    &lt;blockquote&gt;
      &lt;p&gt;事务一旦释放了一个锁，就不再请求任何锁，因为事务具有原子性。&lt;/p&gt;
    &lt;/blockquote&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;若事务读完数据后还需要修改，若直接从S锁升级成X锁，由于S锁不具有排它性，若此时多个S锁请求升级成X锁，则容易造成死锁，因此可以使用U锁先预定要修改数据，读完后若需要写，则由U锁升级成X锁。&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;U锁：升级锁，持有U锁的事务允许读操作，并会在以后升级成X锁（相当于预定要修改数据），具有排它性，加了U锁后不能再加S锁、X锁和U锁。即&amp;lt;S, U&amp;gt;可以相容，但&amp;lt;U, S&amp;gt;不可约相容。&lt;/li&gt;
&lt;/ol&gt;

&lt;h4 id=&quot;多粒度锁&quot;&gt;多粒度锁&lt;/h4&gt;
&lt;p&gt;加锁的对象不一定是整个数据，可以更加细化，可以是块、元组、索引、索引项等等&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;显式加锁：对该粒度的对象显示地加锁&lt;/li&gt;
  &lt;li&gt;隐式加锁：由于该粒度地上层节点加了锁而使当前对象被加了锁。如：对块加了锁，则该块中地元组被加了锁。&lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;意向锁&quot;&gt;意向锁&lt;/h4&gt;
&lt;ul&gt;
  &lt;li&gt;IS锁：意向共享锁&lt;/li&gt;
  &lt;li&gt;IX锁：意向排它锁&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;如果对某个节点加IS或IX锁，说明事务要对该节点的某个下层节点加S锁或X锁。&lt;/p&gt;

&lt;p&gt;若要对某个节点加S锁或X锁，需要从根节点开始对路径上每个节点都加IS锁或IX锁。&lt;/p&gt;

&lt;h2 id=&quot;日志&quot;&gt;日志&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;先写日志再执行操作&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Undo记录了commit失败的需要撤销的事务，Redo记录了执行成功了但需要重新执行的事务。&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;Undo取old value， Redo取new value&lt;/li&gt;
  &lt;li&gt;发生错误时根据日志恢复数据，先Undo再Redo&lt;/li&gt;
  &lt;li&gt;每次日志检查完毕没有错误就加入checkpoint检查点，下次恢复数据时不需要考虑checkpoint前的数据，因为绝对安全。&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;undo日志&quot;&gt;Undo日志&lt;/h3&gt;
&lt;p&gt;写入commit之前必须先将数据写入磁盘，Undo日志中记录的旧值，表示需要撤销的事务，恢复到以前的数据，&lt;strong&gt;立即更新&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;优缺点：内存代价小，恢复代价高&lt;/p&gt;

&lt;h3 id=&quot;redo日志&quot;&gt;Redo日志&lt;/h3&gt;
&lt;p&gt;先写commit日志再把数据写入磁盘，Redo中记录的新值，表示要重新执行的事务，&lt;strong&gt;延迟更新&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;checkpoint点保证了之前的数据全部写入了数据库disk中。&lt;/p&gt;

&lt;p&gt;优缺点：内存代价大，恢复代价小&lt;/p&gt;

</description>
        <pubDate>Sat, 11 Feb 2023 00:00:00 +0000</pubDate>
        <link>http://qiuxiaopeng2000.github.io/2023/02/%E4%B8%AD%E7%A7%91%E5%A4%A7%E6%95%B0%E6%8D%AE%E5%BA%93%E6%9C%9F%E6%9C%AB%E5%A4%8D%E4%B9%A0%E6%80%BB%E7%BB%93/</link>
        <guid isPermaLink="true">http://qiuxiaopeng2000.github.io/2023/02/%E4%B8%AD%E7%A7%91%E5%A4%A7%E6%95%B0%E6%8D%AE%E5%BA%93%E6%9C%9F%E6%9C%AB%E5%A4%8D%E4%B9%A0%E6%80%BB%E7%BB%93/</guid>
        
        <category>中科大</category>
        
        
      </item>
    
      <item>
        <title>文档支持的Markdown语法</title>
        <description>&lt;h2 id=&quot;什么是-markdown&quot;&gt;什么是 Markdown&lt;/h2&gt;

&lt;p&gt;Markdown 是一种方便记忆、书写的纯文本标记语言，用户可以使用这些标记符号以最小的输入代价生成极富表现力的文档：如您正在阅读的这篇文章。它使用简单的符号标记不同的标题，分割不同的段落，&lt;strong&gt;粗体&lt;/strong&gt; 或者 &lt;em&gt;斜体&lt;/em&gt; 某些文字.&lt;/p&gt;

&lt;p&gt;很多产品的文档也是用markdown编写的，并且以“README.MD”的文件名保存在软件的目录下面。
　　&lt;/p&gt;
&lt;h2 id=&quot;一些基本语法&quot;&gt;一些基本语法&lt;/h2&gt;

&lt;p&gt;标题          &lt;br /&gt;
H1 :# Header 1          &lt;br /&gt;
H2 :## Header 2         &lt;br /&gt;
H3 :### Header 3         &lt;br /&gt;
H4 :#### Header 4         &lt;br /&gt;
H5 :##### Header 5          &lt;br /&gt;
H6 :###### Header 6    &lt;br /&gt;
链接 :&lt;a href=&quot;URL&quot;&gt;Title&lt;/a&gt;      &lt;br /&gt;
加粗 :&lt;strong&gt;Bold&lt;/strong&gt;      &lt;br /&gt;
斜体字 :&lt;em&gt;Italics&lt;/em&gt;       &lt;br /&gt;
*删除线 :&lt;del&gt;text&lt;/del&gt;        &lt;br /&gt;
内嵌代码 : &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;alert('Hello World');&lt;/code&gt;&lt;/p&gt;

&lt;h3 id=&quot;列表&quot;&gt;列表&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;列表1&lt;/li&gt;
  &lt;li&gt;列表2&lt;/li&gt;
  &lt;li&gt;列表3&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;列表引用&quot;&gt;列表引用&lt;/h3&gt;

&lt;blockquote&gt;
  &lt;ul&gt;
    &lt;li&gt;列表1&lt;/li&gt;
    &lt;li&gt;列表2&lt;/li&gt;
    &lt;li&gt;列表3&lt;/li&gt;
  &lt;/ul&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;插入一张图片&quot;&gt;插入一张图片&lt;/h3&gt;

&lt;p&gt;打赏一个吧&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/payimg/weipayimg.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;css 的大部分语法同样可以在 markdown 上使用，但不同的渲染器渲染出来的 markdown 内容样式也不一样，下面这些链接里面有 markdown 基本语法，你也可以在下面几个平台上尝试着写一些。&lt;/p&gt;

&lt;h2 id=&quot;博客支持的高级语法&quot;&gt;博客支持的高级语法&lt;/h2&gt;

&lt;h3 id=&quot;1-制作一份待办事宜&quot;&gt;1. 制作一份待办事宜&lt;/h3&gt;

&lt;ul class=&quot;task-list&quot;&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; /&gt;支持以 PDF 格式导出文稿&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; /&gt;改进 Cmd 渲染算法，使用局部渲染技术提高渲染效率&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;新增 Todo 列表功能&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;修复 图标功能&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;2-高亮一段代码&quot;&gt;2. 高亮一段代码&lt;/h3&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
&lt;span class=&quot;o&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;requires_authorization&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;SomeClass&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;pass&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;__name__&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'__main__'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;# A comment
&lt;/span&gt;    &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'hello world'&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;3-绘制表格&quot;&gt;3. 绘制表格&lt;/h4&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;项目&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;价格&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;数量&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;计算机&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;$1600&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;5&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;手机&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;$12&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;12&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;管线&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;$1&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;234&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

</description>
        <pubDate>Fri, 20 Nov 2020 00:00:00 +0000</pubDate>
        <link>http://qiuxiaopeng2000.github.io/2020/11/markdownTool/</link>
        <guid isPermaLink="true">http://qiuxiaopeng2000.github.io/2020/11/markdownTool/</guid>
        
        <category>Markdown</category>
        
        
      </item>
    
      <item>
        <title>Jekyll搭建个人博客</title>
        <description>&lt;p&gt;　之前写了一篇&lt;a href=&quot;http://leopardpan.cn/2015/08/HEXO%E6%90%AD%E5%BB%BA%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A2/&quot;&gt;HEXO搭建个人博客&lt;/a&gt;的教程获得了很好评，尤其是在&lt;a href=&quot;http://www.jianshu.com/p/465830080ea9&quot;&gt;简书&lt;/a&gt;上目前已经累积了10W+的阅读量了，也有好心的读者主动给我打赏，在此感谢。&lt;/p&gt;

&lt;p&gt;　如果你看过我的文章会发现我现在的博客样式跟之前是有很大的区别的，之前我也是使用 HEXO 搭建的博客，后来发现使用 HEXO 在多台电脑上发布博客，操作起来并不是那么方便，果断就转到了 Jekyll 上，接下来我会讲如何使用 Jekyll 搭建博客，&lt;a href=&quot;http://leopardpan.cn/#blog&quot;&gt;博客模板效果&lt;/a&gt;。&lt;/p&gt;

&lt;h3 id=&quot;介绍&quot;&gt;介绍&lt;/h3&gt;

&lt;p&gt;　Jekyll 是一个简单的博客形态的静态站点生产机器。它有一个模版目录，其中包含原始文本格式的文档，通过 Markdown （或者 Textile） 以及 Liquid 转化成一个完整的可发布的静态网站，你可以发布在任何你喜爱的服务器上。Jekyll 也可以运行在 GitHub Page 上，也就是说，你可以使用 GitHub 的服务来搭建你的项目页面、博客或者网站，而且是完全免费的&lt;/p&gt;

&lt;p&gt;　使用 Jekyll 搭建博客之前要确认下本机环境，Git 环境（用于部署到远端）、&lt;a href=&quot;http://www.ruby-lang.org/en/downloads/&quot;&gt;Ruby&lt;/a&gt; 环境（Jekyll 是基于 Ruby 开发的）、包管理器 &lt;a href=&quot;http://rubygems.org/pages/download&quot;&gt;RubyGems&lt;/a&gt;              &lt;br /&gt;
　　如果你是 Mac 用户，你就需要安装 Xcode 和 Command-Line Tools了。下载方式 Preferences → Downloads → Components。&lt;/p&gt;

&lt;p&gt;　　Jekyll 是一个免费的简单静态网页生成工具，可以配合第三方服务例如： Disqus（评论）、多说(评论) 以及分享 等等扩展功能，Jekyll 可以直接部署在 Github（国外） 或 Coding（国内） 上，可以绑定自己的域名。&lt;a href=&quot;http://jekyll.bootcss.com/&quot;&gt;Jekyll中文文档&lt;/a&gt;、&lt;a href=&quot;https://jekyllrb.com/&quot;&gt;Jekyll英文文档&lt;/a&gt;、&lt;a href=&quot;http://jekyllthemes.org/&quot;&gt;Jekyll主题列表&lt;/a&gt;。&lt;/p&gt;

&lt;h3 id=&quot;jekyll-环境配置&quot;&gt;Jekyll 环境配置&lt;/h3&gt;

&lt;p&gt;安装 jekyll&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ gem install jekyll     
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;创建博客&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ jekyll new myBlog    
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;进入博客目录&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ cd myBlog  
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;启动本地服务&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ jekyll serve
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;在浏览器里输入： &lt;a href=&quot;http://localhost:4000&quot;&gt;http://localhost:4000&lt;/a&gt;，就可以看到你的博客效果了。&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/jekyll/image1.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;so easy !&lt;/p&gt;

&lt;h3 id=&quot;目录结构&quot;&gt;目录结构&lt;/h3&gt;
&lt;p&gt;　
　Jekyll 的核心其实是一个文本转换引擎。它的概念其实就是： 你用你最喜欢的标记语言来写文章，可以是 Markdown，也可以是 Textile,或者就是简单的 HTML, 然后 Jekyll 就会帮你套入一个或一系列的布局中。在整个过程中你可以设置URL路径, 你的文本在布局中的显示样式等等。这些都可以通过纯文本编辑来实现，最终生成的静态页面就是你的成品了。&lt;/p&gt;

&lt;p&gt;一个基本的 Jekyll 网站的目录结构一般是像这样的：&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;.
├── _config.yml
├── _includes
|   ├── footer.html
|   └── header.html
├── _layouts
|   ├── default.html
|   ├── post.html
|   └── page.html
├── _posts
|   └── 2016-10-08-welcome-to-jekyll.markdown
├── _sass
|   ├── _base.scss
|   ├── _layout.scss
|   └── _syntax-highlighting.scss
├── about.md
├── css
|   └── main.scss
├── feed.xml
└── index.html

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;这些目录结构以及具体的作用可以参考 &lt;a href=&quot;http://jekyll.com.cn/docs/structure/&quot;&gt;官网文档&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;进入 _config.yml 里面，修改成你想看到的信息，重新 jekyll server ，刷新浏览器就可以看到你刚刚修改的信息了。&lt;/p&gt;

&lt;p&gt;到此，博客初步搭建算是完成了，&lt;/p&gt;

&lt;h3 id=&quot;博客部署到远端&quot;&gt;博客部署到远端&lt;/h3&gt;

&lt;p&gt;　我这里讲的是部署到 Github Page 创建一个 github 账号，然后创建一个跟你账户名一样的仓库，如我的 github 账户名叫 &lt;a href=&quot;https://github.com/leopardpan&quot;&gt;leopardpan&lt;/a&gt;，我的 github 仓库名就叫 &lt;a href=&quot;https://github.com/leopardpan/leopardpan.github.io&quot;&gt;leopardpan.github.io&lt;/a&gt;，创建好了之后，把刚才建立的 myBlog 项目 push 到 username.github.io仓库里去（username指的是你的github用户名），检查你远端仓库已经跟你本地 myBlog 同步了，然后你在浏览器里输入 username.github.io ，就可以访问你的博客了。&lt;/p&gt;

&lt;h3 id=&quot;编写文章&quot;&gt;编写文章&lt;/h3&gt;

&lt;p&gt;　　所有的文章都是 _posts 目录下面，文章格式为 mardown 格式，文章文件名可以是 .mardown 或者 .md。&lt;/p&gt;

&lt;p&gt;　　编写一篇新文章很简单，你可以直接从 _posts/ 目录下复制一份出来 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;2016-10-16-welcome-to-jekyll副本.markdown&lt;/code&gt; ，修改名字为 2016-10-16-article1.markdown ，注意：文章名的格式前面必须为 2016-10-16- ，日期可以修改，但必须为 年-月-日- 格式，后面的 article1 是整个文章的连接 URL，如果文章名为中文，那么文章的连接URL就会变成这样的：http://leopardpan.cn/2015/08/%E6%90%AD%E5/ ， 所以建议文章名最好是英文的或者阿拉伯数字。 双击 2016-10-16-article1.markdown 打开&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
---
layout: post
title:  &quot;Welcome to Jekyll!&quot;
date:   2016-10-16 11:29:08 +0800
categories: jekyll update
---

正文...

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;title: 显示的文章名， 如：title: 我的第一篇文章                  &lt;br /&gt;
date:  显示的文章发布日期，如：date: 2016-10-16                        &lt;br /&gt;
categories: tag标签的分类，如：categories: 随笔&lt;/p&gt;

&lt;p&gt;注意：文章头部格式必须为上面的，…. 就是文章的正文内容。&lt;/p&gt;

&lt;p&gt;我写文章使用的是 Sublime Text2 编辑器，如果你对 markdown 语法不熟悉的话，可以看看&lt;a href=&quot;https://www.zybuluo.com/&quot;&gt;作业部落的教程&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;使用我的博客模板&quot;&gt;使用我的博客模板&lt;/h3&gt;

&lt;p&gt;虽然博客部署完成了，你会发现博客太简单不是你想要的，如果你喜欢我的模板的话，可以使用我的模板。&lt;/p&gt;

&lt;p&gt;首先你要获取的我博客，&lt;a href=&quot;https://github.com/leopardpan/leopardpan.github.io.git&quot;&gt;Github项目地址&lt;/a&gt;，你可以直接&lt;a href=&quot;https://github.com/leopardpan/leopardpan.github.io/archive/master.zip&quot;&gt;点击下载博客&lt;/a&gt;，进去leopardpan.github.io/ 目录下， 使用命令部署本地服务&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ jekyll server   
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;如果你本机没配置过任何jekyll的环境可能会报错&quot;&gt;如果你本机没配置过任何jekyll的环境，可能会报错&lt;/h3&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;/Users/xxxxxxxx/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- bundler (LoadError)
	from /Users/xxxxxxxx/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	from /Users/xxxxxxxx/.rvm/gems/ruby-2.2.2/gems/jekyll-3.3.0/lib/jekyll/plugin_manager.rb:34:in `require_from_bundler'
	from /Users/xxxxxxxx/.rvm/gems/ruby-2.2.2/gems/jekyll-3.3.0/exe/jekyll:9:in `&amp;lt;top (required)&amp;gt;'
	from /Users/xxxxxxxx/.rvm/gems/ruby-2.2.2/bin/jekyll:23:in `load'
	from /Users/xxxxxxxx/.rvm/gems/ruby-2.2.2/bin/jekyll:23:in `&amp;lt;main&amp;gt;'
	from /Users/xxxxxxxx/.rvm/gems/ruby-2.2.2/bin/ruby_executable_hooks:15:in `eval'
	from /Users/xxxxxxxx/.rvm/gems/ruby-2.2.2/bin/ruby_executable_hooks:15:in `&amp;lt;main&amp;gt;'

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;原因： 没有安装 bundler ，执行安装 bundler 命令&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
$ gem install bundler

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;提示：&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Fetching: bundler-1.13.5.gem (100%)
Successfully installed bundler-1.13.5
Parsing documentation for bundler-1.13.5
Installing ri documentation for bundler-1.13.5
Done installing documentation for bundler after 5 seconds
1 gem installed

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;再次执行 $ jekyll server  ，提示&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
Could not find proper version of jekyll (3.1.1) in any of the sources
Run `bundle install` to install missing gems.

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;跟着提示运行命令&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ bundle install
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;这个时候你可能会发现 bundle install 运行卡主不动了。&lt;/p&gt;

&lt;p&gt;如果很长时间都没任何提示的话，你可以尝试修改 gem 的 source&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ gem sources --remove https://rubygems.org/
$ gem sources -a http://ruby.taobao.org/
$ gem sources -l
*** CURRENT SOURCES ***

http://ruby.taobao.org

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;再次执行命令 $ bundle install，发现开始有动静了&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Fetching gem metadata from https://rubygems.org/...........
Fetching version metadata from https://rubygems.org/..
Fetching dependency metadata from https://rubygems.org/.
。。。
Installing jekyll-watch 1.3.1
Installing jekyll 3.1.1
Bundle complete! 3 Gemfile dependencies, 17 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;bundler安装完成，后再次启动本地服务&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ jekyll server

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;继续报错&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Configuration file: /Users/tendcloud-Caroline/Desktop/leopardpan.github.io/_config.yml
  Dependency Error: Yikes! It looks like you don't have jekyll-sitemap or one of its dependencies installed. In order to use Jekyll as currently configured, you'll need to install this gem. The full error message from Ruby is: 'cannot load such file -- jekyll-sitemap' If you run into trouble, you can find helpful resources at http://jekyllrb.com/help/! 
jekyll 3.1.1 | Error:  jekyll-sitemap

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;表示 当前的 jekyll 版本是 3.1.1 ，无法使用 jekyll-sitemap&lt;/p&gt;

&lt;p&gt;解决方法有两个&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;1、打开当前目录下的 _config.yml 文件，把 gems: [jekyll-paginate,jekyll-sitemap] 换成 gems: [jekyll-paginate] ，也就是去掉jekyll-sitemap。&lt;/p&gt;
&lt;/blockquote&gt;

&lt;blockquote&gt;
  &lt;p&gt;2、升级 jekyll 版本，我当前的是 jekyll 3.1.2 。&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;修改完成后保存配置，再次执行&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ jekyll server

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;提示&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Configuration file: /Users/baixinpan/Desktop/OpenSource/Mine/Page-Blog/leopardpan.github.io-github/_config.yml
            Source: /Users/baixinpan/Desktop/OpenSource/Mine/Page-Blog/leopardpan.github.io-github
       Destination: /Users/baixinpan/Desktop/OpenSource/Mine/Page-Blog/leopardpan.github.io-github/_site
 Incremental build: disabled. Enable with --incremental
      Generating... 
                    done in 0.901 seconds.
 Auto-regeneration: enabled for '/Users/baixinpan/Desktop/OpenSource/Mine/Page-Blog/leopardpan.github.io-github'
Configuration file: /Users/baixinpan/Desktop/OpenSource/Mine/Page-Blog/leopardpan.github.io-github/_config.yml
    Server address: http://127.0.0.1:4000/
  Server running... press ctrl-c to stop.

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;表示本地服务部署成功。&lt;/p&gt;

&lt;p&gt;在浏览器输入 &lt;a href=&quot;127.0.0.1:4000&quot;&gt;127.0.0.1:4000&lt;/a&gt; ， 就可以看到&lt;a href=&quot;http://leopardpan.cn&quot;&gt;leopardpan.cn&lt;/a&gt;博客效果了。&lt;/p&gt;

&lt;h3 id=&quot;修改成你自己的博客&quot;&gt;修改成你自己的博客&lt;/h3&gt;

&lt;blockquote&gt;
  &lt;ul&gt;
    &lt;li&gt;如果你想使用我的模板请把 _posts/ 目录下的文章都去掉。&lt;/li&gt;
    &lt;li&gt;修改 _config.yml 文件里面的内容为你自己的。&lt;/li&gt;
  &lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;然后使用 git push 到你自己的仓库里面去，检查你远端仓库，在浏览器输入 username.github.io 就会发现，你有一个漂亮的主题模板了。&lt;/p&gt;

&lt;h3 id=&quot;为什么要是用-jekyll&quot;&gt;为什么要是用 Jekyll&lt;/h3&gt;

&lt;p&gt;使用了 Jekyll 你会发现如果你想使用多台电脑发博客都很方便，只要把远端 github 仓库里的博客 clone 下来，写文章后再提交就可以了，Hexo 由于远端提交的是静态网页，所有无法直接写 Markdown 的文章。如果你想看 Hexo 搭建博客，可以看看我的另一篇&lt;a href=&quot;http://leopardpan.cn/2015/08/HEXO%E6%90%AD%E5%BB%BA%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A2/&quot;&gt;HEXO搭建个人博客&lt;/a&gt;的教程。&lt;/p&gt;

&lt;p&gt;如果你在搭建博客遇到问题，可以在&lt;a href=&quot;http://leopardpan.cn/2016/10/jekyll_tutorials1/&quot;&gt;原文博客&lt;/a&gt;的评论里给我提问。&lt;/p&gt;

&lt;p&gt;后面会继续介绍，在我的博客基础上，如何修改成你自己喜欢的 Style，欢迎继续关注我博客的更新。&lt;/p&gt;

&lt;h3 id=&quot;qa&quot;&gt;Q&amp;amp;A&lt;/h3&gt;

&lt;blockquote&gt;
  &lt;p&gt;问题：最近很多朋友使用我的模板报警告：The CNAME &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;leopardpan.cn&lt;/code&gt; is already taken 
解决：把CNAME里面的baixin.io修改成你自己的域名，如果你暂时没有域名，CNAME里面就什么都不用谢。（之前没人反馈过这个问题，应该是github page最近才最的限制。）&lt;/p&gt;
&lt;/blockquote&gt;

</description>
        <pubDate>Wed, 14 Oct 2020 00:00:00 +0000</pubDate>
        <link>http://qiuxiaopeng2000.github.io/2020/10/jekyll_tutorials1/</link>
        <guid isPermaLink="true">http://qiuxiaopeng2000.github.io/2020/10/jekyll_tutorials1/</guid>
        
        <category>jekyll</category>
        
        
      </item>
    
      <item>
        <title>HEXO搭建个人博客</title>
        <description>&lt;p&gt;　　经过各种找资料，踩过各种坑，终于使用 hexo 搭建个人博客初步完成了，域名目前用得时 github 的，我的 hexo 是 3.1.1 版本，hexo 不同的版本，很多配置都不一样。好吧，废话不多说了，开始吧。&lt;/p&gt;

&lt;p&gt;　　本篇文章累计了大量评论，和我的一些解答，读者有什么问题可以先看看评论，或者搜下关键字，如果还是有问题可以给我在评论里给我留言，问题很着急的可以加我 ＱＱ：2621099562　，或者给我发邮件：&lt;a href=&quot;mailto:leopardpan@icloud.com&quot;&gt;leopardpan@icloud.com&lt;/a&gt;  ，都可以，如果你已经搭建完成了，可以看看我的另一篇博客&lt;a href=&quot;http://leopardpan.cn/2016/06/HEXO_Advanced/&quot;&gt;HEXO进阶&lt;/a&gt;，有讲如何能百度搜索你的博客、多台电脑使用HEXO发布博客等。我现在的博客是使用 Jekyll 搭建的，如果你想使用我现在的模板请看&lt;a href=&quot;http://leopardpan.cn/2016/10/jekyll_tutorials1/&quot;&gt;Jekyll搭建个人博客&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;背景&quot;&gt;背景&lt;/h2&gt;

&lt;p&gt;　这篇教程是针对与Mac的，&lt;a href=&quot;http://ibruce.info/2013/11/22/hexo-your-blog/?utm_source=tuicool&quot;&gt;参考链接&lt;/a&gt;，由于原文讲到的hexo是以前的老版本，所以现在的版本配置的时候会有些改动。&lt;/p&gt;

&lt;p&gt;　之前是想着写博客，一方面是给自己做笔记，可以提升自己的写作、总结能力，一个技术点我们会使用，并不难，但是要做到让让别人也能听懂我们讲得，还是需要一定的技巧和经验的。很多类似于CSDN、博客园也都可以写文章，但是页面的样式我，不是太喜欢，简书还算好点得。最近看到一些大神们的博客（在我的友情链接里有），貌似都是用hexo写得，我也依葫芦画瓢的搭建了一个。不罗嗦了，直接上搭建步骤。&lt;/p&gt;

&lt;h2 id=&quot;配置环境&quot;&gt;配置环境&lt;/h2&gt;

&lt;h3 id=&quot;安装node必须&quot;&gt;安装Node（必须）&lt;/h3&gt;

&lt;p&gt;作用：用来生成静态页面的
到Node.js&lt;a href=&quot;https://nodejs.org/&quot;&gt;官网&lt;/a&gt;下载相应平台的最新版本，一路安装即可。&lt;/p&gt;

&lt;h3 id=&quot;安装git必须&quot;&gt;安装Git（必须）&lt;/h3&gt;
&lt;p&gt;作用：把本地的hexo内容提交到github上去.
安装Xcode就自带有Git，我就不多说了。&lt;/p&gt;

&lt;h3 id=&quot;申请github必须&quot;&gt;申请GitHub（必须）&lt;/h3&gt;
&lt;p&gt;作用：是用来做博客的远程创库、域名、服务器之类的，怎么与本地hexo建立连接等下讲。
&lt;a href=&quot;https://github.com/&quot;&gt;github&lt;/a&gt;账号我也不再啰嗦了,没有的话直接申请就行了，跟一般的注册账号差不多，SSH Keys，看你自己了，可以不配制，不配置的话以后每次对自己的博客有改动提交的时候就要手动输入账号密码，配置了就不需要了，怎么配置我就不多说了，网上有很多教程。&lt;/p&gt;

&lt;h3 id=&quot;正式安装hexo&quot;&gt;正式安装HEXO　&lt;/h3&gt;
&lt;p&gt;Node和Git都安装好后，可执行如下命令安装hexo：&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ sudo npm install -g hexo
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;初始化&quot;&gt;初始化&lt;/h3&gt;
&lt;p&gt;创建一个文件夹，如：Blog，cd到Blog里执行hexo init的。命令：&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;hexo init
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;好啦，至此，全部安装工作已经完成！&lt;/p&gt;

&lt;h3 id=&quot;生成静态页面&quot;&gt;生成静态页面&lt;/h3&gt;
&lt;p&gt;继续再Blog目录下执行如下命令，生成静态页面&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;hexo generate （hexo g  也可以）   
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;本地启动&quot;&gt;本地启动&lt;/h3&gt;
&lt;p&gt;启动本地服务，进行文章预览调试，命令：&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;hexo server   
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;浏览器输入&lt;a href=&quot;就可以看到最原始的效果了&quot;&gt;http://localhost:4000&lt;/a&gt;
我不知道你们能不能，反正我不能，因为我还有环境没配置好&lt;/p&gt;

&lt;h3 id=&quot;常见的hexo配置错误&quot;&gt;常见的HEXO配置错误：&lt;/h3&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ERROR Plugin load failed: hexo-server

原因： Besides, utilities are separated into a standalone module. hexo.util is not reachable anymore.

解决方法，执行命令：$ sudo npm install hexo-server

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;执行命令hexo server，提示：Usage: hexo&amp;lt;Command&amp;gt; ....

原因：我认为是没有生成本地服务

解决方法，执行命令：$ npm install hexo-server --save

提示：hexo-server@0.1.2 node_modules/hexo-server
.... 

表示成功了[参考](https://hexo.io/zh-cn/docs/server.html)

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;这个时候再执行：$ hexo-server&lt;/p&gt;

&lt;p&gt;得到: INFO  Hexo is running at http://0.0.0.0:4000/. Press Ctrl+C to stop.&lt;/p&gt;

&lt;p&gt;这个时候再点击&lt;a href=&quot;http://0.0.0.0:4000&quot;&gt;http://0.0.0.0:4000&lt;/a&gt;，正常情况下应该是最原始的画面，但是我看到的是：
白板和Cannot GET /   几个字
原因： 由于2.6以后就更新了，我们需要手动配置些东西，我们需要输入下面三行命令：&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;npm install hexo-renderer-ejs --save
npm install hexo-renderer-stylus --save
npm install hexo-renderer-marked --save
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;这个时候再重新生成静态文件，命令：&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;hexo generate （或hexo g）
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;启动本地服务器：&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;hexo server （或hexo s）
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;再点击网址&lt;a href=&quot;http://0.0.0.0:4000&quot;&gt;http://0.0.0.0:4000&lt;/a&gt; OK终于可以看到属于你自己的blog啦，?，虽然很简陋，但好歹有了一个属于自己的小窝了。&lt;a href=&quot;https://disqus.com/home/discussion/bsspirit/hexogithubweb/&quot;&gt;参考链接&lt;/a&gt;，本地已经简单的设置好了，但是现在域名和服务器都是基于自己的电脑，接下来需要跟github进行关联。&lt;/p&gt;

&lt;h2 id=&quot;配置github&quot;&gt;配置Github&lt;/h2&gt;

&lt;h3 id=&quot;建立repository&quot;&gt;建立Repository&lt;/h3&gt;

&lt;p&gt;建立与你用户名对应的仓库，仓库名必须为【your_user_name.github.io】，固定写法
然后建立关联，我的Blog在本地/Users/leopard/Blog，Blog是我之前建的东西也全在这里面，有：&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Blog      &lt;br /&gt;
　｜      &lt;br /&gt;
　｜－－ _config.yml     &lt;br /&gt;
　｜－－ node_modules    &lt;br /&gt;
　｜－－ public              &lt;br /&gt;
　｜－－ source                                                &lt;br /&gt;
　｜－－ db.json	        &lt;br /&gt;
　｜－－ package.json        &lt;br /&gt;
　｜－－ scaffolds        &lt;br /&gt;
　｜－－ themes          　　　　　
　　　&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;现在我们需要_config.yml文件，来建立关联，命令：&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;vim _config.yml
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;翻到最下面，改成我这样子的，注意： &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;: 后面要有空格&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;deploy:
  type: git
  repository: https://github.com/leopardpan/leopardpan.github.io.git
  branch: master
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;执行如下命令才能使用git部署&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;npm install hexo-deployer-git --save
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;网上会有很多说法，有的type是github, 还有repository 最后面的后缀也不一样，是github.com.git，我也踩了很多坑，我现在的版本是hexo: 3.1.1，执行命令hexo -vsersion就出来了,貌似3.0后全部改成我上面这种格式了。
忘了说了，我没用SSH Keys如果你用了SSH Keys的话直接在github里复制SSH的就行了，总共就两种协议，相信你懂的。
然后，执行配置命令：&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;hexo deploy
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;　然后再浏览器中输入&lt;a href=&quot;http://leopardpan.github.io/&quot;&gt;http://leopardpan.github.io/&lt;/a&gt;就行了，我的 github 的账户叫 leopardpan ,把这个改成你 github 的账户名就行了&lt;/p&gt;

&lt;h3 id=&quot;部署步骤&quot;&gt;部署步骤&lt;/h3&gt;

&lt;p&gt;每次部署的步骤，可按以下三步来进行。&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;hexo clean
hexo generate
hexo deploy
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;一些常用命令：&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;hexo new &quot;postName&quot; #新建文章
hexo new page &quot;pageName&quot; #新建页面
hexo generate #生成静态页面至public目录
hexo server #开启预览访问端口（默认端口4000，'ctrl + c'关闭server）
hexo deploy #将.deploy目录部署到GitHub
hexo help  #查看帮助
hexo version  #查看Hexo的版本
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;这里有大量的&lt;a href=&quot;https://github.com/hexojs/hexo/wiki/Themes&quot;&gt;主题列表&lt;/a&gt;使用方法里面
都有详细的介绍，我就不多说了。    &lt;br /&gt;
我这里有几款个人认为不错的主题，免去你们，一个一个的选了，欢迎吐槽我的审美，?       &lt;br /&gt;
　&lt;a href=&quot;https://github.com/daisygao/hexo-themes-cover&quot;&gt;Cover&lt;/a&gt; - A chic theme with facebook-like cover photo    &lt;br /&gt;
　&lt;a href=&quot;https://github.com/henryhuang/oishi&quot;&gt;Oishi&lt;/a&gt; - A white theme based on Landscape plus and Writing.    &lt;br /&gt;
　&lt;a href=&quot;https://github.com/hardywu/hexo-theme-sidebar&quot;&gt;Sidebar&lt;/a&gt; - Another theme based on Light with a simple sidebar  &lt;br /&gt;
　&lt;a href=&quot;https://github.com/SuperKieran/TKL&quot;&gt;TKL&lt;/a&gt; - A responsive design theme for Hexo. 一个设计优雅的响应式主题  &lt;br /&gt;
　&lt;a href=&quot;https://github.com/levonlin/Tinnypp&quot;&gt;Tinnypp&lt;/a&gt; - A clean, simple theme based on Tinny   &lt;br /&gt;
　&lt;a href=&quot;https://github.com/yunlzheng/hexo-themes-writing&quot;&gt;Writing&lt;/a&gt; - A small and simple hexo theme based on Light   &lt;br /&gt;
　&lt;a href=&quot;https://github.com/litten/hexo-theme-yilia&quot;&gt;Yilia&lt;/a&gt; - Responsive and simple style 优雅简洁响应式主题，我用得就是这个。  &lt;br /&gt;
　&lt;a href=&quot;https://github.com/Voidly/pacman&quot;&gt;Pacman voidy&lt;/a&gt; - A theme with dynamic tagcloud and dynamic snow&lt;/p&gt;

&lt;h2 id=&quot;博客目录介绍&quot;&gt;博客目录介绍&lt;/h2&gt;
&lt;p&gt;　文章在 source/_posts，编辑器可以用 Sublime，支持 markdown 语法。如果想修改头像可以直接在主题的 _config.yml 文件里面修改，友情链接，之类的都在这里，修改名字在 public/index.html 里修改，开始打理你的博客吧，有什么问题或者建议，都可以提出来，我会继续完善的。&lt;/p&gt;

&lt;p&gt;Markdown语法参考链接: &lt;a href=&quot;https://www.zybuluo.com/mdeditor&quot;&gt;作业部落&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;qa&quot;&gt;Q&amp;amp;A&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;问：如何让文章想只显示一部分和一个 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;阅读全文&lt;/code&gt; 的按钮？     &lt;br /&gt;
答：在文章中加一个 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;!--more--&amp;gt;&lt;/code&gt; ， &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;!--more--&amp;gt;&lt;/code&gt; 后面的内容就不会显示出来了。&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt; &lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;问：本地部署成功了，也能预览效果，但使用 username.github.io 访问，&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;出现 404 &lt;/code&gt; .    &lt;br /&gt;
答：首先确认 hexo d 命令执行是否报错，如果没有报错，再查看一下你的 github 的 username.github.io 仓库，你的博客是否已经成功提交了，你的 github 邮箱也要通过验证才行。&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;转载请注明原地址，潘柏信的博客：&lt;a href=&quot;http://leopardpan.github.io&quot;&gt;http://leopardpan.github.io&lt;/a&gt; 谢谢！&lt;/p&gt;
</description>
        <pubDate>Tue, 25 Aug 2020 00:00:00 +0000</pubDate>
        <link>http://qiuxiaopeng2000.github.io/2020/08/HEXO%E6%90%AD%E5%BB%BA%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A2/</link>
        <guid isPermaLink="true">http://qiuxiaopeng2000.github.io/2020/08/HEXO%E6%90%AD%E5%BB%BA%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A2/</guid>
        
        <category>hexo</category>
        
        
      </item>
    
      <item>
        <title>博客模板功能介绍</title>
        <description>&lt;p&gt;在此之前我有写过一篇&lt;a href=&quot;http://leopardpan.cn/2016/10/jekyll_tutorials1/&quot;&gt;如何使用我博客模板的文章&lt;/a&gt; 请先看这篇基础集成，这篇文章主要讲的是如何使用和修改我的博客主题，文章内容含以下几点：&lt;/p&gt;

&lt;h2 id=&quot;博客特性&quot;&gt;博客特性&lt;/h2&gt;

&lt;ul class=&quot;task-list&quot;&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;适配电脑、手机、平板等各屏幕&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;响应式设计&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;个性化头像&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;每篇文章自动添加打赏功能&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;支持Disqus、livere评论系统&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;支持站点总数访问统计，每篇文章访问统计&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;支持文章自动生成目录&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;支持标签分类&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;支持代码高亮&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;支持文章H1、H2、H3、H4标题样式多样化&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;支持多种三方社交icon展示，能从博客直接跳转到自己的三方社交主页&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;支持三方社交分享(facebook、twitter)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;博客主要模块介绍&quot;&gt;博客主要模块介绍&lt;/h2&gt;

&lt;h3 id=&quot;_configyml&quot;&gt;_config.yml&lt;/h3&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;_config.yml&lt;/code&gt; 是博客的配置文件，整个站点的信息都在这修改，想要把我的模板改成你自己的也需要修改&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;_config.yml&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;重要字段说明&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;enableToc: 是否开启文章自动生成目录，设置为false文章不会自动生成目录&lt;/li&gt;
  &lt;li&gt;comment/livere: livere评论系统，支持微信、qq、微博、豆瓣、twitter等登录后可以直接评论&lt;/li&gt;
  &lt;li&gt;comment/disqus: disqus评论系统，支持facebook、twitter等登录后可以直接评论&lt;/li&gt;
  &lt;li&gt;social/weibo、github、zhihu、jianshu等: 个人站底部展示的微博等三方社交按钮，点击后直接跳转到个人微博或其他社交主页&lt;/li&gt;
  &lt;li&gt;baidu/id: 百度统计，用来统计你个人站点的用户访问情况&lt;/li&gt;
  &lt;li&gt;ga/id: google统计，用来统计你个人站点的用户访问情况&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;_config.yml 文件除以上字段还有一些可以自行修改，例如title之类的字段&lt;/p&gt;

&lt;h3 id=&quot;_posts&quot;&gt;_posts&lt;/h3&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;_posts&lt;/code&gt; 目录是用来存放文章的目录，写新文章，直接放在这个目录即可&lt;/p&gt;

&lt;p&gt;使用博客模板时，请把博客自带的文章给去掉，如果想使用博客自带的文章请 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;注明出处&lt;/code&gt;。&lt;/p&gt;

&lt;h3 id=&quot;自定义页面&quot;&gt;自定义页面&lt;/h3&gt;

&lt;p&gt;about.md、support.md 等为自定义页面，如果你想添加自动以页面可以直接复制about.md 文件修改文件名和里面的内容即可。&lt;/p&gt;

&lt;p&gt;如果需要在导航显示你新增的页面，直接在&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;_config.yml&lt;/code&gt; 文件的nav字段中添加你新页面配置即可&lt;/p&gt;

&lt;h3 id=&quot;修改说明&quot;&gt;修改说明&lt;/h3&gt;

&lt;p&gt;如果要修改博客模板信息建议只修改&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;_config.yml&lt;/code&gt; 文件内容和 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;_posts&lt;/code&gt; 里面的文章信息。因为博客模板一直在更新迭代，改动多了以免你后期更新博客模板的时候不方便。&lt;/p&gt;

&lt;p&gt;如果你想改动模板的样式又想继续更新迭代博客模板，你可以提交在github上提交&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pull request&lt;/code&gt; 或者直接给我发邮件建议改成什么样，如果你的提议确实可以，我会采纳的，并且非常感谢你的建议。&lt;/p&gt;

&lt;p&gt;博客迭代信息请看&lt;a href=&quot;http://leopardpan.cn/2020/07/ReleaseNode/&quot;&gt;ReleaseNode&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;遇到解决不了的问题可以找 &lt;a href=&quot;http://leopardpan.cn/support/&quot;&gt;技术支持&lt;/a&gt;&lt;/p&gt;

</description>
        <pubDate>Sat, 11 Jul 2020 00:00:00 +0000</pubDate>
        <link>http://qiuxiaopeng2000.github.io/2020/07/blog_info/</link>
        <guid isPermaLink="true">http://qiuxiaopeng2000.github.io/2020/07/blog_info/</guid>
        
        <category>jekyll</category>
        
        
      </item>
    
      <item>
        <title>博客迭代记录</title>
        <description>&lt;h2 id=&quot;介绍&quot;&gt;介绍&lt;/h2&gt;

&lt;p&gt;本博客首发时间为2015年，至今已经5个年头了。&lt;/p&gt;

&lt;p&gt;感觉之前更新迭代的有点乱，很多用户在使用的时候也没法确定是否要更新新版的博客，再次我专门用一篇文章来记录博客更新迭代的记录，如果你已经在使用我的博客模板的，你可以看看更新记录后确认下是否要更新。&lt;/p&gt;

&lt;p&gt;博客的全功能介绍请看&lt;a href=&quot;http://leopardpan.cn/2020/07/blog_info/&quot;&gt;博客功能介绍&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;100&quot;&gt;1.0.0&lt;/h2&gt;

&lt;p&gt;2016-11-25 第一版发布，红色主题&lt;/p&gt;

&lt;h2 id=&quot;200-开发中&quot;&gt;2.0.0 开发中&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;2016-11-25 修改博客风格为淡蓝色主题&lt;/li&gt;
  &lt;li&gt;2016-12-16 增长404、about等页面&lt;/li&gt;
  &lt;li&gt;2017-1-12 增加代码高亮&lt;/li&gt;
  &lt;li&gt;2017-3-19 增加打赏公共&lt;/li&gt;
  &lt;li&gt;2017-9-8 多说评论系统停服，切换到disqus评论（多说上的评论全没了😭）&lt;/li&gt;
  &lt;li&gt;2019-1-25 增加博客底部社交链接&lt;/li&gt;
  &lt;li&gt;2020-7-8 博客域名从 &lt;a href=&quot;http://baixin.io&quot;&gt;http://baixin.io&lt;/a&gt; 迁移到 &lt;a href=&quot;http://leopardpan.cn&quot;&gt;http://leopardpan.cn&lt;/a&gt; （baixin.io没法备案之前的统计也全没了😭）.&lt;/li&gt;
  &lt;li&gt;2020-7-13 增加文章自动生成目录功能, 增加livere评论系统&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;博客更新手册&quot;&gt;博客更新手册&lt;/h2&gt;

&lt;p&gt;如果你已经在使我的博客模板了，现在又想继续更新新版的博客，你下载博客后只需要修改两个各方&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;_config.yml 文件&lt;/li&gt;
  &lt;li&gt;_posts 目录&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;_config.yml&lt;/code&gt; 文件里面的内容设置成你自己的，也可以用你原来的，最好是更新版的字段做一下对比。&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;_posts&lt;/code&gt; 目录里面的文章全部删掉，把你自己的文章放进来&lt;/p&gt;

&lt;p&gt;修改以上两个地方新版的博客便更新完成，快看看效果吧！&lt;/p&gt;

</description>
        <pubDate>Fri, 10 Jul 2020 00:00:00 +0000</pubDate>
        <link>http://qiuxiaopeng2000.github.io/2020/07/ReleaseNode/</link>
        <guid isPermaLink="true">http://qiuxiaopeng2000.github.io/2020/07/ReleaseNode/</guid>
        
        <category>jekyll</category>
        
        
      </item>
    
  </channel>
</rss>
