• 2-1 章节综述
  • 2-2 什么是MyCat
  • 2-3 什么是数据库中间层
  • 2-4 MyCat的主要作用
  • 2-5 MyCat基本元素
  • 2-6 MyCat的安装

2-1 章节综述

1、掌握Mycat的基础概念、功能及适用场景;

2、掌握Mycat的安装和启动;

2-2 什么是MyCat

1、不同的工种对Mycat的不同理解;

  • 研发人员;

  • 架构师;

2、实现“读写分离”的两种方式;

  • 从程序的角度实现,配置两套数据源;
  • 通过中间件的角度实现,比如Mycat;

2-3 什么是数据库中间层

1、数据库中间层初识;

2-4 MyCat的主要作用

1、作为分布式数据库中间层使用(关系型与菲关系型均可);

2、实现后端数据库的读写分离及负载均衡;

3、在数据库中,一般读请求操作远高于写请求操作;

4、改下图所示的,仅适用于“一主一从”的MySQL数据库架构;

5、实现“一主多从”的MySQL高可用,需要通过MHA或者3M的方式实现;

6、对业务数据库进行垂直切分;

7、使用Mycat的好处,将后端对应的真实数据库,作为一个“逻辑库”;

8、对业务数据库进行水平切分(分库分表);

9、切分逻辑,通过Mycat;

10、控制数据库连接的数量;

  • 当连接数占满后,所有新请求将无法再连接,影响业务;
  • 通过Mycat中间件,建立一个公共的“数据库连接池”;

2-5 MyCat基本元素

1、逻辑库&逻辑表概念回顾;

2、逻辑表的分类;

  • 分片表
  • 全局表
  • ER关系表

2-6 MyCat的安装

1、下载并解压Mycat;

wget http://dl.mycat.io/1.6.5/Mycat-server-1.6.5-release-20180122220033-linux.tar.gz

2、安装JAVA运行环境JDK1.7或之上版本;

wget http://download.oracle.com/otn/java/jdk/7u80-b15/jdk-7u80-linux-x64.tar.gz?AuthParam=1527933488_83c1bdc9836fadfe600eceed8afc9a1c

3、新建Mycat运行系统账号;

useradd mycat

chown -R mycat:mycat /usr/local/mycat

4、配置系统环境变量;

vim /etc/profile#修改系统环境变量;

export MyCAT_HOME=/usr/local/mycat
export JAVA_HOME=/usr/local/jdk1.7.0_80
export CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib
export PATH=$MyCAT_HOME/bin:$JAVA_HOME/bin:$PATH

source /etc/profile

5、修改mycat启动参数;

vim /usr/local/mycat/conf/wrapper.conf#调整mycat内存大小;

日志:

[BEGIN] 2018/6/2 17:55:10
[root@iZqmo9i3j77p7eZ ~]# cd /usr/local/src/
[root@iZqmo9i3j77p7eZ src]# wget http://dl.mycat.io/1.6.5/Mycat-server-1.6.5-release-20180122220033-linux.tar.gz
--2018-06-02 17:55:20-- http://dl.mycat.io/1.6.5/Mycat-server-1.6.5-release-20180122220033-linux.tar.gz
Resolving dl.mycat.io (dl.mycat.io)... 210.51.26.184
Connecting to dl.mycat.io (dl.mycat.io)|210.51.26.184|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 17480035 (17M) [application/octet-stream]
Saving to: ‘Mycat-server-1.6.5-release-20180122220033-linux.tar.gz’ 100%[====================================================================================================================================================================================================================================>] 17,480,035 507KB/s in 34s 2018-06-02 17:55:55 (502 KB/s) - ‘Mycat-server-1.6.5-release-20180122220033-linux.tar.gz’ saved [17480035/17480035]
[root@iZqmo9i3j77p7eZ src]# wget http://download.oracle.com/otn/java/jdk/7u80-b15/jdk-7u80-linux-x64.tar.gz?AuthParam=1527933488_83c1bdc9836fadfe600eceed8afc9a1c
--2018-06-02 17:56:35-- http://download.oracle.com/otn/java/jdk/7u80-b15/jdk-7u80-linux-x64.tar.gz?AuthParam=1527933488_83c1bdc9836fadfe600eceed8afc9a1c
Resolving download.oracle.com (download.oracle.com)... 23.218.25.93
Connecting to download.oracle.com (download.oracle.com)|23.218.25.93|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 153530841 (146M) [application/x-gzip]
Saving to: ‘jdk-7u80-linux-x64.tar.gz?AuthParam=1527933488_83c1bdc9836fadfe600eceed8afc9a1c’ 100%[====================================================================================================================================================================================================================================>] 153,530,841 5.96MB/s in 24s 2018-06-02 17:57:00 (6.08 MB/s) - ‘jdk-7u80-linux-x64.tar.gz?AuthParam=1527933488_83c1bdc9836fadfe600eceed8afc9a1c’ saved [153530841/153530841] [root@iZqmo9i3j77p7eZ src]# rpm -qa|grep java
[root@iZqmo9i3j77p7eZ src]# ll
total 167008
-rw-r--r-- 1 root root 153530841 Jul 8 2015 jdk-7u80-linux-x64.tar.gz?AuthParam=1527933488_83c1bdc9836fadfe600eceed8afc9a1c
-rw-r--r-- 1 root root 17480035 Jan 22 22:07 Mycat-server-1.6.5-release-20180122220033-linux.tar.gz
[root@iZqmo9i3j77p7eZ src]# mv jdk-7u80-linux-x64.tar.gz\?AuthParam\=1527933488_83c1bdc9836fadfe600eceed8afc9a1c jdk-7u80-linux-x64.tar.gz
[root@iZqmo9i3j77p7eZ src]# tar zxf jdk-7u80-linux-x64.tar.gz -C /usr/local/
[root@iZqmo9i3j77p7eZ src]# vim /etc/profile
[root@iZqmo9i3j77p7eZ src]# source /etc/profile
[root@iZqmo9i3j77p7eZ src]# java
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-d32 use a 32-bit data model if available
-d64 use a 64-bit data model if available
-server to select the "server" VM
The default VM is server. -cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A : separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D<name>=<value>
set a system property
-verbose:[class|gc|jni]
enable verbose output
-version print product version and exit
-version:<value>
require the specified version to run
-showversion print product version and continue
-jre-restrict-search | -no-jre-restrict-search
include/exclude user private JREs in the version search
-? -help print this help message
-X print help on non-standard options
-ea[:<packagename>...|:<classname>]
-enableassertions[:<packagename>...|:<classname>]
enable assertions with specified granularity
-da[:<packagename>...|:<classname>]
-disableassertions[:<packagename>...|:<classname>]
disable assertions with specified granularity
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
-agentlib:<libname>[=<options>]
load native agent library <libname>, e.g. -agentlib:hprof
see also, -agentlib:jdwp=help and -agentlib:hprof=help
-agentpath:<pathname>[=<options>]
load native agent library by full pathname
-javaagent:<jarpath>[=<options>]
load Java programming language agent, see java.lang.instrument
-splash:<imagepath>
show splash screen with specified image
See http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details.
[root@iZqmo9i3j77p7eZ src]# javac
Usage: javac <options> <source files>
where possible options include:
-g Generate all debugging info
-g:none Generate no debugging info
-g:{lines,vars,source} Generate only some debugging info
-nowarn Generate no warnings
-verbose Output messages about what the compiler is doing
-deprecation Output source locations where deprecated APIs are used
-classpath <path> Specify where to find user class files and annotation processors
-cp <path> Specify where to find user class files and annotation processors
-sourcepath <path> Specify where to find input source files
-bootclasspath <path> Override location of bootstrap class files
-extdirs <dirs> Override location of installed extensions
-endorseddirs <dirs> Override location of endorsed standards path
-proc:{none,only} Control whether annotation processing and/or compilation is done.
-processor <class1>[,<class2>,<class3>...] Names of the annotation processors to run; bypasses default discovery process
-processorpath <path> Specify where to find annotation processors
-d <directory> Specify where to place generated class files
-s <directory> Specify where to place generated source files
-implicit:{none,class} Specify whether or not to generate class files for implicitly referenced files
-encoding <encoding> Specify character encoding used by source files
-source <release> Provide source compatibility with specified release
-target <release> Generate class files for specific VM version
-version Version information
-help Print a synopsis of standard options
-Akey[=value] Options to pass to annotation processors
-X Print a synopsis of nonstandard options
-J<flag> Pass <flag> directly to the runtime system
-Werror Terminate compilation if warnings occur
@<filename> Read options and filenames from file [root@iZqmo9i3j77p7eZ src]# java -version
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)
[root@iZqmo9i3j77p7eZ src]# ll
total 167008
-rw-r--r-- 1 root root 153530841 Jul 8 2015 jdk-7u80-linux-x64.tar.gz
-rw-r--r-- 1 root root 17480035 Jan 22 22:07 Mycat-server-1.6.5-release-20180122220033-linux.tar.gz
[root@iZqmo9i3j77p7eZ src]# tar xf Mycat-server-1.6.5-release-20180122220033-linux.tar.gz -C /usr/local/
[root@iZqmo9i3j77p7eZ src]# cd /usr/local/
[root@iZqmo9i3j77p7eZ local]# ls
aegis bin etc games include jdk1.7.0_80 lib lib64 libexec mycat sbin share src
[root@iZqmo9i3j77p7eZ local]# ll
total 52
drwxr-xr-x 6 root root 4096 May 30 10:25 aegis
drwxr-xr-x. 2 root root 4096 Nov 5 2016 bin
drwxr-xr-x. 2 root root 4096 Nov 5 2016 etc
drwxr-xr-x. 2 root root 4096 Nov 5 2016 games
drwxr-xr-x. 2 root root 4096 Nov 5 2016 include
drwxr-xr-x 8 10 143 4096 Apr 11 2015 jdk1.7.0_80
drwxr-xr-x. 2 root root 4096 Nov 5 2016 lib
drwxr-xr-x. 2 root root 4096 Nov 5 2016 lib64
drwxr-xr-x. 2 root root 4096 Nov 5 2016 libexec
drwxr-xr-x 7 root root 4096 Jun 2 17:58 mycat
drwxr-xr-x. 2 root root 4096 Nov 5 2016 sbin
drwxr-xr-x. 6 root root 4096 May 26 11:18 share
drwxr-xr-x. 2 root root 4096 Jun 2 17:57 src
[root@iZqmo9i3j77p7eZ local]# useradd mycat
[root@iZqmo9i3j77p7eZ local]# ll
total 52
drwxr-xr-x 6 root root 4096 May 30 10:25 aegis
drwxr-xr-x. 2 root root 4096 Nov 5 2016 bin
drwxr-xr-x. 2 root root 4096 Nov 5 2016 etc
drwxr-xr-x. 2 root root 4096 Nov 5 2016 games
drwxr-xr-x. 2 root root 4096 Nov 5 2016 include
drwxr-xr-x 8 10 143 4096 Apr 11 2015 jdk1.7.0_80
drwxr-xr-x. 2 root root 4096 Nov 5 2016 lib
drwxr-xr-x. 2 root root 4096 Nov 5 2016 lib64
drwxr-xr-x. 2 root root 4096 Nov 5 2016 libexec
drwxr-xr-x 7 root root 4096 Jun 2 17:58 mycat
drwxr-xr-x. 2 root root 4096 Nov 5 2016 sbin
drwxr-xr-x. 6 root root 4096 May 26 11:18 share
drwxr-xr-x. 2 root root 4096 Jun 2 17:57 src
[root@iZqmo9i3j77p7eZ local]# chown -R mycat:mycat mycat/
[root@iZqmo9i3j77p7eZ local]# cd mycat/
[root@iZqmo9i3j77p7eZ mycat]# ls -l
total 24
drwxr-xr-x 2 mycat mycat 4096 Jun 2 17:58 bin
drwxrwxrwx 2 mycat mycat 4096 Mar 1 2016 catlet
drwxrwxrwx 4 mycat mycat 4096 Jun 2 17:58 conf
drwxr-xr-x 2 mycat mycat 4096 Jun 2 17:58 lib
drwxrwxrwx 2 mycat mycat 4096 Jan 22 22:01 logs
-rwxrwxrwx 1 mycat mycat 219 Jan 22 22:00 version.txt
[root@iZqmo9i3j77p7eZ mycat]# cd bin/
[root@iZqmo9i3j77p7eZ bin]# ls
dataMigrate.sh init_zk_data.sh mycat rehash.sh startup_nowrap.sh wrapper-linux-ppc-64 wrapper-linux-x86-32 wrapper-linux-x86-64
[root@iZqmo9i3j77p7eZ bin]# cd /usr/local/mycat/conf/
[root@iZqmo9i3j77p7eZ conf]# ls -l
total 108
-rwxrwxrwx 1 mycat mycat 88 Jan 22 22:00 autopartition-long.txt
-rwxrwxrwx 1 mycat mycat 48 Jan 22 22:00 auto-sharding-long.txt
-rwxrwxrwx 1 mycat mycat 62 Jan 22 22:00 auto-sharding-rang-mod.txt
-rwxrwxrwx 1 mycat mycat 334 Jan 22 22:00 cacheservice.properties
-rwxrwxrwx 1 mycat mycat 3244 Jan 22 22:00 dbseq.sql
-rwxrwxrwx 1 mycat mycat 439 Jan 22 22:00 ehcache.xml
-rwxrwxrwx 1 mycat mycat 2132 Jan 22 22:00 index_to_charset.properties
-rwxrwxrwx 1 mycat mycat 1253 Dec 1 2016 log4j2.xml
-rwxrwxrwx 1 mycat mycat 178 Jan 22 22:00 migrateTables.properties
-rwxrwxrwx 1 mycat mycat 262 Jan 22 22:00 myid.properties
-rwxrwxrwx 1 mycat mycat 15 Jan 22 22:00 partition-hash-int.txt
-rwxrwxrwx 1 mycat mycat 102 Jan 22 22:00 partition-range-mod.txt
-rwxrwxrwx 1 mycat mycat 4794 Jan 22 22:00 rule.xml
-rwxrwxrwx 1 mycat mycat 4219 Jan 22 22:00 schema.xml
-rwxrwxrwx 1 mycat mycat 413 Jan 22 22:00 sequence_conf.properties
-rwxrwxrwx 1 mycat mycat 75 Jan 22 22:00 sequence_db_conf.properties
-rwxrwxrwx 1 mycat mycat 27 Jan 22 22:00 sequence_distributed_conf.properties
-rwxrwxrwx 1 mycat mycat 51 Jan 22 22:00 sequence_time_conf.properties
-rwxrwxrwx 1 mycat mycat 4623 Jan 22 22:00 server.xml
-rwxrwxrwx 1 mycat mycat 16 Jan 22 22:00 sharding-by-enum.txt
-rwxrwxrwx 1 mycat mycat 4186 Jan 22 22:05 wrapper.conf
drwxrwxrwx 2 mycat mycat 4096 Jun 2 17:58 zkconf
drwxrwxrwx 2 mycat mycat 4096 Jun 2 17:58 zkdownload
[root@iZqmo9i3j77p7eZ conf]# vim wrapper.conf
-rwxrwxrwx 1 mycat mycat 4623 Jan 22 22:00 server.xml
-rwxrwxrwx 1 mycat mycat 16 Jan 22 22:00 sharding-by-enum.txt
-rwxrwxrwx 1 mycat mycat 4186 Jan 22 22:05 wrapper.conf
drwxrwxrwx 2 mycat mycat 4096 Jun 2 17:58 zkconf
drwxrwxrwx 2 mycat mycat 4096 Jun 2 17:58 zkdownload
[root@iZqmo9i3j77p7eZ bin]# vim /etc/profile
[root@iZqmo9i3j77p7eZ bin]# source /etc/profile
[root@iZqmo9i3j77p7eZ bin]# mycat
Usage: /usr/local/mycat/bin/mycat { console | start | stop | restart | status | dump }
[root@iZqmo9i3j77p7eZ bin]# mycat status
Mycat-server is not running.
[root@iZqmo9i3j77p7eZ bin]# mycat start
Starting Mycat-server...

MyCAT+MySQL 搭建高可用企业级数据库集群——第2章 MyCat入门的更多相关文章

  1. MyCAT+MySQL 搭建高可用企业级数据库集群——第3章 MyCat核心配置讲解

    3-1 章节综述 3-2 常用配置文件间的关系 3-3 server.xml配置详解 3-4 log4j2.xml配置文件 3-5 rule.xml 3-6 常用分片算法(上) 3-7 常用分片算法( ...

  2. MyCAT+MySQL搭建高可用企业级数据库集群视频课程

    原文地址:https://www.guangboyuan.cn/mycatmysql%E6%90%AD%E5%BB%BA%E9%AB%98%E5%8F%AF%E7%94%A8%E4%BC%81%E4% ...

  3. keepalived工作原理和配置说明 腾讯云VPC内通过keepalived搭建高可用主备集群

    keepalived工作原理和配置说明 腾讯云VPC内通过keepalived搭建高可用主备集群 内网路由都用mac地址 一个mac地址绑定多个ip一个网卡只能一个mac地址,而且mac地址无法改,但 ...

  4. K8S 使用Kubeadm搭建高可用Kubernetes(K8S)集群 - 证书有效期100年

    1.概述 Kubenetes集群的控制平面节点(即Master节点)由数据库服务(Etcd)+其他组件服务(Apiserver.Controller-manager.Scheduler...)组成. ...

  5. mycat+mysql搭建高可用集群1--垂直分库

    mycat垂直分库 本文主要介绍了如何使用mycat对mysql数据库进行垂直分库,包括: 垂直分库的步骤 垂直分库的环境准备 配置mycat垂直分库 1. 垂直分库的步骤 收集分析业务模块间的关系 ...

  6. 搭建高可用的MongoDB集群

    http://www.csdn.net/article/2014-04-09/2819221-build-high-avialable-mongodb-cluster-part-1/1 在大数据的时代 ...

  7. Redis Cluster搭建高可用Redis服务器集群

    一.Redis Cluster集群简介 Redis Cluster是Redis官方提供的分布式解决方案,在3.0版本后推出的,有效地解决了Redis分布式的需求,当一个节点挂了可以快速的切换到另一个节 ...

  8. 搭建高可用的rabbitmq集群 + Mirror Queue + 使用C#驱动连接

    我们知道rabbitmq是一个专业的MQ产品,而且它也是一个严格遵守AMQP协议的玩意,但是要想骚,一定需要拿出高可用的东西出来,这不本篇就跟大家说 一下cluster的概念,rabbitmq是erl ...

  9. 手动搭建高可用的kubernetes 集群

    之前按照和我一步步部署 kubernetes 集群的步骤一步一步的成功的使用二进制的方式安装了kubernetes集群,在该文档的基础上重新部署了最新的v1.8.2版本,实现了kube-apiserv ...

随机推荐

  1. 匿名union

    #include <stdio.h> enum node_type{    t_int,t_double}; struct node{    enum node_type type;   ...

  2. iOS10 开发权限适配设置 崩溃(上传打包后构建版本一直不显示)

    ios10 系统必须强制配置系统权限 如果不配置,调试的时候导致崩溃,还会引发包无效的问题,导致上传打包后构建版本一直不显示 解决方案1.在项目中找到info.plist文件,右键点击以 Source ...

  3. POST和GET请求区别

    最新博客站点:欢迎来访 1. 请求长度的限制 在HTTP协议中,从未规定GET/POST的请求长度限制,对于GET,对url的限制来源于浏览器或web服务器,浏览器和服务器限制了url的长度.因此,在 ...

  4. 肝题与oj

    oier很多,oj也很多,这些oj分别有怎样的特点,我们又该怎样选择呢?请各位客官听在下分解 (我主要说一些比较大众的oj) (注意:难度与界面友好度为个人意见,不喜勿喷) 1.入门级 1.NOIop ...

  5. 第13届景驰-埃森哲杯广东工业大学ACM程序设计大赛--E-回旋星空

    链接:https://www.nowcoder.com/acm/contest/90/E 来源:牛客网 1.题目描述 曾经有两个来自吉尔尼斯的人(A和C)恋爱了,他们晚上经常在一起看头上的那片名为假的 ...

  6. [洛谷P1390]公约数的和·莫比乌斯反演

    公约数的和 传送门 分析 这道题很显然答案为 \[Ans=\sum_{i=1}^n\sum_{j=i+1}^n (i,j)\] //其中\((i,j)\)意味\(gcd(i,j)\) 这样做起来很烦, ...

  7. poj 2186 Popular Cows :求能被有多少点是能被所有点到达的点 tarjan O(E)

    /** problem: http://poj.org/problem?id=2186 当出度为0的点(可能是缩点后的点)只有一个时就存在被所有牛崇拜的牛 因为如果存在有两个及以上出度为0的点的话,他 ...

  8. ABAP术语-HTML

    HTML 原文:http://www.cnblogs.com/qiangsheng/archive/2008/02/19/1073298.html Hypertext Markup Language( ...

  9. ABAP术语-BW (Business Information Warehouse)

    BW (Business Information Warehouse) 原文:http://www.cnblogs.com/qiangsheng/archive/2008/01/14/1037761. ...

  10. ABAP术语-Application Server

    Application Server 原文:http://www.cnblogs.com/qiangsheng/archive/2007/12/17/1002777.html Server that ...