1

I've got Rocket Chat running on Raspberry Pi 4, on Ubuntu 18.04.4 LTS. The install was done according to the Rocket Chat documentation, using the Snaps method.

After removing many megabytes of files from our chats (purge) I notice the disk space does not get reclaimed on the Raspberry Pi.

I've heard some suggestions of running the mongodb command "compact" but I don't know how to do this with the Snaps install as all of the command line tools (i.e. mongo mongod mongodb) don't seem to be available.

What command can reclaim the disk space and how do I run this command?

Thanks!

nooblag
  • 678
  • 3
  • 23

2 Answers2

3

Thanks to @Joe, this worked for me:

  • sudo rocketchat-server.mongo
  • show dbs (returns the list of databases)
  • use parties (Rocketchat docs state this is the one used for Rocketchat)
  • show collections (lists "collections", of which, rocketchat__trash sounded like the right thing to try and 'compact').

So then,

db.runCommand({ compact: 'rocketchat__trash', force: true });

Or, a nice little loop from @OzzyCzech to compact everything:

db.getCollectionNames().forEach(function (collectionName) {
    print('Compacting: ' + collectionName);
    db.runCommand({ compact: collectionName, force: true });
});
nooblag
  • 678
  • 3
  • 23
1

In order to run compact you will need to connect. You have 2 options for this:

  1. Install the mongo shell on the Pi
    If you followed the documentation and installed the mongodb-org package, this pseudo-package included the mongo shell. All you need to do is ssh to the Pi and execute the shell using the same MONGO_URL and credentials as the rocket chat process.

  2. Configure to mongod instance on the Pi to listen on a public IP so you can connect remotely
    MongoDB only listens on localhost by default, to change this you will need to edit the mongodb.conf file to listen on 0.0.0.0 and restart the mongod process. Then you should be able to connect directly to the mongod from any host on the same network.

Joe
  • 25,000
  • 3
  • 22
  • 44
  • Hi there. Thanks for your suggestions. I installed using `sudo snap install rocketchat-server`. The documentation (https://docs.rocket.chat/installation/manual-installation/ubuntu/snaps) makes no mention of mongodb-org package, but if I install that, how do I connect, and what credentials do I use to connect? I have no idea what they are... – nooblag Jun 16 '20 at 12:09
  • Oh, you used the snap installation method. That should installed mongodb-org for you. See https://docs.rocket.chat/guides/administrator-guides/restoring-an-admin, which discusses how to connect to the MongoDB to reset admin credentials. – Joe Jun 16 '20 at 21:10
  • Okay, getting closer. I'm able to connect to MongoDB using `sudo rocketchat-server.mongo`. Still not any closer on what command to run. `db.runCommand( { compact : 'rocketchat' } )` didn't work. – nooblag Jun 21 '20 at 12:25
  • `didn't work` meaning what? Specific error messages are always helpful. – Joe Jun 22 '20 at 16:08
  • Yes, apologies. `db.runCommand( { compact : 'rocketchat', force : true } )` returns: ```{ "ok" : 0, "errmsg" : "collection does not exist", "code" : 26, "codeName" : "NamespaceNotFound" } – nooblag Jun 23 '20 at 18:19
  • 2
    That's improvement, at least you are connected now. Try running `show dbs`, and for each database lists, switch to it with `use databasename` and run `show collections`. When you find the one with the `rocketchat` collection, run compact there. – Joe Jun 24 '20 at 00:35