mongod启动后,挂载zfs:如何设置启动顺序?

分享于 

2分钟阅读

互联网

  繁體

问题:

我在Ubuntu 18.04.3上,并使用/etc/systemd/system/multi-user中配置,在启动时通过mongo-data正确安装zfs卷。


[Unit]


Description=ZFS startup target



[Install]


WantedBy=multi-user.target



问题是这种情况在mongod服务启动后发生,从而使mongod失败。


[Unit]


Description=MongoDB Database Server


Documentation=https://docs.mongodb.org/manual


After=network.target



[Service]


User=root


Group=root


EnvironmentFile=-/etc/default/mongod


ExecStart=/usr/bin/mongod --config /etc/mongod.conf


PIDFile=/var/run/mongodb/mongod.pid


# file size


LimitFSIZE=infinity


# cpu time


LimitCPU=infinity


# virtual memory size


LimitAS=infinity


# open files


LimitNOFILE=64000


# processes/threads


LimitNPROC=64000


# locked memory


LimitMEMLOCK=infinity


# total threads (user+kernel)


TasksMax=infinity


TasksAccounting=false


Restart=always


# Recommended limits for for mongod as specified in


# http://docs.mongodb.org/manual/reference/ulimit/#recommended-settings



[Install]


WantedBy=multi-user.target




答案1:

你需要使用RequiresMountsFor;


man systemd.directives



例如,该选项类似于RequiresMountsFor = [mountpoint]


RequiresMountsFor=/zfsmount





STA  BOO  SET  引导  mongo  mongod