Changes

Jump to: navigation, search

Dbms workshop

3,434 bytes added, 18:20, 17 June 2014
/* 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''' &gt; M1 = { Member_pseudo : &quot;Pirboazo&quot;, Member_num : 123001, Langue:'fr' } { &quot;Member_pseudo&quot; : &quot;Pirboazo&quot;, &quot;Member_num&quot; : 123001, &quot;Langue&quot; : &quot;fr&quot; }
 
<blockquote>M2 = { Member_pseudo : &quot;Yv&quot;, Member_num : 3001, Langue:'fr' } { &quot;Member_pseudo&quot; : &quot;Yv&quot;, &quot;Member_num&quot; : 3001, &quot;Langue&quot; : &quot;fr&quot; }
</blockquote>
'''Creation de la Collection Membre''' &gt;db.membre.insert(M1) WriteResult({ &quot;nInserted&quot; : 1 }) db.membre.insert(M2) WriteResult({ &quot;nInserted&quot; : 1 })
 
'''Verification de l'insertion.''' &gt; db.membre.find() { &quot;''id&quot; : ObjectId(&quot;53a07eba52a032beb132c6ba&quot;), &quot;Member_pseudo&quot; : &quot;Pirboazo&quot;, &quot;Member_num&quot; : 123001, &quot;Langue&quot; : &quot;fr&quot; } { &quot;''id&quot; : ObjectId(&quot;53a07ed752a032beb132c6bb&quot;), &quot;Member_pseudo&quot; : &quot;Yv&quot;, &quot;Member_num&quot; : 3001, &quot;Langue&quot; : &quot;fr&quot; }
 
** Nota ** &gt; show collections membre system.indexes
 
On Quitte et on se reconnecte &gt; exit bye pboizot@dbi-ntbk02:/u01/projets/mongodb/doc$ /u01/projets/mongodb/bin/mongo MongoDB shell version: 2.6.2 connecting to: test &gt; show dbs FFH 0.078GB admin (empty) local 0.078GB test (empty)
 
Constat la base FFH existe... &gt;use FFH
 
<blockquote>show collections membre system.indexes
</blockquote>
Delete all Member &gt; db.membre.remove({}) WriteResult({ &quot;nRemoved&quot; : 0 })
 
drop collection &gt; db.membre.drop() true
 
show collections system.indexes
 
'''Drop database'''<br />
&gt; use FFH switched to db FFH &gt; db.dropDatabase(); { &quot;dropped&quot; : &quot;FFH&quot;, &quot;ok&quot; : 1 } &gt; exit bye pboizot@dbi-ntbk02:/u01/projets/mongodb/doc$ /u01/projets/mongodb/bin/mongo MongoDB shell version: 2.6.2 connecting to: test &gt; show dbs admin (empty) local 0.078GB test (empty) &gt;
 
<blockquote>Written with [https://stackedit.io/ StackEdit].
</blockquote>
154
edits