PipelineDBã¯ã人æ°ãé«ãŸã£ãŠããã¹ããªãŒãã³ã°DBMSã®å®è£ ã®1ã€ã§ãã çŸåšãããŸããŸãªãªãœãŒã¹ã«é¢ããããŸããŸãªã±ãŒã¹ã§ã®ã¹ããªãŒãã³ã°DBMSã®å©ç¹ã«ã€ããŠèªãããšãã§ããŸãã éåžžã«ç°¡åã«ã圌ãã®ä»äºã®åçã¯ããŠã§ããµã€ãwww.pipelinedb.comã®ãä»çµã¿ãã»ã¯ã·ã§ã³ã§èŠèŠåãããŠããŸãã
å ·äœçã«ã¯ãPipelineDBã¯è¿œå æ©èœãåããPostgreSQLã®ãã©ãŒã¯ã§ãããéçŽãããããŒã¿ã®ã¿ãæ ŒçŽããçä¿¡ã¹ããªãŒã ïŒãã®ã¿ã€ãã®DBMSã®ååïŒãããã®å Žã§ãã«ã¿ãèšç®ã§ããŸãã ãã®ããŒã¿ã¯ãé£ç¶ãã¥ãŒãšåŒã°ããç¹å¥ãªPipelineDBãªããžã§ã¯ãã«ä¿åãããŸãã æãåçŽãªå Žåã®ã¹ããªãŒã èªäœã¯ãåãããŒã¿ããŒã¹ã«æ ŒçŽãããŠããéåžžã®ããŒãã«ãã圢æãããŸãã ãã®ããŒã«ã䜿çšãããšãã¬ããŒãã·ã¹ãã ã®ããŒã¿ãæºåããéã«ETLã¬ã€ã€ãŒãäœæããã³ç¶æããå¿ èŠããªããªããå€ãã®æéãšç¥çµãç¯çŽã§ããŸãã ããããç§ã¯ããªãããããèªãã§ããã®ã§ãããªãã¯ãã§ã«ãã®ããšã«ã€ããŠäœããç¥ã£ãŠãããšä¿¡ããŠããŸãã
PostgreSQL DBMSããŒãžã§ã³9.4以éãæ¢ã«è£œåç°å¢ã§å®è¡ãããŠããã±ãŒã¹ãèŠãŠã¿ãŸããããè€æ°ã®éãSELECTã¯ãšãªããã¡ã€ã³ããŒã¿ããŒã¹ã解æŸããããã«ããã®ãªã¢ã«ã¿ã€ã ïŒãŸãã¯ã»ãŒãªã¢ã«ã¿ã€ã ïŒã¬ããªã«ãååŸããå¿ èŠããããŸããããšãã°ãã¬ããŒãã·ã¹ãã ãDWHããŸãã¯ããŒã¿ããŒããªã©ã§ãã ãŸããåé¡ã調æ»ããåŸãã¹ããªãŒãã³ã°DBMSããŸãã«ãã®ãããªã¿ã¹ã¯ã«éåžžã«é©ããŠãããã®ã決å®ã§ããŸãã
ããããããã«åé¡ããããŸã-ã©ã®ã¬ããªã±ãŒã·ã§ã³ã¡ã«ããºã ã䜿çšããå¿ èŠããããŸããïŒ ãã®åé¡ãããã«èª¿æ»ããçµæãPostgreSQLããŒãžã§ã³9.0ã§ç»å Žãã絶ããé²åããŠããçŽ æŽãããçµã¿èŸŒã¿PostgreSQLéåæïŒç©çïŒã¬ããªã±ãŒã·ã§ã³ã¡ã«ããºã ã¯ããã®å¶éã®ããã«é©åã§ã¯ãªããšããçµè«ã«éããŸããã
aïŒãã¹ã¿ãŒãšã¬ããªã«ã¯PostgreSQLã®åãã¡ãžã£ãŒããŒãžã§ã³ãæã¡ãå¯èœã§ããã°åäžã®ããŒããŠã§ã¢ã§ã¹ãã³ããå¿ èŠããããŸã
bïŒã¬ããªã«ã¯èªã¿åãå°çšã§ããããããã¹ã¿ã³ãã€ãã¢ãŒãã§åäœããŸã
cïŒç©çã¬ããªã±ãŒã·ã§ã³ã䜿çšããå Žåãå®å šãªã1察1ãã®ãã¹ã¿ãŒã¬ããªã«ããæãŠãŸããã
ç§ã®å Žåãæåã®å¶éã«ãããPipelineDBã§Postgre 9.6ãå®è¡ããŠãããã¹ã¿ãŒãµãŒããŒã®ã¬ããªã«ãäœæã§ããŸããã ç§ã䜿çšããPipelineDBã®ææ°ããŒãžã§ã³ã䜿çšãããŠããPostgreã®ããŒãžã§ã³ã¯ããã¹ãã³ãªããããã9.5ã®ã¿ã§ããã ãã¹ã¿ãŒãPostgre 9.5ãå®è¡ããŠããå Žåããã®ãããªããªãã¯ãè©Šãããšãã§ããŸããããã¹ã¿ãŒãµãŒããŒãPipelineDBãæ¬æ Œçãªåçã®PostgreSQLãšããŠèªèããªãå¯èœæ§ãé«ããªããŸã-ç©çã¬ããªã±ãŒã·ã§ã³ã¡ã«ããºã ã¯ãã®ç¹ã§éåžžã«æ°ãŸããã§ãã
2çªç®ã®å¶éã¯ããéèŠã§ãã ãã§ã«ããã£ãããã«ãPipelineDBã¯ãã®ããŒã¿ãããŒã¿ããŒã¹ã«æžã蟌ã¿ãŸãã å°ãªããšãããããã¯é£ç¶çãªãã¥ãŒã§ãããç§ãã¡ã¯åœŒãæ··ä¹±ãããŸããã ãããã2çªç®ã®å¶éã«ãããã¬ããªã«ã¯ãã¹ã¿ãŒããŒã¿ããŒã¹ã®å®å šãªã³ããŒïŒ1察1ïŒã«ããæžã蟌ã¿ã§ããŸããã ãŸã£ããç§ãã¡ã«åããªããã®ã
ãããã£ãŠãç©ççãªè€è£œã¯ç§ãã¡ã«åããªãã®ã§ãè«ççãªè€è£œã«ç®ãåããå¿ èŠãããããšãç解ããŠããŸãã ãã®æ¬ é¥ããªãããã§ã¯ãããŸãããããããã®2ã€ã®å¶éãå®å šã«æé€ããŸãã
aïŒè«çè€è£œã«ããããã¹ã¿ãŒãšã¹ã¬ãŒãã§ããŸããŸãªããŒãžã§ã³ã®DBMSãæäœã§ããŸã
bïŒè«çã¬ããªã±ãŒã·ã§ã³ã«ããããã¹ã¿ãŒã®ãã¹ãŠã®ããŒã¿ã§ã¯ãªããå¿ èŠãªããŒã¿ã®ã¿ã®ã¬ããªã«ã1察1ã§äœæã§ããæžã蟌ã¿ã¹ã¬ãŒãããããã¯ããŸãã
ãããŠãç§ãã¡ã®åã«å¯èœæ§ã®æµ·ãåºãããŸãã
è«çè€è£œãäœæããããã®ããŸããŸãªããŒã«ã®ãªã¹ããšãè€è£œèªäœã®ããŸããŸãªæ¹æ³ã«åããŠæ £ãããšãæåã«çãã欲æ±ã¯ãã¢ã¯ãã£ããã£ã®çš®é¡ãå€æŽãã欲æ±ã§ãã ããããæåã®è¡æã¯éãå»ããç§ãã¡ã¯ãã®æµ·ããã®å€¢ã®éå ·ã®ãã¹ãã«ãµããããåè£è ãèŠã€ãå§ããŸãã
postgresql.leopard.in.ua/html/#replicationãå«ããåé¡ãšã¬ããªã±ãŒã·ã§ã³ããã³ãã®ãŠãŒãã£ãªãã£ãååã«æ€èšãããŠããåªããèšäº
ããã«äœ¿çšãããæã人æ°ã®ããããŒã«ã®1ã€ã¯ãslonyïŒããªã¬ãŒããŒã¹ïŒãšpgpool / pgpool-IIïŒããã«ãŠã§ã¢ïŒã§ãã
éåžžã«æåã§äººæ°ã®ããSlonyãŠãŒãã£ãªãã£ããŒãžã§ã³2.2.5ã䜿çšããŠãã®åé¡ã解決ããããšãããšã2é±éã§æåããŸããã§ãã-æŠå¿µå®èšŒãšãã¹ã¿ãŒãšã¬ããªã«ã®ç®çã§åãããŒãžã§ã³ã®PostgreSQLãå®è¡ããŠããŠãã slonyããŒã¢ã³ã¯ãã»ã°ã¡ã³ããŒã·ã§ã³ãã©ãŒã«ãã®ããã«ãèµ·åæã«ããã«èµ·åããããã«åèµ·åããããšãæã¿ãŸããã§ããããã®åå ã¯èŠã€ãããŸããã§ããã ãããŠããµãŒãããŒãã£è£œãœãããŠã§ã¢ã®ã»ã°ã¡ã³ããŒã·ã§ã³éåã®åå ãæ¢ãããšã¯æ©ç¥ããã§ãã ããã«ããœãŒã¹ã³ãŒããããã®ãŠãŒãã£ãªãã£ãã³ã³ãã€ã«ãããšããããã³ãã€ãã£ãã®Alpine Linuxãªããžããªããã€ã³ã¹ããŒã«ãããšãã«ãåãç¶æ³ã芳å¯ãããŸããã
ãã®å®éšã¯ã次ã®å ¥åããŒã¿ã䜿çšããŠå®æœãããŸããã
-ããã«ãŒã³ã³ãã
-ãã¹ã¿ãŒãšã¹ã¬ãŒãã®äž¡æ¹ïŒ Alpine Linuxã®postgre 9.6
åææ¡ä»¶èªäœã倱æãåŒãèµ·ãããå¯èœæ§ããããŸã-DockerãŸãã¯ãã®Linuxãã£ã¹ããªãã¥ãŒã·ã§ã³ã®äœ¿çš-ç§ã®å Žåããããã¯ã²ãŒã ã®ã«ãŒã«ã§ããã ãŸããç§ã䜿çšããææ°ããŒãžã§ã³ã®Slonyèªäœã®äžå®å®æ§ã«åé¡ãé ããŠããå¯èœæ§ãããããšãèªããŠããŸãã ãããã«ããããã®ãœãªã¥ãŒã·ã§ã³ã¯æ©èœãããSlonyã¯å»æ¢ãããŸããã ãããããç°ãªãã·ã¹ãã æ§æãŸãã¯ç°ãªãããŒãžã§ã³ã®Slonyã§æåããã§ãããã
ãã ãããã®èšäºãããã«èªãã åŸã¯ããã®å€ä»£ã®ãŠãŒãã£ãªãã£ã«çªå ¥ããããªããããããŸããã ãããå¿ããªãã§ãã ããïŒ howfuckedismydatabase.com/postgres/slony.php
éäžã§2çªç®ã®pgpoolãŠãŒãã£ãªãã£ã«ãã©ãçããŸããã§ããã ãªããªã ãæçµçã«ç§ã®ãœãªã¥ãŒã·ã§ã³ã«ãªã£ããã®ãèŠã€ããããã§ãïŒ 2ndQuadrantã®pglogicalãŠãŒãã£ãªãã£ã
ãŠãŒãã£ãªãã£ã®ããã¥ã¡ã³ããèªãã§ã2ndQuadrantã誰ã§ããããç¥ã£ãŠãããã«ãã®æ±ºå®ãäžããŸããã å°æ¥çã«ã¯ãæããã«ããã®ãœãªã¥ãŒã·ã§ã³ã¯è«çã¬ããªã±ãŒã·ã§ã³ã®æšæºãœãªã¥ãŒã·ã§ã³ãšããŠãPostgreSQLã®ä»åŸã®ããŒãžã§ã³10ã«å ¥ãããšãã§ãããšæãããŸãã ããã§ãpgpoolã調æ»ã®ããã«äžŠã¹ãŠåããããšã§åœŒãšéã¶ããšã«ããŸããã
æŠå¿µå®èšŒæ®µéããã€ãã¹ããŠãåŸã§å®çšŒåã«éä¿¡ãããããšã«ãªã£ãŠããã³ã³ããŒãã³ãäžã§ã·ã¹ãã ãããã«æ§ç¯ããããšã«ããŸããã
ãã¹ã¿ãŒïŒæåã®ã±ãŒã¹ãšåãã€ã¡ãŒãžã®dockerã³ã³ãããŒ
åèïŒ å¥ã®ç»åã® PipelineDB Dockerã³ã³ããããã®ãããžã§ã¯ãã®å ¬åŒç»åã®ããã§ãããå¥åŠãªæ¹æ³ã§è£ 食ãããŠããŸãã ã€ã¡ãŒãžã¯ãAlpineã§ã¯ãªãDebianãã£ã¹ããªãã¥ãŒã·ã§ã³ã«åºã¥ããŠããŸãã
ããã§ãpglogicalãæãå§ããŸããã ã»ãŒããã«ãç§ã¯ã²ã©ã倱æããŸãããAPTãªããžããªã§ã¯ããã®ãŠãŒãã£ãªãã£ã¯PostgreSQLããŒãžã§ã³9.4ã9.5ãããã³9.6ã«ã®ã¿ååšããPipelineDBã®èãã¯ããŸããã ãŠãŒãã£ãªãã£ã¯ãPipelineDBã®ãããã¹ããžã®ã€ã³ã¹ããŒã«ãå®å šã«æåŠããäŸåé¢ä¿ãæºããããŠããªãpostgresql-9.5ãå ±åããŸããã T.O. çŽ æŽãããå®éšã¯æ¬è³ªçã«éå§ããããšãªãçµäºããŸããã
ããããPipelineDBãåãPostgreSQLã§ãããšããèªèïŒããŒã¿ããŒã¹ãã£ã¬ã¯ããªãæ§æãã¡ã€ã«ãçµã¿èŸŒã¿ã³ãã³ããããã³ãµãŒãã¹ãŠãŒãã£ãªãã£ã®æ§é ïŒããã®ããšãæ確ã«èšŒæããŸããã ãããŠãã¡ãã£ãšããããªãã¯ã決ããŸããã
pglogicalãŠãŒãã£ãªãã£ã¯ã次ã®ããã«PipelineDBã䜿çšããŠãã¹ãã«ã€ã³ã¹ããŒã«ãããŸãïŒãã¹ãŠãã«ãŒãã®äžã®dockerã³ã³ããã§è¡ãããŸããïŒã
ãªããžããªãè¿œå ãããŠãŒãã£ãªãã£ããã±ãŒãžãããŠã³ããŒãããŸãã
echo "deb [arch=amd64] http://packages.2ndquadrant.com/pglogical/apt/ jessie-2ndquadrant main" > /etc/apt/sources.list.d/2ndquadrant.list wget --quiet -O - http://packages.2ndquadrant.com/pglogical/apt/AA7A6805.asc | apt-key add - apt-get update && apt-get download libpq5 postgresql-9.5-pglogical
äŸåé¢ä¿ãç¡èŠããŠå¿ èŠãªã©ã€ãã©ãªãšããã±ãŒãžèªäœãã€ã³ã¹ããŒã«ããŸãïŒïŒïŒãPostgre以å€ã«ã€ã³ã¹ããŒã«ãããŠãŒãã£ãªãã£ã®äžæ¬æã®åé¡ã解決ããŸãã
dpkg -i --ignore-depends=postgresql-9.5 libpq5_9.4.10-0+deb8u1_amd64.deb dpkg -i --ignore-depends=postgresql-9.5 postgresql-9.5-pglogical_1.2.2-1jessie_amd64.deb
ãã¡ã€ã«/ var / lib / dpkg / statusããäŸåé¢ä¿ãšã³ããªãåé€ããŸããããã«ããããããªãapt-getæäœäžã«ãæ€åºãããªãäŸåé¢ä¿ãèªãããpglogicalã®åé€ãæäŸããŸããã
sed 's/, postgresql-9.5//g' /var/lib/dpkg/status > /var/lib/dpkg/status-new && \ mv /var/lib/dpkg/status /var/lib/dpkg/status.bkp && \ mv /var/lib/dpkg/status-new /var/lib/dpkg/status
以äžã§ãïŒ ãŠãŒãã£ãªãã£ã¯ãPipelineDBãšãšãã«ãã¹ãã«ã€ã³ã¹ããŒã«ãããŸãã ããããããã§ãäžéã§ã-ãŠãŒãã£ãªãã£ã¯postgresqlãšããååã®ãã©ã«ããŒã«ã€ã³ã¹ããŒã«ãããPipelineDBã¯åæ§ã®ãã©ã«ããŒæ§é ãæã¡ãŸãããååã¯pipelinedbã§ãã ããŠãããã«ã€ããŠæ°ã«ããã«ããŠãŒãã£ãªãã£ãã¡ã€ã«ãæ¢ã«PipelineDBã®é©åãªãã©ã«ããŒã«ç§»åããŠã¿ãŸãããã
mv /usr/lib/postgresql/9.5/lib/* /usr/lib/pipelinedb/lib/pipelinedb/ mv /usr/lib/postgresql/9.5/bin/* /usr/lib/pipelinedb/bin/ mv /usr/share/postgresql/9.5/extension/* /usr/lib/pipelinedb/share/pipelinedb/extension/
以äžã§ãã pglogicalãŠãŒãã£ãªãã£ãã€ã³ã¹ããŒã«ãããPipelineDBãåãã皌åäžã®ãµãŒããŒãããã䜿çšãéå§ã§ããŸãã
ãã¹ã¿ãŒã¹ã¬ãŒãã¯ã©ã¹ã¿ãŒã®çãã»ããã¢ããïŒéåžžã®PostgreSQLãšåæ§ã«PipelineDBã¬ããªã«ãæ§æããŸãïŒã®èª¬æã¯ãPostgreã®ããã¥ã¡ã³ããå«ãçŸäžã®ãªãœãŒã¹ã§èª¬æãããŠããããŠãŒãã£ãªãã£èªäœãæ§æããç°¡åãªæé ãå®è¡ããåŸãã¬ããªã±ãŒã·ã§ã³ãæ©èœããããšã確èªã§ããŸãã
UPDïŒDockerã®æ§æããã³åæåã¹ã¯ãªããã®ãœãŒã¹ã¯ã https ïŒ //github.com/akrymets/pg-replicationã«ãããŸãã
ã¹ããŒãªãŒã®æ¬è³ªãšææ¡ã«ã€ããŠã®ã³ã¡ã³ãããåŸ ã¡ããŠãããŸãã æé«ã®ãªãã¡ãŒã¯ãèšäºã®ç·šéãšããŠå®è£ ãããŸãã