您的位置:首页 > 其它

MonetDB用户指南4——(资源)Dump and restore

2013-10-23 14:22 288 查看
AnSQLdumpofadatabaseisacommonmethodtosafelystoreawayasnapshotofthedatabaseforarchivalpurposesortomigratedatabetweendatabaseinstances,e.g.betweentwomajorsystemreleases.ThecontentofaSQLdumpisalargecollectionofSQL
commandsinASCII.Runningthescriptwillrecreatethedatabaseinthesamestateasitwaswhenthedumpwascreated.SinceMonetDBdoesnotprovidegloballockingschemes,atime-consumingdumpoperationmaybecomeinvalidatedbyaconcurrentupdatequery.

TheprimarytooltoconsiderformakinganASCIIdumpis
msqldump,whichincludesawidevarietyofoptions.Asimplifiedversionisavailableaspartofthemclientprogram.

SQL转储是对数据库镜像或者迁移的常用的方法。如在两个版本之间。SQLdump是ASCII编码的SQL的集合。执行这些脚本,可以重新创建一样的数据库。MonetDB不提供全局锁,并发情况下这个转储可能无效。

Linuxplatforms

Linux平台

ConsideryouhavealreadyinstalledtheSQLtutorialdatabase
vocandwishtotransportittoanothermachine.Thenthefollowingclientcommandlineoptiongeneratesthedumpfile.

缺人安装了示例VOC库,并且希望迁移到另外一台机器。下面的客户端命令产生一个dump文件。

shell>mclient-lsql--database=voc--dump>/tmp/voc.sql
Youcaninspectthefile/tmp/voc.sqltoconfirmthatindeedareadabledatabasedumpisavailable.Ifstoragespaceisaproblem,youcanreadilypipetheoutputofthiscommandtoacompressiontoolorsentitdirectlytoanother
machineinyourenvironmentusingconventionalLinuxtools.Asabaseline,movethefileovertothenewmachine.Themonetdbtoolcan
beusedtocreatethedatabaseonthatmachine.Oncedone,itsufficestofeedthedumpfiletomclienttopopulatethedatabase.

可以检察/tmp/voc.sql,确认它是可读的。如果空间是问题,可以用管道把输出给一个压缩工具,或者使用linux工具直接发送到另外一台机器,移动数据文件到新机器。MonetDB可以用于创建数据库。

Creationofthedumprespectsyourcredentials,whichmeansyouonlycandumpthetablesyouhaveaccessto.

shell>mclient-lsql--database=voc/tmp/voc.sql
Migrationofadatabasefromothersystemfollowsthesameroute,butbeawarethatSQLdialectsoftendiffer.AmanualorscriptedpatchofaforeignSQLdumpisoftenneeded.

在不同的操作系统,dump方法类似,只是SQL方言经常不一样。

FastbackupsonLinux

AsidefromtheASCIIdumps,onecanalsotakethedatabaseserveroutofproductionusingcommands

shell>monetdbstopdemo

shell>monetdblockdemo
Afterthedatabasehasbeensecurelystopped,wecancreateacopyofthedatabasedirectoryinthedbfarmandputitasideinasafeplace.Alternatively,incrementalfile-systemdumpscanbeusedtoreducethetimeandstoragespaceforarecoverypoint.
Finally,thedatabaseisreleasedforproductionagain
.Bewarethattakingasystemoutofproductionshouldbefollowedbyensuringthatallrunningquerieshavefinished.Thiscanbeinspectedusingthesystem
monitor.

shell>monetdbreleasedemo

Windowsplatforms

ItisrecommendedtoalwaysdumptheolddatabaseintoASCIIbeforeinstallinganewMonetDBrelease.Subsequentlyremovethedbfarm.Afterinstallation,thedumpcanberestored.

TodumptheSQLdatabase,starttheMonetDBSQLClientprogramandtypethecommand

\>...\databasedump.sql

\D

\>
Thepathafter\>shouldbeanabsolutepathname(i.e.startwithadriveletter)andbeinasavelocation.Bydefaultthedatabaseislocatedin
%APPDATA%\MonetDB5
.Afterhavingmadeadatabasedumpitcanberemoved.Thisfolderislocated
insidethedbfarm\demofolder.

RestoringtheSQLdatabasecanbedoneusingtheMonetDBSQLClientprogramwiththefollowingcommand

\<...\databasedump.sql
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: