镜缘浮影 小人本住在 苏州的城外 家里有屋又有田 生活乐无边

Mycat web 基础

2016-02-29
wilmosfang
原文地址 http://soft.dog/2016/02/29/mycat-web/

前言

Mycat 是一个数据库分库分表中间件

Mycat web 可以对 Mycat进行监控,这里分享一下 Mycat web 的搭建过程

详细内容可以参考 官方文档

Tip: 当前的最新版本为 Mycat-web-1.0


概要


环境依赖

JAVA

mycat-eye 依赖 jdk1.7+ 的环境

[root@h102 src]# java -version
java version "1.7.0_65"
OpenJDK Runtime Environment (rhel-2.5.1.2.el6_5-x86_64 u65-b17)
OpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode)
[root@h102 src]# 

java环境符合要求

Zookeeper

Mycat web 需要 Zookeeper作为配置中心

Zookeeper下载地址

[root@h102 src]# wget http://apache.fayea.com/zookeeper/zookeeper-3.4.8/zookeeper-3.4.8.tar.gz
--2016-02-29 19:53:00--  http://apache.fayea.com/zookeeper/zookeeper-3.4.8/zookeeper-3.4.8.tar.gz
Resolving apache.fayea.com... 119.6.242.165, 119.6.242.164
Connecting to apache.fayea.com|119.6.242.165|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 22261552 (21M) [application/x-gzip]
Saving to: “zookeeper-3.4.8.tar.gz”

100%[============================================================================>] 22,261,552   468K/s   in 46s     

2016-02-29 19:53:47 (468 KB/s) - “zookeeper-3.4.8.tar.gz” saved [22261552/22261552]

[root@h102 src]# 
[root@h102 src]# ll zookeeper-3.4.8.tar.gz 
-rw-r--r-- 1 root root 22261552 Feb 21 04:41 zookeeper-3.4.8.tar.gz
[root@h102 src]# 

Tip: 当前版本为 Release 3.4.8(stable)

安装

下载zk后,确保有java环境的情况下解压就可以使用了

[root@h102 src]# tar -zxvf zookeeper-3.4.8.tar.gz 
zookeeper-3.4.8/
zookeeper-3.4.8/zookeeper-3.4.8.jar.md5
zookeeper-3.4.8/zookeeper-3.4.8.jar.asc
zookeeper-3.4.8/zookeeper-3.4.8.jar
zookeeper-3.4.8/contrib/
...
...
zookeeper-3.4.8/conf/
zookeeper-3.4.8/conf/configuration.xsl
zookeeper-3.4.8/conf/zoo_sample.cfg
zookeeper-3.4.8/conf/log4j.properties
zookeeper-3.4.8/zookeeper-3.4.8.jar.sha1
zookeeper-3.4.8/NOTICE.txt
zookeeper-3.4.8/build.xml
[root@h102 src]# 

配置

zoo_sample.cfg 修改为 zoo.cfg

[root@h102 src]# cd zookeeper-3.4.8/conf
[root@h102 conf]# grep -v  "^#" zoo_sample.cfg 
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/tmp/zookeeper
clientPort=2181
[root@h102 conf]# cp zoo_sample.cfg  zoo.cfg 
[root@h102 conf]# 

运行

[root@h102 zookeeper-3.4.8]# bin/zkServer.sh  start 
ZooKeeper JMX enabled by default
Using config: /usr/local/src/zookeeper-3.4.8/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@h102 zookeeper-3.4.8]# ps faux | grep zook
root     34642  0.0  0.0 103256   824 pts/0    S+   20:03   0:00          \_ grep zook
root     34622 35.0  2.1 2094296 40376 pts/0   Sl   20:03   0:02 java -Dzookeeper.log.dir=. -Dzookeeper.root.logger=INFO,CONSOLE -cp /usr/local/src/zookeeper-3.4.8/bin/../build/classes:/usr/local/src/zookeeper-3.4.8/bin/../build/lib/*.jar:/usr/local/src/zookeeper-3.4.8/bin/../lib/slf4j-log4j12-1.6.1.jar:/usr/local/src/zookeeper-3.4.8/bin/../lib/slf4j-api-1.6.1.jar:/usr/local/src/zookeeper-3.4.8/bin/../lib/netty-3.7.0.Final.jar:/usr/local/src/zookeeper-3.4.8/bin/../lib/log4j-1.2.16.jar:/usr/local/src/zookeeper-3.4.8/bin/../lib/jline-0.9.94.jar:/usr/local/src/zookeeper-3.4.8/bin/../zookeeper-3.4.8.jar:/usr/local/src/zookeeper-3.4.8/bin/../src/java/lib/*.jar:/usr/local/src/zookeeper-3.4.8/bin/../conf: -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false org.apache.zookeeper.server.quorum.QuorumPeerMain /usr/local/src/zookeeper-3.4.8/bin/../conf/zoo.cfg
[root@h102 zookeeper-3.4.8]# netstat  -ant | grep 2181
tcp        0      0 :::2181                     :::*                        LISTEN      
[root@h102 zookeeper-3.4.8]# 

下载

Mycat-web下载地址

[root@h102 src]# wget https://github.com/MyCATApache/Mycat-download/raw/master/mycat-web-1.0/Mycat-web-1.0-SNAPSHOT-20160218145029-linux.tar.gz
--2016-02-29 20:09:04--  https://github.com/MyCATApache/Mycat-download/raw/master/mycat-web-1.0/Mycat-web-1.0-SNAPSHOT-20160218145029-linux.tar.gz
Resolving github.com... 192.30.252.130
Connecting to github.com|192.30.252.130|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://raw.githubusercontent.com/MyCATApache/Mycat-download/master/mycat-web-1.0/Mycat-web-1.0-SNAPSHOT-20160218145029-linux.tar.gz [following]
--2016-02-29 20:09:05--  https://raw.githubusercontent.com/MyCATApache/Mycat-download/master/mycat-web-1.0/Mycat-web-1.0-SNAPSHOT-20160218145029-linux.tar.gz
Resolving raw.githubusercontent.com... 103.245.222.133
Connecting to raw.githubusercontent.com|103.245.222.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 54378894 (52M) [application/octet-stream]
Saving to: “Mycat-web-1.0-SNAPSHOT-20160218145029-linux.tar.gz”

100%[============================================================================>] 54,378,894   191K/s   in 3m 14s  

2016-02-29 20:13:19 (274 KB/s) - “Mycat-web-1.0-SNAPSHOT-20160218145029-linux.tar.gz” saved [54378894/54378894]

[root@h102 src]# file Mycat-web-1.0-SNAPSHOT-20160218145029-linux.tar.gz 
Mycat-web-1.0-SNAPSHOT-20160218145029-linux.tar.gz: gzip compressed data, from FAT filesystem (MS-DOS, OS/2, NT)
[root@h102 src]# ll Mycat-web-1.0-SNAPSHOT-20160218145029-linux.tar.gz 
-rw-r--r-- 1 root root 54378894 Feb 29 20:13 Mycat-web-1.0-SNAPSHOT-20160218145029-linux.tar.gz
[root@h102 src]# 

解压

[root@h102 src]# tar -zxvf Mycat-web-1.0-SNAPSHOT-20160218145029-linux.tar.gz 
mycat-web/mycat-web/
mycat-web/mycat-web/static/
mycat-web/mycat-web/static/highcharts/
mycat-web/mycat-web/static/adminlte/
mycat-web/mycat-web/static/adminlte/dist/
mycat-web/mycat-web/static/adminlte/dist/css/
mycat-web/mycat-web/static/adminlte/dist/css/skins/
mycat-web/mycat-web/static/adminlte/dist/js/
...
...
mycat-web/
mycat-web/readme.txt
mycat-web/start.sh
mycat-web/start.jar
[root@h102 src]# 
[root@h102 src]# ll mycat-web/
total 40
drwxr-xr-x  2 root root  4096 Oct 20 10:44 etc
drwxr-xr-x  3 root root  4096 Oct 20 10:44 lib
drwxr-xr-x 11 root root  4096 Feb 18 14:50 mycat-web
-rwxr-xr-x  1 root root   116 Oct 20 10:44 readme.txt
-rwxr-xr-x  1 root root 17125 Oct 20 10:44 start.jar
-rwxr-xr-x  1 root root   381 Oct 20 10:44 start.sh
[root@h102 src]# 

启动

[root@h102 mycat-web]# ./start.sh 
nohup: ignoring input and appending output to `nohup.out'
...
...
...
----------
[root@h102 etc]# netstat  -ant | grep 8082
tcp        0      0 :::8082                     :::*                        LISTEN      
[root@h102 etc]# 

Note: 要确保 8082 端口是开放的

[root@h102 etc]# iptables -L -nv | grep 8082
    0     0 ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:8082 
[root@h102 etc]# 

访问

输入 http://192.168.100.102:8082/mycat/ 进行访问

mycat_web1.png

新增Mycat监控实例

mycat_web2.png

mycat_web3.png

mycat_web4.png

mycat_web5.png

Mycat系统参数

mycat_web6.png

Mycat日志

mycat_web7.png

Mycat监控

mycat_web8.png mycat_web9.png mycat_web10.png mycat_web11.png

Mycat物理节点

mycat_web12.png

SQL 表分析

mycat_web13.png

SQL监控

mycat_web14.png

mycat_web15.png

高频SQL监控

mycat_web16.png

SQL解析

mycat_web17.png mycat_web18.png


命令汇总

  • java -version
  • wget http://apache.fayea.com/zookeeper/zookeeper-3.4.8/zookeeper-3.4.8.tar.gz
  • ll zookeeper-3.4.8.tar.gz
  • tar -zxvf zookeeper-3.4.8.tar.gz
  • cd zookeeper-3.4.8/conf
  • grep -v "^#" zoo_sample.cfg
  • cp zoo_sample.cfg zoo.cfg
  • bin/zkServer.sh start
  • netstat -ant | grep 2181
  • wget https://github.com/MyCATApache/Mycat-download/raw/master/mycat-web-1.0/Mycat-web-1.0-SNAPSHOT-20160218145029-linux.tar.gz
  • file Mycat-web-1.0-SNAPSHOT-20160218145029-linux.tar.gz
  • tar -zxvf Mycat-web-1.0-SNAPSHOT-20160218145029-linux.tar.gz
  • ./start.sh
  • netstat -ant | grep 8082
  • iptables -L -nv | grep 8082

原文地址 http://soft.dog/2016/02/29/mycat-web/

评论