【转】MySQL-Utilities,mysql工具包

原文:https://blog.csdn.net/leshami/article/details/52795777

MySQL Utilities 是一组基于python语言编写的python库的命令行实用工具集,依赖于python 2.6。该工具提供了MySQL数据库运维工程中常用的一些工具,诸如克隆、复制、比较、差异、导出、导入、安装、配置、索引、磁盘查看等等。有了这个工具包,就好比那些个神医大夫,不管大病小病,先去搞个化验,搞个CT,你也可以当华佗。MySQL Utilities提供了各种平台的软件包,如果没有找到对应自己平台的包,可以通过源码进行编译安装。本文主要描述MySQL Utilities安装以及各个工作功能初步描述。

一、MySQL Utilities功能及组件

Binary Log Operations(二进制日志操作)
mysqlbinlogmove 二进制日志移动
mysqlbinlogpurge 二进制日志清理
mysqlbinlogrotate 二进制日志老化工具

Database Operations(数据库操作)
mysqldbexport 数据导出
mysqldbimport 数据导入
mysqldbcopy 库级别数据库复制
mysqldiff 数据库对象级别比较工具
mysqldbcompare 数据库库级别比较工具

General Operations(通用用的操作)
mysqldiskusage 磁盘空间查看
mysqlfrm 恢复故障表.frm文件
mysqluserclone 用户克隆工具
mysqluc Utilities帮助工具
mysqlindexcheck 索引检测工具
mysqlmetagrep 元数据过滤器
mysqlprocgrep 进程搜索及清理工具

High Availability Operations(高可用)
mysqlreplicate 主从复制工具
mysqlrpladmin 主从复制管理工具
mysqlrplcheck 主从复制检测工具
mysqlrplms 主从多元复制工具
mysqlrplshow 主从复制拓扑图工具
mysqlrplsync 主从复制同步工具
mysqlfailover 主从failover工具
mysqlslavetrx 从库事务跳过工具

Server Operations(服务器操作)
mysqlserverinfo 服务器信息查看工具
mysqlserverclone 服务器克隆工具

Specialized Operations(特殊操作)
mysqlauditadmin 审计管理工具
mysqlauditgrep 审计日志过滤工具

二、安装需求及下载地址

需求
  Python 2.6
  MySQL Connector/Python 连接器
下载地址:
  http://dev.mysql.com/downloads/utilities/

三、安装示例

###本次安装使用1.6.4版本,安装前,需要先安装mysql到python连接器
# cat /etc/redhat-release
CentOS release 6.7 (Final)
# rpm -Uvh mysql-connector-python-2.1.4-1.el6.x86_64.rpm
# rpm -Uvh mysql-utilities-1.6.4-1.el6.noarch.rpm

###如果没有安装连接器,则收到如下错误提示
# rpm -Uvh mysql-utilities-1.6.4-1.el6.noarch.rpm
warning: mysql-utilities-1.6.4-1.el6.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
mysql-connector-python >= 2.0.0 is needed by mysql-utilities-1.6.4-1.el6.noarch

###查看安装后生成的文件
# rpm -ql mysql-utilities-1.6.4-1.el6|grep "/usr/bin"
/usr/bin/mysqlauditadmin
/usr/bin/mysqlauditgrep
/usr/bin/mysqlbinlogmove
/usr/bin/mysqlbinlogpurge
/usr/bin/mysqlbinlogrotate
/usr/bin/mysqldbcompare
/usr/bin/mysqldbcopy
/usr/bin/mysqldbexport
/usr/bin/mysqldbimport
/usr/bin/mysqldiff
/usr/bin/mysqldiskusage
/usr/bin/mysqlfailover
/usr/bin/mysqlfrm
/usr/bin/mysqlgrants
/usr/bin/mysqlindexcheck
/usr/bin/mysqlmetagrep
/usr/bin/mysqlprocgrep
/usr/bin/mysqlreplicate
/usr/bin/mysqlrpladmin
/usr/bin/mysqlrplcheck
/usr/bin/mysqlrplms
/usr/bin/mysqlrplshow
/usr/bin/mysqlrplsync
/usr/bin/mysqlserverclone
/usr/bin/mysqlserverinfo
/usr/bin/mysqlslavetrx
/usr/bin/mysqluc
/usr/bin/mysqluserclone 

四、获取帮助

1、通过mysqluc获取帮助
###可以通过调用mysqluc命令行工具来获取这些工具的帮助信息
### mysqluc提供一个自带的命令行提示符窗口,在这个窗口下也可以完成相应的命令操作

[[email protected] ~]# mysqluc
Launching console ...

Welcome to the MySQL Utilities Client (mysqluc) version 1.6.4
Copyright (c) 2010, 2016 Oracle and/or its affiliates. All rights reserved.
This is a release of dual licensed MySQL Utilities. For the avoidance of
doubt, this particular copy of the software is released
under the version 2 of the GNU General Public License.
MySQL Utilities is brought to you by Oracle.

Type ‘help‘ for a list of commands or press TAB twice for list of utilities.

mysqluc> help
Command Description
---------------------- ---------------------------------------------------
help utilities Display list of all utilities supported.
help <utility> Display help for a specific utility.
show errors Display errors captured during the execution of the
utilities.
clear errors clear captured errors.
show last error Display the last error captured during the
execution of the utilities
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).
###查看utilities包中所有的命令行工具
mysqluc> help utilities

Utility Description
----------------- --------------------------------------------------------
mysqlauditadmin audit log maintenance utility
mysqlauditgrep audit log search utility
mysqlbinlogmove binary log relocate utility
mysqlbinlogpurge purges unnecessary binary log files
mysqlbinlogrotate rotates the active binary log file
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
mysqlgrants display grants per object
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
mysqlrplms establish multi-source replication
mysqlrplshow show slaves attached to a master
mysqlrplsync replication synchronization checker utility
mysqlserverclone start another instance of a running server
mysqlserverinfo show server information
mysqlslavetrx skip transactions on slaves
mysqluserclone clone a MySQL user account to one or more new users

###也可直接在mysqluc提示符下输入 help command 来获取对应命令的帮助信息,如下
mysqluc> help mysqlauditadmin
Usage: mysqlauditadmin --server=user:[email protected]:port --show-options
# Author : Leshami
# Blog : http://blog.csdn.net/leshami
mysqlauditadmin - audit log maintenance utility

Options:
Option Description
------------------------- ------------------------------------------------
--version show program‘s version number and exit
--help display this help message and exit
--license display program‘s license and exit
--server=SERVER connection information for the server in the
form:
<user>[:<password>]@<host>[:<port>][:<socket>]
or <login-path>[:<port>][:<socket>] or <config-
path>[<[group]>].
--audit-log-name=LOG_NAME full path and file name for the audit log file.
Used for stats and copy options.
--show-options display the audit log system variables.
--remote-login=RLOGIN user name and host to be used for remote login
for copying log files. Format:
<user>:<host_or_ip> Password will be prompted.
--file-stats display the audit log file statistics.
--copy-to=COPY_LOCATION the location to copy the audit log file
specified. The path must be locally accessible
for the current user.
--value=VALUE value used to set variables based on the command
specified. See --help for list per command.
--ssl-ca=SSL_CA path to a file that contains a list of trusted
SSL CAs.
--ssl-cert=SSL_CERT name of the SSL certificate file to use for
establishing a secure connection.
--ssl-key=SSL_KEY name of the SSL key file to use for establishing
a secure connection.
--ssl=SSL specifies if the server connection requires use
of SSL. If an encrypted connection cannot be
established, the connection attempt fails. By
default 0 (SSL not required).
-v, --verbose control how much information is displayed. e.g.,
-v = verbose, -vv = more verbose, -vvv = debug
Available Commands: copy - copy the audit log to
a locally accessible path policy - set the audit
log policy Values = ALL, NONE, LOGINS, QUERIES,
DEFAULT rotate - perform audit log rotation
rotate_on_size - set the rotate log size limit
for auto rotation Values = 0, 4294967295

2、直接在shell提示符下获取命令帮助

###如下示例
[[email protected] ~]# mysqlfailover --help|head
MySQL Utilities mysqlfailover version 1.6.4
License type: GPLv2
Usage: mysqlfailover [email protected] --discover-slaves-login=root
[email protected]:3306,[email protected]:3306

mysqlfailover - automatic replication health monitoring and failover

Options:
--version show program‘s version number and exit
--help display this help message and exit
--license display program‘s license and exit

3、基于Linux man获取命令帮助

###如下示例
[email protected] ~]# man mysqlfailover
MYSQLFAILOVER(1) MySQL Utilities MYSQLFAILOVER(1)

NAME
mysqlfailover - Automatic replication master failover

SYNOPSIS
mysqlfailover [options]

原文地址:https://www.cnblogs.com/gered/p/11181781.html

时间: 2024-08-29 21:09:27

【转】MySQL-Utilities,mysql工具包的相关文章

MySQL管理工具MySQL Utilities — 介绍与安装(1)

MySQL Utilities介绍 MySQL Utilities 提供一组命令行工具用于维护和管理 MySQL 服务器,包括: 管理工具 (克隆.复制.比较.差异.导出.导入) 复制工具 (安装.配置) 一般工具 (磁盘使用情况.冗余索引.搜索元数据) MySQL Utilities是一系列的命令行工具以及Python库更容易完成管理的任务.库是用Python语言写的,这就意味着不需要安装其他任何工具和库.当前是基于Python2.6版本设计的,不支持Python3.1版本. MySQL Ut

MySQL Utilities

园子看到使用MySQL对比数据库表结构,参考测试发现 [[email protected] uest]# mysqldiff --server1=dba:[email protected] --server2=dba:[email protected] --changes-for=server2 --show-reverse --difftype=sql test.test1:test.test2 bash: mysqldiff: command not found [[email protec

MySQl学习-——Mysql体系结构与Mysql存储引擎

Mysql体系结构与Mysql存储引擎 Mysql体系结构 mysql体系结构图: 1)        Connectors:指的是不同语言中与SQL的交互 max_connections 就是整个MySQL实例的最大连接数限制 max_user_connections 是单个用户的最大连接数,这里未指明是哪个用户,是任意一个用户. 2)        Management Serveices & Utilities:系统管理和控制工具 备份和恢复的安全性,复制,集群,管理,配置,迁移和元数据

MySQL配置文件mysql.ini参数详解、MySQL性能优化

MySQL配置文件mysql.ini参数详解.MySQL性能优化 my.ini(Linux系统下是my.cnf),当mysql服务器启动时它会读取这个文件,设置相关的运行环境参数. my.ini分为两块:Client Section和Server Section.   Client Section用来配置MySQL客户端参数.   要查看配置参数可以用下面的命令: show variables like '%innodb%'; # 查看innodb相关配置参数 show status like

CoroSync + Drbd + MySQL 实现MySQL的高可用集群

Corosync + DRBD + MySQL 构建高可用MySQL集群 节点规划: node1.huhu.com172.16.100.103 node2.huhu.com172.16.100.104 资源名称规划 资源名称:可以是除了空白字符外的任意ACSII码字符 DRBD设备:在双节点上,此DRBD设备文件,一般为/dev/drbdN,主设备号147 磁盘:在双方节点上,各自提供存储设备 网络配置:双方数据同步所使用的网络属性 DRBD从Linux内核2.6.33起已经整合进内核 1.配置

mysql初学,mysql修改,mysql查找,mysql删除,mysql基本命令

Mysql 下载地址https://dev.mysql.com/downloads/mysql/ 1.连接Mysql格式: mysql -h主机地址 -u用户名 -p用户密码 1.连接到本机上的MYSQL.首先打开DOS窗口,然后进入目录mysql\bin,再键入命令mysql -u root -p,回车后提示你输密码.注意用户名前可以有空格也可以没有空格,但是密码前必须没有空格,否则让你重新输入密码. 如果刚安装好MYSQL,超级用户root是没有密码的,故直接回车即可进入到MYSQL中了,M

mysql之 mysql 5.6不停机主主搭建(活跃双主基于日志点复制)

环境说明:版本 version 5.6.25-log 主库ip: 10.219.24.25从库ip:10.219.24.22os 版本: centos 6.7已安装热备软件:xtrabackup 防火墙已关 补充:主从复制原理: http://blog.csdn.net/zhang123456456/article/details/72972701mysql 5.6安装 :http://blog.csdn.net/zhang123456456/article/details/53608554xt

centos lvs+keepalived+mysql实现mysql数据库热备主主复制-亲测ok

实验环境: linux:centos6.6 虚拟ip(vip):192.168.135.199 mysql master:192.168.20.193 mysql slave:192.168.20.195 (这里只是为了后文方便区分,一个叫master,一个叫slave,其实在主主复制中,都是master也都是slave,没有主从之分) mysql的版本: [[email protected] ~]# mysql -V mysql  Ver 14.14 Distrib 5.1.73, for r

跟王老师学MySQL:MySQL数据类型之小数类型

跟王老师学MySQL:MySQL数据类型之小数类型 主讲教师:王少华   QQ群号:483773664 学习内容 小数类型有哪些以及它们的取值范围 定义语法中的M和D的含义 定点型和浮点型的区别 一.简介 MySQL中使用浮点数类型和定点数类型来表示小数. 浮点数类型包括单精度浮点数(FLOAT型)和双精度浮点数(DOUBLE型). 定点数类型就是DECIMAL型. 二.字节数.取值范围 三.定义语法 1 类据类型 (M,D) M:精度,数据的总长度 D:标度,小数点后的长度 注: 小数点不占长

跟王老师学MySQL:MySQL数据类型之字符类型

跟王老师学MySQL:MySQL数据类型之字符类型 主讲教师:王少华   QQ群号:483773664 学习内容: 字符串类型的种类及其特点 char和varchar的异同 字符串类型是在数据库中存储字符串的数据类型. 字符串类型包括 CHAR. VARCHAR BLOB TEXT 一.char和varchar (一)定义语法 1 字符串类型 (M) 注: 字符串类型:char或varchar M:指定了该字符串最大长度 (二)二者不同之处 char类型长度是固定的,即在创建表时就指定了,其长度