pt-archiverã¨ã¯
- 大ããªãã¼ãã«ããä»ã®ãã¼ãã«ãããã¯ãã¡ã¤ã«ã«ã¬ã³ã¼ããã¢ã¼ã«ã¤ãããã®ã«ãã¼ã«
- whereå¥ã使ããæ½åºæ¡ä»¶ãè¨å®ã§ãã
- åºåãã¡ã¤ã«åã«DBã¹ãã¼ãåããã¼ãã«åãå¹´ææ¥æåç§ãå ¥ãããã
- æ½åºå¯¾è±¡ãã¼ã¿ãèªåçã«åé¤ãã(ããã©ã«ã)
ããã使ãç®çã¨ãã¦ã¯ä»¥ä¸ã ããã
OLTPã¯ã¨ãªã«å½±é¿ãä¸ãããã¨ãªãå¤ããã¼ã¿ãã¢ã¼ã«ã¤ããããã®ãã¼ã¿ãåããµã¼ããããã¯éããµã¼ãã®ä»ã®ãã¼ãã«ã«ä¿åããããããã¯LOAD DATA INFILEæã«é©ãããã©ã¼ãããã§ãã¡ã¤ã«ã«ä¿åãããã¨ã ã
yakst.com ãã
ãã¡ã®ä¼ç¤¾ã§ããä¸è¦ãªãã¼ã¿ãã©ãããï¼ãã¨ããè°é¡ãéå»ã«ãã£ã¦ã ãã¼ãã«åä½ã§ åããããã°ããããæ¹æ³ããããªã¼ãã¨æã£ã¦èª¿ã¹ã¦ã¿ãã
使ãæ¹
pt-archiver [ãªãã·ã§ã³] --source [DSN] --file "ãã¡ã¤ã«å" --where "æ¡ä»¶æ"
å¿ é ç³»ãªãã·ã§ã³
--source [DSN]
(h=ãã¹ãå å¾è¿°ã®è¨å®ãã¡ã¤ã«ã«æ¸ããªãä¸è¦) ,D=DBã¹ãã¼ãå,t=ãã¼ãã«å
--file "ãã¡ã¤ã«å"
ã¢ã¼ã«ã¤ãããå 容ãä¿åãããã¡ã¤ã«åã
ãã¡ã¤ã«åã«DBã¹ãã¼ãåããã¼ãã«åãå¹´ææ¥æåç§ãå ¥ãããã
%d Day of the month, numeric (01..31) %H Hour (00..23) %i Minutes, numeric (00..59) %m Month, numeric (01..12) %s Seconds (00..59) %Y Year, numeric, four digits %D Database name %t Table name
ãããªæãã§æ¸ãã
--file '/var/log/archive/%Y-%m-%d-%D_%t.txt'
ãã®ä¾ã ã¨/var/log/archive/2019-01-29-testdb_testtable.txt
ã¿ãããªãã¡ã¤ã«ãã§ããã¤ã¡ã¼ã¸ã
ã¡ãªã¿ã«ãªãã·ã§ã³ã§æ¥ç¶å ãã¹ãããã¼ããã¦ã¼ã¶ããã¹ã¯ã¼ããè¨å®ã§ããããè¨å®ãã¡ã¤ã«ã«æ¸ãè¾¼ããã¨ãå¯è½ã ã
pt-archiver.confã®ç·¨é
# touch /etc/percona-toolkit/pt-archiver.conf # vim /etc/percona-toolkit/pt-archiver.conf
pt-archiver.conf
user=xxxxx password=xxxxxxx host=xxxxxxx port=xxxx
â»å¯¾è±¡ã®MySQLãã¼ã¿ãã¼ã¹ã«æ¥ç¶ããã®ã«å¿ è¦ãªä»»æã®å¤ãå ¥ãã¦ãã
--where "æ¡ä»¶æ"
ã¢ã¼ã«ã¤ãããã¬ã³ã¼ãã®æ¡ä»¶ãæå®ããã æ¡ä»¶ãç¡ãå ´åã§ãwhereå¥ã¯å¿ é ãªã®ã§ãã®æã¯1=1ã¨ãæ¸ãã°ããã
ãã®ä»ã®ä¸»ãªãªãã·ã§ã³
--no-delete
ããã©ã«ãã§ã¯æ½åºå¯¾è±¡ãã¼ã¿ãåé¤ããã®ã§ãåé¤ããããªãå ´åã¯ã¤ãã
--no-check-charset
ããã©ã«ãã§ã¯ã¬ã³ã¼ãã¨ã¢ã¼ã«ã¤ããã¡ã¤ã«ã®æåã³ã¼ããã§ãã¯ãèµ°ãã®ã§ããã®ãªãã·ã§ã³ã§DBå´ã®æåã³ã¼ãã«ä½µããå½¢ã«ãã
--charset=æåã³ã¼ã
--charset=utf8ã¨ããããã«è¨å®ãã¦ãã¡ã¤ã«ã®æåã³ã¼ããæå®ãã --no-check-charset ã®å ´åãæ½åºå ãã¼ãã«ãutf8mb4ã ã¨ã¨ã©ã¼ã«ãªããã使ãã
--statistics
çµ±è¨æ å ±ã表示ããã
--dest
--file "ãã¡ã¤ã«å" ã§ãã¡ã¤ã«ã«ãã¼ã¿ãæ½åºã§ãããã--destã使ãã¨ä»ã®ãã¼ãã«ã«å¯¾ãã¦ãã®ãã¼ã¿ãç´æ¥å ¥ãããã¨ãã§ãã ã¤ã¡ã¼ã¸ã¯ä»¥ä¸ã®éã
--dest h=ãã¹ãå,P=ãã¼ãçªå·,D=DBã¹ãã¼ãå,t=ãã¼ãã«å,u=ã¦ã¼ã¶,p=ãã¹ã¯ã¼ã
使ç¨æã®æ³¨æ
- PKãå¼µã£ã¦ãªããã¼ãã«ã«ã¯ä½¿ããªã
- utf8mb4ã«ãã¾ã対å¿ã§ãã¦ããªãã®ã§ä½¿ããªã(--no-check-charsetã ã¨2ãã¤ãæåãæååããã--charset=utf8ã ã¨ãã¼ãã«ã¯utf8mb4ã ï¼ã¨æãâè©°ãã§ã)
- åç´ãªãã¼ã¿æ½åºã«ã¯åãã¦ãªã(--no-deleteãä»ããå¿ è¦ããããããã©ã«ããåé¤ããã¨ããã®ã¯å±éº)
å人çãªææ³
- --source [DSN] ã§DBã¹ãã¼ãåã¨ããã¼ãã«åãLIKEã¨ãæå®ç¡ãã¨ãããã¨ãããªãã»ã»ã»ã
- MySQL8ã¯utf8mb4ãããã©ã«ãã ãããç´ã£ã¦ã»ããã
- --no-deleteãããªãã¦deleteããªãã·ã§ã³ã«ãªã£ã¦ã»ããã(ã¡ããã¨ç¥ããªããã¤ã使ãã¨äºæ ã®å )
触ãå§ãã¯ãé¢ç½ããï¼ãã¨æã£ã¦ããã ããããªãããããªãã¼ã«ã ãã³ã¬ã»ã»ã»ã