# 消息 ID：ZFS-8000-K4

## ZFS 意图日志读取失败

|  类型  | 错误              |
| :--: | --------------- |
|  严重性 | 严重              |
|  描述  | 无法读取 ZFS 意图日志设备 |
| 自动响应 | 不会采取自动响应        |
|  影响  | 意图日志无法重放        |

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

由于错误，无法读取 ZFS 意图日志记录。这可能是由于日志设备丢失或损坏，或者池中的某个设备正在经历 I/O 错误。池本身未损坏，但缺少在断电或系统故障前发生的一些池更改。这些更改是应用程序请求同步写入但尚未在池中提交的事务。事务组提交当前每五秒发生一次，因此通常最多丢失五秒内的同步写入。ZFS 本身无法判断丢失的池更改对故障发生时运行的应用程序是否关键，这需要由管理员决定。建议考虑镜像日志设备。首先确定哪个池出现了错误：

```sh
# zpool status -x
  pool: test
 state: FAULTED
status: One or more of the intent logs could not be read.
        Waiting for administrator intervention to fix the faulted pool.
action: Either restore the affected device(s) and run 'zpool online',
        or ignore the intent log records by running 'zpool clear'.
 scrub: none requested
config:

        NAME              STATE     READ WRITE CKSUM
        test              FAULTED      0     0     0  bad intent log
          c3t2d0          ONLINE       0     0     0
        logs              FAULTED      0     0     0  bad intent log
          c5t3d0          UNAVAIL      0     0     0  cannot open
```

有两种方法可以解决此问题。如果从应用程序的角度看，池更改的有效性至关重要，则必须恢复日志设备。确保电源和连接线已连接，并且受影响的设备在线。然后运行 `zpool online`，随后运行 `zpool clear`：

```sh
# zpool online test c5t3d0
# zpool clear test
# zpool status test
  pool: test
 state: ONLINE
 scrub: none requested
config:

        NAME              STATE     READ WRITE CKSUM
        test              ONLINE       0     0     0
          c3t2d0          ONLINE       0     0     0
        logs              ONLINE       0     0     0
          c5t3d0          ONLINE       0     0     0

errors: No known data errors
```

第二种替代操作是忽略无法读取的最近的池变动。为此，运行 `zpool clear`：

```sh
# zpool clear test
# zpool status test
  pool: test
 state: DEGRADED
status: One or more devices could not be opened.  Sufficient replicas exist for
        the pool to continue functioning in a degraded state.
action: Attach the missing device and online it using 'zpool online'.
   see: https://openzfs.github.io/openzfs-docs/msg/ZFS-8000-2Q
 scrub: none requested
config:

        NAME              STATE     READ WRITE CKSUM
        test              DEGRADED     0     0     0
          c3t2d0          ONLINE       0     0     0
        logs              DEGRADED     0     0     0
          c5t3d0          UNAVAIL      0     0     0  cannot open

errors: No known data errors
```

后续的日志记录将不再使用故障的日志设备，而是写入主池。应修复或更换那些发生故障的日志设备。

## 详细信息

消息 ID：`ZFS-8000-K4` 表示日志设备丢失或无法读取。


---

# 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-k4.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.
