2013年6月28日金曜日

もう一度MySQL Utilitiesを試してみる(インストール編)

WEBサーバーが増設されて、MySQLのユーザーを追加しなきゃいけなかった時にCREATE USER .. LIKE ...みたいなのが使えたらなぁとか思っていたら、@RKajiyamaさんにmysqlusercloneがあるよ! と教えてもらったので試してみる。

MySQL Utilitiesはだいぶ前にmysqlfailoverを試したくて入れたっきりで、あの時はまだMySQL Workbenchにしか入っていなかった(いつだったか独立して入れられるようになった)ので、WorkbenchのソースコードからUtilitiesの部分だけインストールしたなぁとか感傷に浸りつつ、お手軽にrpmで突っ込む。

CentOS6.3だから本当は"Oracle & Red Hat Linux 6"じゃないんだけど気にしない。"Linux Generic"がないので。

$ sudo rpm -i http://dev.mysql.com/get/Downloads/MySQLGUITools/mysql-utilities-1.3.2-1.el6.noarch.rpm/from/http://cdn.mysql.com/
エラー: 依存性の欠如:
        mysql-connector-python >= 1.0.9 は mysql-utilities-1.3.2-1.el6.noarch に必要とされています

おやま。
MySQL公式のConnector/Pythonが必要で、MySQL-pythonじゃダメらしい。

$ sudo rpm -i http://dev.mysql.com/get/Downloads/Connector-Python/mysql-connector-python-1.0.10-1.el6.noarch.rpm/fro
m/http://cdn.mysql.com/

$ sudo rpm -i http://dev.mysql.com/get/Downloads/MySQLGUITools/mysql-utilities-1.3.2-1.el6.noarch.rpm/from/http://cdn.mysql.com/

入れたら通った。うん。
取り敢えずmysqluc(MySQL Utilities Client)を起動してみる。

$ mysqluc
Launching console ...
WARNING: mysqlauditadmin failed to read options. This utility will not be shown in 'help utilities' and cannot be accessed from the console.
ERROR: The mysqlauditadmin utility requires Python version 2.7.0 or higher and lower than 3.0.0. The version of Python detected was 2.6.6. You may need to install or redirect the execution of this utility to an environment that includes a compatible Python version.

WARNING: mysqlauditgrep failed to read options. This utility will not be shown in 'help utilities' and cannot be accessed from the console.
ERROR: The mysqlauditgrep utility requires Python version 2.7.0 or higher and lower than 3.0.0. The version of Python detected was 2.6.6. You may need to install or redirect the execution of this utility to an environment that includes a compatible Python version.


Welcome to the MySQL Utilities Client (mysqluc) version 1.3.2
Copyright (c) 2000, 2013, 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' for a list of commands or press TAB twice for list of utilities.

mysqluc>

(;´д`) Python古い言われた。
sudo yum update pythonしても2.6.6のままだったのでまあいいやAudit Pluginからみのやつだけぽいし。

mysqluc> help
Command                 Description
----------------------  ---------------------------------------------------
help utilities          Display list of all utilities supported.
help <utility>          Display help for a specific utility.
help | help commands    Show this list.
exit | quit             Exit the console.
set <variable>=<value>  Store a variable for recall in commands.
show options            Display list of options specified by the user on
                        launch.
show variables          Display list of variables.
<ENTER>                 Press ENTER to execute command.
<ESCAPE>                Press ESCAPE to clear the command entry.
<DOWN>                  Press DOWN to retrieve the previous command.
<UP>                    Press UP to retrieve the next command in history.
<TAB>                   Press TAB for type completion of utility, option,
                        or variable names.
<TAB><TAB>              Press TAB twice for list of matching type
                        completion (context sensitive).
mysqluc> help utilities
Utility           Description
----------------  ---------------------------------------------------------
mysqldbcompare    compare databases for consistency
mysqldbcopy       copy databases from one server to another
mysqldbexport     export metadata and data from databases
mysqldbimport     import metadata and data from files
mysqldiff         compare object definitions among objects where the
                  difference is how db1.obj1 differs from db2.obj2
mysqldiskusage    show disk usage for databases
mysqlfailover     automatic replication health monitoring and failover
mysqlfrm          show CREATE TABLE from .frm files
mysqlindexcheck   check for duplicate or redundant indexes
mysqlmetagrep     search metadata
mysqlprocgrep     search process information
mysqlreplicate    establish replication with a master
mysqlrpladmin     administration utility for MySQL replication
mysqlrplcheck     check replication
mysqlrplshow      show slaves attached to a master
mysqlserverclone  start another instance of a running server
mysqlserverinfo   show server information
mysqluserclone    clone a MySQL user account to one or more new users

mysqluc> help mysqluserclone
Usage: mysqluserclone --source=user:pass@host:port:socket --destination=user:pass@host:port:socket joe@localhost sam:secret1@localhost

mysqluserclone - clone a MySQL user account to one or more new users

Options:
Option                       Description
---------------------------  ----------------------------------------------
--version                    show program's version number and exit
--help                       display a help message and exit
--source=SOURCE              connection information for source server in
                             the form:
                             <user>[:<password>]@<host>[:<port>][:<socket>]
                             or <login-path>[:<port>][:<socket>].
--destination=DESTINATION    connection information for destination server
                             in the form:
                             <user>[:<password>]@<host>[:<port>][:<socket>]
                             or <login-path>[:<port>][:<socket>].
-d, --dump                   dump GRANT statements for user - does not
                             require a destination
--force                      drop the new user if it exists
--include-global-privileges  include privileges that match base_user@% as
                             well as base_user@host
--list                       list all users on the source - does not
                             require a destination
-f, --format=FORMAT          display the list of users in either grid
                             (default), tab, csv, or vertical format -
                             valid only for --list option
-v, --verbose                control how much information is displayed.
                             e.g., -v = verbose, -vv = more verbose, -vvv =
                             debug
-q, --quiet                  turn off all messages for quiet execution.

mysqluc> 

このあたりはドキュメントに書いてあることやmysqluserclone --helpと一緒ね。
mysqluc立ち上げた時のバナーに書いてある通り、TABで補完が利く。

mysqluc> mysqluserclone<TAB><TAB>

Option                       Description
---------------------------  ----------------------------------------------
--version                    show program's version number and exit
--help                       display a help message and exit
--source=SOURCE              connection information for source server in
                             the form:
                             <user>[:<password>]@<host>[:<port>][:<socket>]
                             or <login-path>[:<port>][:<socket>].
--destination=DESTINATION    connection information for destination server
                             in the form:
                             <user>[:<password>]@<host>[:<port>][:<socket>]
                             or <login-path>[:<port>][:<socket>].
-d, --dump                   dump GRANT statements for user - does not
                             require a destination
--force                      drop the new user if it exists
--include-global-privileges  include privileges that match base_user@% as
                             well as base_user@host
--list                       list all users on the source - does not
                             require a destination
-f, --format=FORMAT          display the list of users in either grid
                             (default), tab, csv, or vertical format -
                             valid only for --list option
-v, --verbose                control how much information is displayed.
                             e.g., -v = verbose, -vv = more verbose, -vvv =
                             debug
-q, --quiet                  turn off all messages for quiet execution.

mysqluc> mysqluserclone --s<TAB><TAB>

Option           Description
---------------  ----------------------------------------------------------
--source=SOURCE  connection information for source server in the form:
                 <user>[:<password>]@<host>[:<port>][:<socket>] or <login-
                 path>[:<port>][:<socket>].

オプションも補完が利く&ついでにそのオプションのhelpも出してくれた。ちょっとCISCOぽい?
しかしこのmysqluc自体が誰得な感じがしないでもない…。


当初の目的のmysqlusercloneにたどり着いてないけどとりあえずここまで。
しかし、どうにもmysqltuner的な気配がするよねこいつら。。(mysqldiskusageとかmysqlserverinfoとかmysqlprocgrepとか)


【2013/07/02 13:17】
mysqluserclone試してみた。すごくフツー。
http://yoku0825.blogspot.jp/2013/07/mysql-utilitiesmysqluserclone.html

0 件のコメント :

コメントを投稿