Mycat快速入门(六): Mycat管理命令和监控

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/vbirdbest/article/details/83960210

一:Mycat管理命令和监控

Mycat可以通过终端来监控mycat的各项指标,端口为9066

mysql -h127.0.0.1 -P9066 -uroot -proot123

mysql> show @@help;
+--------------------------------------------------------------+--------------------------------------------+
| STATEMENT                                                    | DESCRIPTION                                |
+--------------------------------------------------------------+--------------------------------------------+
| show @@time.current                                          | Report current timestamp                   |
| show @@time.startup                                          | Report startup timestamp                   |
| show @@version                                               | Report Mycat Server version                |
| show @@server                                                | Report server status                       |
| show @@threadpool                                            | Report threadPool status                   |
| show @@database                                              | Report databases                           |
| show @@datanode                                              | Report dataNodes                           |
| show @@datanode where schema = ?                             | Report dataNodes                           |
| show @@datasource                                            | Report dataSources                         |
| show @@datasource where dataNode = ?                         | Report dataSources                         |
| show @@datasource.synstatus                                  | Report datasource data synchronous         |
| show @@datasource.syndetail where name=?                     | Report datasource data synchronous detail  |
| show @@datasource.cluster                                    | Report datasource galary cluster variables |
| show @@processor                                             | Report processor status                    |
| show @@command                                               | Report commands status                     |
| show @@connection                                            | Report connection status                   |
| show @@cache                                                 | Report system cache usage                  |
| show @@backend                                               | Report backend connection status           |
| show @@session                                               | Report front session details               |
| show @@connection.sql                                        | Report connection sql                      |
| show @@sql.execute                                           | Report execute status                      |
| show @@sql.detail where id = ?                               | Report execute detail status               |
| show @@sql                                                   | Report SQL list                            |
| show @@sql.high                                              | Report Hight Frequency SQL                 |
| show @@sql.slow                                              | Report slow SQL                            |
| show @@sql.resultset                                         | Report BIG RESULTSET SQL                   |
| show @@sql.sum                                               | Report  User RW Stat                       |
| show @@sql.sum.user                                          | Report  User RW Stat                       |
| show @@sql.sum.table                                         | Report  Table RW Stat                      |
| show @@parser                                                | Report parser status                       |
| show @@router                                                | Report router status                       |
| show @@heartbeat                                             | Report heartbeat status                    |
| show @@heartbeat.detail where name=?                         | Report heartbeat current detail            |
| show @@slow where schema = ?                                 | Report schema slow sql                     |
| show @@slow where datanode = ?                               | Report datanode slow sql                   |
| show @@sysparam                                              | Report system param                        |
| show @@syslog limit=?                                        | Report system mycat.log                    |
| show @@white                                                 | show mycat white host                      |
| show @@white.set=?,?                                         | set mycat white host,[ip,user]             |
| show @@directmemory=1 or 2                                   | show mycat direct memory usage             |
| show @@check_global -SCHEMA= ? -TABLE=? -retry=? -interval=? | check mycat global table consistency       |
| switch @@datasource name:index                               | Switch dataSource                          |
| kill @@connection id1,id2,...                                | Kill the specified connections             |
| stop @@heartbeat name:time                                   | Pause dataNode heartbeat                   |
| reload @@config                                              | Reload basic config from file              |
| reload @@config_all                                          | Reload all config from file                |
| reload @@route                                               | Reload route config from file              |
| reload @@user                                                | Reload user config from file               |
| reload @@sqlslow=                                            | Set Slow SQL Time(ms)                      |
| reload @@user_stat                                           | Reset show @@sql  @@sql.sum @@sql.slow     |
| rollback @@config                                            | Rollback all config from memory            |
| rollback @@route                                             | Rollback route config from memory          |
| rollback @@user                                              | Rollback user config from memory           |
| reload @@sqlstat=open                                        | Open real-time sql stat analyzer           |
| reload @@sqlstat=close                                       | Close real-time sql stat analyzer          |
| offline                                                      | Change MyCat status to OFF                 |
| online                                                       | Change MyCat status to ON                  |
| clear @@slow where schema = ?                                | Clear slow sql by schema                   |
| clear @@slow where datanode = ?                              | Clear slow sql by datanode                 |
+--------------------------------------------------------------+--------------------------------------------+
59 rows in set (0.01 sec)

mysql> show @@server;
+-------------+-------------+--------------+------------+---------------+---------------+---------+--------+
| UPTIME      | USED_MEMORY | TOTAL_MEMORY | MAX_MEMORY | RELOAD_TIME   | ROLLBACK_TIME | CHARSET | STATUS |
+-------------+-------------+--------------+------------+---------------+---------------+---------+--------+
| 8m 7s 538ms |   230861432 |   1029177344 | 3817865216 | 1541149359926 |            -1 | utf8    | ON     |
+-------------+-------------+--------------+------------+---------------+---------------+---------+--------+

mysql> show @@database;
+----------+
| DATABASE |
+----------+
| testdb   |
+----------+
1 row in set (0.00 sec)

mysql> show @@heartbeat;
+------------+-------+----------------+------+---------+-------+--------+---------+--------------+---------------------+-------+
| NAME       | TYPE  | HOST           | PORT | RS_CODE | RETRY | STATUS | TIMEOUT | EXECUTE_TIME | LAST_ACTIVE_TIME    | STOP  |
+------------+-------+----------------+------+---------+-------+--------+---------+--------------+---------------------+-------+
| hostMaster | mysql | 172.16.128.148 | 3306 |       1 |     0 | idle   |   30000 | 1,2,2        | 2018-11-02 17:09:40 | false |
| hostMaster | mysql | 172.16.128.153 | 3306 |       1 |     0 | idle   |   30000 | 1,1,1        | 2018-11-02 17:09:40 | false |
| hostMaster | mysql | 172.16.128.152 | 3306 |       1 |     0 | idle   |   30000 | 1,2,2        | 2018-11-02 17:09:40 | false |
+------------+-------+----------------+------+---------+-------+--------+---------+--------------+---------------------+-------+
3 rows in set (0.00 sec)

-- 显示缓存的使用情况,对于性能监控和调优很有价值
mysql> show @@cache;
+-------------------------------------+-------+------+--------+------+------+-------------+----------+
| CACHE                               | MAX   | CUR  | ACCESS | HIT  | PUT  | LAST_ACCESS | LAST_PUT |
+-------------------------------------+-------+------+--------+------+------+-------------+----------+
| ER_SQL2PARENTID                     |  1000 |    0 |      0 |    0 |    0 |           0 |        0 |
| SQLRouteCache                       | 10000 |    0 |      0 |    0 |    0 |           0 |        0 |
| TableID2DataNodeCache.TESTDB_ORDERS | 50000 |    0 |      0 |    0 |    0 |           0 |        0 |
+-------------------------------------+-------+------+--------+------+------+-------------+----------+
3 rows in set (0.00 sec)

mysql> show @@connection;
+------------+------+-----------+------+------------+------+--------+---------+--------+---------+---------------+-------------+------------+---------+------------+
| PROCESSOR  | ID   | HOST      | PORT | LOCAL_PORT | USER | SCHEMA | CHARSET | NET_IN | NET_OUT | ALIVE_TIME(S) | RECV_BUFFER | SEND_QUEUE | txlevel | autocommit |
+------------+------+-----------+------+------------+------+--------+---------+--------+---------+---------------+-------------+------------+---------+------------+
| Processor3 |    1 | 127.0.0.1 | 9066 |      62623 | root | NULL   | utf8:33 |    314 |    9785 |           869 |        4096 |          0 |         |            |
+------------+------+-----------+------+------------+------+--------+---------+--------+---------+---------------+-------------+------------+---------+------------+
1 row in set (0.00 sec)

-- 重新加载配置文件schema.xml使其生效。
mysql> reload @@config;
mysql> show @@datanode;

二:Mycat-Eye安装

  1. 下载代码 https://gitee.com/MycatOne/Mycat-Eye

  2. 新建数据库mycat_eye,导入build/mycat_eye.sql文件,并在此数据库中新建数据库账户:dev,密码:123456

    mysql -h127.0.0.1 -P3306  -uroot -proot123
    mysql> create database mycat_eye default character set utf8mb4 collate utf8mb4_unicode_ci;
    
    mysql> use mycat_eye;
    
    mysql> source /Users/mengday/Softwares/Mycat-Eye/build/mycat_eye.sql
    
    mysql> CREATE USER 'dev'@'%' IDENTIFIED BY '07fa533360d9';
    mysql> update mysql.user set authentication_string=password('123456') where user='dev';
    mysql> grant all privileges on *.* to 'dev'@'%';
    mysql> flush privileges;
    
    ➜  ~ cd /Users/mengday/Softwares/Mycat-Eye
    ➜  mvn clean install
    
    cd /var/log
    sudo touch dbeye-for-nosql.log
    sudo chmod 777 dbeye-for-nosql.log
    

    ①:命令行启动

    # 启动mycateye-agent-xx.jar
    cd ~/Softwares/Mycat-Eye/mycateye-agent/target/
    java -jar mycateye-agent-0.8.jar --mysql.host=localhost --spring.profiles.active=prod &
    
    # 启动mycateye-web-xx.jar
    java -jar mycateye-web-0.8.jar --mysql.host=localhost --agent.url=http://127.0.0.1:7003/agent &
    

    ②:IDEA中启动程序 DbeyeAgentApplication

  3. 修改/Mycat-Eye/mycateye-agent/src/main/resources/application.properties

    spring.profiles.active=prod
    
  4. 修改application-prod.properties 中的mysql地址

    mysql.host=127.0.0.1
    
  5. 运行Mycat-Eye/mycateye-agent/src/main/java/io/mycat/eye/agent/DbeyeAgentApplication.java

  6. 修改mycateye-web中的application.properties中的环境
    /Mycat-Eye/mycateye-web/src/main/resources/application.properties

    spring.profiles.active=test
    
  7. 运行Mycat-Eye/mycateye-web/src/main/java/io/mycat/eye/web/MycatEyeApplication.java

  8. 访问http://localhost:7001/

猜你喜欢

转载自blog.csdn.net/vbirdbest/article/details/83960210