# 消息 ID：ZFS-8000-9P

## 复制配置中的设备故障

|  类型  | 错误                                                  |
| :--: | --------------------------------------------------- |
|  严重性 | 次要                                                  |
|  描述  | 在复制配置中，某设备出现了无法校正的错误。                               |
| 自动响应 | ZFS 已尝试修复受影响的数据。                                    |
|  影响  | 系统不受影响，但这些错误可能表明后续会发生故障。后续的错误可能会导致 ZFS 自动将该设备标记为故障。 |

## 建议系统管理员采取的操作

运行 `zpool status -x` 确定哪个池出现了错误：

```sh
# zpool status
  pool: test
 state: ONLINE
status: One or more devices has experienced an unrecoverable error.  An
        attempt was made to correct the error.  Applications are unaffected.
action: Determine if the device needs to be replaced, and clear the errors
        using 'zpool online' or replace the device with 'zpool replace'.
   see: https://openzfs.github.io/openzfs-docs/msg/ZFS-8000-9P
 scrub: none requested
config:

        NAME                  STATE     READ WRITE CKSUM
        test                  ONLINE       0     0     0
          mirror              ONLINE       0     0     0
            c0t0d0            ONLINE       0     0     2
            c0t0d1            ONLINE       0     0     0

errors: No known data errors
```

找到 READ、WRITE 或 CKSUM 的错误计数不为零的设备。这表明该设备经历了读 I/O 错误、写 I/O 错误或校验和验证错误。由于该设备属于镜像或 RAID-Z 设备的一部分，ZFS 能够从错误中恢复，并随后修复受损的数据。

如果这些错误在一段时间内持续出现，ZFS 可能会判定该设备存在故障并将其标记为故障。不过，这些错误计数未必表示该设备不可用。这取决于错误产生的原因，而系统管理员可以在任何 ZFS 诊断之前就确定这一点。例如，以下情况都会产生错误，但并不表示设备可能发生故障：

* 一个网络附加设备曾经失去连接，但现在已经恢复
* 一个设备发生了位翻转，这是在长时间运行中预期会发生的事件
* 系统管理员意外使用其他程序覆盖写入了磁盘的一部分

在这些情况下，错误的存在并不表示该设备将来可能发生故障，因此不需要更换设备。如果是这种情况，应当使用 `zpool clear` 清除设备错误：

```sh
# zpool clear test c0t0d0
```

另一方面，错误也很可能表明设备已经发生故障或即将发生故障。如果某个设备在系统中已正确连接并正常工作，但仍然持续出现 I/O 错误，则很可能需要更换该设备。系统管理员应检查系统日志，查看是否存在任何可能表明硬件故障的驱动程序消息。如果确定需要更换设备，则应使用 `zpool replace` 命令：

```sh
# zpool replace test c0t0d0 c0t0d2
```

这将把新设备附加到池中，并开始向其重新同步数据。待重新同步过程完成，旧设备将自动从池中移除，此时可以安全地将旧设备从系统中移除。如果设备需要原位更换（因为没有可用的备用设备），则可以移除原设备并用新设备替换，此时可以使用另一种形式的 `zpool replace`：

```sh
# zpool replace test c0t0d0
```

这假设原先位于“c0t0d0”的设备已经被替换为在相同路径下的新设备，并会据此进行替换。

可以通过使用 `zpool status -x` 命令来监控重新同步操作的进度：

```sh
# zpool status -x
  pool: test
 state: DEGRADED
status: One or more devices is currently being replaced.  The pool may not be
        providing the necessary level of replication.
action: Wait for the resilvering operation to complete
 scrub: resilver in progress, 0.14% done, 0h0m to go
config:

        NAME                  STATE     READ WRITE CKSUM
        test                  ONLINE       0     0     0
          mirror              ONLINE       0     0     0
            replacing         ONLINE       0     0     0
              c0t0d0          ONLINE       0     0     3
              c0t0d2          ONLINE       0     0     0  58.5K resilvered
            c0t0d1            ONLINE       0     0     0

errors: No known data errors
```

## 详细信息

消息 ID：`ZFS-8000-9P` 表示某个设备的错误数量已经超过系统允许的可接受上限。有关更多信息，请参见文档 [203768](http://web.archive.org/web/20090409151209/http://sunsolve.sun.com/search/document.do?assetkey=1-61-203768-1\&searchclause=203768/)。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://book.bsdcn.org/zfs/zfs-xiao-xi/zfs-8000-9p.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
