Merge pull request #600 from geekpi/master

[Translating] 27 The Linux Kernel--Configuring the Kernel Part 23
This commit is contained in:
Xingyu.Wang 2013-12-26 21:23:44 -08:00
commit c1c125b826
4 changed files with 221 additions and 220 deletions

View File

@ -1,106 +0,0 @@
Linux vmstat Command Tool to Report Virtual Memory Statistics
================================================================================
As we already know that computer must have memory which called RAM to make the computer works. RAM is refer to a physical memory that planted into the computer mainboard. This RAM is used to load applications such as browser, word processor and so on. So actually, programs that you are using are running on the memory.
Let say you have 2 GB of memory. When you are running an operating system, it may that your available memory is only 1,5 GB. Then you actively using a lot of applications. When the usage of the memory is full, you can load more applications anymore. In plain English, the computer may say “Sorry, you can not run more applications, please close some programs if you would like to run more applications”
To solve this problem, operating system including Linux use a method named Virtual Memory. This method will search the area of memory which not used recently by any applications, then copy it into computer harddisk. This can give some free memory area and give you chance to run more applications.
To monitor this virtual memory activities, we can use **vmstat** tool.
### What is vmstat ###
Vmstat is a tool that provide reporting virtual memory statistics. It covers systems memory, swap and processors utilizations in real time.
### How to run vmstat ###
Same with [mpstat][1], vmstat is included inside sysstat package. If you dont have it, please install sysstat package.
To run vmstat, just type vmstat in your console. Running vmstat without parameter will show you a default result of vmstat.
![](http://linoxide.com/wp-content/uploads/2013/12/vmstat_default.png)
Lets see how to read the information provided by vmstat :
### Procs ###
Procs have **r** column and **b** column. **r** columns means the total number of processes that waiting access fot the processor. While b column means the total no processes in a sleep state. Below those columns, there are values. From the above screenshot, we have 2 processes that waiting access to the processor and 0 for sleep processes.
### Memory ###
Memory have **swpd, free, buff** and **cache** columns. This information is the same with **free -m** command. The **swpd column** show you about how much memory has been swapped to a swap file or disk. The **free column** show you the unallocated memory available. **Buff column** means how much in use memory. And **cache column** show you about how much memory that can be swapped into swap file or disk if there are some application is needed by them.
### Swap ###
Swap show us how much memory is sent or retrieved from the swap system. The **si** column tell us how much memory is moved **from swap to real memory** per second. The so column tell us how much memory that is moved **from real memory to swap**.
### I/O ###
The **io** show us the amount of input and output activity per second in terms of blocks read and blocks written. The **bi** column tell us about the number of blocks received and the **bo** tell us about the number of blocks sent.
### System ###
System show us the number of system operations per second. The **in** column tell us about the number system interrupts per second. The **cs** column tell us the number of context switches that the system makes in order to process all tasks.
### CPU ###
CPU show us the use of CPUs resources. The **us column** tell us how much time that processor spends on non-kernel processes. The **sy column** tell us about how much time that processor spends on kernel related tasks. The **id column** tell us about how long the processor are idle. The **wa column** tell us how much time that the processor has been waiting for I/O operations to complete before being able to continue processing tasks.
### Using vmstat with delay ###
As a tool for statistics, the best way of using vmstat is using a **delay**. So you can capture the activity periodically. Let say we want to run vmstat with 5 second delay. Just type **vmstat 5** on your console to do it.
![](http://linoxide.com/wp-content/uploads/2013/12/vmstat_delay_5.png)
The command will run every 5 seconds **until** you press Ctrl-C to stop it.
You can use **count** to limit how many times vmstat will running.
![](http://linoxide.com/wp-content/uploads/2013/12/vmstat_count_7.png)
The above command will run **vmstat with 5 seconds delay for 7 times**.
### Show active and inactive memory ###
To do it, you can add **-a** parameter to vmstat. Heres a sample.
![](http://linoxide.com/wp-content/uploads/2013/12/vmstat_a.png)
### Show summarize disk statistics ###
vmstat can print your system disk statistics if you want. Use **-D** parameter to print it.
![](http://linoxide.com/wp-content/uploads/2013/12/vmstat_disk_sum.png)
### Show display unit ###
You can choose what unit character you want to print. Use **-S followed by k (1000), K (1024), m (1000000), M (1048576)** bytes. If you dont choose the unit, vmstat will use K (1024).
![](http://linoxide.com/wp-content/uploads/2013/12/vmstat_define_unit.png)
### Print detail statistics for specific partition ###
To do it, you can use **-p parameter followed by device name**. Heres an example of it.
![](http://linoxide.com/wp-content/uploads/2013/12/vmstat_partition.png)
### Files ###
vmstat is using these files to works.
/proc/meminfo
/proc/stat
/proc/*/stat
### Conclusion ###
If you feel your system is running out memory, before you add some physical memory, this tool can help you to determine the root cause of the problem. As usual, you can explore more detail about vmstat command by typing **man vmstat** on your console. It will bring you to vmstat manual page.
--------------------------------------------------------------------------------
via: http://linoxide.com/linux-command/linux-vmstat-command-tool-report-virtual-memory-statistics/
译者:[译者ID](https://github.com/译者ID) 校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[1]:http://linoxide.com/linux-command/linux-mpstat-command/

View File

@ -1,114 +0,0 @@
27 The Linux Kernel: Configuring the Kernel Part 23
================================================================================
![](http://www.linux.org/attachments/slide-jpg.735/)
Aloha and welcome to the next kernel configuration article! In this article, we will configure the Cryptographic API, Virtualization, and Library Routines. Cryptography refers to encryption and secure communication between desired computers. Users may encrypt data to ensure only the recipient reads the data instead of hackers that may obtain the data.
The Linux kernel requires the "Cryptographic algorithm manager" to be enabled in the kernel. This feature provides the software needed to operate the cryptographic abilities of the kernel.
The userspace can configure the cryptography features when this driver is enabled (Userspace cryptographic algorithm configuration). NOTE: This configuration is referring to the cryptographic setup during kernel runtime, not the tool for making the kernel.
To enhance performance, enable this feature which stops self-tests on cryptographic algorithms (Disable run-time self tests).
The "GF(2^128) multiplication functions" is a specific algorithm used by some ciphers. GF stands for Galois field and is a set of finite numbers. These sets are called fields and they come in a variety of sizes.
"Null algorithms" are algorithms used in IPsec. Null encryption means no encryption, so this driver allows IPsec to use no encryption.
Arbitrary algorithms can be converted to parallel algorithms (Parallel crypto engine). This feature provides that converter.
Arbitrary algorithms can also be converted to asynchronous algorithms (Software async crypto daemon).
"Authenc support" is needed by IPsec. Authenc support stands for Authenticated Encryption and offers multiple encryptions to IPsec.
CCM stands for "Counter with CBC MAC" and is needed by IPsec (CCM support).
This driver offers "GCM/GMAC support". GCM is "Galois/Counter Mode" and GMAC is "Galois Message Authentication Code".
NOTE: I will not be able to explain specifically the use and details of some of these features. Cryptography is a detail field of computers and explaining cryptography is beyond the scope of this article.
The "Sequence Number IV Generator" is a special number generator used by some cryptography software.
The Linux kernel supports various cipher algorithms (CBC support), (CTR support), (CTS support), (ECB support), (LRW support), (PCBC support), (XTS support), (HMAC support), (XCBC support), and (VMAC support).
The "CRC32c CRC algorithm" is used specifically with SPARC64 processors.
"CRC32c INTEL hardware acceleration" is another processor specific algorithm. It works on Intel processors with SSE4.2.
The kernel also offers many digests, ciphers, and other cryptographic software. Generally, allow the defaults unless you have a specific reason for enabling or disabling features.
NOTE: A digest (like MD5) generates a hash (sequence of characters) based on a file. Hashes are then used to check files. For example, if you download the Ubuntu installation ISO file from Canonical's website, you may want to know if the file on your hard-drive is an exact replica of the server's file. Users do this because the ISO may become corrupted during the long download. The hash is used to prove that the file is unchanged.
NOTE: A cipher is an encryption/decryption algorithm. Encryption is the process of making a file unreadable to anyone other than the intended recipients/owners. Decryption is the process used to view an encrypted file.
The Linux kernel also supports various compression algorithms that users are strongly recommended to enable (Deflate compression algorithm), (Zlib compression algorithm), and (LZO compression algorithm).
The kernel can generate random numbers which are needed for cryptographic software (Pseudo Random Number Generation for Cryptographic modules), (User-space interface for hash algorithms), and (User-space interface for symmetric key cipher algorithms).
"Hardware crypto devices" is a sub-menu that contains a list of drivers for hardware-based cryptography tools. This is hardware that has the algorithms in the firmware.
Various drivers for asymmetric public-keys exist in the "Asymmetric (public-key cryptographic) key type" menu.
Now, we can move on to the next entry on the main menu of the configuration tool (on menu-based interfaces). Virtualization is the ability to host an operating system. This means Linux (and other systems) can run another operating system as if the guest system is an application.
"Kernel-based Virtual Machine (KVM) support" allows the kernel itself to manage the guest system. Computers with Intel processors need this driver (KVM for Intel processors support) and AMD processors need (KVM for AMD processors support).
The memory management unit (MMU) for the Kernel Virtual Machine (KVM) can have an auditing system.
The guest's network can become faster with this feature enabled (Host kernel accelerator for virtio net).
After configuring the virtual machine abilities for the kernel, the last menu on the main screen of the configuration tool (when using a menu interface) is the last portion of the kernel to configure. This menu is for the "Library Routines", also called library functions. Parts of the kernel can be used as a linkable library. For example, XZ filters (compression algorithms) can be accessed by external programs. The different libraries are listed below.
NOTE: The CRC functions are mostly the same but with different features or performance. Generally, it is best to allow the defaults.
CRC-CCITT functions - The Cyclic Redundancy Check function tests for changes in raw data
CRC16 functions - The Cyclic Redundancy Check function tests for changes in raw data
CRC calculation for the T10 Data Integrity Field - The Cyclic Redundancy Check function tests for changes in raw data
CRC ITU-T V.41 functions - The Cyclic Redundancy Check function tests for changes in raw data
CRC32/CRC32c functions - The Cyclic Redundancy Check function tests for changes in raw data
CRC32 perform self test on init - The Cyclic Redundancy Check function tests for changes in raw data
CRC32 implementation (Slice by 8 bytes) - The Cyclic Redundancy Check function tests for changes in raw data
CRC7 functions - The Cyclic Redundancy Check function tests for changes in raw data
CRC32c (Castagnoli, et al) Cyclic Redundancy-Check - The Cyclic Redundancy Check function tests for changes in raw data
CRC8 function - The Cyclic Redundancy Check function tests for changes in raw data
* BCJ filter decoder - XZ decoder design for a specific processor where "*" is the processor. The kernel lists a few different architectures.
XZ decompressor tester - Debug functions for testing the XZ decoder
Averaging functions - Load average as seen in the output of "uptime"
CORDIC algorithm - hyperbolic and trigonometry functions
JEDEC DDR data - JEDEC Double Data Rate SD-RAM specification
Guess what? You have finished configuring your kernel. I am sure after twenty-three articles, this is how you feel -
Video link:[http://www.youtube.com/embed/barWV7RWkq0?wmode=opaque][1]
Next, we can compile and install.
In the far distance, I still hear this -
Video link:[http://www.youtube.com/embed/ELoUppY1esw?wmode=opaque][2]
--------------------------------------------------------------------------------
via: http://www.linux.org/threads/the-linux-kernel-configuring-the-kernel-part-23.5112/
译者:[译者ID](https://github.com/译者ID) 校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[1]:http://www.youtube.com/embed/barWV7RWkq0?wmode=opaque
[2]:http://www.youtube.com/embed/ELoUppY1esw?wmode=opaque

View File

@ -0,0 +1,106 @@
Linux vmstat 命令 - 报告虚拟内存统计的工具
================================================================================
众所周知计算机必须有称之为RAM(随机访问内存)的存储器使得计算机工作。RAM指的是插在计算机主板上的物理存储。这里的RAM被用于加载像浏览器、文字处理器这类的程序、实际上你使用的程序都运行在内存上。
让我们假设你有2GB的内存。当你在运行操作系统时你的可用内存可能只有1.5GB。接着你使用了大量的程序。当内存使用满之后,你可能再也无法加载更多的程序。浅显地说,计算机可能会说:"抱歉,你不能在运行更多的程序了,如果你还要运行其他的程序请先关闭一些程序。"
为了解决这个问题操作系统包括Linux使用了一个方法称之为虚拟内存。这个方法会搜索最近不在使用的程序的内存区域接着将它们拷贝到计算机硬盘上。这会腾出一些剩余内存空间给你有机会运行更多的程序。
为了监视虚拟内存的活动,我们使用**vmstat**工具。
### 什么事 vmstat ###
vmstat是一个提供报告虚拟内存统计的工具。他/她覆盖了系统内存、交换和实时处理器利用率。
### 如何运行 vmstat ###
和[mpstat][1]一样vmstat包含在sysstat包中。如果你还没有请安装sysstat包。
为了运行vmstat只需在控制台输入vmstat。不带参数运行vmstat会显示vmstat的默认结果。
![](http://linoxide.com/wp-content/uploads/2013/12/vmstat_default.png)
让我们看下如何读取vmstat提供的信息
### Procs ###
procs有 **r**列和**b**列。**r**列代表等待访问CPU进程的数量。而b列意味着睡眠进程的数量。在这些列的下面是它们的值。从上面的截图中我门有2个进程正在等待访问CPU0个睡眠进程。
### Memory ###
memory有**swpd、 free、 buff** 和 **cache** 这些列.这些信息和命令**free -m**相同。**swpd列**显示了有多少内存已经被交换到了交换文件或者磁盘。**free列**显示了未分配的可用内存。**buff列**显示了使用中的内存。**cache列**显示了有多少内存可以被交换到交换文件或者磁盘上如果一些应用需要他们。
### Swap ###
swap显示了从交换系统上发送或取回了多少内存。**si**列告诉我们每秒有多少内存被**从swap移到真实内存**中。**so**列告诉我们每秒有多少内存被**从真实内存移到swap**中。
### I/O ###
**io**依据块的读写显示了每秒输入输出的活动。**bi**列告诉我们块收到的数量,**bo**列告诉我们块发送的数量。
### System ###
system显示了每秒的系统操作数量。**in**列显示了系统每秒被中断的数量。**cs**列显示了系统为了处理所以任务而上下文切换的数量。
### CPU ###
CPU告诉了我们CPU资源的使用情况。**us列**显示了处理器在非内核程序消耗的时间。**sy列**显示了处理器在内核相关任务上消耗的时间。**id列**显示了处理器的空闲时间。**wa列**显示了处理器在等待IO操作完成以继续处理任务上的时间。
### 代延迟使用vmstat ###
作为一个统计工具使用vmstat最好的方法是使用**延迟**。你可以间断地捕捉活动。让我假设以5秒的延迟使用vmstat。只需要在你的控制台中输入**vmstat 5**就行。
![](http://linoxide.com/wp-content/uploads/2013/12/vmstat_delay_5.png)
命令将会每5秒运行一次**直到**你按下Ctrl-C来终止它。你可以使用**count**来显示vmstat运行的次数。
![](http://linoxide.com/wp-content/uploads/2013/12/vmstat_count_7.png)
上面的命令会**以5秒的间隔运行7次vmstat**。
### 显示活跃和非活跃内存 ###
要这么做你可以在vmstat后加入**-a**选项。这是个示例。
![](http://linoxide.com/wp-content/uploads/2013/12/vmstat_a.png)
### 显示磁盘统计数据总结 ###
如果你想vmstat可以打印系统磁盘统计。使用**-D**选项就行。
![](http://linoxide.com/wp-content/uploads/2013/12/vmstat_disk_sum.png)
### 显示单位 ###
你可以选择你想打印的显示单位字符。在**-S后跟上k (1000)、 K (1024)、 m (1000000)、 M (1048576)** 字节. 如果你不想选择单位默认使用的是K (1024)。
![](http://linoxide.com/wp-content/uploads/2013/12/vmstat_define_unit.png)
### 为特定分区打印详细统计数据 ###
要这么做,你可以使用**-p选项跟上设备名**。这里有个例子。
![](http://linoxide.com/wp-content/uploads/2013/12/vmstat_partition.png)
### 文件 ###
vmstat使用这些文件工作。
/proc/meminfo
/proc/stat
/proc/*/stat
### 总结 ###
vmstat** on your console. It will bring you to vmstat manual page.
如果你感觉系统运行超出内存了,在你增加物理内存前,这个工具可以帮助你确定问题的根本原因。通常上,你可以在控制台中输入**man vmstat**获取更多的关于vmstat的详细信息。这会带你进入vmstat的手册页。
--------------------------------------------------------------------------------
via: http://linoxide.com/linux-command/linux-vmstat-command-tool-report-virtual-memory-statistics/
译者:[geekpi](https://github.com/geekpi) 校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[1]:http://linoxide.com/linux-command/linux-mpstat-command/

View File

@ -0,0 +1,115 @@
戴文的Linux内核专题27 配置内核 (23)
================================================================================
![](http://www.linux.org/attachments/slide-jpg.735/)
欢迎来到内核配置的下一章本篇中我们会配置密码API虚拟化和运行库。密码学指的是在需要的计算机之间加密和安全通信。用户可能加密数据以保证是收件人而不是黑客收到数据。
Linux内核需要在内核中启用"Cryptographic algorithm manager"(密码算法管理器)。这个特性提供了操作内核的加密特性所需的软件。
当启用这个它,用户空间提供了配置加密特性(Userspace cryptographic algorithm configuration)。注意:这个配置指的是内核运行时的加密设置,不是编译内核的工具。
为了加强性能,启用这个会在加密算法中停止自我检测的特性 (Disable run-time self tests)。
"GF(2^128) multiplication functions"是一种被一些密码使用特殊算法。GF代表的是" Galois field"(伽罗瓦域),是一种有限数的集合。这写集合称之为域并且有不同的大小。
"Null algorithms"是用于IPSec的算法。NULL加密意味这没有加密因此这个驱动允许IPSec不使用加密。
任意算法可以转换成并行算法(Parallel crypto engine)。这个特性提供了转换器。
任意算法同样可以转换成异步算法(Software async crypto daemon)。
IPsec需要"Authenc support"。"Authenc support"代表"Authenticated Encryption and offers multiple encryptions to IPsec"(认证加密并对IPSec提供多重加密)。
CCM代表的是"Counter with CBC MAC"(CBC MAC计数器)IPSec需要它(CCM support)。
这个驱动提供了"GCM/GMAC support"。GCM意思是"Galois/Counter Mode"(伽罗瓦/计数器 模式)GMAC是"Galois Message Authentication Code"(伽罗瓦消息验证码)。
注意:我不会明确地解释一些特性的使用和细节。密码学是计算机中的特定领域,解释加密学超出了这篇文章的范围。
"Sequence Number IV Generator"是一个被某些加密软件使用的特殊的号码生成器。
Linux内核提供了不同的密码算法(CBC support)、 (CTR support)、 (CTS support)、 (ECB support)、 (LRW support)、 (PCBC support)、 (XTS support)、 (HMAC support)、 (XCBC support) 和 (VMAC support)。
"CRC32c CRC algorithm" 明确被SPARC64处理器使用。
"CRC32c INTEL hardware acceleration"是另外一个特定处理器的算法。它工作于带SSE4.2的Intel处理器。
内核提供了很多摘要、密码和其他加密软件。通常上,默认允许它们除非你有特殊的理由来启用或禁用这些特性。
注意:摘要(像MD5)会基于一个文件生成一个哈希值(字符序列)。哈希值接着被用于检查文件。比如如果你从Canonical网站上下载了Ubuntu ISO安装盘你可能想要知道你硬盘上的文件就是服务器上的文件的复制品。用户这么做的原因是ISO可能在长时间下载中被损坏。哈希值被用来证明文件没有被改变。
注意:密码是一种加密/解密算法。加密是使文件对除了接受者/拥有者之外的人都不可读。解密是浏览加密文件的过程。
Linux内核同样支持用户被强烈建议启用的不同的压缩算法(Deflate compression algorithm)、 (Zlib compression algorithm) 和 (LZO compression algorithm)。
内核可以生成用于加密软件的随机数(Pseudo Random Number Generation for Cryptographic modules)、(User-space interface for hash algorithms) 和 (User-space interface for symmetric key cipher algorithms)。
"Hardware crypto devices"是一个子菜单,包含了基于硬件加密工具的驱动。这个硬件在固件中含有算法。
"Asymmetric (public-key cryptographic) key type" 菜单中存在着不同的非对称公开密钥。
下面,我们可以进入配置工具主菜单(基于菜单接口)的下一个入口。虚拟化是寄放一个操作系统的
能力。这意味这Linux(和其他的系统)可以运行其他的操作系统,仿佛客户机是一个应用一样。
"Kernel-based Virtual Machine (KVM) support"运行内核本身管理客户机。带Intel处理器的计算机需呀这个驱动(KVM for Intel processors support)AMD的则需要(KVM for AMD processors support)。
用于内核虚拟机(KVM)的内存管理单元(MMU)可以有一个审计系统。
启用这个特性使客户机的网络变得更快(Host kernel accelerator for virtio net)。
在配置哇内核虚拟机特性后,配置工具主菜单下的最后菜单是内核配置的最后一部分。这个菜单用于"Library Routines"(库运行时)同样也成为库函数。一部分内核可以被作为可以链接的库。比如XZ过滤(压缩算法)可以被外部程序访问。下面列出了不同的库。
注意CRC函数大多数都相同但有不同的特性和性能通常来讲最好启用这些特性。
CRC-CCITT functions - 循环冗余校验测试(Cyclic Redundancy Check)用于测试原始数据中的改变。
CRC16 functions - 循环冗余校验测试(Cyclic Redundancy Check)用于测试原始数据中的改变。
CRC calculation for the T10 Data Integrity Field - 循环冗余校验测试(Cyclic Redundancy Check)用于测试原始数据中的改变。
CRC ITU-T V.41 functions - 循环冗余校验测试(Cyclic Redundancy Check)用于测试原始数据中的改变。
CRC32/CRC32c functions - 循环冗余校验测试(Cyclic Redundancy Check)用于测试原始数据中的改变。
CRC32 perform self test on init - 循环冗余校验测试(Cyclic Redundancy Check)用于测试原始数据中的改变。
CRC32 implementation (Slice by 8 bytes) - 循环冗余校验测试(Cyclic Redundancy Check)用于测试原始数据中的改变。
CRC7 functions - 循环冗余校验测试(Cyclic Redundancy Check)用于测试原始数据中的改变。
CRC32c (Castagnoli, et al) Cyclic Redundancy-Check - 循环冗余校验测试(Cyclic Redundancy Check)用于测试原始数据中的改变。
CRC8 function - 循环冗余校验测试(Cyclic Redundancy Check)用于测试原始数据中的改变。
\* BCJ filter decoder - 为特定处理器设计的XZ解码器这里的"*"是处理器。内核列出了一些不同的架构。
XZ decompressor tester - 用于测试XZ解码器的调试函数。
Averaging functions - "uptime"在"uptime"中看到的平均负载。
CORDIC algorithm - 双曲线和三角函数。
JEDEC DDR data - JEDEC双倍数据速率SD-RAM规范
你猜怎么了我们已经完成便宜内核。在23篇之后我敢肯定这是你的感觉 -
视频链接:[http://www.youtube.com/embed/barWV7RWkq0?wmode=opaque][1]
下面,我们可以编译并安装了
在遥远的地方,我仍然在听 -
视频链接:[http://www.youtube.com/embed/ELoUppY1esw?wmode=opaque][2]
--------------------------------------------------------------------------------
via: http://www.linux.org/threads/the-linux-kernel-configuring-the-kernel-part-23.5112/
译者:[geekpi](https://github.com/geekpi) 校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[1]:http://www.youtube.com/embed/barWV7RWkq0?wmode=opaque
[2]:http://www.youtube.com/embed/ELoUppY1esw?wmode=opaque