filessources.list

sources.list  时间:2021-05-05  阅读:()
MongoDBiAbouttheTutorialMongoDBisanopen-sourcedocumentdatabaseandleadingNoSQLdatabase.
MongoDBiswritteninC++.
ThistutorialwillgiveyougreatunderstandingonMongoDBconceptsneededtocreateanddeployahighlyscalableandperformance-orienteddatabase.
AudienceThistutorialisdesignedforSoftwareProfessionalswhoarewillingtolearnMongoDBDatabaseinsimpleandeasysteps.
ItwillthrowlightonMongoDBconceptsandaftercompletingthistutorialyouwillbeatanintermediatelevelofexpertise,fromwhereyoucantakeyourselfathigherlevelofexpertise.
PrerequisitesBeforeproceedingwiththistutorial,youshouldhaveabasicunderstandingofdatabase,texteditorandexecutionofprograms,etc.
Becausewearegoingtodevelophighperformancedatabase,soitwillbegoodifyouhaveanunderstandingonthebasicconceptsofDatabase(RDBMS).
Copyright&DisclaimerCopyright2018byTutorialsPoint(I)Pvt.
Ltd.
Allthecontentandgraphicspublishedinthise-bookarethepropertyofTutorialsPoint(I)Pvt.
Ltd.
Theuserofthise-bookisprohibitedtoreuse,retain,copy,distributeorrepublishanycontentsorapartofcontentsofthise-bookinanymannerwithoutwrittenconsentofthepublisher.
Westrivetoupdatethecontentsofourwebsiteandtutorialsastimelyandaspreciselyaspossible,however,thecontentsmaycontaininaccuraciesorerrors.
TutorialsPoint(I)Pvt.
Ltd.
providesnoguaranteeregardingtheaccuracy,timelinessorcompletenessofourwebsiteoritscontentsincludingthistutorial.
Ifyoudiscoveranyerrorsonourwebsiteorinthistutorial,pleasenotifyusatcontact@tutorialspoint.
comMongoDBiiTableofContentsAbouttheTutorialiAudience.
iPrerequisites.
iCopyright&Disclaimer.
iTableofContents.
iiMONGODB.
11.
MongoDBOverview22.
MongoDBAdvantages.
43.
MongoDBEnvironment.
54.
MongoDBDataModelling105.
MongoDBCreateDatabase126.
MongoDBDropDatabase.
137.
MongoDBCreateCollection148.
MongoDBDropCollection.
169.
MongoDBDatatypes1710.
MongoDBInsertDocument.
1811.
MongoDBQueryDocument2012.
MongoDBUpdateDocument2413.
MongoDBDeleteDocument.
2614.
MongoDBProjection2815.
MongoDBLimitRecords2916.
MongoDBSortRecords3117.
MongoDBIndexing.
3218.
MongoDBAggregation3419.
MongoDBReplication.
3820.
MongoDBSharding.
4121.
MongoDBCreateBackup.
43MongoDBiii22.
MongoDBDeployment.
4523.
MongoDBJava.
4824.
MongoDBPHP.
60ADVANCEDMONGODB.
6625.
MongoDBRelationships6726.
MongoDBDatabaseReferences7027.
MongoDBCoveredQueries7228.
MongoDBAnalyzingQueries7429.
MongoDBAtomicOperations.
7630.
MongoDBAdvancedIndexing7831.
MongoDBIndexingLimitations8032.
MongoDBObjectId.
8133.
MongoDBMapReduce.
8334.
MongoDBTextSearch8635.
MongoDBRegularExpression.
8836.
MongoDBRockMongo.
9037.
MongoDBGridFS9138.
MongoDBCappedCollections9339.
MongoDBAuto-IncrementSequence95MongoDB4MongoDBMongoDB5MongoDBisacross-platform,documentorienteddatabasethatprovides,highperformance,highavailability,andeasyscalability.
MongoDBworksonconceptofcollectionanddocument.
DatabaseDatabaseisaphysicalcontainerforcollections.
Eachdatabasegetsitsownsetoffilesonthefilesystem.
AsingleMongoDBservertypicallyhasmultipledatabases.
CollectionCollectionisagroupofMongoDBdocuments.
ItistheequivalentofanRDBMStable.
Acollectionexistswithinasingledatabase.
Collectionsdonotenforceaschema.
Documentswithinacollectioncanhavedifferentfields.
Typically,alldocumentsinacollectionareofsimilarorrelatedpurpose.
DocumentAdocumentisasetofkey-valuepairs.
Documentshavedynamicschema.
Dynamicschemameansthatdocumentsinthesamecollectiondonotneedtohavethesamesetoffieldsorstructure,andcommonfieldsinacollection'sdocumentsmayholddifferenttypesofdata.
ThefollowingtableshowstherelationshipofRDBMSterminologywithMongoDB.
RDBMSMongoDBDatabaseDatabaseTableCollectionTuple/RowDocumentcolumnFieldTableJoinEmbeddedDocumentsPrimaryKeyPrimaryKey(Defaultkey_idprovidedbymongodbitself)DatabaseServerandClientMysqld/Oraclemongod1.
MongoDBOverviewMongoDB6mysql/sqlplusmongoSampleDocumentFollowingexampleshowsthedocumentstructureofablogsite,whichissimplyacommaseparatedkeyvaluepair.
{_id:ObjectId(7df78ad8902c)title:'MongoDBOverview',description:'MongoDBisnosqldatabase',by:'tutorialspoint',url:'http://www.
tutorialspoint.
com',tags:['mongodb','database','NoSQL'],likes:100,comments:[{user:'user1',message:'Myfirstcomment',dateCreated:newDate(2011,1,20,2,15),like:0},{user:'user2',message:'Mysecondcomments',dateCreated:newDate(2011,1,25,7,45),like:5}]}_idisa12byteshexadecimalnumberwhichassurestheuniquenessofeverydocument.
Youcanprovide_idwhileinsertingthedocument.
Ifyoudon'tprovidethenMongoDBprovidesauniqueidforeverydocument.
These12bytesfirst4bytesforthecurrenttimestamp,next3bytesformachineid,next2bytesforprocessidofMongoDBserverandremaining3bytesaresimpleincrementalVALUE.
MongoDB7Anyrelationaldatabasehasatypicalschemadesignthatshowsnumberoftablesandtherelationshipbetweenthesetables.
WhileinMongoDB,thereisnoconceptofrelationship.
AdvantagesofMongoDBoverRDBMSSchemaless:MongoDBisadocumentdatabaseinwhichonecollectionholdsdifferentdocuments.
Numberoffields,contentandsizeofthedocumentcandifferfromonedocumenttoanother.
Structureofasingleobjectisclear.
Nocomplexjoins.
Deepquery-ability.
MongoDBsupportsdynamicqueriesondocumentsusingadocument-basedquerylanguagethat'snearlyaspowerfulasSQL.
Tuning.
Easeofscale-out:MongoDBiseasytoscale.
Conversion/mappingofapplicationobjectstodatabaseobjectsnotneeded.
Usesinternalmemoryforstoringthe(windowed)workingset,enablingfasteraccessofdata.
WhyUseMongoDBDocumentOrientedStorage:DataisstoredintheformofJSONstyledocuments.
IndexonanyattributeReplicationandhighavailabilityAuto-shardingRichqueriesFastin-placeupdatesProfessionalsupportbyMongoDBWheretoUseMongoDBBigDataContentManagementandDeliveryMobileandSocialInfrastructure2.
MongoDBAdvantagesMongoDB8UserDataManagementDataHubMongoDB9LetusnowseehowtoinstallMongoDBonWindows.
InstallMongoDBonWindowsToinstallMongoDBonWindows,firstdownloadthelatestreleaseofMongoDBfromhttp://www.
mongodb.
org/downloads.
MakesureyougetcorrectversionofMongoDBdependinguponyourWindowsversion.
TogetyourWindowsversion,opencommandpromptandexecutethefollowingcommand.
C:\>wmicosgetosarchitectureOSArchitecture64-bitC:\>32-bitversionsofMongoDBonlysupportdatabasessmallerthan2GBandsuitableonlyfortestingandevaluationpurposes.
Nowextractyourdownloadedfiletoc:\driveoranyotherlocation.
Makesurethenameoftheextractedfolderismongodb-win32-i386-[version]ormongodb-win32-x86_64-[version].
Here[version]istheversionofMongoDBdownload.
Next,openthecommandpromptandrunthefollowingcommand.
C:\>movemongodb-win64-*mongodb1dir(s)moved.
C:\>IncaseyouhaveextractedtheMongoDBatdifferentlocation,thengotothatpathbyusingcommandcdFOOLDER/DIRandnowruntheabovegivenprocess.
MongoDBrequiresadatafoldertostoreitsfiles.
ThedefaultlocationfortheMongoDBdatadirectoryisc:\data\db.
SoyouneedtocreatethisfolderusingtheCommandPrompt.
Executethefollowingcommandsequence.
C:\>mddataC:\mddata\dbIfyouhavetoinstalltheMongoDBatadifferentlocation,thenyouneedtospecifyanalternatepathfor\data\dbbysettingthepathdbpathinmongod.
exe.
Forthesame,issuethefollowingcommands.
3.
MongoDBEnvironmentMongoDB10Inthecommandprompt,navigatetothebindirectorypresentintheMongoDBinstallationfolder.
SupposemyinstallationfolderisD:\setup\mongodbC:\Users\XYZ>d:D:\>cd"setup"D:\setup>cdmongodbD:\setup\mongodb>cdbinD:\setup\mongodb\bin>mongod.
exe--dbpath"d:\setup\mongodb\data"Thiswillshowwaitingforconnectionsmessageontheconsoleoutput,whichindicatesthatthemongod.
exeprocessisrunningsuccessfully.
NowtoruntheMongoDB,youneedtoopenanothercommandpromptandissuethefollowingcommand.
D:\setup\mongodb\bin>mongo.
exeMongoDBshellversion:2.
4.
6connectingto:test>db.
test.
save({a:1})>db.
test.
find(){"_id":ObjectId(5879b0f65a56a454),"a":1}>ThiswillshowthatMongoDBisinstalledandrunsuccessfully.
NexttimewhenyourunMongoDB,youneedtoissueonlycommands.
D:\setup\mongodb\bin>mongod.
exe--dbpath"d:\setup\mongodb\data"D:\setup\mongodb\bin>mongo.
exeInstallMongoDBonUbuntuRunthefollowingcommandtoimporttheMongoDBpublicGPGkeysudoapt-keyadv--keyserverhkp://keyserver.
ubuntu.
com:80--recv7F0CEB10Createa/etc/apt/sources.
list.
d/mongodb.
listfileusingthefollowingcommand.
echo'debhttp://downloads-distro.
mongodb.
org/repo/ubuntu-upstartdist10gen'|sudotee/etc/apt/sources.
list.
d/mongodb.
listNowissuethefollowingcommandtoupdatetherepositorysudoapt-getupdateMongoDB11NextinstalltheMongoDBbyusingthefollowingcommandapt-getinstallmongodb-10gen=2.
2.
3Intheaboveinstallation,2.
2.
3iscurrentlyreleasedMongoDBversion.
Makesuretoinstallthelatestversionalways.
NowMongoDBisinstalledsuccessfully.
StartMongoDBsudoservicemongodbstartStopMongoDBsudoservicemongodbstopRestartMongoDBsudoservicemongodbrestartTouseMongoDBrunthefollowingcommand.
mongoThiswillconnectyoutorunningMongoDBinstance.
MongoDBHelpTogetalistofcommands,typedb.
help()inMongoDBclient.
Thiswillgiveyoualistofcommandsasshowninthefollowingscreenshot.
MongoDB12MongoDB13MongoDBStatisticsTogetstatsaboutMongoDBserver,typethecommanddb.
stats()inMongoDBclient.
Thiswillshowthedatabasename,numberofcollectionanddocumentsinthedatabase.
Outputofthecommandisshowninthefollowingscreenshot.
MongoDB14DatainMongoDBhasaflexibleschema.
documentsinthesamecollection.
Theydonotneedtohavethesamesetoffieldsorstructure,andcommonfieldsinacollection'sdocumentsmayholddifferenttypesofdata.
SomeconsiderationswhiledesigningSchemainMongoDBDesignyourschemaaccordingtouserrequirements.
Combineobjectsintoonedocumentifyouwillusethemtogether.
Otherwiseseparatethem(butmakesurethereshouldnotbeneedofjoins).
Duplicatethedata(butlimited)becausediskspaceischeapascomparetocomputetime.
Dojoinswhilewrite,notonread.
Optimizeyourschemaformostfrequentusecases.
Docomplexaggregationintheschema.
ExampleSupposeaclientneedsadatabasedesignforhisblog/websiteandseethedifferencesbetweenRDBMSandMongoDBschemadesign.
Websitehasthefollowingrequirements.
Everyposthastheuniquetitle,descriptionandurl.
Everypostcanhaveoneormoretags.
Everyposthasthenameofitspublisherandtotalnumberoflikes.
Everyposthascommentsgivenbyusersalongwiththeirname,message,data-timeandlikes.
Oneachpost,therecanbezeroormorecomments.
InRDBMSschema,designforaboverequirementswillhaveminimumthreetables.
4.
MongoDBDataModellingMongoDB15WhileinMongoDBschema,designwillhaveonecollectionpostandthefollowingstructure:{_id:POST_IDtitle:TITLE_OF_POST,description:POST_DESCRIPTION,by:POST_BY,url:URL_OF_POST,tags:[TAG1,TAG2,TAG3],likes:TOTAL_LIKES,comments:[{user:'COMMENT_BY',message:TEXT,dateCreated:DATE_TIME,like:LIKES},{user:'COMMENT_BY',message:TEXT,dateCreated:DATE_TIME,like:LIKES}]}MongoDB16Sowhileshowingthedata,inRDBMSyouneedtojointhreetablesandinMongoDB,datawillbeshownfromonecollectiononly.
MongoDB17Inthischapter,wewillseehowtocreateadatabaseinMongoDB.
TheuseCommandMongoDBuseDATABASE_NAMEisusedtocreatedatabase.
Thecommandwillcreateanewdatabaseifitdoesn'texist,otherwiseitwillreturntheexistingdatabase.
SyntaxBasicsyntaxofuseDATABASEstatementisasfollows:useDATABASE_NAMEExampleIfyouwanttocreateadatabasewithname,thenuseDATABASEstatementwouldbeasfollows:>usemydbswitchedtodbmydbTocheckyourcurrentlyselecteddatabase,usethecommanddb>dbmydbIfyouwanttocheckyourdatabaseslist,usethecommandshowdbs.
>showdbslocal0.
78125GBtest0.
23012GBYourcreateddatabase(mydb)isnotpresentinlist.
Todisplaydatabase,youneedtoinsertatleastonedocumentintoit.
>db.
movie.
insert({"name":"tutorialspoint"})>showdbslocal0.
78125GBmydb0.
23012GB5.
MongoDBCreateDatabaseMongoDB18test0.
23012GBInMongoDBdefaultdatabaseistest.
Ifyoudidn'tcreateanydatabase,thencollectionswillbestoredintestdatabase.
MongoDB19Inthischapter,wewillseehowtodropadatabaseusingMongoDBcommand.
ThedropDatabase()MethodMongoDBdb.
dropDatabase()commandisusedtodropaexistingdatabase.
SyntaxBasicsyntaxofdropDatabase()commandisasfollows:db.
dropDatabase()Thiswilldeletetheselecteddatabase.
Ifyouhavenotselectedanydatabase,thenitwilldeletedefault'test'database.
ExampleFirst,checkthelistofavailabledatabasesbyusingthecommand,showdbs.
>showdbslocal0.
78125GBmydb0.
23012GBtest0.
23012GB>Ifyouwanttodeletenewdatabase,thendropDatabase()commandwouldbeasfollows:>usemydbswitchedtodbmydb>db.
dropDatabase()>{"dropped":"mydb","ok":1}>Nowchecklistofdatabases.
>showdbslocal0.
78125GBtest0.
23012GB>6.
MongoDBDropDatabaseMongoDB20Inthischapter,wewillseehowtocreateacollectionusingMongoDB.
ThecreateCollection()MethodMongoDBdb.
createCollection(name,options)isusedtocreatecollection.
SyntaxBasicsyntaxofcreateCollection()commandisasfollows:db.
createCollection(name,options)Inthecommand,nameisnameofcollectiontobecreated.
Optionsisadocumentandisusedtospecifyconfigurationofcollection.
ParameterTypeDescriptionNameStringNameofthecollectiontobecreatedOptionsDocument(Optional)SpecifyoptionsaboutmemorysizeandindexingOptionsparameterisoptional,soyouneedtospecifyonlythenameofthecollection.
Followingisthelistofoptionsyoucanuse:FieldTypeDescriptioncappedBoolean(Optional)Iftrue,enablesacappedcollection.
Cappedcollectionisafixedsizecollectionthatautomaticallyoverwritesitsoldestentrieswhenitreachesitsmaximumsize.
Ifyouspecifytrue,youneedtospecifysizeparameteralso.
autoIndexIDBoolean(Optional)Iftrue,automaticallycreateindexon_idfield.
Defaultvalueisfalse.
sizenumber(Optional)Specifiesamaximumsizeinbytesforacappedcollection.
Ifcappedistrue,thenyouneedtospecifythisfieldalso.
7.
MongoDBCreateCollectionMongoDB21maxnumber(Optional)Specifiesthemaximumnumberofdocumentsallowedinthecappedcollection.
Whileinsertingthedocument,MongoDBfirstcheckssizefieldofcappedcollection,thenitchecksmaxfield.
ExamplesBasicsyntaxofcreateCollection()methodwithoutoptionsisasfollows:>usetestswitchedtodbtest>db.
createCollection("mycollection"){"ok":1}>Youcancheckthecreatedcollectionbyusingthecommandshowcollections.
>showcollectionsmycollectionsystem.
indexesThefollowingexampleshowsthesyntaxofcreateCollection()methodwithfewimportantoptions:>db.
createCollection("mycol",{capped:true,autoIndexID:true,size:6142800,max:10000}){"ok":1}>InMongoDB,youdon'tneedtocreatecollection.
MongoDBcreatescollectionautomatically,whenyouinsertsomedocument.
>db.
tutorialspoint.
insert({"name":"tutorialspoint"})>showcollectionsmycolmycollectionsystem.
indexestutorialspoint>MongoDB22EndofebookpreviewIfyoulikedwhatyousaw…Buyitfromourstore@https://store.
tutorialspoint.
com

创梦网络-四川大带宽、镇江电信服务器云服务器低至56元

达州创梦网络怎么样,达州创梦网络公司位于四川省达州市,属于四川本地企业,资质齐全,IDC/ISP均有,从创梦网络这边租的服务器均可以备案,属于一手资源,高防机柜、大带宽、高防IP业务,一手整C IP段,四川电信,一手四川托管服务商,成都优化线路,机柜租用、服务器云服务器租用,适合建站做游戏,不须要在套CDN,全国访问快,直连省骨干,大网封UDP,无视UDP攻击,机房集群高达1.2TB,单机可提供1...

【IT狗】在线ping,在线tcping,路由追踪

IT狗为用户提供 在线ping、在线tcping、在线路由追踪、域名被墙检测、域名被污染检测 等实用工具。【工具地址】https://www.itdog.cn/【工具特色】1、目前同类网站中,在线ping 仅支持1次或少量次数的测试,无法客观的展现目标服务器一段时间的网络状况,IT狗Ping工具可持续的进行一段时间的ping测试,并生成更为直观的网络质量柱状图,让用户更容易掌握服务器在各地区、各线...

丽萨主机:美国CN2 GIA精品网/KVM/9折,美国原生IP,最低27元/月

丽萨主机怎么样?丽萨主机,团队于2017年成立。成立之初主要做的是 CDN 和域名等相关业务。最近开辟新领域,新增了独立服务器出租、VPS 等业务,为了保证业务质量从一开始就选择了中美之间的 CN2 GIA 国际精品网络,三网回程 CN2 GIA,电信去程 CN2 GIA + BGP 直连智能路由,联通移动去程直连,原生IP。适合对网络要求较高的用户,同时价格也比较亲民。点击进入:丽萨主机官方网站...

sources.list为你推荐
温州市网络文明传播志愿者信息登记表操作http操作httpoutlookexpressOUTLOOK EXPRESS作用是什么?我想删除它会不会影响系统美要求解锁iPhoneiphone美版解锁硬解大概需要多少钱啊密码cuteftp抢米网怎么用小米商城可以快速抢到手机!大侠们 帮帮忙!银花珠树晓来看关于下雪景的诗句武林官网武林外传网游国服2019年还有多少人玩?dedecms自动采集织梦CMS系统的采集功能不知道怎么采集软件。
高防服务器租用 海外服务器 主机屋免费空间 500m空间 工信部icp备案号 hostloc 双11秒杀 绍兴电信 流媒体加速 cloudlink 腾讯总部在哪 外贸空间 酸酸乳 可外链的相册 带宽测试 广州服务器托管 汤博乐 cdn加速技术 weblogic部署 傲盾代理 更多