ZFS数据集在重新启动后消失


13


我已经在Centos 7中安装了ZFS(0.6.5),并且还创建了一个zpool,除了我的数据集在重新启动后消失之外,其他所有功能都可以正常工作。
我一直在尝试借助各种在线资源和博客来调试此问题,但无法获得理想的结果。
重新启动后,当我发出zfs list命令时,我得到“没有可用的数据集”,并zpool list给出“没有可用的池” 在进行了很多在线研究之后,我可以通过使用zpool import -c cachefile手动导入缓存文件来使其工作,但是我仍然必须在重新启动之前运行zpool set cachefile = / etc / zfs / zpool.cache池,以便稍后在重新启动后将其导入。

这是什么systemctl status zfs-import-cache 看起来像,

zfs-import-cache.service - Import ZFS pools by cache file Loaded: loaded (/usr/lib/systemd/system/zfs-import-cache.service; static) Active: inactive (dead)

cat /etc/sysconfig/zfs

# ZoL userland configuration.

# Run `zfs mount -a` during system start?
ZFS_MOUNT='yes'

# Run `zfs unmount -a` during system stop?
ZFS_UNMOUNT='yes'

# Run `zfs share -a` during system start?
# nb: The shareiscsi, sharenfs, and sharesmb dataset properties.
ZFS_SHARE='yes'

# Run `zfs unshare -a` during system stop?
ZFS_UNSHARE='yes'

# Specify specific path(s) to look for device nodes and/or links for the
# pool import(s). See zpool(8) for more information about this variable.
# It supersedes the old USE_DISK_BY_ID which indicated that it would only
# try '/dev/disk/by-id'.
# The old variable will still work in the code, but is deprecated.
#ZPOOL_IMPORT_PATH="/dev/disk/by-vdev:/dev/disk/by-id"

# Should the datasets be mounted verbosely?
# A mount counter will be used when mounting if set to 'yes'.
VERBOSE_MOUNT='no'

# Should we allow overlay mounts?
# This is standard in Linux, but not ZFS which comes from Solaris where this
# is not allowed).
DO_OVERLAY_MOUNTS='no'

# Any additional option to the 'zfs mount' command line?
# Include '-o' for each option wanted.
MOUNT_EXTRA_OPTIONS=""

# Build kernel modules with the --enable-debug switch?
# Only applicable for Debian GNU/Linux {dkms,initramfs}.
ZFS_DKMS_ENABLE_DEBUG='no'

# Build kernel modules with the --enable-debug-dmu-tx switch?
# Only applicable for Debian GNU/Linux {dkms,initramfs}.
ZFS_DKMS_ENABLE_DEBUG_DMU_TX='no'

# Keep debugging symbols in kernel modules?
# Only applicable for Debian GNU/Linux {dkms,initramfs}.
ZFS_DKMS_DISABLE_STRIP='no'

# Wait for this many seconds in the initrd pre_mountroot?
# This delays startup and should be '0' on most systems.
# Only applicable for Debian GNU/Linux {dkms,initramfs}.
ZFS_INITRD_PRE_MOUNTROOT_SLEEP='0'

# Wait for this many seconds in the initrd mountroot?
# This delays startup and should be '0' on most systems. This might help on
# systems which have their ZFS root on a USB disk that takes just a little
# longer to be available
# Only applicable for Debian GNU/Linux {dkms,initramfs}.
ZFS_INITRD_POST_MODPROBE_SLEEP='0'

# List of additional datasets to mount after the root dataset is mounted?
#
# The init script will use the mountpoint specified in the 'mountpoint'
# property value in the dataset to determine where it should be mounted.
#
# This is a space separated list, and will be mounted in the order specified,
# so if one filesystem depends on a previous mountpoint, make sure to put
# them in the right order.
#
# It is not necessary to add filesystems below the root fs here. It is
# taken care of by the initrd script automatically. These are only for
# additional filesystems needed. Such as /opt, /usr/local which is not
# located under the root fs.
# Example: If root FS is 'rpool/ROOT/rootfs', this would make sense.
#ZFS_INITRD_ADDITIONAL_DATASETS="rpool/ROOT/usr rpool/ROOT/var"

# List of pools that should NOT be imported at boot?
# This is a space separated list.
#ZFS_POOL_EXCEPTIONS="test2"

# Optional arguments for the ZFS Event Daemon (ZED).
# See zed(8) for more information on available options.
#ZED_ARGS="-M"

我不确定这是否是已知问题,如果可以,是否有任何解决方法?也许是重新启动后保存我的数据集的一种简便方法,并且最好没有缓存文件的开销。


zpool status -v和zpool import表示什么?
ostendali

嗨, zpool status -v zpool status -v no pools available而且,zpool import使我这个pool: zfsPool id: 10064980395446559551 state: ONLINE action: The pool can be imported using its name or numeric identifier. config: zfsPool ONLINE sda4 ONLINE
毗湿奴奈尔

zfs import是我可以通过使用set cachefile命令最初设置缓存文件来使其工作的方式
Vishnu Nair

您错过了/etc/init/zpool-import.conf,是否也可以发布该文件的内容?
ostendali

1
是否启用了ZFS目标?systemctl status zfs.target
迈克尔·汉普顿

Answers:


6

请确保启用zfs服务(目标)。这就是在启动/关闭时处理池导入/导出的内容。

zfs.target loaded active active ZFS startup target

您永远不必为此苦苦挣扎。如果有机会,请在您的zfs发行版上运行更新,因为我知道启动服务在最近的几个发行版中有所改进:

[root@zfs2 ~]# rpm -qi zfs
Name        : zfs
Version     : 0.6.5.2
Release     : 1.el7.centos

嗨,我也测试了0.6.5.3,它恰好是我相信的最新版本,但仍然面临这个问题,对于.6.5.3,我modprobe zfs每次重新启动时都必须运行以加载模块。顺便说一句,没有启用目标,请检查上面评论中的输出(回复迈克尔)。我可以设置一个吗?谢谢。
Vishnu Nair 2015年

您需要做的大概是:systemctl enable zfs.target
ewwhite

5

好的,因此该池在那里,这意味着问题出在zfs.cache上,它不是持久性的,这就是为什么在重启时会丢失其配置。我建议要做的是运行:

      zpool import zfsPool 
      zpool list 

并检查是否可用。重新启动服务器,看看它是否回来了,如果没有,请执行相同的步骤并运行:

      zpool scrub

只是为了确保您的泳池等一切都好

请张贴以下内容:

      /etc/default/zfs.conf
      /etc/init/zpool-import.conf

或者,如果您正在寻找解决此问题的方法,则可以将其设置如下。

将值从1更改为0:

    /etc/init/zpool-import.conf

并将以下内容添加到您的/etc/rc.local中:

    zfs mount -a

这样就可以了。


zfs import zfsPool按照预期的方式运行了该程序,然后将其导入了我的池,然后我重新启动了程序,zfs list这给了我no datasets。我再次重复了步骤并运行了zfs scrub,但没有任何输出,现在又重新启动了一次,但仍然没有保留数据集
Vishnu Nair 2015年

如果您没有看到我的请求,我将再次发布“您还可以发布/ etc / default / zfs中的内容吗?”
ostendali

4

我还遇到了重启后zfs消失的问题。运行CentOS 7.3和ZFS 0.6.5.9重新导入仅在下次重启之前将其恢复(zpool import zfspool)。

这是对我有用的命令(以使其在重新启动后仍然存在):

systemctl preset zfs-import-cache zfs-import-scan zfs-mount zfs-share zfs-zed zfs.target

(在https://github.com/zfsonlinux/zfs/wiki/RHEL-%26-CentOS上找到它 )


By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.