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

EdgeNat 新年开通优惠 - 韩国独立服务器原生IP地址CN2线路七折优惠

EdgeNat 商家在之前也有分享过几次活动,主要提供香港和韩国的VPS主机,分别在沙田和首尔LG机房,服务器均为自营硬件,电信CN2线路,移动联通BGP直连,其中VPS主机基于KVM架构,宿主机采用四路E5处理器、raid10+BBU固态硬盘!最高可以提供500Gbps DDoS防御。这次开年活动中有提供七折优惠的韩国独立服务器,原生IP地址CN2线路。第一、优惠券活动EdgeNat优惠码(限月...

licloud:$39/月,香港物理服务器,30M带宽,e3-1230v3/16G内存/1T硬盘

licloud官方消息:当前对香港机房的接近100台物理机(香港服务器)进行打折处理,30Mbps带宽,低至不到40美元/月,速度快,性价比高,跑绝大多数项目都是绰绰有余了。该款香港服务器自带启动、关闭、一键重装功能,正常工作日内30~60分钟交货(不包括非工作日)。 官方网站:https://licloud.io 特价香港物理服务器 CPU:e3-1230v2(4核心、8线程、3.3GH...

企鹅小屋:垃圾服务商有跑路风险,站长注意转移备份数据!

企鹅小屋:垃圾服务商有跑路风险!企鹅不允许你二次工单的,二次提交工单直接关服务器,再严重就封号,意思是你提交工单要小心,别因为提交工单被干了账号!前段时间,就有站长说企鹅小屋要跑路了,站长不太相信,本站平台已经为企鹅小屋推荐了几千元的业绩,CPS返利达182.67CNY。然后,站长通过企鹅小屋后台申请提现,提现申请至今已经有20几天,企鹅小屋也没有转账。然后,搞笑的一幕出现了:平台账号登录不上提示...

sources.list为你推荐
uctools新浪UC下载地址outlookexpress家里电脑老是弹出“outlook express”这个东西,怎么除去啊?什么是支付宝支付宝是什么internetexplorer无法打开Internet Explorer 打不开了360防火墙在哪里怎么查找到360防火墙在自己电脑里的位置?并且关闭掉面板flash中国保健养猪网猪场基本保健包括哪些方面?申请400电话申请400电话需要什么条件metinfoMetInfo跟织梦那个比较好?各自的优点跟缺点是什么,图文模块微信公众号底部推荐阅读,图文模块是怎么实现的
info域名注册 海外域名注册 3322动态域名注册 高防直连vps vmsnap3 一元域名 湖南服务器托管 777te linux服务器维护 umax120 吉林铁通 ca187 免费mysql数据库 yundun 架设邮件服务器 美国盐湖城 杭州电信宽带优惠 服务器防御 架设代理服务器 reboot 更多