将 Rocket.Chat 数据移动到不同的硬盘

将 Rocket.Chat 数据移动到不同的硬盘

我通过 Snap 在 Ubuntu 18.04.4 LTS 上运行 Rocket.Chat。我想将数据(但不是整个 snap)移动到另一个硬盘上。到目前为止,我尝试过以下方法:

备份 Rocket.Chat

sudo service snap.rocketchat-server.rocketchat-server stop
sudo snap run rocketchat-server.backupdb
sudo service snap.rocketchat-server.rocketchat-server start

允许可移动媒体

sudo snap connect rocketchat-server:removable-media

停止 Rocket.Chat 和 mongodb

sudo service snap.rocketchat-server.rocketchat-server stop
sudo service snap.rocketchat-server.rocketchat-mongo stop

在外部驱动器上创建目录以保存 Rocket.Chat 数据

sudo mkdir /mnt/mountpoint/rocketchat-server-data

将公共目录从 Snap 目录移动到外部驱动器

sudo mv /var/snap/rocketchat-server/common /mnt/mountpoint/rocketchat-server-data/common

将 Snap 公共目录替换为指向外部驱动器上新位置的符号链接

sudo ln -s /mnt/mountpoint/rocketchat-server-data/common /var/snap/rocketchat-server/common

启动 mongodb 和 Rocket.Chat

sudo service snap.rocketchat-server.rocketchat-mongo start
sudo service snap.rocketchat-server.rocketchat-server start

然而,启动一切后,RocketChat 无法连接到 mongodb:

May 07 15:28:16 hostname rocketchat-server.rocketchat-server[4281]: Was unable to connect to Mongo.  Please make sure Mongo has started successfully: sudo systemctl status snap.rocketchat-server.rocketchat-mongo to view logs: sudo journalctl -u snap.rocketchat-server.rocketchat-mongo
May 07 15:28:16 hostname systemd[1]: snap.rocketchat-server.rocketchat-server.service: Main process exited, code=exited, status=1/FAILURE
May 07 15:28:16 hostname systemd[1]: snap.rocketchat-server.rocketchat-server.service: Failed with result 'exit-code'.
May 07 15:28:17 hostname systemd[1]: snap.rocketchat-server.rocketchat-server.service: Service hold-off time over, scheduling restart.
May 07 15:28:17 hostname systemd[1]: snap.rocketchat-server.rocketchat-server.service: Scheduled restart job, restart counter is at 7.
May 07 15:28:17 hostname systemd[1]: Stopped Service for snap application rocketchat-server.rocketchat-server.
May 07 15:28:17 hostname systemd[1]: Started Service for snap application rocketchat-server.rocketchat-server.
May 07 15:28:17 hostname rocketchat-server.rocketchat-server[4518]: Mongo is not available, can't start. Waiting 10 seconds and trying again

作为回应,我尝试使用以下命令更改common目录的权限(仅暂时):

sudo chmod -R 777 /mnt/mountpoint/rocketchat-server-data/common

然后我重新启动了所有程序,但仍然收到相同的错误消息。有人知道吗?

谢谢!

更新 1:(忘记附加 mongod 状态)

跑步sudo service snap.rocketchat-server.rocketchat-mongo status

生成:

snap.rocketchat-server.rocketchat-mongo.service - Service for snap application rocketchat-server.rocketchat-mongo
   Loaded: loaded (/etc/systemd/system/snap.rocketchat-server.rocketchat-mongo.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Thu 2020-05-07 16:50:53 EDT; 1s ago
  Process: 16485 ExecStart=/usr/bin/snap run rocketchat-server.rocketchat-mongo (code=exited, status=1/FAILURE)
 Main PID: 16485 (code=exited, status=1/FAILURE)

May 07 16:50:53 hostname systemd[1]: snap.rocketchat-server.rocketchat-mongo.service: Service hold-off time over, scheduling restart.
May 07 16:50:53 hostname systemd[1]: snap.rocketchat-server.rocketchat-mongo.service: Scheduled restart job, restart counter is at 5.
May 07 16:50:53 hostname systemd[1]: Stopped Service for snap application rocketchat-server.rocketchat-mongo.
May 07 16:50:53 hostname systemd[1]: snap.rocketchat-server.rocketchat-mongo.service: Start request repeated too quickly.
May 07 16:50:53 hostname systemd[1]: snap.rocketchat-server.rocketchat-mongo.service: Failed with result 'exit-code'.
May 07 16:50:53 hostname systemd[1]: Failed to start Service for snap application rocketchat-server.rocketchat-mongo.

更新 2

sudo journalctl -u snap.rocketchat-server.rocketchat-mongo产生以下内容:

-- Logs begin at Thu 2020-03-19 14:41:33 EDT, end at Thu 2020-05-07 17:07:33 EDT. --
Apr 27 10:52:04 hostname systemd[1]: Started Service for snap application rocketchat-server.rocketchat-mongo.
Apr 27 10:52:07 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:07.797-0400 I CONTROL  [initandlisten] MongoDB starting : pid=5004 port=27017 dbpath=/var/snap/rocketchat-server/common 64-bit 
Apr 27 10:52:07 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:07.797-0400 I CONTROL  [initandlisten] db version v3.6.14
Apr 27 10:52:07 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:07.797-0400 I CONTROL  [initandlisten] git version: cbef87692475857c7ee6e764c8f5104b39c342a1
Apr 27 10:52:07 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:07.797-0400 I CONTROL  [initandlisten] allocator: tcmalloc
Apr 27 10:52:07 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:07.797-0400 I CONTROL  [initandlisten] modules: none
Apr 27 10:52:07 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:07.797-0400 I CONTROL  [initandlisten] build environment:
Apr 27 10:52:07 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:07.797-0400 I CONTROL  [initandlisten]     distarch: x86_64
Apr 27 10:52:07 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:07.797-0400 I CONTROL  [initandlisten]     target_arch: x86_64
Apr 27 10:52:07 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:07.797-0400 I CONTROL  [initandlisten] options: { net: { bindIp: "127.0.0.1" }, processManagement: { pidFilePath: "/var/snap/ro
Apr 27 10:52:07 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:07.798-0400 I STORAGE  [initandlisten]
Apr 27 10:52:07 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:07.798-0400 I STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage
Apr 27 10:52:07 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:07.798-0400 I STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem
Apr 27 10:52:07 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:07.798-0400 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=3422M,session_max=20000,eviction=(threads_min=
Apr 27 10:52:08 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:08.916-0400 I STORAGE  [initandlisten] WiredTiger message [1587999128:916340][5004:0x7faa065a4a40], txn-recover: Set global rec
Apr 27 10:52:09 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:09.081-0400 W STORAGE  [initandlisten] Detected configuration for non-active storage engine mmapv1 when current storage engine 
Apr 27 10:52:09 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:09.081-0400 I CONTROL  [initandlisten]
Apr 27 10:52:09 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:09.081-0400 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
Apr 27 10:52:09 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:09.081-0400 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
Apr 27 10:52:09 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:09.081-0400 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
Apr 27 10:52:09 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:09.081-0400 I CONTROL  [initandlisten]
Apr 27 10:52:09 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:09.242-0400 I STORAGE  [initandlisten] createCollection: local.startup_log with no UUID.
Apr 27 10:52:09 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:09.298-0400 W FTDC     [initandlisten] Error getting directory iterator '/sys/block': Permission denied
Apr 27 10:52:09 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:09.298-0400 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory '/var/snap/rocketchat-serv
Apr 27 10:52:09 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:09.299-0400 I STORAGE  [initandlisten] createCollection: local.me with no UUID.
Apr 27 10:52:09 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:09.352-0400 I STORAGE  [initandlisten] createCollection: local.replset.minvalid with no UUID.
Apr 27 10:52:09 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:09.389-0400 I STORAGE  [initandlisten] createCollection: local.replset.election with no UUID.
Apr 27 10:52:09 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:09.431-0400 I REPL     [initandlisten] Did not find local initialized voted for document at startup.
Apr 27 10:52:09 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:09.432-0400 I REPL     [initandlisten] Did not find local Rollback ID document at startup. Creating one.
Apr 27 10:52:09 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:09.432-0400 I STORAGE  [initandlisten] createCollection: local.system.rollback.id with no UUID.
Apr 27 10:52:09 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:09.486-0400 I REPL     [initandlisten] Initialized the rollback ID to 1
Apr 27 10:52:09 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:09.487-0400 I REPL     [initandlisten] Did not find local replica set configuration document at startup;  NoMatchingDocument: D
Apr 27 10:52:09 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:09.488-0400 I NETWORK  [initandlisten] waiting for connections on port 27017
Apr 27 10:52:09 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:09.488-0400 I CONTROL  [LogicalSessionCacheReap] Sessions collection is not set up; waiting until next sessions reap interval: 
Apr 27 10:52:15 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:15.393-0400 I NETWORK  [listener] connection accepted from 127.0.0.1:42776 #1 (1 connection now open)
Apr 27 10:52:15 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:15.416-0400 I NETWORK  [conn1] received client metadata from 127.0.0.1:42776 conn1: { application: { name: "MongoDB Shell" }, d
Apr 27 10:52:15 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:15.435-0400 I REPL     [conn1] replSetInitiate admin command received from client
Apr 27 10:52:15 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:15.499-0400 I REPL     [conn1] replSetInitiate config object with 1 members parses ok
Apr 27 10:52:15 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:15.499-0400 I REPL     [conn1] ******
Apr 27 10:52:15 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:15.499-0400 I REPL     [conn1] creating replication oplog of size: 4367MB...
Apr 27 10:52:15 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:15.500-0400 I STORAGE  [conn1] createCollection: local.oplog.rs with no UUID.
Apr 27 10:52:15 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:15.516-0400 I STORAGE  [conn1] Starting WiredTigerRecordStoreThread local.oplog.rs
Apr 27 10:52:15 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:15.517-0400 I STORAGE  [conn1] The size storer reports that the oplog contains 0 records totaling to 0 bytes
Apr 27 10:52:15 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:15.517-0400 I STORAGE  [conn1] Scanning the oplog to determine where to place markers for truncation
Apr 27 10:52:15 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:15.690-0400 I REPL     [conn1] ******
Apr 27 10:52:15 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:15.691-0400 I STORAGE  [conn1] createCollection: local.system.replset with no UUID.
Apr 27 10:52:15 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:15.745-0400 I COMMAND  [conn1] Assigning UUID <UUID here> to collection local.system.rollback.id
Apr 27 10:52:15 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:15.745-0400 I COMMAND  [conn1] Assigning UUID <UUID here> to collection local.system.replset
Apr 27 10:52:15 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:15.745-0400 I COMMAND  [conn1] Assigning UUID <UUID here> to collection local.me
Apr 27 10:52:15 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:15.746-0400 I COMMAND  [conn1] Assigning UUID <UUID here> to collection local.startup_log
Apr 27 10:52:15 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:15.746-0400 I COMMAND  [conn1] Assigning UUID <UUID here> to collection local.replset.minvalid
Apr 27 10:52:15 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:15.746-0400 I COMMAND  [conn1] Assigning UUID <UUID here> to collection local.oplog.rs
Apr 27 10:52:15 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:15.746-0400 I COMMAND  [conn1] Assigning UUID <UUID here> to collection local.replset.election
Apr 27 10:52:15 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:15.746-0400 I STORAGE  [conn1] createCollection: admin.system.version with provided UUID: <UUID here>

更新 3

在进一步研究之后,我发现了这篇文章:https://forums.rocket.chat/t/changing-mongo-data-directory/1458/3这似乎表明 Snap 不允许使用外部目录,即使它们是符号链接。我尝试通过 AppArmor 添加以下行来覆盖此设置:

alias /var/snap/rocketchat-server/common -> /mnt/mountpoint/rocketchat-server-data/common,

/etc/apparmor.d/tunables/alias重新启动 AppArmor 和 Mongo。这不起作用。

相关内容