mycat+mysql实现按照⽉份数据分表
1. ⾸先下载 :( “选择win版本 第6个⽂件就是”)
2. 下载完毕,解压mycat之后配置环境变量
3. ok,环境变量配置完毕,解压后的mycat⼀⼤堆⽂件,⾸先我们要找到这⼏个:
4. 依次打开这⼏个⽂件,我们就按照⽉份分⽚配置好mycat
<?xml version="1.0" encoding="UTF-8"?>
<!---- Licend under the Apache Licen, Version 2.0(the "Licen");
- you may not u this file except in compliance with the Licen.- You
may obtain a copy of the Licen at -- www.apache/licens/LICENSE-2.0
-- Unless required by applicable law or agreed to in writing, software -
distributed under the Licen is distributed on an "AS IS"BASIS,-WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- See the
Licen for the specific language governing permissions and - limitations
under the Licen.-->
英文邮箱
<!DOCTYPE mycat:rver SYSTEM"rver.dtd">
<mycat:rver xmlns:mycat="io.mycat/">
<system>
<property name="uSqlStat">0</property><!--1为开启实时统计、0为关闭-->
<property name="uGlobleTableCheck">0</property><!--1为开启全加班⼀致性检测、0为关闭-->
<property name="qunceHandlerType">2</property>
<!--<property name="uCompression">1</property>--><!--1为开启mysql压缩协议-->11岁标准身高
<!--<property name="fakeMySQLVersion">5.6.20</property>--><!--设置模拟的MySQL版本号--> <!--<property name="processorBufferChunk">40960</property>-->
<!--
<property name="processors">1</property>
<property name="processorExecutor">32</property>
-->
<!--默认为type 0: DirectByteBufferPool | type 1 ByteBufferArena-->
<property name="processorBufferPoolType">0</property>
<!--默认是6553564K ⽤于sql解析时最⼤⽂本长度-->
<!--<property name="maxStringLiteralLength">65535</property>-->
<!--<property name="qunceHandlerType">0</property>-->
<!--<property name="backSocketNoDelay">1</property>-->
<!--<property name="frontSocketNoDelay">1</property>-->
<!--<property name="processorExecutor">16</property>-->
<!--
<property name="rverPort">8066</property><property name="managerPort">9066</property>
<property name="idleTimeout">300000</property><property name="bindIp">0.0.0.0</property>
<property name="frontWriteQueueSize">4096</property><property name="processors">32</property>-->
<!--分布式事务开关,0为不过滤分布式事务,1为过滤分布式事务(如果分布式事务内只涉及全局表,则不过滤),2为不过滤分布式事务,但是记录分布式事务⽇志-->
<property name="handleDistributedTransactions">0</property>
<!--
off heap for merge/order/group/limit 1开启0关闭
-->
<property name="uOffHeapForMerge">1</property>
<!--
单位为m
-->
<property name="memoryPageSize">1m</property>
<!--
单位为k
-->
<property name="spillsFileBufferSize">1k</property>
<property name="uStreamOutput">0</property>
<!--
单位为m
-->
<property name="systemRerveMemorySize">384m</property>
<!--是否采⽤zookeeper协调切换-->
<property name="uZKSwitch">fal</property>
</system>
<!--全局SQL防⽕墙设置-->
<!--
<firewall>
<whitehost>
<host host="127.0.0.1" ur="mycat"/>
<host host="127.0.0.2" ur="mycat"/>
</whitehost>
<blacklist check="fal">
</blacklist>
</firewall>
-->
<!--mycat ⽤户名-->
<ur name="root">
<!--mycat 密码-->中华上下五千年简介
<property name="password">root</property>
<property name="schemas">TESTDB</property>
<!--是否只读-->
<property name="readOnly">fal</property>
<!--表级DML权限设置
<privileges check="fal">
<schema name="TESTDB" dml="0110">
<table name="dn1" dml="1111"></table>
</schema>
</privileges>-->
</ur>
<ur name="ur">
<property name="password">ur</property>
<property name="schemas">TESTDB</property>
<property name="readOnly">true</property>
</ur>
</mycat:rver>
<?xml version="1.0"?>
<!DOCTYPE mycat:schema SYSTEM"schema.dtd">
<mycat:schema xmlns:mycat="io.mycat/">
<!-- name="TESTDB"是在l中配置<property name="schemas">TESTDB</property>-->
<schema name="TESTDB" checkSQLschema="fal" sqlMaxLimit="100">
<table name="nsor_data" subTables="january,february,march,april,may,june,july,august,ptember,october,november,december" primaryKey="id" au toIncrement="true" dataNode="dn1" rule="sharding-by-month"></table>
</schema>
<!--配置mysql数据库testdb2 mycat逻辑库名为 dn1-->
<dataNode name="dn1" dataHost="localhost1" databa="testdb2"/>
<!--配置数据类型 balance="0"读写不分离-->
<dataHost name="localhost1" maxCon="1000" minCon="10" balance="0" writeType="0" dbType="mysql" dbDriver="native" switchType="1" slaveThres hold="100">
<!--⼼跳包-->
<heartbeat>lect ur()</heartbeat>
<!--配置mysql数据账户密码-->
<writeHost host="hostM1" url="localhost:3306" ur="root" password="root"/>
</dataHost>
</mycat:schema>
<?xml version="1.0" encoding="UTF-8"?>
描写动物<!---- Licend under the Apache Licen, Version 2.0(the "Licen");
- you may not u this file except in compliance with the Licen.- You
may obtain a copy of the Licen at -- www.apache/licens/LICENSE-2.0
-- Unless required by applicable law or agreed to in writing, software -
distributed under the Licen is distributed on an "AS IS"BASIS,-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- See the Licen for the specific language governing permissions and - limitations
under the Licen.-->
<!DOCTYPE mycat:rule SYSTEM"rule.dtd">
<mycat:rule xmlns:mycat="io.mycat/">
<tableRule name="sharding-by-month">
<rule>
<!--按照创建时间分表-->
<!--属性指定对应表中⽤于分⽚的列名-->
<columns>create_time</columns>
<!--属性对应function中指定的算法的名称-->
<algorithm>sharding-by-month</algorithm>
</rule>
我走后简谱
</tableRule>
<function name="sharding-by-month"class="ute.function.PartitionByMonth"> <!--按⽉分⽚-->
<property name="dateFormat">yyyy-MM-dd HH:mm:ss</property>
高三自我总结<!--开始时间,插⼊数据只能是这个年份的数据-->
<property name="sBeginDate">2020-01-0100:00:00</property>
</function>
</mycat:rule>
#********************************************************************
# Wrapper Properties
#********************************************************************
# Java Application
and=C:\Program Files\Java\jdk1.8.0_131\
wrapper.working.dir=..
swim的过去式
# Java Main class. This class must implement the WrapperListener interface
# or guarantee that the WrapperManager class is initialized. Helper
# class are provided to do this for you. See the Integration ction
# of the documentation for details.
wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp
t.default.REPO_DIR=lib
t.APP_BASE=.
红烧肉焖饭# Java Classpath(include wrapper.jar) Add class path elements as
# needed starting from1
wrapper.java.classpath.1=lib/wrapper.jar
wrapper.java.classpath.2=conf
wrapper.java.classpath.3=%REPO_DIR%/*
# Java Library Path (location of Wrapper.DLL or libwrapper.so)
wrapper.java.library.path.1=lib
# Java Additional Parameters
#wrapper.java.additional.1=
wrapper.java.additional.1=-DMYCAT_HOME=.
wrapper.java.additional.2=-rver
wrapper.java.additional.3=-XX:MaxPermSize=64M