Simplified Chinese Translation of the latest geom/ and audit/.
Submitted by: delphij Obtained from: The FreeBSD Simplified Chinese Project
This commit is contained in:
parent
57897a5681
commit
cd18914b71
Notes:
svn2git
2020-12-08 03:00:23 +00:00
svn path=/head/; revision=25471
4 changed files with 892 additions and 0 deletions
16
zh_CN.GB2312/books/handbook/audit/Makefile
Normal file
16
zh_CN.GB2312/books/handbook/audit/Makefile
Normal file
|
@ -0,0 +1,16 @@
|
|||
#
|
||||
# Build the Handbook with just the content from this chapter.
|
||||
#
|
||||
# Original Revision: 1.1
|
||||
# $FreeBSD$
|
||||
#
|
||||
|
||||
CHAPTERS= audit/chapter.sgml
|
||||
|
||||
VPATH= ..
|
||||
|
||||
MASTERDOC= ${.CURDIR}/../${DOC}.${DOCBOOKSUFFIX}
|
||||
|
||||
DOC_PREFIX?= ${.CURDIR}/../../../..
|
||||
|
||||
.include "../Makefile"
|
467
zh_CN.GB2312/books/handbook/audit/chapter.sgml
Normal file
467
zh_CN.GB2312/books/handbook/audit/chapter.sgml
Normal file
|
@ -0,0 +1,467 @@
|
|||
<!--
|
||||
The FreeBSD Documentation Project
|
||||
The FreeBSD Simplified Chinese Project
|
||||
|
||||
Original Revision: 1.5
|
||||
$FreeBSD$
|
||||
-->
|
||||
|
||||
<!--
|
||||
This version of the document assumes that the Audit system needs to be
|
||||
installed as part of the trustedbsd/audit project. When/if audit becomes
|
||||
part of FreeBSD proper, then these sections should be removed, or at least
|
||||
reworded. The sections in question are marked with 'PROTOTYPE' labels in
|
||||
commentary.
|
||||
-->
|
||||
|
||||
<!-- Need more documenation on praudit, audtreduce, etc. Plus more info
|
||||
on the triggers from the kernel (log rotation, out of space, etc).
|
||||
And the /dev/audit special file if we choose to support that. Could use
|
||||
some coverage of integrating MAC with Event auditing and perhaps discussion
|
||||
on how some companies or organizations handle auditing and auditing
|
||||
requirements. -->
|
||||
|
||||
<chapter id="audit">
|
||||
<chapterinfo>
|
||||
<authorgroup>
|
||||
<author>
|
||||
<firstname>Tom</firstname>
|
||||
<surname>Rhodes</surname>
|
||||
<contrib>原作 </contrib>
|
||||
</author>
|
||||
</authorgroup>
|
||||
</chapterinfo>
|
||||
|
||||
<title>内核事件审计</title>
|
||||
|
||||
<sect1 id="audit-synopsis">
|
||||
<title>概述</title>
|
||||
|
||||
<indexterm><primary>AUDIT</primary></indexterm>
|
||||
<indexterm>
|
||||
<primary>内核事件审计</primary>
|
||||
<see>MAC</see>
|
||||
</indexterm>
|
||||
|
||||
<para>在 &os; 6.0 操作系统的发行版本中, 包含了基于 &posix;.1e 草案,
|
||||
以及 &sun; <acronym>BSM</acronym> 实现的事件审计机制。
|
||||
事件审计功能使得选择性地记录与安全有关的系统事件成为可能,
|
||||
而这些日志可以帮助人们完成系统分析、 监视, 以及安全评估等工作。</para>
|
||||
|
||||
<para>这一章将主要关注与安装和配置事件审计机制。
|
||||
同时, 为了方便读者, 也介绍了审计策略,
|
||||
并给出了一个实例加以说明。</para>
|
||||
|
||||
<para>读完这章, 您将了解:</para>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>事件审计是什么, 以及它如何工作。</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>如何在 &os; 上为用户和进程配置事件审计。</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para>阅读这章之前, 您应该:</para>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>理解 &unix; 和 &os; 的基础知识
|
||||
(<xref linkend="basics">)。</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>熟悉关于内核配置和编译的基本方法
|
||||
(<xref linkend="kernelconfig">)。</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>熟悉安全知识以及如何在 &os; 运用它们 (<xref linkend="security">)。</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<warning>
|
||||
<para>事件审计可能会产生大量的日志文件数据, 在某些配置中,
|
||||
可能每周都会产生超过数 GB 的数据。 管理员应完整地阅读完这一章的内容,
|
||||
以避免由于不当配置产生的自作自受型 <acronym>DoS</acronym>。</para>
|
||||
</warning>
|
||||
|
||||
<para>在 &os; 中的事件审计机制, 与 &sun; 的基本安全模块,
|
||||
即 <acronym>BSM</acronym> 库类似。 因此, 这些配置与 &solaris;
|
||||
和 Darwin 操作系统之间可以完全互换。</para>
|
||||
</sect1>
|
||||
|
||||
<sect1 id="audit-inline-glossary">
|
||||
<title>您需要了解的一些关键术语</title>
|
||||
|
||||
<para>在开始阅读这章之前, 首先需要解释一些关键的术语。
|
||||
这是为了清除一些由于引入新术语而带来的困惑和阅读障碍。</para>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para><emphasis>类</emphasis>(class): 类用于区分系统中不同的动作类型。
|
||||
例如, 使用 &man.login.1; 这一行为就可以放在一个类里。</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><emphasis>事件</emphasis>(event): 可以把事件理解为发生在系统中的动作。
|
||||
例如, 创建文件就是一个事件。</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><emphasis>记录</emphasis>(record): 记录是关于某一特定动作的日志内容。</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><emphasis>前缀</emphasis>(prefix): 前缀指用于切换成功和失败审计事件的配置单元。</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</sect1>
|
||||
|
||||
<sect1 id="audit-install">
|
||||
<title>安装审计支持</title>
|
||||
|
||||
<para>对于事件审计的支持, 已经随标准的 <maketarget>installworld</maketarget>
|
||||
过程完成。 管理员可以通过查看
|
||||
<filename role="directory">/etc/security</filename> 的内容来确认这一点。
|
||||
您应能看到一些名字以 <emphasis>audit</emphasis> 开头的文件,
|
||||
例如 <filename>audit_event</filename>。</para>
|
||||
|
||||
<para>此外, 还必须加入内核部分的支持。
|
||||
这可以通过在本地的内核配置文件中加入下面一行来实现:</para>
|
||||
|
||||
<programlisting>options AUDIT</programlisting>
|
||||
|
||||
<para>接下来, 您应按照
|
||||
<xref linkend="kernelconfig"> 中所介绍的步骤来完成一次内核的编译和安装。</para>
|
||||
|
||||
<para>一旦完成, 可以通过下列 &man.rc.conf.5; 配置来启动审计服务:</para>
|
||||
|
||||
<programlisting>auditd_enable="YES"</programlisting>
|
||||
|
||||
<para>默认不启用的那些功能可以在此处以 <option>auditd_flags</option> 选项来增加。</para>
|
||||
</sect1>
|
||||
|
||||
<sect1 id="audit-config">
|
||||
<title>对审计进行配置</title>
|
||||
|
||||
<para>默认情况下, 所有配置都可以通过
|
||||
<filename role="directory">/etc/security</filename> 下的文件来完成。
|
||||
要启动审计服务, 下面这些文件必须存在:</para>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para><filename>audit_class</filename> - 包含对于审计类的定义。</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><filename>audit_control</filename> - 控制审计子系统的特性,
|
||||
例如默认审计类、 在审计日志所在的卷上保留的最小空间, 等等。</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><filename>audit_event</filename> - 定义内核审计事件。
|
||||
它们多数都对应于某些系统调用。</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><filename>audit_user</filename> - 针对特定用户进行的事件审计。
|
||||
用户名在这里并不必须出现。</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><filename>audit_warn</filename> - 用于 auditd 生成警告信息的
|
||||
shell 脚本。</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para>如果由于某些原因这些文件并不存在,
|
||||
则可以很容易地用下列命令来安装:</para>
|
||||
|
||||
<screen>&prompt.root; <userinput>cd /usr/src/contrib/bsm/etc && make install</userinput></screen>
|
||||
|
||||
<sect2>
|
||||
<title>审计文件的语法</title>
|
||||
|
||||
<para>配置文件的语法看上去可能有点怪异, 尽管用起来会很容易。
|
||||
管理员必须非常谨慎的一件事是改变系统的默认值,
|
||||
因为这样做可能会造成潜在的无法正确收集审计数据的问题。</para>
|
||||
|
||||
<para>审计子系统能够同时接受配置语法中的长短名字。 接下来,
|
||||
我们将给出语法表。</para>
|
||||
|
||||
<para>下面是所支持的全部审计类:</para>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para><option>all</option> - <literal>all</literal> -
|
||||
设置全部审计标志。</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><option>ad</option> - <literal>administrative</literal>
|
||||
- 所有在系统上所进行的管理性操作。</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><option>ap</option> - <literal>application</literal> -
|
||||
应用程序定义的动作。</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><option>cl</option> - <literal>file_close</literal> -
|
||||
审计对 <function>close</function> 系统调用的操作。</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><option>ex</option> - <literal>exec</literal> -
|
||||
审计程序或实用工具的执行。</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><option>fa</option> - <literal>file_attr_acc</literal>
|
||||
- 审计访问对象属性, 例如
|
||||
&man.stat.1;、 &man.pathconf.2; 以及类似事件。</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><option>fc</option> - <literal>file_creation</literal>
|
||||
- 审计创建了文件的事件。</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><option>fd</option> - <literal>file_deletion</literal>
|
||||
- 审计所发生的文件删除事件。</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><option>fm</option> - <literal>file_attr_mod</literal>
|
||||
- 审计文件属性发生变化的事件,
|
||||
例如 &man.chown.8;、 &man.chflags.1;、 &man.flock.2;,
|
||||
等等。</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><option>fr</option> - <literal>file_read</literal>
|
||||
- 审计读取数据、 文件以读方式打开等事件。</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><option>fw</option> - <literal>file_write</literal> -
|
||||
审计写入数据、 文件以写方式打开等事件。</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><option>io</option> - <literal>ioctl</literal> -
|
||||
审计对 &man.ioctl.2; 系统调用的使用。</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><option>ip</option> - <literal>ipc</literal> - 审计
|
||||
System V <acronym>IPC</acronym> 操作。</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><option>lo</option> - <literal>login_logout</literal> -
|
||||
审计系统中发生的 &man.login.1; 和 &man.logout.1; 事件。</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><option>na</option> - <literal>non_attrib</literal> -
|
||||
审计无法归类的事件。</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><option>no</option> - <literal>no_class</literal> -
|
||||
空类, 用于禁用事件审计。</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><option>nt</option> - <literal>network</literal> -
|
||||
与网络操作有关的事件, 例如
|
||||
&man.connect.2; 和 &man.accept.2;。</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><option>ot</option> - <literal>other</literal> -
|
||||
审计各类杂项事件。</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><option>pc</option> - <literal>process</literal> -
|
||||
审计进程操作, 例如 &man.exec.3; 和
|
||||
&man.exit.3;。</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><option>tf</option> - <literal>tfm</literal> -
|
||||
I HAVE NO CLUE!</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para>下面是全部支持的审计前缀:</para>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para><literal>none</literal> - 同时审计事件的成功和失败。
|
||||
例如, 秩序列出一个事件类就可以同时审计其成功或失败。</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><literal>+</literal> - 只审计成功事件。</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><literal>-</literal> - 只审计失败事件。</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<warning>
|
||||
<para>使用 <option>all</option> 类, 无论是正还是负号作为前缀,
|
||||
都会以极快的速度产生大量的数据。</para>
|
||||
</warning>
|
||||
|
||||
<para>其他用于改变默认配置值得前缀:</para>
|
||||
<!-- XXX: Perhaps a variable listing here. -->
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>^- - 禁用对于失败事件的审计。</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>^+ - 启用对于成功事件的审计。</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>^ - 同时禁用成功和失败事件的审计。</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</sect2>
|
||||
|
||||
<sect2>
|
||||
<title>配置文件</title>
|
||||
|
||||
<para>配置是在两个文件中进行设置的。 第一个文件是
|
||||
<filename>audit_control</filename> 而第二个是
|
||||
<filename>audit_user</filename>。 第一个文件是系统级的,
|
||||
用于控制系统中的所有事件统计。 而后一个则可以实现细粒度的用户级审计。</para>
|
||||
|
||||
<sect3 id="audit-auditcontrol">
|
||||
<title>传说中的 <filename>audit_control</filename> 文件</title>
|
||||
|
||||
<para><filename>audit_control</filename> 文件包含了一些基本的默认值,
|
||||
管理员通常会希望加以修改, 有时甚至是设置一些新的配置。
|
||||
察看这个文件的内容, 我们会发现:</para>
|
||||
|
||||
<programlisting>dir:/var/audit
|
||||
flags:lo,ad,-all,^-fa,^-fc,^-cl
|
||||
minfree:20
|
||||
naflags:lo</programlisting>
|
||||
|
||||
<para>这里的 <option>dir</option> 表示默认存放审计日志的目录。</para>
|
||||
|
||||
<para><option>flags</option> 则用来设置系统级的默认。
|
||||
目前的设置, 即
|
||||
<option>lo,ad,-all,^-fa,^-fc,^-cl</option> 表示审计所有的系统
|
||||
&man.login.1; 和 &man.logout.1; 动作、 所有管理动作,
|
||||
以及所有系统中失败的动作, 但最后禁用对 <option>fa</option>、
|
||||
<option>fc</option>, 以及 <option>cl</option> 的失败常是。
|
||||
尽管 <option>-all</option> 会打开所有事件的失败常是,
|
||||
但之后的选项中的 <option>^-</option> 前缀则会改变相应的设置。</para>
|
||||
|
||||
<para>请注意前一节也说明了配置是从左到右读取的。 同样地,
|
||||
较为靠右的值可以替代靠左的值所设定的默认。</para>
|
||||
|
||||
<para><option>minfree</option> 参数定义了用于审计的文件系统上,
|
||||
剩余空间的最小值。 这一百分比值是相对于保存审计日志的文件系统来计算的。
|
||||
例如, 如果 <option>dir</option> 指定了
|
||||
<filename role="directory">/var/audit</filename> 而
|
||||
<option>minfree</option> 设为两成 (20), 则当
|
||||
<filename role="directory">/var</filename> 文件系统有八成
|
||||
(80) 空间被填满时将会给出警告消息。</para>
|
||||
|
||||
<para><option>naflags</option> 参数用于指定不可归类的审计标志;
|
||||
比如说, 无法归类于系统上某一特定用户的事件类。 这可以通过在
|
||||
<filename>audit_user</filename> 配置文件中的设置来改变。</para>
|
||||
</sect3>
|
||||
|
||||
<sect3 id="audit-audituser">
|
||||
<title><filename>audit_user</filename> 文件</title>
|
||||
|
||||
<para><filename>audit_user</filename> 允许管理员将某些事件直接映射到特定用户。
|
||||
这提供了针对所有系统用户的精细控制机制。</para>
|
||||
|
||||
<para>下面是 <filename>audit_user</filename> 文件中的一些默认值:</para>
|
||||
|
||||
<programlisting>root:lo:no
|
||||
audit:fc:no</programlisting>
|
||||
|
||||
<para>注意默认值将审计所有的
|
||||
<command>login</command>/<command>logout</command>
|
||||
事件, 而禁止审计所有其他由
|
||||
<username>root</username> 完成的动作。
|
||||
这一配置也会审计所有文件创建操作,
|
||||
并禁止所有其他由 <username>audit</username>
|
||||
用户完成的操作。 尽管事件审计并不依赖特殊的用户才能正常工作,
|
||||
某些配置, 特别是使用了 <acronym>MAC</acronym> 的环境中,
|
||||
却可能需要这个用户存在。</para>
|
||||
</sect3>
|
||||
</sect2>
|
||||
</sect1>
|
||||
|
||||
<sect1 id="audit-administration">
|
||||
<title>管理事件审计</title>
|
||||
|
||||
<para>来自 <command>auditd</command> 服务的数据,
|
||||
并不能以普通的文本形式进行修改或阅读。 数据以类似 &man.ktrace.1;
|
||||
和 &man.kdump.1 的形式存储, 也就是说, 只能通过
|
||||
<command>praudit</command> 或 <command>auditreduce</command>
|
||||
工具来查看它们。</para>
|
||||
|
||||
<para>所提供的两个工具是为了不同的用途而准备的。
|
||||
例如, <command>praudit</command> 将转存整个事件日志的内容,
|
||||
并保存成普通的文本文件。 要将整个审计日志转存, 可使用:</para>
|
||||
|
||||
<screen>&prompt.root; <userinput>praudit /var/audit/AUDITFILE</userinput></screen>
|
||||
|
||||
<para>这里 <replaceable>AUDITFILE</replaceable> 是希望查看的审计日志。
|
||||
由于审计日志可能包含大量的数据,
|
||||
管理员可能更希望选择某一特定用户的相关事件。
|
||||
要达到这个目的, 可以使用下面的命令,
|
||||
这里我们选择的用户是 <username>trhodes</username>:</para>
|
||||
|
||||
<screen>&prompt.root; <userinput>auditreduce -e trhodes /var/audit/AUDITFILE</userinput></screen>
|
||||
|
||||
<para>这将选择保存在 <replaceable>AUDITFILE</replaceable> 中的所有由
|
||||
<username>trhodes</username> 产生的审计日志。</para>
|
||||
|
||||
<para>还有许多其他选项可以在阅读审计记录时使用。 请参见前述命令的联机书册,
|
||||
以获得进一步的解释。</para>
|
||||
|
||||
<sect2>
|
||||
<title>审计日志文件的轮转</title>
|
||||
|
||||
<para>手工轮转日志文件将给系统造成混乱。 因此, 在
|
||||
&man.newsyslog.conf.5; 中加入一行配置是不起作用的。
|
||||
那么如何让日志轮转呢? 这可以通过给
|
||||
<command>audit</command> 适当的参数来关闭事件审计,
|
||||
并安全地完成轮转操作。 下面的命令将为管理员完成全部所需的操作:</para>
|
||||
|
||||
<screen>&prompt.root; <userinput>audit -n</userinput></screen>
|
||||
|
||||
<warning>
|
||||
<para>如果 <command>auditd</command> 服务程序没有在运行,
|
||||
则前述命令将失败并给出错误提示。</para>
|
||||
</warning>
|
||||
|
||||
<para>在 <filename>/etc/crontab</filename> 加入如下设置,
|
||||
将使 &man.cron.8; 每十二小时将日志轮转一次。</para>
|
||||
|
||||
<programlisting>* */12 * * * root /usr/sbin/audit -n</programlisting>
|
||||
|
||||
<para>这些修改会在您保存 <filename>/etc/crontab</filename> 后生效。</para>
|
||||
</sect2>
|
||||
</sect1>
|
||||
</chapter>
|
16
zh_CN.GB2312/books/handbook/geom/Makefile
Normal file
16
zh_CN.GB2312/books/handbook/geom/Makefile
Normal file
|
@ -0,0 +1,16 @@
|
|||
#
|
||||
# Build the Handbook with just the content from this chapter.
|
||||
#
|
||||
# Original Revision: 1.1
|
||||
# $FreeBSD$
|
||||
#
|
||||
|
||||
CHAPTERS= geom/chapter.sgml
|
||||
|
||||
VPATH= ..
|
||||
|
||||
MASTERDOC= ${.CURDIR}/../${DOC}.${DOCBOOKSUFFIX}
|
||||
|
||||
DOC_PREFIX?= ${.CURDIR}/../../../..
|
||||
|
||||
.include "../Makefile"
|
393
zh_CN.GB2312/books/handbook/geom/chapter.sgml
Normal file
393
zh_CN.GB2312/books/handbook/geom/chapter.sgml
Normal file
|
@ -0,0 +1,393 @@
|
|||
<!--
|
||||
The FreeBSD Documentation Project
|
||||
The FreeBSD Simplified Chinese Project
|
||||
|
||||
Original Revision: 1.7
|
||||
$FreeBSD$
|
||||
|
||||
-->
|
||||
|
||||
<chapter id="GEOM">
|
||||
<chapterinfo>
|
||||
<authorgroup>
|
||||
<author>
|
||||
<firstname>Tom</firstname>
|
||||
<surname>Rhodes</surname>
|
||||
<contrib>原作 </contrib>
|
||||
</author>
|
||||
</authorgroup>
|
||||
</chapterinfo>
|
||||
|
||||
<title>GEOM: 模块化磁盘变换框架</title>
|
||||
|
||||
<sect1 id="GEOM-synopsis">
|
||||
<title>概述</title>
|
||||
|
||||
<indexterm>
|
||||
<primary>GEOM</primary>
|
||||
</indexterm>
|
||||
<indexterm>
|
||||
<primary>GEOM 磁盘框架</primary>
|
||||
<see>GEOM</see>
|
||||
</indexterm>
|
||||
|
||||
<para>本章将介绍以 &os; 新的 GEOM 框架来使用磁盘。
|
||||
这包括了使用这一框架来配置的主要的 <acronym
|
||||
role="Redundant Array of Inexpensive Disks">RAID</acronym>
|
||||
控制工具。 这一仗不会深入讨论 GEOM
|
||||
如何处理或控制 I/O、 其下层的子系统或代码。
|
||||
您可以从 &man.geom.4; 联机手册及其众多 SEE ALSO 参考文献中得到这些信息。
|
||||
这一章也不是对 <acronym>RAID</acronym> 配置的权威介绍,
|
||||
它只介绍由 GEOM 支持的 <acronym>RAID</acronym>
|
||||
级别。</para>
|
||||
|
||||
<para>读完这章, 您将了解:</para>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>通过 GEOM 支持的 <acronym>RAID</acronym> 类型。</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>如何使用基本工具来配置和管理不同的 <acronym>RAID</acronym>
|
||||
级别。</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>如何通过 GEOM 使用镜像、 条带、 加密和挂接在远程的磁盘设备。</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>如何排除挂接在 GEOM 框架上的磁盘设备的问题。</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para>阅读这章之前, 您应:</para>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>理解 &os; 如何处理磁盘设备
|
||||
(<xref linkend="disks">)。</para>
|
||||
<listitem>
|
||||
<para>了解如何配置和安装新的 &os; 内核
|
||||
(<xref linkend="kernelconfig">)。</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</sect1>
|
||||
|
||||
<sect1 id="GEOM-intro">
|
||||
<title>GEOM 介绍</title>
|
||||
|
||||
<para>GEOM 允许访问和控制类 (classes) — 主引导记录、
|
||||
<acronym>BSD</acronym> 标签 (label), 等等 — 通过使用
|
||||
provider, 或在
|
||||
<filename role="directory">/dev</filename> 中的特殊文件。
|
||||
它支持许多软件 <acronym>RAID</acronym> 配置, GEOM 能够向操作系统,
|
||||
以及在其上运行的工具提供透明的访问方式。</para>
|
||||
</sect1>
|
||||
|
||||
<sect1 id="GEOM-striping">
|
||||
<sect1info>
|
||||
<authorgroup>
|
||||
<author>
|
||||
<firstname>Tom</firstname>
|
||||
<surname>Rhodes</surname>
|
||||
<contrib>原作 </contrib>
|
||||
</author>
|
||||
<author>
|
||||
<firstname>Murray</firstname>
|
||||
<surname>Stokely</surname>
|
||||
</author>
|
||||
</authorgroup>
|
||||
</sect1info>
|
||||
|
||||
<title>RAID0 - 条带</title>
|
||||
|
||||
<indexterm>
|
||||
<primary>GEOM</primary>
|
||||
</indexterm>
|
||||
<indexterm>
|
||||
<primary>条带</primary>
|
||||
</indexterm>
|
||||
|
||||
<para>条带是一种将多个磁盘驱动器合并为一个卷的方法。
|
||||
许多情况下, 这是通过硬件控制器来完成的。 GEOM
|
||||
磁盘子系统提供了 <acronym>RAID</acronym>0 的软件支持,
|
||||
它也成为磁盘条带。</para>
|
||||
|
||||
<para>在 <acronym>RAID</acronym>0 系统中, 数据被分为多个块,
|
||||
这些块将分别写入阵列的所有磁盘。 与先前需要等待系统将 256k
|
||||
数据写到一块磁盘上不同, <acronym>RAID</acronym>0 系统,
|
||||
能够同时分别将打碎的 64k 写到四块磁盘上, 从而提供更好的 I/O
|
||||
性能。 这一性能提升还能够通过使用多个磁盘控制器来进一步改进。</para>
|
||||
|
||||
<para>在 <acronym>RAID</acronym>0 条带中的每一个盘的尺寸必须一样,
|
||||
因为 I/O 请求是分散到多个盘上的, 以便让这些盘上的读写并行完成。</para>
|
||||
|
||||
<mediaobject>
|
||||
<imageobject>
|
||||
<imagedata fileref="geom/striping" align="center">
|
||||
</imageobject>
|
||||
|
||||
<textobject>
|
||||
<phrase>磁盘条带图</phrase>
|
||||
</textobject>
|
||||
</mediaobject>
|
||||
|
||||
<procedure>
|
||||
<title>在未格式化的 ATA 磁盘上建立条带</title>
|
||||
|
||||
<step><para>加载 <filename>geom_stripe</filename>
|
||||
模块:</para>
|
||||
|
||||
<screen>&prompt.root; <userinput>kldload geom_stripe.ko</userinput></screen>
|
||||
</step>
|
||||
|
||||
<step><para>确信存在合适的挂接点 (mount point)。 如果这个卷将成为根分区,
|
||||
那么暂时把它挂接到其他位置i, 如 <filename
|
||||
role="directory">/mnt</filename>。</para>
|
||||
|
||||
<screen>&prompt.root; <userinput>mkdir /mnt</userinput></screen>
|
||||
</step>
|
||||
|
||||
<step><para>确定将被做成条带卷的磁盘的设备名,
|
||||
并创建新的条带设备。 举例而言,
|
||||
下面的命令可以把两个未用的、 尚未分区的 <acronym>ATA</acronym> 磁盘:
|
||||
<filename>/dev/ad2</filename> 和
|
||||
<filename>/dev/ad3</filename> 标记为条带卷成员。</para>
|
||||
|
||||
<screen>&prompt.root; <userinput>gstripe label -v st0 /dev/ad2 /dev/ad3</userinput></screen>
|
||||
|
||||
<!--
|
||||
<para>A message should be returned explaining that meta data has
|
||||
been stored on the devices.
|
||||
XXX: What message? Put it inside the screen output above.
|
||||
-->
|
||||
</step>
|
||||
|
||||
<step><para>如果卷将被用于作为根设备来启动系统,
|
||||
还必须在创建文件系统之前执行下面的命令:</para>
|
||||
|
||||
<screen>&prompt.root; <userinput>fdisk -vBI /dev/stripe/st0</userinput></screen>
|
||||
</step>
|
||||
|
||||
<step><para>此外还需要用下面的命令在新卷上创建分区表:</para>
|
||||
|
||||
<screen>&prompt.root; <userinput>bsdlabel -wB /dev/stripe/st0</userinput></screen>
|
||||
|
||||
</step>
|
||||
|
||||
<step><para>上述过程将在
|
||||
<filename role="directory">/dev/stripe</filename>
|
||||
目录中的 <filename>st0</filename> 设备基础上建立两个新设备。
|
||||
这包括 <filename>st0a</filename> 和
|
||||
<filename>st0c</filename>。 现在需要在
|
||||
<filename>st0a</filename> 设备上用下述
|
||||
<command>newfs</command> 命令建立文件系统:</para>
|
||||
|
||||
<screen>&prompt.root; <userinput>newfs -U /dev/stripe/st0a</userinput></screen>
|
||||
|
||||
<para>在屏幕上将滚过一些数字, 整个操作应该能在数秒内完成。
|
||||
现在可以挂接刚刚做好的卷了:</para>
|
||||
</step>
|
||||
</procedure>
|
||||
|
||||
<para>下列命令可以用来手工挂接新创建的条带盘。</para>
|
||||
|
||||
<screen>&prompt.root; <userinput>mount /dev/stripe/st0a /mnt</userinput></screen>
|
||||
|
||||
<para>要在启动过程中自动挂接这个条带上的文件系统,
|
||||
需要把关于卷的信息放到
|
||||
<filename>/etc/fstab</filename> 文件中:</para>
|
||||
|
||||
<screen>&prompt.root; <userinput>echo "/dev/stripe/st0a /mnt ufs rw 2 2" \</userinput>
|
||||
<userinput>>> /etc/fstab</userinput></screen>
|
||||
|
||||
<para>此外, geom 模块也必须在系统初始化过程中自动加载,
|
||||
这可以通过在
|
||||
<filename>/boot/loader.conf</filename> 中进行适当的设置来达到。</para>
|
||||
|
||||
<screen>&prompt.root; <userinput>echo 'geom_stripe_load="YES"' >> /boot/loader.conf</userinput></screen>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="GEOM-mirror">
|
||||
<title>RAID1 - 镜像</title>
|
||||
|
||||
<indexterm>
|
||||
<primary>GEOM</primary>
|
||||
</indexterm>
|
||||
<indexterm>
|
||||
<primary>磁盘镜像</primary>
|
||||
</indexterm>
|
||||
|
||||
<para>镜像是一种许多公司和家庭用户使用的不需中断的备份技术。
|
||||
当存在镜像时, 它的意思是说 磁盘B 简单地复制 磁盘A。
|
||||
或者, 也可能是 磁盘C+D
|
||||
复制 磁盘A+B。 无论磁盘如何配置, 共同的特征,
|
||||
都是磁盘或卷的信息会被复制。 随后, 这些信息可以很容易地恢复原样、
|
||||
备份, 而不需要造成服务或访问的停顿, 甚至其他更安全的地方。</para>
|
||||
|
||||
<para>要开始做这件事, 首先要确保系统中有两个同样大的磁盘驱动器,
|
||||
下面的例子假定使用直接访问方式 (Direct Access, &man.da.4;)
|
||||
<acronym>SCSI</acronym> 的磁盘。</para>
|
||||
|
||||
<para>首先需要把 &os; 安装到第一块磁盘上, 并建立两个分区。
|
||||
第一个分区将成为交换区, 其尺寸应该是两倍的
|
||||
<acronym>RAM</acronym> 尺寸, 而余下的空间,
|
||||
则作为根 (<filename role="directory">/</filename> 文件系统来使用。
|
||||
当然, 也可以为其他挂接点划分不同的分区;
|
||||
但是, 这将使难度提高一个量级,
|
||||
因为您将不得不手工修改 &man.bsdlabel.8; 和 &man.fdisk.8;
|
||||
的设置。</para>
|
||||
|
||||
<para>重新启动系统, 并等待其完全初始化完。
|
||||
当这个过程完成之后, 以 <username>root</username>
|
||||
用户的身份登录。</para>
|
||||
|
||||
<para>创建 <filename>/dev/mirror/gm</filename> 设备,
|
||||
并将其连接到 <filename>/dev/da1</filename>:</para>
|
||||
|
||||
<screen>&prompt.root; <userinput>gmirror label -vnb round-robin gm0 /dev/da1</userinput></screen>
|
||||
|
||||
<note>
|
||||
<para>这个命令将在
|
||||
<filename role="directory">/dev/mirror</filename>
|
||||
目录中创建 <filename>gm0</filename>、 <filename>gm0s1</filename>、
|
||||
<filename>gm0s1a</filename>, 以及 <filename>gm0s1c</filename>
|
||||
设备节点。</para>
|
||||
</note>
|
||||
|
||||
<para>初始化 GEOM, 这将加载
|
||||
<filename>/boot/kernel/geom_mirror.ko</filename> 内核模块:</para>
|
||||
|
||||
<screen>&prompt.root; <userinput>geom load</userinput></screen>
|
||||
|
||||
<para>安装通用的 <command>fdisk</command> 标签和引导区代码到刚刚创建的
|
||||
<filename>gm0</filename> 设备上:</para>
|
||||
|
||||
<screen>&prompt.root; <userinput>fdisk -vBI /dev/mirror/gm0</userinput></screen>
|
||||
|
||||
<para>接下来安装通用的 <command>bsdlabel</command>
|
||||
信息:</para>
|
||||
|
||||
<screen>&prompt.root; <userinput>bsdlabel -wB /dev/mirror/gm0s1</userinput></screen>
|
||||
|
||||
<note>
|
||||
<para>如果存在多个区段 (slice) 或分区 (partition),
|
||||
则需要修改一部分上面命令的参数。
|
||||
它们必须与另一个盘上对应的区段和分区匹配。</para>
|
||||
</note>
|
||||
|
||||
<para>使用 &man.newfs.8; 工具来创建默认的文件系统到
|
||||
<filename>gm0s1a</filename> 设备节点上:</para>
|
||||
|
||||
<screen>&prompt.root; <userinput>newfs -U /dev/mirror/gm0s1a</userinput></screen>
|
||||
|
||||
<para>这将让系统输出很多信息和一系列数字。 不必为此担心,
|
||||
只需看看是否有错误提示就可以了, 如果没问题, 接下来把它挂到
|
||||
<filename role="directory">/mnt</filename> 挂接点上面:</para>
|
||||
|
||||
<screen>&prompt.root <userinput>mount /dev/mirror/gm0s1a /mnt</userinput></screen>
|
||||
|
||||
<para>现在需要把酥藕有引导盘上的数据迁移到新的文件系统上了。
|
||||
下面的例子使用了 &man.dump.8; 和 &man.restore.8;
|
||||
这两个命令; 不过, 用 &man.dd.1; 在这里也可以达到完全一样的目的。
|
||||
我们并不使用 &man.tar.1; 因为它并不覆盖引导区的代码,
|
||||
而那样一定会造成出错的。</para>
|
||||
|
||||
<screen>&prompt.root; <userinput>dump -L -0 -f- / |(cd /mnt && restore -r -v -f-)</userinput></screen>
|
||||
|
||||
<para>这个操作必须在所有文件系统上都作一遍。 您可以将前述命令中的文件系统,
|
||||
改为所希望的文件系统的位置。</para>
|
||||
|
||||
<para>接下来应该编辑复制出来的 <filename>/mnt/etc/fstab</filename>
|
||||
文件, 并删去或注释掉交换分区。 此外应该修改文件系统信息,
|
||||
以便让它们使用新盘。 参考下面的例子:</para>
|
||||
|
||||
<programlisting># Device Mountpoint FStype Options Dump Pass#
|
||||
#/dev/da0s2b none swap sw 0 0
|
||||
/dev/mirror/gm0sa1 / ufs rw 1 1</programlisting>
|
||||
|
||||
<para>接下来需要建一个 <filename>boot.conf</filename> 文件,
|
||||
在当前和新盘的根分区上各放一份。 这个文件将
|
||||
<quote>帮助</quote> 系统的 <acronym>BIOS</acronym>
|
||||
从正确的驱动器上引导:</para>
|
||||
|
||||
<screen>&prompt.root; <userinput>echo "1:da(1,a)/boot/loader" > /boot.config</userinput></screen>
|
||||
|
||||
<screen>&prompt.root; <userinput>echo "1:da(1,a)/boot/loader" > /mnt/boot.config</userinput></screen>
|
||||
|
||||
<note>
|
||||
<para>在所有的分区上都放这些是为了保证系统能够正确引导。
|
||||
如果由于某种原因系统无法从新的根分区读数据,
|
||||
则还有一根救命稻草。</para>
|
||||
</note>
|
||||
|
||||
<para>然后再到
|
||||
<filename>/boot/loader.conf:</filename> 中加入一些设置:</para>
|
||||
|
||||
<screen>&prompt.root; <userinput>echo 'geom_mirror_load="YES"' >> /boot/loader.conf</userinput></screen>
|
||||
|
||||
<para>这将让 &man.loader.8; 在系统初始化过程中自动加载
|
||||
<filename>geom_mirror.ko</filename>。</para>
|
||||
|
||||
<para>最后重新启动系统:</para>
|
||||
|
||||
<screen>&prompt.root; <userinput>shutdown -r now</userinput></screen>
|
||||
|
||||
<para>如果一切顺利, 系统将从
|
||||
<filename>gm0s1a</filename> 设备启动, 并给出 <command>login</command>
|
||||
提示等待用户登录。 如果发生错误, 请查阅接下来的故障排除环节。 我们继续将
|
||||
<filename>da0</filename> 磁盘加入 <filename>gm0</filename>
|
||||
设备:</para>
|
||||
|
||||
<screen>&prompt.root; <userinput>gmirror configure -a gm0</userinput>
|
||||
&prompt.root; <userinput>gmirror insert gm0 /dev/da0</userinput></screen>
|
||||
|
||||
<para>此处 <option>-a</option> 告诉 &man.gmirror.8; 采用自动同步,
|
||||
或换言之: 自动地将磁盘的写操作做镜像处理。 联机手册中详细解释了如何重建,
|
||||
以及替换磁盘, 只不过它用 <filename>data</filename>
|
||||
表示这里的 <filename>gm0</filename>。</para>
|
||||
|
||||
<sect2>
|
||||
<title>故障排除</title>
|
||||
|
||||
<sect3>
|
||||
<title>系统拒绝引导</title>
|
||||
|
||||
<para>如果系统引导时出现类似下面的提示:</para>
|
||||
|
||||
<programlisting>ffs_mountroot: can't find rootvp
|
||||
Root mount failed: 6
|
||||
mountroot></programlisting>
|
||||
|
||||
<para>这种情况应使用电源或复位按钮重启机器。
|
||||
在引导菜单中, 选择第六 (6) 个选项。
|
||||
这将让系统进入 &man.loader.8; 提示符。
|
||||
在此处手工加载内核模块:</para>
|
||||
|
||||
<screen>OK? <userinput>load geom_mirror.ko</userinput>
|
||||
OK? <userinput>boot</userinput></screen>
|
||||
|
||||
<para>如果这样做能解决问题, 则说明由于某种原因模块没有被正确加载。
|
||||
可以通过在内核配置文件中加入:</para>
|
||||
|
||||
<programlisting>options GEOM_MIRROR</programlisting>
|
||||
|
||||
<para>然后重新编译和安装内核来解决这个问题。</para>
|
||||
</sect3>
|
||||
</sect2>
|
||||
</sect1>
|
||||
</chapter>
|
||||
|
||||
<!--
|
||||
Local Variables:
|
||||
mode: sgml
|
||||
sgml-declaration: "../chapter.decl"
|
||||
sgml-indent-data: t
|
||||
sgml-omittag: nil
|
||||
sgml-always-quote-attributes: t
|
||||
sgml-parent-document: ("../book.sgml" "part" "chapter")
|
||||
End:
|
||||
-->
|
Loading…
Reference in a new issue