Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using "replSet" in MONGO_CONFIG_OPTIONS #88

Closed
ohardy opened this issue Aug 2, 2017 · 9 comments
Closed

Using "replSet" in MONGO_CONFIG_OPTIONS #88

ohardy opened this issue Aug 2, 2017 · 9 comments

Comments

@ohardy
Copy link

@ohardy ohardy commented Aug 2, 2017

If i export MONGO_CONFIG_OPTIONS with :

export MONGO_CONFIG_OPTIONS=" --auth --replSet example "

And i create a new mongo database with :

dokku mongo:create test

It's just return just after the first echo in functions.sh L54.

dokku mongo:connect test

give me :

connecting to: mongodb://127.0.0.1:27017/test
MongoDB server version: 3.4.6
2017-08-02T12:21:27.542+0000 E QUERY    [thread1] Error: Authentication failed. :
DB.prototype._authOrThrow@src/mongo/shell/db.js:1461:20
@(auth):6:1
@(auth):1:2
exception: login failed

If i try manually to run the docker command got with trace, i get :

2017-08-02T12:15:42.339+0000 E QUERY    [thread1] Error: couldn't add user: not master :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype.createUser@src/mongo/shell/db.js:1292:15
@(shell):1:1
bye
@josegonzalez
Copy link
Member

@josegonzalez josegonzalez commented Aug 26, 2017

I've never used replSet, so I don't really know what either of those errors mean.

Loading

@malixsys
Copy link
Contributor

@malixsys malixsys commented Feb 20, 2018

@ohardy I'm trying to convert my container, too...

Direct running needs a patch
docker-library/mongo#211 (comment)

Meanwhile, did you try to invert the options?

--replSet example --auth

Loading

@wootwoot1234
Copy link

@wootwoot1234 wootwoot1234 commented Jul 22, 2018

@ohardy Did you ever get this working?

@malixsys I tried inverting the options as suggested but no luck. Still can't connect. Any other ideas?

Loading

@malixsys
Copy link
Contributor

@malixsys malixsys commented Jul 22, 2018

I got it to work “à postériori”.. I’ll try and create a gist...

Loading

@malixsys
Copy link
Contributor

@malixsys malixsys commented Jul 22, 2018

YMMV

(updated for latest version)

nano  /var/lib/dokku/services/mongo/YOUR_SERVICE/MONGO_CONFIG_OPTIONS
 --replSet rs0  --storageEngine wiredTiger --auth
sudo docker pull mongo:3.6
dokku mongo:upgrade YOUR_SERVICE  -I 3.6
dokku mongo:upgrade YOUR_SERVICE  -I 3.6.13
dokku mongo:connect-admin YOUR_SERVICE

// IN MONGO

use admin
rs.initiate()
use local
db.system.replset.find()
exit

Loading

@StefanoDeVuono
Copy link

@StefanoDeVuono StefanoDeVuono commented Jul 29, 2018

@malixsys is correct. As per mongo's documentation a standaone db needs to be initiated to run as a replica set.

rs.initiate()

Then wait until the prompt says PRIMARY or SECONDARY.

Loading

@josegonzalez
Copy link
Member

@josegonzalez josegonzalez commented Jul 29, 2018

Closing as this isn't really in the scope of this plugin, and I think folks have a sufficiently good answer to get started down this path.

Loading

@archy-bold
Copy link

@archy-bold archy-bold commented May 1, 2020

For anyone struggling with @malixsys's code not working, it's likely because your MongoDB version is already up to date and the dokku mongo:upgrade command doesn't run and restart the container. To do that instead of upgrading, do the following:

docker rm dokku.mongo.YOUR_SERVICE
dokku mongo:start YOUR_SERVICE

Hat tip https://realmenweardress.es/2019/07/running-rocketchat-on-a-dokku-paas-server/

Loading

@archy-bold
Copy link

@archy-bold archy-bold commented May 7, 2020

Quick question for those in the discussion: Did any of you manage to use a hostname other than the container ID? I've tried updating it but realise I need to update the /etc/hosts file in order to do it. I though maybe that would be possible with the docker-options plugin but it only seems to work on dokku apps and not plugin containers.

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants