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

酷番云78元台湾精品CN2 2核 1G 60G SSD硬盘

酷番云怎么样?酷番云就不讲太多了,介绍过很多次,老牌商家完事,最近有不少小伙伴,一直问我台湾VPS,比较难找好的商家,台湾VPS本来就比较少,也介绍了不少商家,线路都不是很好,有些需求支持Windows是比较少的,这里我们就给大家测评下 酷番云的台湾VPS,支持多个版本Linux和Windows操作系统,提供了CN2线路,并且还是原生IP,更惊喜的是提供的是无限流量。有需求的可以试试。可以看到回程...

Stablehost 美国主机商黑五虚拟主机四折

如今我们网友可能较多的会选择云服务器、VPS主机,对于虚拟主机的话可能很多人不会选择。但是我们有些外贸业务用途的建站项目还是会有选择虚拟主机的。今天看到的Stablehost 商家虚拟主机在黑五期间也有四折优惠,对于这个服务商而言不是特别的喜欢,虽然他们商家和我们熟悉的老鹰主机商有些类似,且在后来老鹰主机改版和方案后,Stablehost 商家也会跟随改版,但是性价比认为不如老鹰主机。这次黑色星期...

CloudCone:$17.99/年KVM-1GB/50GB/1TB/洛杉矶MC机房

CloudCone在月初发了个邮件,表示上新了一个系列VPS主机,采用SSD缓存磁盘,支持下单购买额外的CPU、内存和硬盘资源,最低年付17.99美元起。CloudCone成立于2017年,提供VPS和独立服务器租用,深耕洛杉矶MC机房,最初提供按小时计费随时退回,给自己弄回一大堆中国不能访问的IP,现在已经取消了随时删除了,不过他的VPS主机价格不贵,支持购买额外IP,还支持购买高防IP。下面列...

sources.list为你推荐
apple.com.cn苹果官网怎么查序列号小企业如何做品牌小公司的品牌建设怎么样才能做好mediawikiwiki,wikipedia与mediawiki三者的区别企业推广推广专员一般每天要做哪些工作360邮箱360免费申请邮箱在那里支付宝调整还款日蚂蚁借呗怎么设置还款时间asp.net网页制作怎么用ASP.NET 做一个网页注册。简单的就行支付宝注册网站在哪里注册支付宝360免费建站搭建卡盟分站(卡乐购系统,免费360网站收录)只要29元,想建的找2208647548!tumblr上不去为什么,爱看软件打不开?页面一直在加载
传奇服务器租用 深圳域名空间 希网动态域名 vultr美国与日本 美国主机网 英文站群 ibox官网 可外链网盘 卡巴斯基试用版 美国免费空间 电信主机 支持外链的相册 吉林铁通 华为云服务登录 网购分享 秒杀品 php服务器 114dns 创速 广州主机托管 更多