[Support] jasonbean - MongoDB


Taddeusz

Recommended Posts

This template can be found at: https://github.com/jason-bean/template-mongodb

 

This is a template for the official MongoDB docker container. This template exposes port 27017 so that remote connections are possible.

 

What is MongoDB?

MongoDB (from "humongous") is a cross-platform document-oriented database. Classified as a NoSQL database, MongoDB eschews the traditional table-based relational database structure in favor of JSON-like documents with dynamic schemas (MongoDB calls the format BSON), making the integration of data in certain types of applications easier and faster. Released under a combination of the GNU Affero General Public License and the Apache License, MongoDB is free and open-source software.

Link to comment
  • 11 months later...
  • 1 month later...
On 10/2/2018 at 9:53 PM, s34nDROID said:

How do I start with --auth  or is it on by default?

 

It's not on by default. You can do it by editing the container, enabling Advanced view, and setting the extra parameters field like so:

 

mongo --auth #

 

  • Like 1
Link to comment
  • 1 year later...

Posting my procedure steps to upgrade mongoDB image from 3.6 to 4.0/4.2 because it was a pain to figure out.  

 

Before you begin it is highly recommended to open a terminal window to your current mongodb instance and run...

mongod --version

Write that version number down somewhere.  Mine was 3.6.14 and corresponds with a docker image tag if this whole process goes tits up and you need to revert.

 

Backup your old mongodb volume

  1. Open a terminal into unRAID
  2. Run the following command assuming you have a cache drive.  If not modify your path to wherever your appdata is stored
    cp -avr /usr/mnt/appdata/mongodb /usr/mnt/appdata/mongodb-bak

     

Mount a new volume to your current MongoDB container:

  1. create a new directory in /usr/mnt/cache/appdata called mongodb-temp
  2. open your containers configuration
  3. click the + to add new path, variable, etc
  4. Fill out the form as follows and click add
    image.png.67f674fa4807d8134383dbad00ccb4f2.png
  5. Save your docker configuration

Dump current mongodb database to temp directory

These next steps assume your mongodb instance is running on the default port and you mounted a volume named temp.

  1. Open a terminal window to your mongodb container
  2. Run the following command
    mongodump -v --host localhost:27017 --out=/temp
  3. The -v flag is for verbose so you should see a bunch of stuff scroll by and when its done it should report successful on the last line printed in the terminal.

Upgrading MongoDB!!!

This next step can be done one of two ways.  The first method is nuke your current container and install brand new.  The second method requires you have the "Enable Reinstall Default" setting set to "Yes" in your Community Application Settings.  This write up will not cover turning that setting on.

 

Upgrade Option 1:

  1. Open the mongodb container menu and choose remove
  2. Un-check "also remove image"
  3. Click Yes and watch it go bye-bye
    a. Delete the contents of your old /appdata/mongodb directory
  4. Go to Community Apps and re-install MongoDB
  5. Remember to add the /temp path to this new container just like in the screen shot above
  6. Skip down to Restoring Mongodb data

Upgrade Option 2: 

This is the one I chose to use because it left my old mongodb instance completely intact

  1. Shutdown your current Mongodb container
  2. With "Enable Reinstall Default" turned on in Community Apps go to your "Installed" apps page
  3. Click the first icon on the MongoDb listing to reinstall from default
  4. Be sure to  CHANGE the NAME and HOST PATH 1 values to create a new duplicate container.  And don't forget to remap the /temp volume so we can do the restore later.  If using custom br0 feel free to use the same IP address since your other container is now dormant
    image.thumb.png.0319898f2609833b81aa867690ea6ad9.png
  5. Click Apply to create the container
  6. Move on to Restoring Mongodb data

Restoring Mongodb data

  1. Open a terminal window into your current running mongodb instance.
  2. Enter the following command
    mongorestore -v --host localhost:27017 /temp
  3. Assuming you mounted the volume named /temp and everything went ok you should see a giant list of stuff scroll by the terminal window.  At the bottom will be a report of successful and failed imports
  4. You can now leave the /temp volume mapped for later use or remove it if you like

 

I created this process for myself last night after attempting to upgrade from 3.6 to 4.2 and running into a pesky "Invalid feature compatibility version" error.  You can read about that here.  I tried all the steps in the mongo documentation but being installed in a docker made things a bit trickier.  I found it easier just to backup, dump, recreate image, and restore my data.  

Edited by sansoo22
Link to comment
  • 1 month later...
On 8/31/2019 at 5:11 AM, sansoo22 said:

Before you begin it is highly recommended to open a terminal window to your current mongodb instance and run...


mongod --version

 

I cannot even do this, the container shuts down almost straight away.

 

Not sure how I can do the demo/restore without the container running.

Link to comment
  • 1 year later...

I have been using this with Rocket chat. but just in the last few days it has stopped working. I keep getting the following re occurring in the logs. 

 

{"t":{"$date":"2020-12-04T11:46:09.052+00:00"},"s":"I", "c":"STORAGE", "id":3856202, "ctx":"IndexBuildsCoordinatorMongod-2","msg":"'voteCommitIndexBuild' command failed.","attr":{"indexBuildUUID":{"uuid":{"$uuid":"7d0cfc2d-1a22-40fd-88fa-bc7740c41fd7"}},"responseStatus":{"operationTime":{"$timestamp":{"t":1607082359,"i":1}},"ok":0.0,"errmsg":"command voteCommitIndexBuild requires authentication","code":13,"codeName":"Unauthorized","$clusterTime":{"clusterTime":{"$timestamp":{"t":1607082359,"i":1}},"signature":{"hash":{"$binary":{"base64":"w16K3Ax9dNrRM28e4KL7aAJD+5Y=","subType":"0"}},"keyId":6861917765322670082}}}}}

 

certain variables change but its the same over and over again. I have tried to delete the docker and image and reinstall but just goes back to the same thing. Rocket chat obviously wont start without it. 

Link to comment

yea if im honest i havent liked mongo at all. i use maria with my nextcloud and have found it rock solid. but ive been using this with rocketchat and its very flakey I had it corrupt on me in my early use. Then it seemed more stable so i deployed if for my use case and now this. im on the most recent build for it. i have left it stopped until the most recent build just to see if that solved my problem but it hasnt. thanks for getting back to me but looks like its a fresh install and hope for the best.  

Link to comment
On 12/6/2020 at 7:58 AM, tazire said:

yea if im honest i havent liked mongo at all. i use maria with my nextcloud and have found it rock solid. but ive been using this with rocketchat and its very flakey I had it corrupt on me in my early use. Then it seemed more stable so i deployed if for my use case and now this. im on the most recent build for it. i have left it stopped until the most recent build just to see if that solved my problem but it hasnt. thanks for getting back to me but looks like its a fresh install and hope for the best.  

I'm getting the same error you are - started this morning for me.   I'm going to try going back a build and see if that helps.   I've tried restoring the appdata mongodb folder from a day ago, and that didn't help.

 

Found this over in the RocketChat thread - It worked for me.  

 

Edited by konaboy
added link
Link to comment
24 minutes ago, konaboy said:

I'm getting the same error you are - started this morning for me.   I'm going to try going back a build and see if that helps.   I've tried restoring the appdata mongodb folder from a day ago, and that didn't help.

 

Found this over in the RocketChat thread - It worked for me.  

 

cheers for the response. I have just started from scratch. Stopped using it completely for now and im looking into alternatives at this point. 

Link to comment
18 minutes ago, tazire said:

cheers for the response. I have just started from scratch. Stopped using it completely for now and im looking into alternatives at this point. 

I'm interested in an alternative too - Nextcloud (which I use for files) has a chat facility, but they don't have a windows app and I don't like chats in a browser.  Let me know if you find a good alternative  I'd appreciate!...

Link to comment
On 12/11/2020 at 6:29 PM, konaboy said:

I'm interested in an alternative too - Nextcloud (which I use for files) has a chat facility, but they don't have a windows app and I don't like chats in a browser.  Let me know if you find a good alternative  I'd appreciate!...

i was looking at mattermost... i had a quick try to get it working but couldnt get it to connect to a database for whatever reason. Didnt spend alot of time with it though. I was thinking about nextcloud but i dont want to use my own nextcloud for my chat. TBH my ideal app would be a self hosted discord server. I really like all the features it has. 

Link to comment
  • 1 month later...

Hi, I just updates to the latest version, all settings to default.

 

image.thumb.png.fd8d378c4f19b06aaa69de7b3c9f94ad.png

 

Now the container does not start anymore. The log shows the message:

 

BadValue: security.keyFile is required when authorization is enabled with replica sets
try 'mongod --help' for more information

 

How can I fix this. thx

Edited by odiby
Link to comment
3 hours ago, odiby said:

Hi, I just updates to the latest version, all settings to default.

 

image.thumb.png.fd8d378c4f19b06aaa69de7b3c9f94ad.png

 

Now the container does not start anymore. The log shows the message:

 


BadValue: security.keyFile is required when authorization is enabled with replica sets
try 'mongod --help' for more information

 

How can I fix this. thx

Having the same problem after update.

Link to comment

Me too Mongod cant start anymore i try reinstall and same.I get error:

 

BadValue: security.keyFile is required when authorization is enabled with replica sets
try 'mongod --help' for more information

Edited by Vesko
Link to comment

OK 😅 even if I would understand what a Replica Set is and why I would need it ... as long as the server does not start, I guess i have no chance to do what ever needs to be done as mentioned here.

 

So for now, I will stick to the version 4.4.3

image.png.d95f159ec41b98dbaf2a071a93bafb8d.png

  • Thanks 1
Link to comment
4 hours ago, odiby said:

OK 😅 even if I would understand what a Replica Set is and why I would need it ... as long as the server does not start, I guess i have no chance to do what ever needs to be done as mentioned here.

 

So for now, I will stick to the version 4.4.3

image.png.d95f159ec41b98dbaf2a071a93bafb8d.png

Thank you for the advice i reinstall with mongo:4.4.3 and now works i will never update if works like this.

Dont see point to update until works normal .Updates brakes things:)

Link to comment
4 hours ago, Vesko said:

Thank you for the advice i reinstall with mongo:4.4.3 and now works i will never update if works like this.

Dont see point to update until works normal .Updates brakes things:)

 

 

Hmm I tried this but didn't work for me. Just got new errors. This seems to be the important part:

{"t":{"$date":"2021-02-18T12:35:47.675-05:00"},"s":"W", "c":"STORAGE", "id":22347, "ctx":"initandlisten","msg":"Failed to start up WiredTiger under any compatibility version. This may be due to an unsupported upgrade or downgrade."}

 

Link to comment

This post/thread...Yall gonna have to skim and read around but they solve your issue; despite that it's about RocketChat. I successfully upgraded to 4.4.4. I do have a error every hour about some time crap but the DB itself works and etc. 🙂

 

https://forums.unraid.net/topic/61337-support-rocketchat/?do=findComment&comment=816403

 

You all WILL HAVE TO READ around to find exact post with info but in this "area" of thread you'll find conversation about the RS junk.

Link to comment

Hey, wondering if anyone can help.  My MongoDB docker might be installed to my cache and I want to ensure the database files are going to the array. I assume I could just create a share that doesn't use the cache then change the storage parameter in my mogod.conf to aim at a folder in that share.  Then I would stop mongodb, move the *.wt files to the new share.  

 

storage:
  dbPath: 
  journal:
    enabled: true

 

 would I just configure

 

storage:
  dbPath: /mnt/user/<databaseshare>/<mongodb>/
  journal:
    enabled: true

 

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.