PMXBOT Log file Viewer

Help | Karma | Search:

#mongodb logs for Friday the 27th of December, 2013

(Back to #mongodb overview) (Back to channel listing) (Animate logs)
[18:43:51] <lavaman> Is there a way to suppress the version and connecting strings from mongo shell? Trying to run a javascript file and just get the output from the javascript.
[18:44:52] <lavaman> nm. it's —quiet
[18:51:31] <fruitFly_> what is the difference between the commands mongod and mongo?
[18:52:04] <lavaman> mongo is the shell, mongod is the database itself
[19:11:27] <quattro_> i accidentally removed my shards from MMS, is there a way i can get/add them back?
[19:30:35] <fruitFly_> what is the difference between running mongod and mongo?
[19:30:59] <fruitFly_> oh, looks like my question has been answered alreayd
[19:31:54] <fruitFly_> when I run "mongo" i'm in the test database, are documents permanently stored in this database? where is it located?
[19:32:53] <Joeskyyy> By default /var/lib/mongodb/
[19:33:25] <Joeskyyy> (assuming linuxs of course)
[19:33:45] <fruitFly_> Joeskyyy: well of course
[19:33:54] <fruitFly_> :P
[19:34:07] <Joeskyyy> (:
[19:41:00] <fruitFly_> i tried to make a database and this happened: http://pastebin.com/sfYS3j3s
[19:41:19] <fruitFly_> how do I make a database in a particular folder?
[19:41:31] <ranman> fruitFly_: looks like you already have a mongod running?
[19:41:36] <ranman> Fri Dec 27 14:36:05.082 [websvr] ERROR: listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:28017
[19:41:58] <Joeskyyy> +1
[19:42:35] <fruitFly_> ranman: where? i have only once instance of terminal running, do I have to manually kill it somehow?
[19:44:52] <ranman> fruitFly_: are you on OSX? It is possible that a service called launchd (the service that launches background programs on OSX) has already started one for you. Depending on how you installed mongodb this may happen whenever your computer starts. You could confirm by running `mongo` and seeing if it connects to a database or you can just run ps aux | grep mongod and see if a mongod is running
[19:45:59] <fruitFly_> ramsey: linux mint 16
[19:46:28] <fruitFly_> ramsey: mongo connects to the test db
[19:47:14] <lavaman> service mongodb status?
[19:48:15] <fruitFly_> lavaman: start/running, proces 3651
[19:48:27] <lavaman> service mongodb stop
[19:48:40] <lavaman> then you can run mongod manually
[19:49:18] <fruitFly_> lavaman: I stopped it then tried "mongod --dbpath ~/node.js/resolutionSystemMongo/db/" again and it exited
[19:49:36] <lavaman> are you sure it stopped?
[19:49:42] <lavaman> what's the status after?
[19:51:04] <fruitFly_> lavaman: got it! :P
[19:51:09] <fruitFly_> i didn't sudo stop lol
[19:51:13] <lavaman> ah, yeah :)
[19:51:33] <ranman> fruitFly_: err sorry I'm ranman not ramsey so I didn't see your replies haha
[19:52:12] <fruitFly_> ranman: woops lol, sorry man
[19:53:03] <fruitFly_> there are 4 things created in my folder: a journal folder, local.0, local.ns and mongod.lock
[19:53:09] <fruitFly_> does that look right?
[19:53:18] <fruitFly_> where will my collections be stored in this folder?
[19:53:21] <lavaman> until you create a db, yes
[19:53:27] <lavaman> in a folder the name of the db you create
[19:53:46] <fruitFly_> ok i'm goona try that
[19:54:39] <lavaman> also, if you're gonna leave this up and possibly reboot, you probably want to disable the mongodb service with initctl
[19:56:06] <lavaman> or alter the mongodb.conf to reflect what you're doing
[19:57:55] <fruitFly_> lavaman:
[19:58:25] <fruitFly_> db.test.save{test:'testing'}); isn't working
[19:58:31] <fruitFly_> db.test.find();
[19:58:38] <fruitFly_> not responding
[19:58:49] <fruitFly_> just showing that flashing cmd cursor
[19:59:30] <lavaman> I think the syntax of that first command is off
[19:59:35] <lavaman> missing a (
[19:59:46] <lavaman> the mongo shell is terrible about syntax errors
[20:00:07] <lavaman> because it accepts javascript natively, it waits to see if you're going to complete something sensible :)
[20:01:05] <fruitFly_> lavaman: i didn't have a syntax error when i typed it lol
[20:01:11] <lavaman> haha
[20:01:26] <fruitFly_> let me try again
[20:01:37] <lavaman> did you do a use test?
[20:02:07] <fruitFly_> no
[20:02:12] <fruitFly_> and it's not working
[20:02:24] <lavaman> try use test
[20:02:41] <fruitFly_> "help"
[20:02:45] <fruitFly_> isn't even showing anything
[20:02:50] <fruitFly_> i'm typing this stuff in terminal
[20:02:58] <lavaman> and i'm pretty sure you want to insert, not save
[20:03:10] <fruitFly_> ?
[20:03:23] <lavaman> db.test.save{test:'testing'});
[20:03:27] <lavaman> that should be db.test.insert
[20:04:38] <fruitFly_> not working
[20:05:08] <fruitFly_> i was going off the mongodb tutorial
[20:05:22] <fruitFly_> but i'm not getting any response out of this
[20:07:07] <lavaman> Not really sure. I don't usually run mongod manually, so there may be other options you need to pass to make it work
[20:07:28] <Joeskyyy> db.test.save({test:'testing'})
[20:07:34] <Joeskyyy> You were missing a { there
[20:07:39] <Joeskyyy> errr a (
[20:07:41] <fruitFly_> Joeskyyy: stil nto working
[20:08:24] <lavaman> use test didn't do anything?
[20:08:34] <Joeskyyy> ?
[20:08:35] <Joeskyyy> > use test
[20:08:35] <Joeskyyy> switched to db test
[20:08:35] <Joeskyyy> > db.test.save({test:'testing'})
[20:08:35] <Joeskyyy> > db.test.find({test:'testing'})
[20:08:35] <Joeskyyy> { "_id" : ObjectId("52bddd9e76cc7352848ddd69"), "test" : "testing" }
[20:08:52] <lavaman> yeah, it's generally quite straightforward
[20:09:20] <lavaman> oh, are you putting semicolons at the end?
[20:09:28] <lavaman> that implies you want to do something else
[20:09:35] <lavaman> I think
[20:10:04] <lavaman> like in bash putting multiple commands on one line
[20:10:05] <fruitFly_> i'm not using them now
[20:10:16] <fruitFly_> Joeskyyy: I tried that test example and it's not showing me the record
[20:10:34] <lavaman> did it switch to the test db?
[20:10:50] <Joeskyyy> semi colons shouldn't matter on the mongo shell.
[20:10:56] <lavaman> ok. wasn't sure
[20:11:41] <Joeskyyy> fruitFly_: You're at just a > prompt right? not a … prompt?
[20:12:38] <fruitFly_> Fri Dec 27 15:05:22.009 [websvr] admin web console waiting for connections on port 28017
[20:12:58] <fruitFly_> then a prompt like when you press insert
[20:13:07] <fruitFly_> and it's flashing
[20:13:16] <fruitFly_> i should have a >?
[20:13:52] <Joeskyyy> er…. wat… haha
[20:14:05] <Joeskyyy> # mongo
[20:14:05] <Joeskyyy> MongoDB shell version: 2.4.6
[20:14:05] <Joeskyyy> connecting to: test
[20:14:05] <Joeskyyy> >
[20:14:10] <Joeskyyy> You should get something like that when you run mongo
[20:16:39] <fruitFly_> yes, but I ran mongod --dbpath myProjectFolder
[20:17:47] <fruitFly_> Joeskyyy: what is the difference between running mongod vs mongo
[20:17:49] <fruitFly_> Joeskyyy: ^
[20:17:53] <fruitFly_> functionally?
[20:18:05] <lavaman> mongod is the database itself that anything can connect to
[20:18:11] <Joeskyyy> mongod is the database daemon process
[20:18:16] <lavaman> mongo is jsut the shell they provide to manually interact with mongod
[20:18:17] <Joeskyyy> mongo is the shell client to connect to a database.
[20:19:39] <fruitFly_> so if I want to create documents i have to be in the shell...... and does mongod need to be running at the same time? or when does mongod need to be running exactly?
[20:19:57] <Joeskyyy> mongod needs to be running whenever you need your database up
[20:20:00] <lavaman> whenever you want to access the db through any means (mongo shell, application code, etc)
[20:20:12] <lavaman> mongod *is* the database
[20:20:18] <Joeskyyy> you can use the —fork flag when starting mongod to fork it to the background
[20:20:19] <lavaman> mongo is just one of many ways to interact with it
[20:20:42] <Joeskyyy> Or, simply open up another session in your terminal that way you can use two shells
[20:22:45] <fruitFly_> ohh k
[20:23:24] <fruitFly_> i'm connected to test now
[20:23:37] <fruitFly_> but i wanna save a db to my project folder
[20:24:24] <lavaman> create your documents
[20:24:36] <lavaman> then do http://docs.mongodb.org/manual/reference/method/db.fsyncLock/
[20:24:39] <lavaman> to flush the journal
[20:24:48] <lavaman> then you should have a test dir in your project folder
[20:25:31] <lavaman> then of course unlock it if you want to add more documents
[20:26:15] <Joeskyyy> His DB should already be in his project folder
[20:26:28] <lavaman> ok. I wasn't sure how that worked with journaling
[20:26:37] <lavaman> I know it only periodically writes the files to disk
[20:26:49] <Joeskyyy> He ran "mongod --dbpath myProjectFolder" so his DB path (including journals for this specific mongod) are all in myProjectFolder
[20:26:50] <Joeskyyy> :D
[20:27:14] <lavaman> right. he already saw the locals and lock and such
[20:27:26] <lavaman> i wasn't sure *when* it creates the dir
[20:27:31] <lavaman> with journaling and all
[20:27:48] <Joeskyyy> Mongo, luckily, takes all that pain in the ass stuff off your hands haha
[20:27:53] <fruitFly_> can you only have 1 mongo db running at a time?
[20:27:57] <Joeskyyy> As long as the directory exists, it does the rest for you.
[20:28:02] <fruitFly_> right? or they would have to be on different ports
[20:28:06] <lavaman> no, but you need to run them on different ports
[20:28:06] <lavaman> right
[20:28:09] <Joeskyyy> +1
[20:28:13] <lavaman> and not using the same directory :)
[20:28:20] <Joeskyyy> +2
[20:28:21] <fruitFly_> right ok
[20:28:21] <Joeskyyy> haha
[20:28:23] <fruitFly_> :P
[20:30:09] <fruitFly_> so how do I view all my collections, and documents etc. because in my project folder is a bunch of mystery magic, nothing that clearly makes sense... and it created some new files called test.0 and test.1, why would it created files called test when I saved a document called "kases"?
[20:30:43] <Joeskyyy> "show collections" will show all collections in a db
[20:30:53] <lavaman> so you have a db
[20:30:56] <Joeskyyy> db.collection.find() will show your documents.
[20:30:59] <lavaman> and the db can have multiple collections
[20:31:12] <lavaman> so your db is test, but your collection is kases
[20:31:18] <lavaman> collections don't get their own files
[20:31:59] <fruitFly_> { "v" : 1, "key" : { "_id" : 1 }, "ns" : "test.kases", "name" : "_id_" }
[20:32:08] <fruitFly_> why is my db "test"
[20:32:19] <lavaman> because you did use test :)
[20:32:21] <Joeskyyy> Because you typed in "use test" earlier.
[20:32:40] <fruitFly_> no i just typed mongo and it efaulted to test
[20:32:44] <fruitFly_> defaulted*
[20:33:06] <lavaman> It might be reading from the mongodb.conf
[20:33:16] <Joeskyyy> True story, that's the default db when connecting to mongo
[20:33:41] <lavaman> but isn't that just because it's the default in mongodb.conf?
[20:33:46] <Joeskyyy> *nods*
[20:34:00] <kali> it's the default in the code
[20:34:04] <fruitFly_> could you go over this:
[20:34:05] <fruitFly_> { "v" : 1, "key" : { "_id" : 1 }, "ns" : "test.kases", "name" : "_id_" }
[20:34:08] <lavaman> oh, interesting
[20:34:23] <fruitFly_> that's db.system.index.find();
[20:34:44] <Joeskyyy> Those are the indexes on your collection.
[20:34:52] <Joeskyyy> By default _id is indexed on a collection
[20:36:09] <Joeskyyy> kali: yeah you're right, you can set it in mongodb.conf though if I'm not mistaken? I know at the very least in your mongo connection you can.
[20:36:21] <lavaman> you can def. set it in mongodb.conf
[20:36:31] <lavaman> i just thought that's where it pulled the default of test from
[20:36:37] <kali> Joeskyyy: i don't use mongdb.conf, so i'm not sure
[20:38:39] <fruitFly_> what is "v" : 1
[20:38:47] <fruitFly_> in
[20:38:48] <fruitFly_> { "v" : 1, "key" : { "_id" : 1 }, "ns" : "test.kases", "name" : "_id_" }
[20:39:26] <fruitFly_> it all remains the same when i add more records to kases
[20:39:32] <carbonpile> it's the number of times the document has been updated
[20:40:35] <fruitFly_> oooooooooooh
[20:40:52] <fruitFly_> carbonpile: wait, but I added a record to it and it didn't change
[20:41:40] <Joeskyyy> v is the version
[20:41:44] <Joeskyyy> http://docs.mongodb.org/manual/reference/method/db.collection.getIndexes/#db.collection.getIndexes
[20:42:06] <Joeskyyy> That's all the params there.
[20:42:18] <carbonpile> oh sorry, i was thinking __v, which is a mongoose feature
[20:43:35] <ChristianDC> hello.. I'm sort of new to mongodb and document stores. say for example I have documents that also can be assigned tags. Should my Document store an array of the tags (each my string) or should that array store the ObjectId of the specific tag in another collection? So have 2 collections (Documents and Tags) or just Documents and embed each individual tag string
[20:44:00] <joannac> Are your tags likely to need changing?
[20:44:10] <ChristianDC> probably not
[20:44:14] <ChristianDC> renamed?
[20:44:14] <joannac> How oftwn are you going to need tags?
[20:44:27] <ChristianDC> each document is going to have multiple tags
[20:44:58] <ChristianDC> each document will have at least 1 tag
[20:46:31] <ChristianDC> my first attempt has been to just create 2 different collections and assign the objectId to the array but i'm kind of struggling and getting it working. I have to check if the tag exists, and if not then create it.. then add the new objectId to the array
[20:47:03] <ChristianDC> not sure if mongo provides a simple method for doing that
[21:32:33] <Industrial> How do I search for 'where username or email matches this "handle"' ?
[21:32:59] <Industrial> nvm, $or.
[21:33:50] <Joeskyyy> :D
[22:10:04] <fruitFly_> what is the difference between the test database and now local database and admin database?
[22:10:47] <Joeskyyy> http://docs.mongodb.org/manual/reference/local-database/
[22:11:37] <Joeskyyy> The admin database is pretty much for authentication and configuration stuff
[22:12:33] <Joeskyyy> test is just the default db mongo puts in for you to connect to unless you specify otherwise.
[22:27:59] <fruitFly_> Joeskyyy: I'm a little confused, so I should use test for general purposes? local is something special?
[22:28:43] <Joeskyyy> local is used for replication information and such, don't use it.
[22:29:07] <fruitFly_> ok
[22:29:08] <Joeskyyy> test can be used to your general purposes yes, or you can create any database you wish
[22:29:34] <Joeskyyy> local and admin shouldn't hardly ever be touched though, unless you need to do explicit maintenance