PMXBOT Log file Viewer

Help | Karma | Search:

#mongodb logs for Sunday the 10th of January, 2016

(Back to #mongodb overview) (Back to channel listing) (Animate logs)
[00:02:47] <metame> so in the same place you project the fields you want in your query, you would project out _id
[00:02:53] <metame> e.g...
[00:04:21] <sandstrom> Okay, I understand. Thanks for explaining this to me, I appreciate your help!
[00:05:18] <metame> db.find(query,{a:1,b:1,_id:0})
[00:05:25] <metame> sandstrom: np
[00:05:41] <sandstrom> metame thanks!
[00:52:25] <flaf> Hello @all, can you confirm to me that noauth=false is equivalent to auth=true?
[01:02:49] <flaf> (it's for mongo 2.4)
[02:13:29] <flaf> Is it possible to have a replica set _and_ auth=true with mongo 2.4?
[02:15:09] <flaf> When I create my first user the replica set seems to be down.
[02:17:56] <Waheedi> flaf: this is the best you can find around auth and replica sets https://docs.mongodb.org/manual/tutorial/enable-internal-authentication/
[02:19:04] <flaf> Waheedi: this page concerns mongo 3.2
[02:19:24] <flaf> personally I'm trying https://docs.mongodb.org/v2.4/tutorial/deploy-replica-set/
[02:20:05] <Waheedi> and whats your problem exactly?
[02:21:04] <flaf> In fact, if I don't create a user (in my case an admin user) all is fine.
[02:21:30] <flaf> I have a replica set up, PRIMARY SECONDARY SECONDARY etc.
[02:22:17] <flaf> But, in the primary, if I create a admin use with http://paste.alacon.org/39270
[02:22:50] <flaf> Boum, the replica set is down. In the log I have [conn27] command denied: { replSetGetStatus: 1.0, forShell: 1.0 }
[02:23:04] <flaf> when I try a command in the mongo shell.
[02:23:25] <Waheedi> did u set auth to true flaf ?
[02:23:58] <flaf> http://paste.alacon.org/39271
[02:24:02] <flaf> yes
[02:25:18] <Waheedi> flaf: i would generate a key file and try KeyFile first
[02:25:38] <flaf> My key file is already generated.
[02:26:06] <flaf> (and indeed without the keyfile, no replica set up, tested)
[02:26:43] <Waheedi> alright, I'm sure you restarted your mongodb too :)
[02:26:51] <flaf> Of course.
[02:27:27] <flaf> Anyway, without the keyfile and the service restarted, no replica set possible.
[02:27:42] <Waheedi> secondaries reflect the same config file?
[02:28:03] <flaf> Yes, it's a file generated by puppet.
[02:28:09] <flaf> the same file on the 3 nodes.
[02:29:58] <flaf> If I don't create user, all is fine.
[02:30:17] <flaf> Each node is in the replica set.
[02:30:54] <flaf> The problem begins at the moment where I create my admin user in the PRIMARY.
[02:31:12] <flaf> Before the creation, I have PRIMARY in the prompt.
[02:31:20] <Waheedi> for sure when you create your first user that would happen
[02:31:22] <Waheedi> https://docs.mongodb.org/manual/core/security-users/#localhost-exception
[02:31:24] <flaf> Just after, I have just ">"
[02:32:02] <Waheedi> https://docs.mongodb.org/manual/reference/parameters/#param.enableLocalhostAuthBypass
[02:32:21] <Waheedi> you can try to disable localhostauth
[02:32:34] <Waheedi> flaf:
[02:32:52] <Waheedi> all secondaries and primary got reloaded with the new config right?
[02:33:02] <flaf> Yes.
[02:33:10] <Waheedi> ok so thats irrelevant
[02:33:14] <flaf> Sure.
[02:34:00] <flaf> Another information: I have tried before with noauth=true and no problem to have my replica set up.
[02:35:46] <flaf> https://groups.google.com/forum/#!topic/mongodb-user/o6SuftekFSI
[02:36:03] <flaf> maybe a bug in 2.4 ?
[02:36:45] <flaf> I have exactly the same error as the OP.
[02:37:33] <flaf> But I absolutely don't understand the answer of Tad Marshall (I'm a mongo beginner).
[02:37:42] <flaf> Waheedi:
[02:39:21] <flaf> In fact this https://docs.mongodb.org/v2.4/tutorial/deploy-replica-set/ is absolutely fine. But all is down when I create my first user.
[02:40:44] <flaf> For information, to create my first user, I have launched “mongo <create.js” in my shell bash where create.js is this file http://paste.alacon.org/39270
[02:41:44] <Waheedi> I would rather type that on mongo
[02:41:47] <Waheedi> and then db.system.users.find()
[02:43:03] <flaf> > db.system.users.find()
[02:43:05] <flaf> { "_id" : ObjectId("5691bcb110413ffe6e827b0d"), "user" : "admin", "pwd" : "2a467ed5e5c8b800a403670332c8d18a", "roles" : [ "userAdminAnyDatabase" ] }
[02:44:34] <Waheedi> how do you run your mongo?
[02:45:18] <flaf> node are Ubuntu trusty. apt-get install mongo-server; service mongodb start etc...
[02:46:17] <Waheedi> I need to see what options are passed to mongo when its run
[02:46:56] <flaf> # ps aux | grep mong[o]
[02:46:57] <flaf> mongodb 31367 0.4 1.0 3949416 44208 ? Ssl 03:01 0:10 /usr/bin/mongod --config /etc/mongodb.conf
[02:46:59] <flaf> root 31830 0.0 0.0 7492 616 pts/1 S+ 03:38 0:00 tail -f /var/log/mongodb/mongodb.log
[02:48:09] <Waheedi> so all your conf is in the right place /etc/mongodb.conf
[02:48:23] <flaf> yes I thing.
[02:48:42] <flaf> k
[02:49:19] <Waheedi> so now without adding the user, they are already using the key file to communicate
[02:49:55] <Waheedi> ?
[02:50:17] <flaf> I think yes. But how to check it?
[02:51:19] <flaf> Currently, my replica set is UP. No user created.
[02:52:09] <flaf> Waheedi: for instance http://paste.alacon.org/39272
[02:52:36] <flaf> But I know that if I create my admin user, boum!
[02:54:00] <flaf> as if the fact to create a user break something.
[02:54:25] <flaf> https://docs.mongodb.org/v2.4/reference/configuration-options/#auth
[02:54:39] <flaf> If no users exist, the localhost interface will continue to have access to the database until you create the first user.
[02:54:45] <flaf> Quote
[02:55:30] <flaf> I think it's related with my problem.
[02:57:21] <Waheedi> ok i think you should do rs.remove("secondaries") first
[02:57:25] <Waheedi> then add the user
[02:57:49] <flaf> It seems I had tried that too... but I retry...
[02:58:50] <Waheedi> ok remove secondaries, add user, restart primary, rs.initiate() then restart secondaries then rs.add(secondaries)
[02:59:08] <Waheedi> that should fix it :)
[02:59:31] <flaf> Waheedi: rs.remove("moogo02") doesn't work rror: couldn't find moogo02 in [
[02:59:32] <flaf> {
[02:59:34] <flaf> "_id" : 0,
[02:59:36] <flaf> "host" : "moogo01:27017"
[02:59:38] <flaf> },
[02:59:40] <flaf> {
[02:59:42] <flaf> "_id" : 1,
[02:59:44] <flaf> "host" : "moogo02:27017"
[02:59:46] <flaf> },
[02:59:48] <flaf> {
[02:59:50] <flaf> "_id" : 2,
[02:59:52] <flaf> "host" : "moogo03:27017"
[02:59:54] <flaf> }
[02:59:56] <flaf> ]
[02:59:58] <flaf> Ah the port is needed
[03:00:01] <Waheedi> it needs the rs.remove "moogo02:27017"
[03:00:03] <Waheedi> man
[03:00:15] <Waheedi> stop flooding the channel first
[03:00:28] <flaf> ok, now my PRIMARY is allone.
[03:00:35] <flaf> ah sorry.
[03:00:36] <Waheedi> thats good
[03:00:49] <Waheedi> add user restart primary
[03:00:55] <flaf> ok.
[03:01:13] <Waheedi> now restart secondaries
[03:01:18] <Waheedi> then mongo on primary
[03:01:26] <flaf> done.
[03:01:31] <Waheedi> rs.initiate()
[03:01:54] <Waheedi> rs.add("host:port")
[03:01:57] <flaf> http://paste.alacon.org/39273
[03:02:18] <Waheedi> u didn't login with ur user and password?
[03:02:18] <Waheedi> lol
[03:02:33] <Waheedi> u forgot u just added one
[03:03:05] <flaf> http://paste.alacon.org/39274
[03:03:08] <flaf> no
[03:03:16] <flaf> My user is added.
[03:03:33] <flaf> And rs.initiate() failed.
[03:03:54] <flaf> admin has the role "userAdminAnyDatabase"
[03:04:12] <flaf> (I can see that with "show users")
[03:04:28] <Waheedi> hmm
[03:04:35] <flaf> yes.... hmm :)
[03:04:45] <Waheedi> now the error looks better
[03:05:05] <Waheedi> at least it says you are not authorized
[03:05:12] <Waheedi> which means you are authenticated
[03:05:43] <flaf> the error is the same "unauthorized"
[03:07:25] <Waheedi> I'm trying to help you
[03:07:35] <flaf> yes thx Waheedi :)
[03:07:45] <Waheedi> i don't work for anyone :)
[03:08:37] <flaf> For me it's a bug.
[03:08:59] <flaf> I have followed exactly https://docs.mongodb.org/v2.4/tutorial/deploy-replica-set/
[03:09:48] <Waheedi> flaf: create user admin again with these roles roles: [ "userAdminAnyDatabase",
[03:09:49] <Waheedi> "readWriteAnyDatabase",
[03:09:50] <Waheedi> "dbAdminAnyDatabase",
[03:09:50] <Waheedi> "clusterAdmin"
[03:10:27] <Waheedi> that should be sufficient for good authorization
[03:10:39] <Waheedi> i think rs.initiate needs clusterAdmin
[03:10:42] <Waheedi> just thinking
[03:11:14] <Waheedi> if this takes more 5 minutes of my time I'm leaving :)
[03:11:28] <flaf> I'm trying...
[03:15:18] <flaf> oh oh !
[03:15:23] <flaf> \o/
[03:15:34] <flaf> It work Waheedi
[03:15:38] <Waheedi> lol
[03:15:39] <Waheedi> :)
[03:15:43] <Waheedi> i told ya
[03:15:49] <flaf> Thx a lot for your help. :)))
[03:15:59] <Waheedi> you are welcome
[03:16:17] <flaf> thx for your patience too
[03:16:33] <Waheedi> ;)
[03:16:47] <flaf> it's probably the clusteradmin role...
[03:17:14] <Waheedi> I'm wondering who creates these tutorials :S
[03:17:36] <flaf> so if I understand well I have to create my user before to create my replica set.
[03:17:51] <Waheedi> yes
[03:18:02] <flaf> maybe my keyfile is useless, no?
[03:18:09] <Waheedi> no its not
[03:18:15] <Waheedi> its another security layer
[03:18:31] <flaf> I don't understand the goal of this keyfile?
[03:19:22] <flaf> Ah it just add a kind of salt in the communication?
[03:19:33] <Waheedi> You can read about that, kinda
[03:19:55] <Waheedi> alright I'm rolling
[03:20:07] <flaf> ok, thx again Waheedi :)
[03:20:17] <Waheedi> np flaf
[03:20:20] <Waheedi> glad it worked
[03:20:26] <flaf> me too
[15:03:13] <dbounds> Hello. Occasionally (once every one or two weeks) I start noticing the load avg on my DB creep up and query response along with it. At the times when this happens there doesn't appear to be any system work happening or anything IO related that's unusual.
[15:03:36] <dbounds> What solves the problem immediately is droping and recreating an index.
[15:04:05] <dbounds> I'm not sure why, but it does. Can anyone provide any insight into what may be happening here?
[15:17:07] <tnViking> when I do .find("tags": "yellow"), it prints out a whole bunch of stuff I'm not looking for, but when I do .findOne("tags": "yellow") it finds the first with yellow tag. But I've got several entries with yellow tag, so how can I get it to work?
[15:20:39] <dbounds> tnViking. find() will give you all the results, findOne will give you the first. pretty semantic.
[15:21:12] <dbounds> also, I assume your criteria was actually find({"tags":"yellow"})
[15:21:57] <tnViking> Yeah, this is what I get http://kopy.io/4XIyZ
[15:22:02] <tnViking> with find
[15:23:32] <dbounds> paste your exact query.
[15:25:07] <tnViking> http://kopy.io/pLuU9
[15:26:16] <dbounds> but you said findOne() was working, show me the find() query.
[15:26:45] <tnViking> it's the same, but just with find() instead of findOne()
[15:37:41] <dbounds> what happens if you don't specify any criteria? Are you sure that collection isn't filled with other data?
[15:38:01] <tnViking> when I use MongoChef, and do the query {"tags": {$all: ["yellow"]}}, it's run in a .find(), and it outputs all entries with said tag
[15:39:05] <tnViking> With no criteria, it gives me the same
[15:42:59] <tnViking> this is my entries within the pictures collection http://kopy.io/78DID
[15:44:35] <dbounds> it sounds like something is jacked with your collection then.
[15:44:50] <dbounds> but I'm not expert. I'm here for help as well. ;)
[15:44:59] <dbounds> *not an expert
[15:48:30] <tnViking> Dunno how I could have messed up the collection, the last link is all it contains
[15:48:49] <tnViking> Though, I'm quite new with mongo
[15:50:11] <dbounds> if you go to the commandline shell and do a db.pictures.find({}); what do you get
[15:50:12] <dbounds> ?
[15:52:37] <tnViking> it gives me all the entries
[15:53:39] <dbounds> the ones you want?
[15:54:01] <dbounds> oh hold on
[15:54:58] <tnViking> Yeah, works through the shell
[15:55:39] <dbounds> find() returns a cursor
[15:55:59] <dbounds> the API with findOne and find differs a bit
[15:56:22] <tnViking> so how can I achieve what I want?
[15:57:12] <dbounds> this is node?
[15:57:33] <tnViking> because what I want is really to choose 1 randomly from the entires with the tags, so if there's 10 entries with tag "Yellow", it randomly picks number #4, so I can't use findOne
[15:57:35] <tnViking> yeah
[15:57:37] <dbounds> https://docs.mongodb.org/getting-started/node/query/
[15:57:45] <dbounds> good example of a find query there.
[15:57:53] <dbounds> just add your own criteria in find()
[15:59:18] <dbounds> basically db.collection('pictures').find({}).each(error, docs) {}
[16:17:55] <tnViking> how can I know if it doesn't find anything? the response is empty?
[16:18:19] <tnViking> Oh, I think I know
[17:23:34] <tnViking> How dbounds, how then could I count how many it finds?, I tried db.collection("pictures").find({"tags": {$all: tags}}).count(), but it gives me Promise { <rejected> [Error: write after end]}
[18:13:55] <dbounds> tnViking, you should read the docs. This is all very well documented.
[22:55:02] <morf> can i ask questions about morphia here?
[22:55:15] <morf> or is it not part of mongodb?
[22:57:03] <Derick> it is not part of mongodb, buy you can always try
[22:57:51] <cheeser> it's not? :D
[22:58:02] <morf> is there some simple way to persist models without updating each field? (something like datastore.persist(myModel))
[22:58:16] <cheeser> you can use UpdateOperation
[22:59:18] <morf> cheeser: but still i need to do the .inc("something", "something") for each field?
[22:59:26] <cheeser> well, sure
[23:00:01] <morf> hm i guess it has something to do with the whole concept of mongo?
[23:00:28] <cheeser> you want to update fields without specifying the fields?
[23:00:58] <Derick> cheeser: sorry - I didn't think it was? I mean, is it under github.com/mongodb ?
[23:01:03] <morf> ok let's say update whole document (model) at once without doing calling each field
[23:01:17] <cheeser> Derick: yep. and it's a huge part of my job :D
[23:01:22] <Derick> oh hah
[23:01:27] <Derick> ← clueless
[23:01:51] <morf> i guess i want something impossible like always ;)
[23:02:06] <morf> thx for clarification i will cope somehow
[23:05:55] <morf> oh just found it
[23:08:22] <morf> if somebody is interested http://blog.knuthaugen.no/2010/07/comparing-mongodb-java-frameworks.html
[23:08:46] <morf> (convert to model to db object store to collection)
[23:13:08] <cheeser> so what exactly are you trying to do?
[23:15:03] <morf> cheeser: something like this persons.save(morph.toDBObject(test));
[23:15:19] <morf> it's ok :) now i know how
[23:15:27] <morf> thx again
[23:16:49] <cheeser> why would you do that?
[23:17:10] <cheeser> don't tie yourself to toDBObject(). it's going away as soon as I can make it.
[23:17:48] <cheeser> that's an internal method the people shouldn't be using but too many have started using it.
[23:25:57] <morf> cheeser: oh well that's because ppl are lazy
[23:26:52] <cheeser> what is your particular design trying to achieve
[23:30:36] <morf> it's querying api (inserts / updates / deletes) + modifying by user in app
[23:31:12] <morf> getting data from api / mapping -> updating local db
[23:31:32] <morf> it's certainly possible i'm doing it completely wrong
[23:31:57] <cheeser> why not just save test directly? you've already got that class mapped.
[23:32:41] <morf> not sure how
[23:33:00] <cheeser> what type is persons?
[23:33:29] <morf> cheeser: look here http://blog.knuthaugen.no/2010/07/comparing-mongodb-java-frameworks.html
[23:33:53] <morf> also it's possible ppl are getting the idea use .toDBObject() from there
[23:34:02] <cheeser> yes, i saw that. it's terrible advice to build things like that.
[23:35:04] <cheeser> extending BasicDBObject will lose you all your type safety without casting in and out of your entity
[23:35:05] <morf> so... if i have entity/model i can just use it with the collection? (entities.save(entity))
[23:35:18] <cheeser> have you looked at the mapping documentation?
[23:35:46] <morf> let's see...
[23:37:18] <cheeser> yeah, that's not a great blog entry
[23:37:37] <cheeser> i mean, it's 5 years old but it's skipping so much of what morphia is supposed to do for you.
[23:39:09] <morf> omg omg omg
[23:39:20] <morf> blind and stupid like always
[23:39:49] <morf> just datastore.save() ...
[23:39:55] <cheeser> yeah :)
[23:40:58] <morf> really need to get some sleep