dokku / dokku-mongo

a mongo plugin for dokku
MIT License
174 stars 32 forks source link

Failed: error connecting to db server: server returned error on SASL authentication step #115

Closed shsunmoonlee closed 5 years ago

shsunmoonlee commented 5 years ago

Description of problem

Can't mongo:import file

How reproducible

seunghunlee$ ssh root@157.230.217.128 mongo:import seunghunlee.net < seunghunlee.net.dump.gz

Actual Results

Failed: error connecting to db server: server returned error on SASL authentication step

Expected Results

Successfully import mongodumped file into my database seunghunlee.net

Environment Information

one click deployed digital ocean dokku droplet

dokku report APP_NAME output

-----> uname: Linux dokku-s-1vcpu-1gb-nyc1-01 4.15.0-36-generic #39-Ubuntu SMP Mon Sep 24 16:19:09 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
-----> memory:
                     total        used        free      shared  buff/cache   available
       Mem:            985         260         151           0         573         561
       Swap:          2047          87        1960
-----> docker version:
       Client:
        Version:           18.06.1-ce
        API version:       1.38
        Go version:        go1.10.3
        Git commit:        e68fc7a
        Built:             Tue Aug 21 17:24:51 2018
        OS/Arch:           linux/amd64
        Experimental:      false

       Server:
        Engine:
         Version:          18.06.1-ce
         API version:      1.38 (minimum version 1.12)
         Go version:       go1.10.3
         Git commit:       e68fc7a
         Built:            Tue Aug 21 17:23:15 2018
         OS/Arch:          linux/amd64
         Experimental:     false
-----> docker daemon info:
       Containers: 8
        Running: 2
        Paused: 0
        Stopped: 6
       Images: 16
       Server Version: 18.06.1-ce
       Storage Driver: overlay2
        Backing Filesystem: extfs
        Supports d_type: true
        Native Overlay Diff: true
       Logging Driver: json-file
       Cgroup Driver: cgroupfs
       Plugins:
        Volume: local
        Network: bridge host macvlan null overlay
        Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
       Swarm: inactive
       Runtimes: runc
       Default Runtime: runc
       Init Binary: docker-init
       containerd version: 468a545b9edcd5932818eb9de8e72413e616e86e
       runc version: 69663f0bd4b60df09991c08812a60108003fa340
       init version: fec3683
       Security Options:
        apparmor
        seccomp
         Profile: default
       Kernel Version: 4.15.0-36-generic
       Operating System: Ubuntu 18.04.1 LTS
       OSType: linux
       Architecture: x86_64
       CPUs: 1
       Total Memory: 985.5MiB
       Name: dokku-s-1vcpu-1gb-nyc1-01
       ID: 2QFE:RZFN:FK7D:C5TD:H5UD:SRWZ:IKST:ARAR:VFD2:NY6H:QPQK:SGAG
       Docker Root Dir: /var/lib/docker
       Debug Mode (client): true
       Debug Mode (server): false
       Registry: https://index.docker.io/v1/
       Labels:
       Experimental: false
       Insecure Registries:
        127.0.0.0/8
       Live Restore Enabled: false

-----> sigil version: 0.4.0
-----> herokuish version:
       herokuish: 0.4.4
       buildpacks:
         heroku-buildpack-multi     v1.0.0
         heroku-buildpack-ruby      v190
         heroku-buildpack-nodejs    v123
         heroku-buildpack-clojure   v82
         heroku-buildpack-python    v138
         heroku-buildpack-java      v62
         heroku-buildpack-gradle    v27
         heroku-buildpack-scala     v82
         heroku-buildpack-play      v26
         heroku-buildpack-php       v143
         heroku-buildpack-go        v90
         buildpack-nginx            v9
-----> dokku version: 0.12.13
-----> dokku plugins:
       plugn: 0.3.0
         00_dokku-standard    0.12.13 enabled    dokku core standard plugin
         20_events            0.12.13 enabled    dokku core events logging plugin
         apps                 0.12.13 enabled    dokku core apps plugin
         build-env            0.12.13 enabled    dokku core build-env plugin
         certs                0.12.13 enabled    dokku core certificate management plugin
         checks               0.12.13 enabled    dokku core checks plugin
         common               0.12.13 enabled    dokku core common plugin
         config               0.12.13 enabled    dokku core config plugin
         docker-options       0.12.13 enabled    dokku core docker-options plugin
         domains              0.12.13 enabled    dokku core domains plugin
         enter                0.12.13 enabled    dokku core enter plugin
         git                  0.12.13 enabled    dokku core git plugin
         letsencrypt          0.8.8 enabled    Automated installation of let's encrypt TLS certificates
         logs                 0.12.13 enabled    dokku core logs plugin
         mongo                1.4.10 enabled    dokku mongo service plugin
         network              0.12.13 enabled    dokku core network plugin
         nginx-vhosts         0.12.13 enabled    dokku core nginx-vhosts plugin
         plugin               0.12.13 enabled    dokku core plugin plugin
         proxy                0.12.13 enabled    dokku core proxy plugin
         ps                   0.12.13 enabled    dokku core ps plugin
         repo                 0.12.13 enabled    dokku core repo plugin
         scheduler-docker-local 0.12.13 enabled    dokku corescheduler-docker-local plugin
         shell                0.12.13 enabled    dokku core shell plugin
         ssh-keys             0.12.13 enabled    dokku core ssh-keys plugin
         storage              0.12.13 enabled    dokku core storage plugin
         tags                 0.12.13 enabled    dokku core tags plugin
         tar                  0.12.13 enabled    dokku core tar plugin
=====> seunghunlee.net app information
       App dir:                       /home/dokku/seunghunlee.net
       Git sha:                       35dc7d8
       Deploy source:                 git
       Locked:                        false
=====> seunghunlee.net ssl information
       Ssl dir:                       /home/dokku/seunghunlee.net/tls
       Ssl enabled:                   false
       Ssl hostnames:
       Ssl expires at:
       Ssl issuer:
       Ssl starts at:
       Ssl subject:
       Ssl verified:
=====> seunghunlee.net checks information
       Checks disabled list:          none
       Checks skipped list:           none
=====> seunghunlee.net docker options information
       Docker options build:          --link dokku.mongo.seunghunlee.net:dokku-mongo-seunghunlee-net
       Docker options deploy:         --link dokku.mongo.seunghunlee.net:dokku-mongo-seunghunlee-net --restart=on-failure:10
       Docker options run:            --link dokku.mongo.seunghunlee.net:dokku-mongo-seunghunlee-net
=====> seunghunlee.net domains information
       Domains app enabled:           true
       Domains app vhosts:            seunghunlee.net *.seunghunlee.net
       Domains global enabled:        true
       Domains global vhosts:         seunghunlee.net seunghunlee.net *.seunghunlee.net
=====> seunghunlee.net git information
       Git rev env var:               GIT_REV
       Git deploy branch:             master
       Git global deploy branch:      master
=====> seunghunlee.net network information
       Network bind all interfaces:   false
       Network listeners:             172.17.0.3:5000
=====> seunghunlee.net proxy information
       Proxy enabled:                 true
       Proxy type:                    nginx
       Proxy port map:                http:80:5000
=====> seunghunlee.net ps information
       Processes:                     1
       Deployed:                      true
       Running:                       true
       Restore:                       true
       Restart policy:                on-failure:10
       Status web.1:                  running    (CID: 64355033d747)
=====> seunghunlee.net scheduler-docker-local information
       Scheduler docker local disable chown:
=====> seunghunlee.net storage information
       Storage build mounts:
       Storage deploy mounts:
       Storage run mounts:

This is required! Issues missing this information may be closed.

For problems affecting all applications, the report output for a broken application is useful for our debugging. You may also run dokku report without any arguments to display the top-level reporting information.

How (deb/make/rpm) and where (AWS, VirtualBox, physical, etc.) was Dokku installed?:

Additional information

shsunmoonlee commented 5 years ago

related: https://github.com/dokku/dokku-mongo/issues/113 I'm suspecting it's related to the fact that I've changed droplet's password which is different from the mongodb local password when I run dokku --trace mongo:import seunghunlee.net

josegonzalez commented 5 years ago

The droplet password and the mongodb password are not related. Did you change the password in the mongodb server itself?

shsunmoonlee commented 5 years ago

No I haven't

josegonzalez commented 5 years ago

Can you post the actual output of the command you are running?

shsunmoonlee commented 5 years ago
ssh root@157.230.217.128
dokku mongo:import seunghunlee.net < seunghunlee.net.dump.gz
2019-02-04T02:10:26.659+0000    Failed: error connecting to db server: server returned error on SASL authentication step:
josegonzalez commented 5 years ago

Yeah, so changing the password on the server had no effect on mongo itself.

What is the output of dokku mongo:enter seunghunlee.net?

shsunmoonlee commented 5 years ago

It succesfully enters somewhere

root@554447683e7f:/#
shsunmoonlee commented 5 years ago
root@554447683e7f:/# mongo
MongoDB shell version v3.4.9
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.9
> show dbs
2019-02-04T02:26:51.671+0000 E QUERY    [thread1] Error: listDatabases failed:{
        "ok" : 0,
        "errmsg" : "not authorized on admin to execute command { listDatabases: 1.0 }",
        "code" : 13,
        "codeName" : "Unauthorized"
} :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
Mongo.prototype.getDBs@src/mongo/shell/mongo.js:62:1
shellHelper.show@src/mongo/shell/utils.js:769:19
shellHelper@src/mongo/shell/utils.js:659:15
@(shellhelp2):1:1
>
josegonzalez commented 5 years ago

Try dokku mongo:connect-admin seunghunlee.net

shsunmoonlee commented 5 years ago
root@dokku-s-1vcpu-1gb-nyc1-01:~# dokku mongo:connect-admin seunghunlee.net
MongoDB shell version v3.4.9
connecting to: mongodb://127.0.0.1:27017/seunghunlee.net
2019-02-04T14:28:54.958+0000 E QUERY    [thread1] Error: Failed to parse mongodb:// URL: mongodb://127.0.0.1:27017/seunghunlee.net :
connect@src/mongo/shell/mongo.js:237:13
@(connect):1:6
exception: connect failed
josegonzalez commented 5 years ago

Did you change the admin password on mongodb? Thats the only reason you'd see that error.

shsunmoonlee commented 5 years ago

No I've only changed the droplet password

On Tue, Feb 5, 2019, 1:07 AM Jose Diaz-Gonzalez <notifications@github.com wrote:

Did you change the admin password on mongodb? Thats the only reason you'd see that error.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dokku/dokku-mongo/issues/115#issuecomment-460305669, or mute the thread https://github.com/notifications/unsubscribe-auth/AG-Ov5YRhElmWcDZF5vzIu5pllk9hPFNks5vKFrIgaJpZM4afcr6 .

josegonzalez commented 5 years ago

Might be that periods are not valid in a mongodb database name?

shsunmoonlee commented 5 years ago

Sorry what does that mean? What steps should I take?

josegonzalez commented 5 years ago

Can you check if a period character (.) can be used in a mongodb database name?

shsunmoonlee commented 5 years ago

doens't seem to be an issue

Using a database name with a period in it works for most operations but causes safe mode to throw an error. If these are not valid database names reject them at connection time so the error is obvious. E.g. this code fails:

https://jira.mongodb.org/browse/CSHARP-40

shsunmoonlee commented 5 years ago

let me delete and re create database without period

shsunmoonlee commented 5 years ago

That was it! You shouldn't include dot in your mongodb name when 'dokku mongo:create ' I've changed it to seunghunlee instead of seunghunlee.net now this command works

dokku mongo:import seunghunlee < seunghunlee.net.dump.gz

Thank you so much @josegonzalez for your awesome help.

shsunmoonlee commented 5 years ago

Oh I found this issue persisting tho!

root@dokku-s-1vcpu-1gb-nyc1-01:~# dokku mongo:enter seunghunlee
-----> Filesystem changes may not persist after container restarts
root@842a127467f1:/# mongo
MongoDB shell version v3.4.9
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.9
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
        http://docs.mongodb.org/
Questions? Try the support group
        http://groups.google.com/group/mongodb-user
> show dbs
2019-02-08T05:35:26.599+0000 E QUERY    [thread1] Error: listDatabases failed:{
        "ok" : 0,
        "errmsg" : "not authorized on admin to execute command { listDatabases: 1.0 }",
        "code" : 13,
        "codeName" : "Unauthorized"
} :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
Mongo.prototype.getDBs@src/mongo/shell/mongo.js:62:1
shellHelper.show@src/mongo/shell/utils.js:769:19
shellHelper@src/mongo/shell/utils.js:659:15
@(shellhelp2):1:1
josegonzalez commented 5 years ago

What are your exact reproduction steps for creating this database and interacting with it?

josegonzalez commented 5 years ago

Ah we may need to grant admin to that database? https://github.com/dokku/dokku-mongo/blob/1ce8d1747b11f1addf67d70ce8ba5f41816c7e87/functions#L96

josegonzalez commented 5 years ago

Wait, so you're just entering the container and running arbitrary commands? You may wish to instead use dokku mongo:connect-admin SERVICE, which will connect via the administrative credentials, which will give you listDatabases.

shsunmoonlee commented 5 years ago

Ah gotcha. dokku mongo:connect-admin SERVICE works for me!