Percona Cloud Tools for MySQL 介紹及安裝

percona

Percona 去年推出一套 Cloud Tools for MySQL,藉由這套雲端服務可以幫忙分析 MySQL 系統內全部 Slow Query,並且計算出時間,畫出統計圖,此套系統目前還在 Beta 版,並且有些限制,只能開 3 個 organizations,每個 organizations 只能有 5 agents,最後資料只會保留 8 天,超過就會清除。這套系統後端是由 GO Language 完成,前端則是由 AngularJS 串起來,上個月 Percona 還在 MySQL Performance Blog 徵求 GO 的開發者,可見 Percona 也看好此服務,大膽使用 Google 推的 GO Language。

Percona Cloud Tools 由三個部份組成,分別是

Slow log filesPercona ToolkitPercona CloudSlow log files 就是系統要將 slow query 紀錄到檔案,經由 Percona Toolkit 將檔案分析好,最後透過 https 上傳到 Percona Cloud。所底下安裝就是這三個部份。

安裝方式

CentOS 安裝方式如下:

$ yum install percona-toolkit perl-JSON

請用 Google 帳號登入 https://cloud.percona.com/ 取得 API Key,畫面如下

Percona Cloud Tools 2014-03-06 15-42-34

接著用 pt-agent 指令安裝 Daemon

$ pt-agent --install --user={mysql username} --password={password} --api-key={API Key copied from web site}

也可以簡化成

$ pt-agent --install

執行後可以看到底下結果

$ pt-agent --install
Step 1 of 12: Verify the user is root: OK
Step 2 of 12: Check Perl module dependencies: OK
Step 3 of 12: Check for crontab: OK
Step 4 of 12: Verify pt-agent is not installed: OK
Step 5 of 12: Verify the API key:
Enter your API key: 631f9cc0c54a41248300cbc16a047ad6
Step 5 of 12: Verify the API key: OK
Step 6 of 12: Connect to MySQL: OK
Step 7 of 12: Check if MySQL is a slave: NO
Step 8 of 12: Create a MySQL user for the agent: OK
Step 9 of 12: Initialize /etc/percona/agent/my.cnf: OK
Step 10 of 12: Initialize /root/.pt-agent.conf: OK
Step 11 of 12: Create the agent: OK
Step 12 of 12: Run the agent: pt-agent has daemonized and is running as PID 22791:

–lib /var/lib/pt-agent –log /var/log/pt-agent.log –pid /var/run/pt-agent.pid

These values can change if a different configuration is received. OK INSTALLATION COMPLETE The agent has been installed and started, but it is not running any services yet. Go to https://cloud.percona.com/agents#xxx to enable services for the agent.

最後到 cloud.percona 看執行結果,就算大功告成了,只要等個半小時就會有資料進來了

Percona Cloud Tools 2014-03-06 15-47-13

Percona Cloud 成功收到資料就會變成綠色標記

Percona Cloud Tools 2014-03-06 15-50-39

點選 Report 可以看到執行效率很慢的 Query 結果

Percona Cloud Tools 2014-03-06 15-52-04


See also