I have Rocket.Chat running on Ubuntu 18.04.4 LTS through Snap. I would like to move the data (but not the entire snap) to another hard drive. So far this is what I have tried:
Backup Rocket.Chat
sudo service snap.rocketchat-server.rocketchat-server stop
sudo snap run rocketchat-server.backupdb
sudo service snap.rocketchat-server.rocketchat-server start
Allow removable media
sudo snap connect rocketchat-server:removable-media
Stop Rocket.Chat and mongodb
sudo service snap.rocketchat-server.rocketchat-server stop
sudo service snap.rocketchat-server.rocketchat-mongo stop
Create directory on external drive to hold Rocket.Chat data
sudo mkdir /mnt/mountpoint/rocketchat-server-data
Move common directory from Snap directory to the external drive
sudo mv /var/snap/rocketchat-server/common /mnt/mountpoint/rocketchat-server-data/common
Replace Snap common directory with sym link to it's new location on the external drive
sudo ln -s /mnt/mountpoint/rocketchat-server-data/common /var/snap/rocketchat-server/common
Start mongodb and Rocket.Chat
sudo service snap.rocketchat-server.rocketchat-mongo start
sudo service snap.rocketchat-server.rocketchat-server start
However, upon starting everything, RocketChat is unable to connect to 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
In response, I attempted changing permissions of the common
directory (only temporarily) with:
sudo chmod -R 777 /mnt/mountpoint/rocketchat-server-data/common
I then restarted everything but received the same error message. Does anyone have any ideas?
Thanks!
Update 1: (forgot to attach mongod status)
Running sudo service snap.rocketchat-server.rocketchat-mongo status
Produces:
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.
Update 2
sudo journalctl -u snap.rocketchat-server.rocketchat-mongo
produces the following:
-- 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>
Update 3
During more research I found this post: https://forums.rocket.chat/t/changing-mongo-data-directory/1458/3 which seems to indicate that Snap will not allow outside directories to be used even if they are sym links. I tried overriding this through AppArmor adding the line:
alias /var/snap/rocketchat-server/common -> /mnt/mountpoint/rocketchat-server-data/common,
to /etc/apparmor.d/tunables/alias
and restarting AppArmor and Mongo. This did not work.
0 Answers