1、环境及版本

操作系统:   CentOS 7.5

MySQL:5.7.23

jdk:1.8.0_191

MyCat:1.6.6.1

cat /etc/centos-release
mysql -V
java -version

  

2、安装包准备

下载网站:http://dl.mycat.io/1.6.6/

【2】上传至linux服务器:

mkdir /home/rhr/soft/mycat
cd /home/rhr/soft/mycat
rz

  

3、开始安装

【1】解压

tar -zxvf Mycat-server-1.6-RELEASE-20161028204710-linux.tar.gz

【2】安装tree(可选,使目录结构更好看)

yum -y install tree

查看tree:

4、创建用户并修改配置文件

【1】为了更好的进入mycat,设置MYCAT_HOME的变量

vim /etc/profile

 添加绿色部分:


export JAVA_HOME=/home/rhr/soft/jdk/jdk1.8.0_191
export MYCAT_HOME=/home/rhr/soft/mycat/mycat
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:/usr/local/mysql/bin:$MYCAT_HOME/bin:$PATH

使得变量生效
source /etc/profile

检查

【2】配置mycat文件

(1)修改server.xml

cd home/rhr/soft/mycat/mycat/conf
cp server.xml server_bak.xml
vim server.xml

修改前:

修改后:

(2)修改schema.xml

1)  修改schema 标签

修改前:

    <schema name="TESTDB" checkSQLschema="false" sqlMaxLimit="100">
<!-- auto sharding by id (long) -->
<table name="travelrecord" dataNode="dn1,dn2,dn3" rule="auto-sharding-long" /> <!-- global table is auto cloned to all defined data nodes ,so can join
with any table whose sharding node is in the same data node -->
<table name="company" primaryKey="ID" type="global" dataNode="dn1,dn2,dn3" />
<table name="goods" primaryKey="ID" type="global" dataNode="dn1,dn2" />
<!-- random sharding using mod sharind rule -->
<table name="hotnews" primaryKey="ID" autoIncrement="true" dataNode="dn1,dn2,dn3" rule="mod-long" />
<!-- <table name="dual" primaryKey="ID" dataNode="dnx,dnoracle2" type="global"
needAddLimit="false"/> <table name="worker" primaryKey="ID" dataNode="jdbc_dn1,jdbc_dn2,jdbc_dn3" rule="mod-long" /> -->
<table name="employee" primaryKey="ID" dataNode="dn1,dn2" rule="sharding-by-intfile" />
<table name="customer" primaryKey="ID" dataNode="dn1,dn2" rule="sharding-by-intfile">
<childTable name="orders" primaryKey="ID" joinKey="customer_id" parentKey="id">
<childTable name="order_items" joinKey="order_id" parentKey="id" />
</childTable>
<childTable name="customer_addr" primaryKey="ID" joinKey="customer_id" parentKey="id" />
</table>
<!-- <table name="oc_call" primaryKey="ID" dataNode="dn1$0-743" rule="latest-month-calldate" /> -->
</schema>

修改后:

    <schema name="TESTDB" checkSQLschema="false" sqlMaxLimit="100">
<!-- auto sharding by id (long) -->
<table name="travelrecord" dataNode="dn1,dn2,dn3" rule="auto-sharding-long" /> <!-- global table is auto cloned to all defined data nodes ,so can join
with any table whose sharding node is in the same data node --> <table name="company" primaryKey="company_id" type="global" dataNode="dn1,dn2,dn3" />
<table name="goods" primaryKey="goods_id" type="global" dataNode="dn1,dn2" /> <!-- random sharding using mod sharind rule -->
<table name="hotnews" primaryKey="hotnews_id" autoIncrement="true" dataNode="dn1,dn2,dn3" rule="mod-long" /> <!-- <table name="dual" primaryKey="ID" dataNode="dnx,dnoracle2" type="global"
needAddLimit="false"/> <table name="worker" primaryKey="ID" dataNode="jdbc_dn1,jdbc_dn2,jdbc_dn3" rule="mod-long" /> --> <table name="employee" primaryKey="employee_id" dataNode="dn1,dn2" rule="sharding-by-intfile" /> <table name="customer" primaryKey="customer_id" dataNode="dn1,dn2" rule="sharding-by-murmur">
<childTable name="orders" primaryKey="order_id" joinKey="customer_id" parentKey="customer_id">
<childTable name="order_items" joinKey="order_id" parentKey="order_id" />
</childTable>
<childTable name="customer_addr" primaryKey="customer_addr_id" joinKey="customer_id" parentKey="customer_id" />
</table>
<!-- <table name="oc_call" primaryKey="ID" dataNode="dn1$0-743" rule="latest-month-calldate" /> -->
</schema>

2)  修改schema 标签

修改前

        <!-- can have multi write hosts -->
<writeHost host="hostM1" url="localhost:3306" user="root" password="123">
<!-- can have multi read hosts -->
<readHost host="hostS2" url="localhost:3306" user="root" password="123" />
</writeHost>
<writeHost host="hostS1" url="localhost:3306" user="root" password="123" />
<!-- <writeHost host="hostM2" url="localhost:3316" user="root" password="123456"/> -->

修改后:

    <!-- can have multi write hosts -->
<writeHost host="hostM1" url="localhost:3306" user="root" password="YYBrhr_2018">
<!-- can have multi read hosts -->
<!-- <readHost host="hostS2" url="localhost:3306" user="root" password="123" /> -->
</writeHost>
<!-- <writeHost host="hostS1" url="localhost:3306" user="root" password="123" /> -->
<!-- <writeHost host="hostM2" url="localhost:3316" user="root" password="123456"/> -->
</dataHost>

(3)修改role.xml

修改前:

<tableRule name="sharding-by-intfile">
<rule>
<columns>sharding_id</columns>
<algorithm>hash-int</algorithm>
</rule>
</tableRule>
<tableRule name="auto-sharding-long">
<rule>
<columns>id</columns>
<algorithm>rang-long</algorithm>
</rule>
</tableRule>
<tableRule name="mod-long">
<rule>
<columns>id</columns>
<algorithm>mod-long</algorithm>
</rule>
</tableRule>
<tableRule name="sharding-by-murmur">
<rule>
<columns>id</columns>
<algorithm>murmur</algorithm>
</rule>
</tableRule>

修改后:

    <tableRule name="sharding-by-intfile">
<rule>
<columns>employee_id</columns>
<algorithm>hash-int</algorithm>
</rule>
</tableRule>
<tableRule name="auto-sharding-long">
<rule>
<columns>id</columns>
<algorithm>rang-long</algorithm>
</rule>
</tableRule>
<tableRule name="mod-long">
<rule>
<columns>hotnews_id</columns>
<algorithm>mod-long</algorithm>
</rule>
</tableRule>
<tableRule name="sharding-by-murmur">
<rule>
<columns>customer_id</columns>
<algorithm>murmur</algorithm>
</rule>
</tableRule>

5、启动mycat并测试

【1】启动mycat

mycat start
mycat status

【2】测试

mysql -u root -p -P8066 -h 127.0.0.1

这里输入的密码,是在/home/rhr/soft/mycat/mycat/conf/server.xml里面看到的密码

这样就说明安装成功了,安装或者启动mycat之前

CentOS7.5 搭建mycat1.6.6的更多相关文章

  1. centos7 环境搭建

    centos7 环境搭建    CentOS-7-x86_64-DVD-1511.iso    vmware121. 安装    使用iso安装系统:2. 修改yum源到光盘        先把光盘C ...

  2. Kafka(二)CentOS7.5搭建Kafka2.11-1.1.0集群与简单测试

    一.下载 下载地址: http://kafka.apache.org/downloads.html    我这里下载的是Scala 2.11对应的 kafka_2.11-1.1.0.tgz 二.kaf ...

  3. 在Centos7下搭建Socks5代理服务器

    在Centos7下搭建Socks5代理服务器 http://blog.51cto.com/quliren/2052776   采用socks协议的代理服务器就是SOCKS服务器,是一种通用的代理服务器 ...

  4. 第四百零五节,centos7下搭建sentry错误日志服务器,接收python以及Django错误,

    第四百零五节,centos7下搭建sentry错误日志服务器,接收python以及Django错误, 注意:版本,不然会报错 Docker >=1.11Compose >1.6.0 通过d ...

  5. Hyperledger超级账本在Centos7下搭建运行环境

    超级账本(hyperledger)是Linux基金会于2015年发起的推进区块链数字技术和交易验证的开源项目,加入成员包括:荷兰银行(ABN AMRO).埃森哲(Accenture)等十几个不同利益体 ...

  6. git操作:在CentOS7上面搭建GitLab服务器

    在这篇文章中将要讲解如何在CentOS7上面搭建本地的GitLab服务器. 一.安装并配置必要的依赖关系 首先要在CentOS系统上面安装所需的依赖:ssh.防火墙.postfix(用于邮件通知).w ...

  7. Storm(二)CentOS7.5搭建Storm1.2.2集群

    一.Storm的下载 官网下载地址:http://storm.apache.org/downloads.html 这里下载最新的版本storm1.2.2,进入之后选择一个镜像下载 二.Storm伪分布 ...

  8. HBase(二)CentOS7.5搭建HBase1.2.6HA集群

    一.安装前提 1.HBase 依赖于 HDFS 做底层的数据存储 2.HBase 依赖于 MapReduce 做数据计算 3.HBase 依赖于 ZooKeeper 做服务协调 4.HBase源码是j ...

  9. Spark(二)CentOS7.5搭建Spark2.3.1分布式集群

    一 下载安装包 1 官方下载 官方下载地址:http://spark.apache.org/downloads.html 2  安装前提 Java8         安装成功 zookeeper  安 ...

随机推荐

  1. 【面试题046】求1+2+...+n

    [面试题046]求1+2+...+n 题目:     求1+2+...+n,要求不能使用乘除法.for.while.if.else.switch.case等关键字及条件判断语句(A?B:C).   思 ...

  2. POI2014

    ...一个shabi和一堆神题的故事 今天只写了两道 之后随缘更吧 啊 顺便 snake我是不会更的 bzoj3829 POI2014 Farmcraft mhy住在一棵有n个点的树的1号结点上,每个 ...

  3. RMAN兼容性、控制文件自动备份、保存时间、备份策略、备份脚本(二)

    RMAN 程序的兼容性 RMAN 环境由以下5部分组成:(1) RMAN executable(2) Recovery catalog database(3) Recovery catalog sch ...

  4. jquery.one()

    one() 方法为被选元素附加一个或多个事件处理程序,并规定当事件发生时运行的函数. 当使用 one() 方法时,每个元素只能运行一次事件处理器函数. 也就是,绑定的function,只会执行一次. ...

  5. HL7 ADT Message Sample

    http://pixpdqtests.nist.gov:8080/#tests%2Fdriver%2Fversion.htm 可以打开上述连接, 选中version和actor, 然后获取对于samp ...

  6. Redis实现求交集操作结果缓存的设计方案

    Redis的集合操作 实话说,Redis提供的集合操作是我选择它成为内存数据库的一个主要理由,它弥补了传统关系型数据库在这方面带来的复杂度,使得只需要简单的一个命令就可以完成一个复杂SQL任务,并且交 ...

  7. java-并发-进程和线程

    浏览以下内容前,请点击并阅读 声明 软件的并发是指同时做多件事情,java平台一开始就支持并发编程,java编程语言以及类库含有对并发最基本的支持,从5.0版本开始,java平台开始包含一些高并发的A ...

  8. java的clone()的使用

    clone()方法的约定 首先明确的是clone()是object的方法.Cloneable接口没有任何方法,它只起到标识的作用.(java的原型模式有用到) Cloneable接口的目的是作为对象的 ...

  9. linux命令:gzip命令

    减少文件大小有两个明显的好处,一是可以减少存储空间,二是通过网络传输文件时,可以减少传输的时间.gzip是在Linux系统中经常使用的一个对文件进行压缩和解压缩的命令,既方便又好用.gzip不仅可以用 ...

  10. ie8兼容rgba的方法

    现在做个网页还得考虑ie8,只想说:尼玛! 但是没办法,屈于淫威也得弄. 首先说下rgba的含义吧,rgba,r代表red,g代表green,b代表blue,a代表透明度. filter:progid ...