好久没有写文章了,今天来看看MYSQL的实例管理器(MYSQLMANAGER)。
一、简单介绍:
1、MySQL实例管理器(IM)是通过TCP/IP端口运行的后台程序,用来监视和管理MySQL数据库服务器实例。(如果你之前用过MYSQLD_MULTI就很清楚了。)
2、如果IM挂了,则所有的实例就挂掉了;如果实例挂了,IM会尝试重新启动它。
3、IM读取配置文件比如MY.CNF的[manager]段。
4、此例是在LINUX下试验的,其他的系统手册上有详细介绍。
二、一些详细配置。
1、
以下是我的配置文件
[manager]
user=mysql
default-mysqld-path = /usr/local/mysql/bin/mysqld
socket=/tmp/manager.sock
pid-file=/tmp/manager.pid
password-file = /etc/mysqlmanager.passwd
monitoring-interval = 2
port = 1999
bind-address = 192.168.0.231
log = /usr/local/mysql/bin/mysqlmanager.log
run-as-service = true
[mysqld1]
...
[mysqld2]
...
这个有两个配置实例,具体就不说了。见我的安装多个实例的文章。

具体含义查看mysqlmanager --help

2、密码文件。
IM将用户信息保存到密码文件中。密码文件的默认位置为/etc/mysqlmanager.passwd。

密码应类似于:

petr:*35110DC9B4D8140F5DE667E28C72DD2597B5C848

我的mysqlmanager.passwd内容
user_all:*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9
3、启动IM。
[root@localhost tmp]# /usr/local/mysql/bin/mysqlmanager

WARNING: This program is deprecated and will be removed in 6.0.

[2483/3086632640] [08/04/24 14:24:50] [INFO] IM: started.
[2483/3086632640] [08/04/24 14:24:50] [INFO] Loading config file 'my.cnf'...
[2483/3086632640] [08/04/24 14:24:50] [INFO] Manager: initializing...
[2483/3086632640] [08/04/24 14:24:50] [INFO] Manager: detected threads model: POSIX threads.
[2483/3086632640] [08/04/24 14:24:50] [INFO] Loading the password database...
[2483/3086632640] [08/04/24 14:24:50] [INFO] Loaded user 'user_all'.
[2483/3086632640] [08/04/24 14:24:50] [INFO] The password database loaded successfully.
[2483/3086632640] [08/04/24 14:24:50] [INFO] Manager: pid file (/tmp/manager.pid) created.
[2483/3086632640] [08/04/24 14:24:50] [INFO] mysqld instance 'mysqld1' has been added successfully.
[2483/3086632640] [08/04/24 14:24:50] [INFO] mysqld instance 'mysqld2' has been added successfully.
[2483/3076139920] [08/04/24 14:24:50] [INFO] Guardian: started.
[2483/3076139920] [08/04/24 14:24:50] [INFO] Guardian: starting 'mysqld1'...
[2483/3076058000] [08/04/24 14:24:50] [INFO] Instance 'mysqld1': Monitor: started.
[2483/3076058000] [08/04/24 14:24:50] [INFO] Instance 'mysqld1': Monitor: starting mysqld...
[2483/3076139920] [08/04/24 14:24:50] [INFO] Guardian: starting 'mysqld2'...
[2483/3076058000] [08/04/24 14:24:50] [INFO] Instance 'mysqld1': Monitor: waiting for mysqld to stop...
[2483/3075894160] [08/04/24 14:24:50] [INFO] Instance 'mysqld2': Monitor: started.
[2483/3075894160] [08/04/24 14:24:50] [INFO] Instance 'mysqld2': Monitor: starting mysqld...
[2483/3075894160] [08/04/24 14:24:50] [INFO] Instance 'mysqld2': Monitor: waiting for mysqld to stop...
[2483/3086632640] [08/04/24 14:24:50] [INFO] Manager: started.
[2483/3075976080] [08/04/24 14:24:50] [INFO] Listener: started.
[2483/3075976080] [08/04/24 14:24:50] [INFO] Listener: accepting connections on ip socket (port: 1999)...
[2483/3075976080] [08/04/24 14:24:50] [INFO] Listener: accepting connections on unix socket '/tmp/manager.sock'...
...
InnoDB: than specified in the .cnf file 0 5242880 bytes!
080424 14:24:50  InnoDB: Started; log sequence number 0 46409
080424 14:24:50 [Note] Event Scheduler: Loaded 0 events
080424 14:24:50 [Note] /usr/local/mysql/bin/mysqld: ready for connections.
Version: '5.1.23a-maria-alpha-log'  socket: '/tmp/mysql1.sock'  port: 3306  MySQL Community Server [Maria] (GPL)
080424 14:24:50 [Warning] 'user' entry 'root@localhost.localdomain' ignored in --skip-name-resolve mode.
080424 14:24:50 [Warning] 'user' entry '@localhost.localdomain' ignored in --skip-name-resolve mode.
080424 14:24:50 [Note] Event Scheduler: Loaded 0 events
080424 14:24:50 [Note] /usr/local/mysql/bin/mysqld: ready for connections.
Version: '5.1.23a-maria-alpha-log'  socket: '/tmp/mysql2.sock'  port: 3309  MySQL Community Server [Maria] (GPL)
[2483/3076139920] [08/04/24 14:24:52] [INFO] Guardian: 'mysqld1' is running, set state to STARTED.

4、连接IM。
[root@localhost ~]# mysql -uuser_all -p -S/tmp/manager.sock -P1999
三、用IM来管理MYSQL。

1、显示实例的状态和版本信息。
[root@localhost ~]# mysql -uuser_all -p -S/tmp/manager.sock -P1999
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or /g.
Your MySQL connection id is 1
Server version: 1.0-beta

Type 'help;' or '/h' for help. Type '/c' to clear the buffer.

mysql> show instances;
+---------------+--------+
| instance_name | state  |
+---------------+--------+
| mysqld1       | online |
| mysqld2       | online |
+---------------+--------+
2 rows in set (0.00 sec)
关闭实例1
mysql> stop instance mysqld1;
Query OK, 0 rows affected (0.30 sec)

mysql> show instances;
+---------------+---------+
| instance_name | state   |
+---------------+---------+
| mysqld1       | offline |
| mysqld2       | online  |
+---------------+---------+
2 rows in set (0.00 sec)
开启实例1
mysql> start instance mysqld1;
Query OK, 0 rows affected (0.00 sec)
Instance started

mysql> show instances;
+---------------+--------+
| instance_name | state  |
+---------------+--------+
| mysqld1       | online |
| mysqld2       | online |
+---------------+--------+
2 rows in set (0.00 sec)

查看实例的版本信息
mysql> show instance status mysqld2;
+---------------+--------+----------------+------------------------------------------------------------------------------------------+-------------------+
| instance_name | state  | version_number | version                                                                                  | mysqld_compatible |
+---------------+--------+----------------+------------------------------------------------------------------------------------------+-------------------+
| mysqld2       | online | 5.1.23         | 5.1.23a-maria-alpha for redhat-linux-gnu on i686 (MySQL Community Server [Maria] (GPL))
 | no                |
+---------------+--------+----------------+------------------------------------------------------------------------------------------+-------------------+
1 row in set (0.00 sec)

也可以显示实例的选项信息。
mysql> show instance options mysqld1;
+-----------------------+-----------------------------------+
| option_name           | value                             |
+-----------------------+-----------------------------------+
| instance_name         | mysqld1                           |
| basedir               | /usr/local/mysql                  |
| datadir               | /usr/local/mysql/data             |
| user                  | mysql                             |
| default-character-set | utf8                              |
| port                  | 3306                              |
| socket                | /tmp/mysql1.sock                  |
| skip-locking          |                                   |
| skip-name-resolve     |                                   |
| key_buffer            | 126M                              |
| max_allowed_packet    | 2M                                |
| table_cache           | 512                               |
| sort_buffer_size      | 2M                                |
| read_buffer_size      | 2M                                |
| read_rnd_buffer_size  | 4M                                |
| net_buffer_length     | 2K                                |
| thread_stack          | 64K                               |
| log-bin               | mysql.log                         |
| expire_logs_days      | 5                                 |
| wait_timeout          | 20                                |
| pid-file              | mysqld1-localhost.localdomain.pid |
+-----------------------+-----------------------------------+
21 rows in set (0.00 sec)

也可以查询实例的日志相关信息,这里我就不写了。

可以看出,管理实例非常方便。

2、管理用户。

1)、添加管理用户
[root@localhost ~]# /usr/local/mysql/bin/mysqlmanager --add-user

WARNING: This program is deprecated and will be removed in 6.0.

[3046/3086816960] [08/04/24 14:33:13] [INFO] IM: started.
[3046/3086816960] [08/04/24 14:33:13] [INFO] Loading config file 'my.cnf'...
Enter user name: shit_all
[3046/3086816960] [08/04/24 14:33:18] [INFO] Loading the password database...
[3046/3086816960] [08/04/24 14:33:18] [INFO] Loaded user 'user_all'.
[3046/3086816960] [08/04/24 14:33:18] [INFO] The password database loaded successfully.
Enter password:
Re-type password:
[3046/3086816960] [08/04/24 14:33:23] [INFO] IM: finished.
[root@localhost ~]# cat /etc/mysqlmanager.passwd
user_all:*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9
shit_all:*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9
不过注意必须重新启动IM才可以生效。
[root@localhost ~]# mysql -ushit_all -p -S/tmp/manager.sock -P1999
Enter password:
ERROR 1045 (28000): Access denied. Bad username/password pair

2)、修改用户密码
[root@localhost ~]# /usr/local/mysql/bin/mysqlmanager --edit-user

WARNING: This program is deprecated and will be removed in 6.0.

[3214/3086845632] [08/04/24 14:35:15] [INFO] IM: started.
[3214/3086845632] [08/04/24 14:35:15] [INFO] Loading config file 'my.cnf'...
Enter user name: shit_all
[3214/3086845632] [08/04/24 14:35:19] [INFO] Loading the password database...
[3214/3086845632] [08/04/24 14:35:19] [INFO] Loaded user 'user_all'.
[3214/3086845632] [08/04/24 14:35:19] [INFO] Loaded user 'shit_all'.
[3214/3086845632] [08/04/24 14:35:19] [INFO] The password database loaded successfully.
Enter password:
Re-type password:
[3214/3086845632] [08/04/24 14:35:24] [INFO] IM: finished.
3)、删除用户。
[root@localhost ~]# /usr/local/mysql/bin/mysqlmanager --drop-user

WARNING: This program is deprecated and will be removed in 6.0.

[3338/3086501568] [08/04/24 14:36:42] [INFO] IM: started.
[3338/3086501568] [08/04/24 14:36:42] [INFO] Loading config file 'my.cnf'...
Enter user name: shit_all
[3338/3086501568] [08/04/24 14:36:45] [INFO] Loading the password database...
[3338/3086501568] [08/04/24 14:36:45] [INFO] Loaded user 'user_all'.
[3338/3086501568] [08/04/24 14:36:45] [INFO] Loaded user 'shit_all'.
[3338/3086501568] [08/04/24 14:36:45] [INFO] The password database loaded successfully.
[3338/3086501568] [08/04/24 14:36:45] [INFO] IM: finished.

4)、列出当前管理用户。

[root@localhost ~]# /usr/local/mysql/bin/mysqlmanager --list-user

WARNING: This program is deprecated and will be removed in 6.0.

[3366/3086087872] [08/04/24 14:37:07] [INFO] IM: started.
[3366/3086087872] [08/04/24 14:37:07] [INFO] Loading config file 'my.cnf'...
[3366/3086087872] [08/04/24 14:37:07] [INFO] Loading the password database...
[3366/3086087872] [08/04/24 14:37:07] [INFO] Loaded user 'user_all'.
[3366/3086087872] [08/04/24 14:37:07] [INFO] The password database loaded successfully.
user_all
[3366/3086087872] [08/04/24 14:37:07] [INFO] IM: finished.
[root@localhost ~]#

四、远程管理
C:/Documents and Settings/Administrator>mysql -uuser_all -p -P1999 -h192.168.0.2
31
Enter password: ******
Welcome to the MySQL monitor.  Commands end with ; or /g.
Your MySQL connection id is 3
Server version: 1.0-beta

Type 'help;' or '/h' for help. Type '/c' to clear the buffer.

mysql> show instances;
+---------------+--------+
| instance_name | state  |
+---------------+--------+
| mysqld1       | online |
| mysqld2       | online |
+---------------+--------+
2 rows in set (0.00 sec)

mysql> quit
Bye

总结:MYSQL的实例管理器对于多个MYSQL实例的管理还是很方便的。
不过有两个缺点
1、不能直接进行数据库的SQL管理命令。
2、一定要保证IM进程不挂掉。

MYSQLMANAGER实例管理器总结的更多相关文章

  1. [MySQL 5.1 体验]MySQL 实例管理器 mysqlmanager 初试

    原贴:http://imysql.cn/node/313 [MySQL 5.1 体验]MySQL 实例管理器 mysqlmanager 初试 周二, 2007/06/19 - 22:10 - yejr ...

  2. WCF 服务的集合管理器的设计

    今天是2019年2月1日,时间过得针对,马上就年底了,当前新年也离我们越来越近了.在此,我也祝福经常浏览我博客的朋友们“新年快乐.阖家欢乐”,来年有一个好彩头.在即将结束这一年之计,写今年的最后一片文 ...

  3. (转)Java 的swing.GroupLayout布局管理器的使用方法和实例

    摘自http://www.cnblogs.com/lionden/archive/2012/12/11/grouplayout.html (转)Java 的swing.GroupLayout布局管理器 ...

  4. Java 的swing.GroupLayout布局管理器的使用方法和实例(转)

    The following builds a panel consisting of two labels in one column, followed by two textfields in t ...

  5. Expression Blend实例中文教程(11) - 视觉管理器快速入门Visual State Manager(VSM)

    Visual State Manager,中文又称视觉状态管理器(简称为VSM),是Silverlight 2中引进的一个概念.通过使用VSM,开发人员和设计人员可以轻松的改变项目控件的视觉效果,在项 ...

  6. Expression Blend实例中文教程(11) - 视觉管理器快速入门Visual State Manager(VSM)

    Expression Blend实例中文教程(11) - 视觉管理器快速入门Visual State Manager(V 时间:2010-04-12 16:06来源:SilverlightChina. ...

  7. Duilib源码分析(四)绘制管理器—CPaintManagerUI

    接下来,分析uilib.h中的UIManager.h,在正式分析CPaintManagerUI前先了解前面的一些宏.结构: 枚举类型EVENTTYPE_UI:定义了UIManager.h中事件通告类型 ...

  8. [WCF编程]12.事务:事务协议与管理器

    一.事务协议 总体来说,WCF开发人员不需要涉及事务协议与管理器.我们应该依赖WCF来选择相应的事务协议和管理器,重点关注业务逻辑的实现. WCF是根据事务范围里的参与个体来选择事务管理协议的.事务管 ...

  9. 从零开始山寨Caffe·叁:全局线程管理器

    你需要一个管家,随手召唤的那种,想吃啥就吃啥. ——设计一个全局线程管理器 一个机器学习系统,需要管理一些公共的配置信息,如何存储这些配置信息,是一个难题. 设计模式 MVC框架 在传统的MVC编程框 ...

随机推荐

  1. CodeForces 570B Simple Game 概率

    原题: http://codeforces.com/contest/570/problem/B 题目: Simple Game time limit per test1 second memory l ...

  2. vue30-单一事件管理组件通信: vuex

    ------------------------------------------------------ 可以单一事件管理组件通信: vuex var Event=new Vue(); Event ...

  3. PowerDesigner删除外键关系,而不删除外键列[转] 及编码格式

    PowerDesigner删除外键关系,而不删除外键列[转]  数据库 database  -> generate database ->format 设置为utf-8 PowerDesi ...

  4. 转:Java读写文件各种方法及性能比较

    干Java这么久,一直在做WEB相关的项目,一些基础类差不多都已经忘记.经常想得捡起,但总是因为一些原因,不能如愿. 其实不是没有时间,只是有些时候疲于总结,今得空,下定决心将丢掉的都给捡起来. 文件 ...

  5. selenium无法定位元素问题

    在用自动化测试工具selenium完成下载任务时,经常会遇到定位不到元素的情况,总结如下: 1.frame/iframe原因定位不到元素: 这个是最常见的原因,首先要理解下frame的实质,frame ...

  6. AJAX 前后端交互 验证信息是否正确

    1.前段: function checkPtCode(obj){ $.ajax({ type: "post", url: "xxxxxxx", data: {& ...

  7. hdu5024

    思路要开阔些,或者说要转化一下思路,别太死 把每一个点当拐点,爆一边就能够.用记忆化搜索也行.都不会超时 #include<bits/stdc++.h> using namespace s ...

  8. 前台ajax验证技术采用正则表达式

    var flag1,flag2,flag3,flag4,flag5,flag6=false; function val(obj) { var regBox = { /* regEmail : /^([ ...

  9. Scott Hanselman的问题-2

    .Net程序员面试 每个人都应知道篇 (回答Scott Hanselman的问题)   昨天回答了Scott Hanselman在他清单上关于C#那部分的题目,.Net 程序员面试 C# 语言篇 (回 ...

  10. 蓝桥杯训练 2n皇后

    问题描述 给定一个n*n的棋盘,棋盘中有一些位置不能放皇后.现在要向棋盘中放入n个黑皇后和n个白皇后,使任意的两个黑皇后都不在同一行.同一列或同一条对角线上,任意的两个白皇后都不在同一行.同一列或同一 ...