Changes
/* Semaine 4 17/06/2014 */
== Semaine 4 17/06/2014 ==
= Mise en place d'une base mongodb =
== Installation ==
Téléchargement depuis le site http://www.mongodb.org/downloads
on décompresse le dossier
Puis on crée les arborescences pour accueillir une base de test et les binaires
Soit la racine /u01/projets/mongodb
les binaires dans /u01/projets/mongodb/bin > bsondump mongo mongod mongodump mongoexport mongofiles mongoimport mongooplog mongoperf mongorestore mongos mongostat mongotop
Un repertoire data/db à la racine.
== Lancement du serveur ==
<blockquote>/u01/projets/mongodb/bin/mongod --dbpath /u01/projets/mongodb/data/db 2014-06-17T19:05:22.147+0200 [initandlisten] MongoDB starting : pid=14868 port=27017 dbpath=/u01/projets/mongodb/data/db 64-bit host=dbi-ntbk02 2014-06-17T19:05:22.151+0200 [initandlisten] db version v2.6.2 2014-06-17T19:05:22.152+0200 [initandlisten] git version: 4d06e27876697d67348a397955b46dabb8443827 2014-06-17T19:05:22.152+0200 [initandlisten] build info: Linux build10.nj1.10gen.cc 2.6.32-431.3.1.el6.x86_64 #1 SMP Fri Jan 3 21:39:27 UTC 2014 x86_64 BOOST_LIB_VERSION=1_49
</blockquote>
== lancement du client ==
<blockquote>boizot@dbi-ntbk02:/u01/projets/mongodb/doc$ /u01/projets/mongodb/bin/mongo MongoDB shell version: 2.6.2 connecting to: test show dbs admin (empty) local 0.078GB
</blockquote>
== Creation de la base FFH ==
<blockquote>use FFH switched to db FFH db FFH
</blockquote>
'''Initialisation de données''' > M1 = { Member_pseudo : "Pirboazo", Member_num : 123001, Langue:'fr' } { "Member_pseudo" : "Pirboazo", "Member_num" : 123001, "Langue" : "fr" }
<blockquote>M2 = { Member_pseudo : "Yv", Member_num : 3001, Langue:'fr' } { "Member_pseudo" : "Yv", "Member_num" : 3001, "Langue" : "fr" }
</blockquote>
'''Creation de la Collection Membre''' >db.membre.insert(M1) WriteResult({ "nInserted" : 1 }) db.membre.insert(M2) WriteResult({ "nInserted" : 1 })
'''Verification de l'insertion.''' > db.membre.find() { "''id" : ObjectId("53a07eba52a032beb132c6ba"), "Member_pseudo" : "Pirboazo", "Member_num" : 123001, "Langue" : "fr" } { "''id" : ObjectId("53a07ed752a032beb132c6bb"), "Member_pseudo" : "Yv", "Member_num" : 3001, "Langue" : "fr" }
** Nota ** > show collections membre system.indexes
On Quitte et on se reconnecte > exit bye pboizot@dbi-ntbk02:/u01/projets/mongodb/doc$ /u01/projets/mongodb/bin/mongo MongoDB shell version: 2.6.2 connecting to: test > show dbs FFH 0.078GB admin (empty) local 0.078GB test (empty)
Constat la base FFH existe... >use FFH
<blockquote>show collections membre system.indexes
</blockquote>
Delete all Member > db.membre.remove({}) WriteResult({ "nRemoved" : 0 })
drop collection > db.membre.drop() true
show collections system.indexes
'''Drop database'''<br />
> use FFH switched to db FFH > db.dropDatabase(); { "dropped" : "FFH", "ok" : 1 } > exit bye pboizot@dbi-ntbk02:/u01/projets/mongodb/doc$ /u01/projets/mongodb/bin/mongo MongoDB shell version: 2.6.2 connecting to: test > show dbs admin (empty) local 0.078GB test (empty) >
<blockquote>Written with [https://stackedit.io/ StackEdit].
</blockquote>