Contents
MySQL Enterprise (有償版, 商用版, Commercial) のインストール手順について記します。MySQLには無償(Community)版と有償(Commercial)版が存在します。私がセミナー参加などで受けた印象ですが、以下の機能が無償版に比べて強化されている印象でした。
- グラフィカルインターフェース ( GUI ) による管理機能
- FISC, NISC, PCIDSS等で定義されたセキュリティ/監査機能
「セキュリティ/監査機能が必要である」「運用メンバーの学習コストを抑えたい」「でも、Oracleはライセンス料が高すぎて払えない」・・・。そんな要件ならば、商用版MySQLを検討する価値もあるかと思います。
なお、無償版(Community版)のMySQLについては、以下を参照ください。
MySQL Enterprise について
MySQL Enterpriseのライセンス体系
MySQLには無償(Community)版と有償(Commercial)版が存在します。有償版を使用する事によって、以下のようなメリットを享受する事ができます。
- MySQLソースコード解析ができるレベルの超有名エンジニアからのサポートが受けられるらしい ( Oracle のセミナーで聞いた限りでは・・・ )
- グラフィカルインターフェース ( GUI ) による管理機能
- FISC, NISC, PCIDSS等で定義されたセキュリティ/監査機能
- 一部機能の性能改善 ( 例 : thread pool, 並列処理のmysqldumpなど )
有償版はさらに、Standard Edition, Enterprise Edition, Cluster Carrier Grade Editionの3つのエディションに分類されます。機能体系は比較的Oracleに近く、パーティショニングをしたい場合はEnterprise Editionの購入が必要となります。
MySQL Enterpriseの機能
MySQL Enterpriseは管理機能が非常に充実しております。もちろん、SHOW ENGINE INNODB STATUS, SHOW SLAVE STATUS, information_schemaを使いこなせるエンジニアには管理機能は不要かもしれませんが、管理コマンドを使いこなせない人(いわゆるオペレータ) を多く抱える会社や社内人件費が高い会社にとっては魅力的な機能かと思います。
MySQL Enterpriseはデータベース本体以外に、以下のような管理機能を提供する周辺ソフトウェアが存在します。
- MySQL Enterprise Monitor
- Oracle Enterprise Manager for MySQL Database
- MySQL Enterprise Backup ( 旧名 : Innodb Hot Backup )
- MySQL Enterprise Security
- MySQL Enterprise Encryption
- MySQL Enterprise Audit
- MySQL Thread Pool
MySQL Enterpriseのダウンロード
MySQL公式サイト(dev.mysql.com)にアクセスし、Downloads, Enterpriseの順に押下します。
画面を下の方にスクロールさせ、Oracle eDeliveryへのリンクを押下します。
Oracle edeliveryの画面で、「Sign In」を押下します。
Oracleのアカウント情報を入力して下さい。
なお、Oracleアカウントは誰でも作成する事ができます。また、検証目的の利用ならば、ライセンス費なしでMySQL Enterpriseを使用しても法律上の問題はございません(2015/01/11現在)。
ライセンスと輸出に関して同意した上で、Continueを押下します。
お使いのOSを選択し、Goを押下します。
“Download”を押下し、MySQL Databaseをダウンロードして下さい。
Enterprise Monitor, Enterprise Backupなど、MySQL Enterpriseに含まれるその他ソフトウェアもこの画面からダウンロードする事ができます。
MySQL Enterprise Database
MySQL Enterprise Databaseのインストール
ダウンロードしたzipファイルを適当なディレクトリに展開します。
1 |
# unzip V73603-01.zip |
zipファイルを展開すると、以下のようなファイルが作成されます。
1 2 3 4 5 6 7 8 9 10 11 |
[ec2-user@ip-172-31-11-1 MysqlEnterpriseDatabase]$ ls -lh total 222M -rw-rw-rw-. 1 ec2-user ec2-user 18M Nov 24 05:24 MySQL-client-advanced-5.6.22-1.el6.x86_64.rpm -rw-rw-rw-. 1 ec2-user ec2-user 3.2M Nov 24 05:24 MySQL-devel-advanced-5.6.22-1.el6.x86_64.rpm -rw-rw-rw-. 1 ec2-user ec2-user 85M Nov 24 05:25 MySQL-embedded-advanced-5.6.22-1.el6.x86_64.rpm -rw-rw-rw-. 1 ec2-user ec2-user 63M Nov 24 05:26 MySQL-server-advanced-5.6.22-1.el6.x86_64.rpm -rw-rw-rw-. 1 ec2-user ec2-user 2.0M Nov 24 05:26 MySQL-shared-advanced-5.6.22-1.el6.x86_64.rpm -rw-rw-rw-. 1 ec2-user ec2-user 3.8M Nov 24 05:26 MySQL-shared-compat-advanced-5.6.22-1.el6.x86_64.rpm -rw-rw-rw-. 1 ec2-user ec2-user 49M Nov 24 05:27 MySQL-test-advanced-5.6.22-1.el6.x86_64.rpm -rw-rw-rw-. 1 ec2-user ec2-user 19K Dec 1 11:55 README.txt [ec2-user@ip-172-31-11-1 MysqlEnterpriseDatabase]$ |
各パッケージのインストールを行います。各パッケージの意味や手順の意図については、MySQL インストール手順 Linuxの場合を参照ください。
まず、mysql-libsの互換性パッケージをインストールします。
1 |
# rpm -ihv MySQL-shared-compat-advanced-5.6.22-1.el6.x86_64.rpm |
mysql-libsを削除します。crontab, sysstatなどのmysql-libs依存のパッケージも含めてアンインストールされていない事を確認します。
もし、同時にアンインストールれてしまった場合は、互換性パッケージ(MySQL-shared-compat-advanced)のインストール漏れが疑われます。
1 2 3 |
[root@ip-172-31-11-1 ~]# rpm -e mysql-libs warning: /etc/my.cnf saved as /etc/my.cnf.rpmsave [root@ip-172-31-11-1 ~]# |
その他のMySQL関連のパッケージをインストールします。
1 2 3 4 5 |
# rpm -ihv \ MySQL-client-advanced-5.6.22-1.el6.x86_64.rpm \ MySQL-devel-advanced-5.6.22-1.el6.x86_64.rpm \ MySQL-server-advanced-5.6.22-1.el6.x86_64.rpm \ MySQL-shared-compat-advanced-5.6.22-1.el6.x86_64.rpm |
MySQL Enterprise Databaseの起動/接続
起動スクリプトを用いてMySQLを起動します。
1 |
# /etc/init.d/mysql start |
もし、起動に失敗した場合は以下のように表示されます。
1 2 3 |
[root@ip-172-31-11-1 ~]# /etc/init.d/mysql start Starting MySQL..The server quit without updating PID file (/var/lib/mysql/ip-172-31-11-1.ap-northeast-1.compute.internal.pid). [FAILED] [root@ip-172-31-11-1 ~]# |
起動に失敗した場合はエラーログを参照して下さい。エラーログは/etc/my.cnfのlog_errorで指定したパスに存在します。my.cnfが存在しない、またはlog_errorの指定がない場合は、/var/lib/mysql配下にホスト名でエラーログのファイルが作成されます。
例えば以下のようなエラーログの場合は、”InnoDB: Cannot allocate memory for the buffer pool”と出力されているのでメモリ不足を表しています。AWS t1.microを使用する場合は、MySQLのデフォルト設定ではメモリ不足が起きてしまうので、innodb_buffer_pool_size, innodb_log_buffer_sizeをデフォルト値よりも小さくしなければなりません。
なお、起動時のエラーは環境により異なりますので、エラーログの具体的な読み方については説明を省略します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
[root@ip-172-31-11-1 ~]# head -n 20 /var/lib/mysql/ip-172-31-11-1.ap-northeast-1 .compute.internal.err <omitted> 2015-01-11 02:06:16 2191 [Note] InnoDB: Using CPU crc32 instructions 2015-01-11 02:06:16 2191 [Note] InnoDB: Initializing buffer pool, size = 128.0M InnoDB: mmap(137363456 bytes) failed; errno 12 2015-01-11 02:06:16 2191 [ERROR] InnoDB: Cannot allocate memory for the buffer pool 2015-01-11 02:06:16 2191 [ERROR] Plugin 'InnoDB' init function returned error. 2015-01-11 02:06:16 2191 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 2015-01-11 02:06:16 2191 [ERROR] Unknown/unsupported storage engine: InnoDB 2015-01-11 02:06:16 2191 [ERROR] Aborting 2015-01-11 02:06:16 2191 [Note] Binlog end 2015-01-11 02:06:16 2191 [Note] Shutting down plugin 'partition' |
MySQLの起動に成功しましたら、rootユーザのパスワードを確認します。rootユーザのパスワードは~/.mysql_secretに格納されています。
1 2 3 4 |
[root@ip-172-31-11-1 ~]# cat .mysql_secret # The random password set for the root user at Sun Jan 11 01:59:46 2015 (local time): aMa0rDzbRapbRC3R [root@ip-172-31-11-1 ~]# |
確認したパスワードを用いてMySQLに接続できる事を確認します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
[root@ip-172-31-11-1 ~]# mysql -uroot -paMa0rDzbRapbRC3R Warning: Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.6.22-enterprise-commercial-advanced-log Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> |
MySQL Enterprise Backup
MySQL Enterprise Backup 概要
MySQLの無償版で使用できるバックアップ手法は、大きく分けて以下の2つです。
- mysqldump によるファイルバックアップ
- ファイルコピーによるバックアップ ( scp, rsync, LVM snapshotなど )
「mysqldumpによるバックアップ」はデータをSQL文に変換する処理であるため、大量データのバックアップは非常に時間がかかります。一方、「ファイルコピーによるバックアップ」は高速であるものの、まだデータベースに書き込まれていない中途半端なデータ(トランザクション単位に満たないデータ)も含めてバックアップされるます。そのため、リストア時に中途半端なデータをロールバックするINNODB crash recoveryという待ち時間が長い処理が実行されます。
どちらの処理も一長一短ですが、これら処理の良い所取りしたのが、Enterprise Backup (旧名 : Innodb Hot Backup)です。Enterprise Backupは、ファイルそのものもコピーするのと同時に、中途半端なデータのつじつまを合わせてくれる優れものです。 (正確な説明は省略します。興味のある方は、innodb_log_buffer_size, ib_logfile, LSNなどのキーワードを正確に抑えてから調査する事をお勧めします。)
MySQL Enterprise Backup のインストール
Enterprise Backupをダウンロードし、ダウンロードしたzipファイルを適当なディレクトリに展開します。
1 |
# unzip V59669-01.zip |
zipファイルを展開すると、以下のようなファイルが作成されます。
1 2 3 4 5 |
[root@ip-172-31-10-1 MysqlEnterpriseBackup]# ls -l total 2416 -rw-r--r--. 1 ec2-user ec2-user 2465804 Nov 5 08:32 meb-3.11.1-el6.x86_64.rpm -rw-r--r--. 1 ec2-user ec2-user 2130 Nov 5 15:06 README.txt [root@ip-172-31-10-1 MysqlEnterpriseBackup]# |
RPMファイルをインストールします。
1 |
# rpm -ihv meb-3.11.1-el6.x86_64.rpm |
mysqlbackupというファイルがEnterprise Backupの実行ファイルです。/opt/mysql/以下にmysqlbackupというファイルが作成されている事を確認します。
1 2 3 |
[root@ip-172-31-10-1 ~]# ls -l /opt/mysql/meb-3.11/bin/mysqlbackup -rwxr-xr-x. 1 root root 8393544 Nov 4 03:00 /opt/mysql/meb-3.11/bin/mysqlbackup [root@ip-172-31-10-1 ~]# |
MySQL Enterprise Backup のバックアップ実行例
Enterprise Backupは単純なFull Backupだけでなく、Incremental Backup, Compress Backupなど多数のバックアップ方法を提供します。全てのバックアップ方法を紹介すると説明が長くなりますので、ここではFull Backupの実行例を紹介します。
mysqlbackupに適当な引数を渡して実行します。ユーザ名, パスワード, 接続先ホスト, ソケットファイルなどの接続情報はmysqlコマンドと同様の引数を指定します。–backup-dirはバックアップファイルを保存するディレクトリです。最後の引数は、バックアップ方法の指定で、backup, backup-and-apply-log, backup-to-imageの3つから選べます。
1 2 3 4 |
# /opt/mysql/meb-3.11/bin/mysqlbackup \ -uroot --socket=/var/lib/mysql/mysql.sock \ --backup-dir=/tmp/backup \ backup-and-apply-log |
実行結果は以下のようになります。”mysqlbackup completed OK!”と出力される事を確認して下さい。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
[root@ip-172-31-10-1 ~]# /opt/mysql/meb-3.11/bin/mysqlbackup -uroot --socket=/va r/lib/mysql/mysql.sock --backup-dir=/tmp/backup backup-and-apply-log MySQL Enterprise Backup version 3.11.1 Linux-2.6.39-400.17.1.el6uek.x86_64-x86_64 [2014/11/04] Copyright (c) 2003, 2014, Oracle and/or its affiliates. All Rights Reserved. mysqlbackup: INFO: Starting with following command line ... /opt/mysql/meb-3.11/bin/mysqlbackup -uroot --socket=/var/lib/mysql/mysql.sock --backup-dir=/tmp/backup backup-and-apply-log mysqlbackup: INFO: mysqlbackup: INFO: MySQL server version is '5.6.22-enterprise-commercial-advanced-log'. mysqlbackup: INFO: Got some server configuration information from running server. IMPORTANT: Please check that mysqlbackup run completes successfully. At the end of a successful 'backup-and-apply-log' run mysqlbackup prints "mysqlbackup completed OK!". <omitted> ------------------------------------------------------------- Parameters Summary ------------------------------------------------------------- Start LSN : 186004992 End LSN : 186346766 ------------------------------------------------------------- mysqlbackup: INFO: Creating 14 buffers each of size 65536. 150112 01:40:12 mysqlbackup: INFO: Apply-log operation starts with following threads 1 read-threads 1 process-threads mysqlbackup: INFO: Using up to 100 MB of memory. 150112 01:40:12 mysqlbackup: INFO: ibbackup_logfile's creation parameters: start lsn 186004992, end lsn 186346766, start checkpoint 186005347. mysqlbackup: INFO: InnoDB: Starting an apply batch of log records to the database... InnoDB: Progress in percent: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 mysqlbackup: INFO: InnoDB: Setting log file size to 50331648 mysqlbackup: INFO: InnoDB: Setting log file size to 50331648 150112 01:40:15 mysqlbackup: INFO: We were able to parse ibbackup_logfile up to lsn 186346766. mysqlbackup: INFO: Last MySQL binlog file position 0 374388431, file name mysql-bin.000001:374388431 150112 01:40:15 mysqlbackup: INFO: The first data file is '/tmp/backup/datadir/ibdata1' and the new created log files are at '/tmp/backup/datadir' 150112 01:40:15 mysqlbackup: INFO: Apply-log operation completed successfully. 150112 01:40:15 mysqlbackup: INFO: Full backup prepared for recovery successfully. mysqlbackup completed OK! [root@ip-172-31-10-1 ~]# |
バックアップに関するファイルが作成された事を確認します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
[root@ip-172-31-10-1 ~]# ls -l /tmp/backup/ total 32 -rw-r--r--. 1 root root 245 Jan 12 01:39 backup-my.cnf drwx------. 16 root root 4096 Jan 12 01:40 datadir drwx------. 2 root root 4096 Jan 12 01:40 meta -rw-r--r--. 1 root root 12885 Jan 12 01:40 server-all.cnf -rw-r--r--. 1 root root 3557 Jan 12 01:40 server-my.cnf [root@ip-172-31-10-1 ~]# ls -l /tmp/backup/datadir/ total 542160 -rw-r--r--. 1 root root 342528 Jan 12 01:40 ibbackup_logfile -rw-r--r--. 1 root root 79691776 Jan 12 01:40 ibdata1 -rw-r-----. 1 root root 50331648 Jan 12 01:40 ib_logfile0 -rw-r-----. 1 root root 50331648 Jan 12 01:40 ib_logfile1 drwx------. 2 root root 4096 Jan 12 01:40 mem drwx------. 2 root root 4096 Jan 12 01:40 mem__advisors drwx------. 2 root root 4096 Jan 12 01:40 mem__advisor_text drwx------. 2 root root 4096 Jan 12 01:40 mem__bean_config drwx------. 2 root root 4096 Jan 12 01:40 mem__config drwx------. 2 root root 4096 Jan 12 01:40 mem__enterprise drwx------. 2 root root 4096 Jan 12 01:40 mem__events drwx------. 2 root root 16384 Jan 12 01:40 mem__instruments drwx------. 2 root root 4096 Jan 12 01:40 mem__instruments_config drwx------. 2 root root 12288 Jan 12 01:40 mem__inventory drwx------. 2 root root 4096 Jan 12 01:40 mem__quan drwx------. 2 root root 4096 Jan 12 01:40 mysql -rw-r--r--. 1 root root 374388431 Jan 12 01:40 mysql-bin.000001 -rw-r--r--. 1 root root 19 Jan 12 01:39 mysql-bin.index drwx------. 2 root root 4096 Jan 12 01:40 performance_schema drwx------. 2 root root 4096 Jan 12 01:39 test [root@ip-172-31-10-1 ~]# |
MySQL Enterprise Backup のリストア実行例
先ほど取得したバックアップをリストア先のサーバへ転送します。
1 |
# rsync -av -e ssh /tmp/backup 172.31.10.3:/tmp/ |
リストア先のサーバで、あらかじめmysqldを停止させておきます。
1 |
# /etc/init.d/mysql stop |
mysqlbackupコマンドに適当な引数を与えて実行します。マニュアルは誤植が目立ちますので、エラーメッセージを見つつ、適宜オプションを見つけて下さい。mysqlbackupに与える引数の意味は読んだままの意味ですので、説明を省略します。
1 2 3 4 |
# /opt/mysql/meb-3.11/bin/mysqlbackup \ --backup-dir=/tmp/backup/ \ --datadir=/var/lib/mysql \ copy-back-and-apply-log |
実行時のログは以下の通りです。”mysqlbackup completed OK”と表示される事を確認して下さい。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
[root@ip-172-31-10-3 ~]# /opt/mysql/meb-3.11/bin/mysqlbackup \ > --backup-dir=/tmp/backup/ \ > --datadir=/var/lib/mysql \ > copy-back-and-apply-log MySQL Enterprise Backup version 3.11.1 Linux-2.6.39-400.17.1.el6uek.x86_64-x86_64 [2014/11/04] Copyright (c) 2003, 2014, Oracle and/or its affiliates. All Rights Reserved. mysqlbackup: INFO: Starting with following command line ... /opt/mysql/meb-3.11/bin/mysqlbackup --backup-dir=/tmp/backup/ --datadir=/var/lib/mysql copy-back-and-apply-log mysqlbackup: INFO: IMPORTANT: Please check that mysqlbackup run completes successfully. At the end of a successful 'copy-back-and-apply-log' run mysqlbackup prints "mysqlbackup completed OK!". 150112 02:09:46 mysqlbackup: INFO: Copying the database directory 'test' 150112 02:09:46 mysqlbackup: INFO: Completing the copy of all non-innodb files. 150112 02:09:47 mysqlbackup: INFO: Apply-log operation has already been done on that backup. 150112 02:09:47 mysqlbackup: INFO: Creating server config files server-my.cnf and server-all.cnf in /var/lib/mysql 150112 02:09:47 mysqlbackup: INFO: Copy-back operation completed successfully. mysqlbackup completed OK! with 3 warnings [root@ip-172-31-10-3 ~]# |
MySQL Enterprise Monitor
MySQL Enterprise Monitorの概要
MySQL Enterprise Monitorは、MySQLの性能情報をグラフィカルに見せてくれるツールです。出力内容は”SHOW ENGINE INNODB STATUS”, “SHOW SLAVE STATUS”などと変わりませんが、グラフィカルで直観的な画面になっていますので、MySQLの知識がない人でも何となく状況を理解する事ができます。
MySQL Enterprise Monitorは、Server MonitorとMonitor Agentの2つで構成されます。以下、この2つのコンポーネントのインストール方法について説明します。
MySQL Enterprise Server Monitorのインストール
Server Monitor (Enterprise Monitor との表記揺れあり) をダウンロードし、zipファイルを展開します。すると、以下のようなファイルが作成されます。
1 2 3 4 5 6 7 |
[root@ip-172-31-11-1 MysqlEnterpriseMonitor]# ls -l total 514684 -rwxrwxr-x. 1 ec2-user ec2-user 263485007 Dec 11 12:12 mysqlmonitor-3.0.18.3095-linux-x86_64-installer.bin -rwxrwxr-x. 1 ec2-user ec2-user 263508040 Dec 11 12:12 mysqlmonitor-3.0.18.3095-linux-x86_64-update-installer.bin -rw-r-xr--. 1 ec2-user ec2-user 12470 Dec 16 13:10 README_en.txt -rw-r-xr--. 1 ec2-user ec2-user 12470 Dec 16 13:13 READ_ME_ja.txt [root@ip-172-31-11-1 MysqlEnterpriseMonitor]# |
mysqlmonitor-3.0.18.3095-linux-x86_64-installer.binというファイルを実行します。GUI環境ならばインストーラーが起動し、CLI環境ならば対話式のインストールが開始されます。
1 |
# ./mysqlmonitor-3.0.18.3095-linux-x86_64-installer.bin |
インストール時に使用する言語を選びます。日本語版はテスト不十分である事が多く、思わぬ不具合に遭遇する可能性が高いです。従って、私は”Engilish”を強く推奨します。
1 2 3 4 |
Please select the installation language [1] English - English [2] Japanese - 日本語 Please choose an option [1] : 1 |
ユーザ名やパスワードを控えられるよう、メモの準備をして下さい。
1 2 3 4 5 |
Info: During the installation process you will be asked to enter usernames and passwords for various pieces of the Enterprise Monitor. Please be sure to make note of these in a secure location so you can recover them in case they are forgotten. Press [Enter] to continue : |
MySQL Enterprise Monitor をインストールするディレクトリを指定してください。
1 2 3 4 5 6 7 8 |
---------------------------------------------------------------------------- Welcome to the setup wizard for the MySQL Enterprise Monitor ---------------------------------------------------------------------------- Please specify the directory where the MySQL Enterprise Monitor will be installed Installation directory [/opt/mysql/enterprise/monitor]: |
監視対象となるMySQLサーバの台数を3択で指定します。10台未満ならば1を、100台未満ならば2を、100台超ならば3を押下します。
1 2 3 4 5 6 7 8 9 10 11 12 13 |
---------------------------------------------------------------------------- Select Requirements Select Requirements Please indicate the scope of monitoring this installation will initially encompass so we can configure Tomcat and MySQL memory usage accordingly. The manual contains instructions for updating the configuration later, if needed. This installation will monitor a: System Size [1] Small system: No more than 5 to 10 MySQL Servers monitored from a laptop computer or low-end server with no more than 4 GB of RAM [2] Medium system: Up to 100 MySQL Servers monitored from a medium-size but shared server with 4 GB to 8 GB of RAM [3] Large system: More than 100 MySQL Servers monitored from a high-end server dedicated to MEM with more than 8 GB RAM Please choose an option [2] : 1 |
Yとnのどちらを選んでも差し支えございません。
1 |
Click here for more information [Y/n]: n |
Enterprise Monitor ServerはTomcatによるWebアプリケーションです。Tomcatがhttp, httpsで使用するポート番号を指定します。
1 2 3 4 5 6 7 8 |
---------------------------------------------------------------------------- Tomcat Server Options Please specify the following parameters for the bundled Tomcat Server Tomcat Server Port [18080]: Tomcat SSL Port [18443]: |
Server Monitorを実行するLinuxユーザを指定します。デフォルトのmysqlmemのままで、エンターを押下するのが良いでしょう。
1 2 3 4 5 6 7 8 9 |
---------------------------------------------------------------------------- Service Manager User Account You are installing as root, but it's not good practice for the Service Manager to run under the root user account. Please specify the name of a user account to use for the Service Manager below. Note that this user account will be created for you if it doesn't already exist. User Account [mysqlmem]: |
予めインストール済のMySQLにリポジトリ(監視結果格納データベース)を構築するのか、それともMySQLを新規インストールしリポジトリを構築するのかを選択します。MySQLインストール済の場合は、2を選択します。
1 2 3 4 5 6 7 8 |
---------------------------------------------------------------------------- Database Installation Please select which database configuration you wish to use [1] I wish to use the bundled MySQL database [2] I wish to use an existing MySQL database * Please choose an option [1] : 1 |
次の質問でServer Managerがリポジトリ (監視結果格納データベース) に接続する情報を聞かれます。質問に答える前に、あらかじめServer Managerが使用するMySQLユーザを作成しましょう。
mysqlにログインし、ユーザ”service_manager”を作成します。
1 |
mysql> GRANT ALL PRIVILEGES ON *.* TO 'service_manager'@'localhost' IDENTIFIED BY 'password'; |
Server Managerがリポジトリ (監視結果格納データベース)に接続可能になるよう、接続情報を入力します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
---------------------------------------------------------------------------- Repository Configuration Please specify the following parameters for the existing MySQL server Repository Username [service_manager]: Password : Re-enter : MySQL Hostname or IP address [localhost]: MySQL Database Port [3306]: MySQL Database Name [mem]: Use SSL when connecting to the database [y/N]: N |
Yを押下し、インストールを開始します。
1 2 3 4 |
---------------------------------------------------------------------------- Setup is now ready to install MySQL Enterprise Monitor on your computer. Do you want to continue? [Y/n]: Y |
インストールが終了するまで待ちます。
1 2 3 4 5 6 |
---------------------------------------------------------------------------- Please wait while Setup installs MySQL Enterprise Monitor on your computer. Installing 0% ______________ 50% ______________ 100% #################################### |
インストールが完了すると以下のようなメッセージが表示されます。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
---------------------------------------------------------------------------- Completed installing files Setup has completed installing the MySQL Enterprise Monitor files on your computer (errors were found during the installation process). Uninstalling the MySQL Enterprise Monitor files can be done by invoking: /opt/mysql/enterprise/monitor/uninstall To complete the installation, launch the MySQL Enterprise Monitor UI and complete the initial setup. Refer to the readme file for additional information and a list of known issues. Press [Enter] to continue : ---------------------------------------------------------------------------- Completed installing files WARNING: To improve security, all communication with the Service Manager uses SSL. Because only a basic self-signed security certificate is included when the Service Manager is installed, it is likely that your browser will display a warning about an untrusted connection. Please either install your own certificate or add a security exception for the Service Manager URL to your browser. See the documentation for more information. http://dev.mysql.com/doc/mysql-monitor/3.0/en/mem-install-server.html Press [Enter] to continue : ---------------------------------------------------------------------------- Setup has finished installing MySQL Enterprise Monitor on your computer. View Readme File [Y/n]: n Info: To configure the MySQL Enterprise Monitor please visit the following page: https://localhost:18443 Press [Enter] to continue : |
MySQL Enterprise Server Monitorの初期セットアップ
ブラウザに以下のようなURLを入力し、MySQL Enterprise Monitoryの画面に接続します。(IPアドレス, ホスト名部分は適宜変更)
1 |
https://54.65.100.244:18443/ |
MySQL Enterprise Monitorは複数のコンポーネントによって構成されます。複数のコンポーネントの中でも重要なのが、Enterprise MonitorとEnterprise Agentです。
MonitorとAgentのそれぞれについて、ユーザ名とパスワードを入力して下さい。なお、MonitorとAgentには異なるユーザ名が必要となります。
Complete Setupを押下します。
MySQL Enterprise Server Monitorの日本語化
以下、日本語化の方法について説明します。ユーザ名, User Preferencesの順に押下します。
Localeを「日本語」に設定し、Saveを押下します。
MySQL Enterprise Server Monitorの動作確認
MySQLサーバ1台のみの監視ならば、Enterprise Monitorのみで(Enterprise Agentなしで)監視を実現できます。適当なボタンを押下し、監視データを取得できている事を確認します。
MySQL Enterprise Monitor Agentのインストール
MySQL Enterprise Monitorで複数台の監視を行うには、Monitor Agentが必要になります。以下、Monitor Agentのインストール方法について説明します。
Enterprise Monitor Agentをダウンロードし、zipファイルを展開します。すると、以下のようなファイルが作成されます。
1 2 3 4 5 6 7 8 |
[root@slave MysqlEnterpriseAgent]# ls -l total 290500 -rwxrwxr-x. 1 ec2-user ec2-user 74747475 Dec 11 12:13 mysqlmonitoragent-3.0.18.3095-linux-x86-64bit-installer.bin -rwxrwxr-x. 1 ec2-user ec2-user 74746908 Dec 11 12:13 mysqlmonitoragent-3.0.18.3095-linux-x86-64bit-update-installer.bin -rw-rwxr--. 1 ec2-user ec2-user 12470 Dec 11 12:13 README_en.txt -rw-rwxr--. 1 ec2-user ec2-user 12470 Dec 11 12:13 READ_ME_ja.txt -rw-r--r--. 1 ec2-user ec2-user 147941154 Jan 11 01:06 V73880-01_MysqlEnterpriseMonitorAgent.zip [root@slave MysqlEnterpriseAgent]# |
mysqlmonitoragent-3.0.18.3095-linux-x86-64bit-installer.binというファイルを実行します。GUI環境ならばインストーラーが起動し、CLI環境ならば対話式のインストールが開始されます。
1 |
# ./mysqlmonitoragent-3.0.18.3095-linux-x86-64bit-installer.bin |
インストール時に使用する言語を選びます。日本語版はテスト不十分である事が多く、思わぬ不具合に遭遇する可能性が高いです。従って、私は”Engilish”を強く推奨します。
1 2 3 4 5 6 |
Language Selection Please select the installation language [1] English - English [2] Japanese - 日本語 Please choose an option [1] : 1 |
データベースへの接続方法を、TCP/IP通信, socket通信の2択から選びます。ローカルホスト内部の通信ならばsocketの方がオーバーヘッドが少なくお勧めできますが、ここは不要な不具合遭遇リスクを嫌い、敢えて公式手順書通りのTCP/IPを選択します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
---------------------------------------------------------------------------- Installation directory Please specify the directory where MySQL Enterprise Monitor Agent will be installed Installation directory [/opt/mysql/enterprise/agent]: How will the agent connect to the database it is monitoring? [1] TCP/IP [2] Socket Please choose an option [1] : 1 |
Monitor Agentとデータベース間の接続設定を今行うか、それとも後程、GUI ( Server Manager ) 経由で行うかを選択します。ここは手順書通り、接続設定を今行う”2″を選択します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
---------------------------------------------------------------------------- Monitoring Options You can configure the Agent to monitor this host (file systems, CPU, RAM, etc.) and then use the Monitor UI to furnish connection parameters for all current and future running MySQL Instances. This can be automated or done manually for each MySQL Instance discovered by the Agent. (Note: scanning for running MySQL processes is not available on Windows, but you can manually add new connections and parameters from the Monitor UI as well.) Visit the following URL for more information: http://dev.mysql.com/doc/mysql-monitor/3.0/en/mem-qanal-using-feeding.html Monitoring options: [1] Host only: Configure the Agent to monitor this host and then use the Monitor UI to furnish connection parameters for current and future running MySQL Instances. [2] Host and database: Configure the Agent to monitor this host and furnish connection parameters for a specific MySQL Instance now. This process may be scripted. Once installed, this Agent will also continuously look for new MySQL Instances to monitor as described above. Please choose an option [2] : 2 |
インストールを開始するかどうかを問われます。Yを押下し、インストールを開始して下さい。
1 2 3 4 5 |
---------------------------------------------------------------------------- Setup is now ready to begin installing MySQL Enterprise Monitor Agent on your computer. Do you want to continue? [Y/n]: Y |
インストールが完了するまで待ちます。
1 2 3 4 5 6 7 |
---------------------------------------------------------------------------- Please wait while Setup installs MySQL Enterprise Monitor Agent on your computer. Installing 0% ______________ 50% ______________ 100% ########################## |
MySQL Enterprise Monitor ( Server Monitor )との接続情報を入力します。”Agent Username”, “Agent Password”は、Server Monitor初回アクセス時に入力を求められたAgent側のユーザ名, パスワードです。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
---------------------------------------------------------------------------- MySQL Enterprise Monitor Options Hostname or IP address []: 172.31.10.1 Tomcat SSL Port [18443]: The following are the username and password that the Agent will use to connect to the Monitor. They were defined when you installed the Monitor. They can be modified under Settings, Manage Users. Their role is defined as "agent". Agent Username [agent]: Agent Password : Re-enter : |
この後、Monitor Agentのインストーラーは、管理者, 一般, 限られた権限の3ユーザの入力を求めます。Monitor Agentはこの3ユーザを用いて、MySQLデータベースに接続します。
この3ユーザをmysqlのコンソールに接続し作成しましょう。以下設定例はかなり強い権限になっておりますが。最小限の権限を設定したい方は、公式な手順書を参照ください(と言っても、私が打鍵した限りでは、公式手順に記された手順は権限不足でした・・・。詳細は追い切れておりません。)。
1 2 3 |
mysql> grant all privileges on *.* to 'admin'@'localhost' identified by 'password'; mysql> grant all privileges on *.* to 'general'@'localhost' identified by 'password'; mysql> grant all privileges on *.* to 'limited'@'localhost' identified by 'password'; |
Monitor AgentからMySQLデータベースへの接続情報を問われます。”Admin User”には、先ほど作成したユーザのユーザ名とパスワードを入力して下さい。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
---------------------------------------------------------------------------- Monitored Database Information IMPORTANT: The Admin user account specified below requires special MySQL privileges. Visit the following URL for more information: http://dev.mysql.com/doc/mysql-monitor/3.0/en/mem-agent-rights.html MySQL hostname or IP address [localhost]: Validate MySQL hostname or IP address [Y/n]: n MySQL Port [3306]: Admin User []: admin Admin Password : Re-enter Password : Monitor Group []: |
“GeneralUser”, “Limited User”には、先ほど作成したユーザのユーザ名とパスワードを入力して下さい。
なお、”Auto-Create Less Privileges Users”との説明が出力されますが、自動生成されるユーザは権限不足のため接続できません。上記手順のように、手作業で”GeneralUser”, “Limited User”を作成して下さい。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
---------------------------------------------------------------------------- Agent User Account Creation IMPORTANT: Less privileged accounts can be used to enhance monitoring security, and can even be created for you if the Admin account has GRANT privileges. Visit the following URL for more information: http://dev.mysql.com/doc/mysql-monitor/3.0/en/mem-agent-rights.html Auto-Create Less Privileged Users [Y/n]: General Username []: general General Password : Re-enter Password : Limited Username []: limited Limited Password : Re-enter Password : |
今まで設定した情報のサマリが表示されます。エンターキー押下で設定ファイルが自動生成されます。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
---------------------------------------------------------------------------- Configuration Report MySQL Enterprise Monitor Agent (Version 3.0.18.3095) The settings you specified are listed below. Note that if you are using a Connector to collect Query Analyzer data, you will need some of these settings to configure the Connector. See the following for more information: http://dev.mysql.com/doc/mysql-monitor/3.0/en/mem-qanal-using-feeding.html Installation directory: /opt/mysql/enterprise/agent MySQL Enterprise Monitor UI: ------------------------- Hostname or IP address: 172.31.10.1 Tomcat Server Port: 18443 Use SSL: yes Monitored MySQL Database: ------------------------- Hostname or IP address: localhost Port: 3306 |
以上でインストールおよび設定ファイルの作成が完了です。最後に、Readmeを表示するかどうかを聞かれますので、”N”を選択します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
---------------------------------------------------------------------------- Start MySQL Enterprise Monitor Agent Info to start the MySQL Enterprise Monitor Agent The MySQL Enterprise Monitor Agent was successfully installed. To start the Agent please invoke: /etc/init.d/mysql-monitor-agent start Press [Enter] to continue : ---------------------------------------------------------------------------- Setup has finished installing MySQL Enterprise Monitor Agent on your computer. View Agent Readme File [Y/n]: n |
Monitor, Agentの起動を行います。起動と同時に、Agent側の情報がMonitor Serverに送られます。
1 2 3 |
[root@ip-172-31-10-2 MysqlEnterpriseAgent]# /etc/init.d/mysql-monitor-agent start Starting MySQL Enterprise Agent service... [ OK ] [root@ip-172-31-10-2 MysqlEnterpriseAgent]# |
MySQL Enterprise Monitor Agentの動作確認
Monitor AgentがServer Monitorへ情報を送っている事を確認します。
Server Monitorにログインし、モニター, MySQL Instanceの順に押下します。監視対象が2 Instanceに増えている事を確認します。
Tips
MySQL Enterprise Monitorの省リソース性について
MySQL Enterprise Monitorは省リソースという意味では、あまり優れていないようです。
このサイト「ネットワークチェンジニアとして」を動かしているMySQL Community Edition 5.6をMySQL Enterprise Monitorで試しに監視してみました。すると、今まで見たことがない程の、コネクション数とコマンド発行回数を記録しました。グラフで山状になっている部分がMySQL Enterprise Monitorで監視を行っていた期間です。
監視ツールの中には省リソースを意識し、より少ないコマンド発行回数、より少ないコネクション数を目指しているものもあります。例えば、MySQL監視について言えば、DBforBIXやblackbirdを挙げる事ができます。富豪的プログラミングが許されないような環境ならば、Enterprise Monitor以外のツールを検討しましょう。
動作確認環境
動作確認を行った環境は以下の通りです。
- 動作確認日 : 2015/01/12
- Redhat 6.5 ( Amazon Web Service )
- MySQL Enterprise Database 5.6.22
- MySQL Enterprise Monitor 3.0
- MySQL Enterprise Backup 3.11.1
- Enterprise Manager for MySQL Database 12.1.0.1.0