在 Arch Linux 上将 MongoDB 作为服务运行

在 Arch Linux 上将 MongoDB 作为服务运行

我正在尝试让 mongoDB 在 Arch 下运行。
但是,我只能以 root 身份启动它或使用systemctl默认路径。

我想做的是更改默认数据路径

/data/db

/home/manuel/ExtDrive/Data/mongodb

并使用 运行它systemctl

正如 ExtDrive 所示,这是通过 SATA(而非 USB)连接的 ext4 格式驱动器。

一旦我更改 mongoconfig 中的路径,服务就会开始失败:

mongodb.service - High-performance, schema-free document-oriented database
   Loaded: loaded (/usr/lib/systemd/system/mongodb.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Fri 2019-01-11 19:45:56 CET; 1s ago
  Process: 29468 ExecStart=/usr/bin/mongod --quiet --config /etc/mongodb.conf (code=exited, status=100)
 Main PID: 29468 (code=exited, status=100)

Jan 11 19:45:56 Rechner mongod[29468]: 2019-01-11T19:45:56.311+0100 I CONTROL  [initandlisten]     distarch: x86_64
Jan 11 19:45:56 Rechner mongod[29468]: 2019-01-11T19:45:56.311+0100 I CONTROL  [initandlisten]     target_arch: x86_64
Jan 11 19:45:56 Rechner mongod[29468]: 2019-01-11T19:45:56.311+0100 I CONTROL  [initandlisten] options: { config: "/etc/mongodb.conf", net: { bindIp: "127.0.0.1", port: 27017 }, storage: { dbPath: "/home/manuel/ExtDrive/Data/mongodb/", jo>
Jan 11 19:45:56 Rechner mongod[29468]: 2019-01-11T19:45:56.312+0100 I STORAGE  [initandlisten] exception in initAndListen: Location28596: Unable to determine status of lock file in the data directory /home/manuel/ExtDrive/Data/mongodb/: b>
Jan 11 19:45:56 Rechner mongod[29468]: 2019-01-11T19:45:56.312+0100 I NETWORK  [initandlisten] shutdown: going to close listening sockets...
Jan 11 19:45:56 Rechner mongod[29468]: 2019-01-11T19:45:56.312+0100 I NETWORK  [initandlisten] removing socket file: /tmp/mongodb-27017.sock
Jan 11 19:45:56 Rechner mongod[29468]: 2019-01-11T19:45:56.312+0100 I CONTROL  [initandlisten] now exiting
Jan 11 19:45:56 Rechner mongod[29468]: 2019-01-11T19:45:56.312+0100 I CONTROL  [initandlisten] shutting down with code:100
Jan 11 19:45:56 Rechner systemd[1]: mongodb.service: Main process exited, code=exited, status=100/n/a
Jan 11 19:45:56 Rechner systemd[1]: mongodb.service: Failed with result 'exit-code'.

该目录的权限是:

drwxr-xr-x 4 mongodb daemon 4.0K Jan 11 19:37 mongodb

这是我的 mongo 配置:

storage:

  dbPath: "/home/manuel/ExtDrive/Data/mongodb/"

  journal:

    enabled: true

net:

  port: 27017

  bindIp: 127.0.0.1

为什么它可以在标准路径下完美运行,但一旦指定替代路径就停止工作?

相关内容