51,411
社区成员
发帖
与我相关
我的任务
分享
<?xml version="1.0"?>
<!DOCTYPE mycat:schema SYSTEM "schema.dtd">
<mycat:schema xmlns:mycat="http://io.mycat/">
<!-- name:是mycat的逻辑库名称,必须保证和server.xml文件中配置的schemas一致,链接需要用的
checkSQLschema:是否检测SQL语句中的MyCat特殊语义,比如如果采用数据库方式实现自增ID,则SQL语句中ID字段的值需改成next value for MYCATSEQ_TEST,如果checkSQLschema为false则不会检测,按字段串处理,开启则会检测为MyCat语义进行ID生成。
-->
<schema name="dsserver_db" checkSQLschema="false" sqlMaxLimit="100" dataNode="dn1">
<!-- name:逻辑表名
primaryKey:真实主键
autoIncrement:是否开启主键自增
dataNode:指定数据节点(绑定真实数据库)
subTables:指定所有真实分表,t_user_0$0-2为缩写,最终会被解析成t_user_00,t_user_01,t_user_02
role:指定路由策略
-->
<table name="NDS_Log" dataNode="dn1" rule="rule1" />
</schema>
<!--
dataNode节点中各属性说明:
name:指定逻辑数据节点名称;
dataHost:指定逻辑数据节点物理主机节点名称;
database:指定物理主机节点上。如果一个节点上有多个库,可使用表达式db$0-99, 表示指定0-99这100个数据库;-->
<dataNode name="dn1" dataHost="localhost1" database="dsserver_db" />
<dataHost name="localhost1" maxCon="1000" minCon="10" balance="0"
writeType="0" dbType="mysql" dbDriver="jdbc" switchType="1" slaveThreshold="100">
<heartbeat>select user()</heartbeat>
<writeHost host="hostM1" url="jdbc:mysql://127.0.0.1:3306/dsserver_db?autoReconnect=true&useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT" user="root" password=""></writeHost>
</dataHost>
</mycat:schema>
<?xml version="1.0" encoding="UTF-8"?>
<!-- - - Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License. - You
may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0
- - Unless required by applicable law or agreed to in writing, software -
distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the
License for the specific language governing permissions and - limitations
under the License. -->
<!DOCTYPE mycat:server SYSTEM "server.dtd">
<mycat:server xmlns:mycat="http://io.mycat/">
<system>
<property name="nonePasswordLogin">0</property> <!-- 0为需要密码登陆、1为不需要密码登陆 ,默认为0,设置为1则需要指定默认账户-->
<property name="useHandshakeV10">1</property>
<property name="useSqlStat">0</property> <!-- 1为开启实时统计、0为关闭 -->
<property name="useGlobleTableCheck">0</property> <!-- 1为开启全加班一致性检测、0为关闭 -->
<!-- 配置MyCat ID自增方式,0 为本地文件方式,1 为数据库方式,2 为时间戳序列方式,3 为分布式 ZK ID 生成器,4 为 zk 递增 id 生成。 从 1.6 增加 两种 ZK 的全局 ID 生成算法。详细请参考:http://www.mycat.io/document/mycat-definitive-guide.pdf -->
<property name="sequnceHandlerType">1</property>
<property name="charset">utf8</property>
<property name="serverPort">8066</property>
<property name="managerPort">9066</property>
</system>
<!-- 全局SQL防火墙设置 -->
<!--白名单可以使用通配符%或着*-->
<!--例如<host host="127.0.0.*" user="root"/>-->
<!--例如<host host="127.0.*" user="root"/>-->
<!--例如<host host="127.*" user="root"/>-->
<!--例如<host host="1*7.*" user="root"/>-->
<!--这些配置情况下对于127.0.0.1都能以root账户登录-->
<!--
<firewall>
<whitehost>
<host host="1*7.0.0.*" user="root"/>
</whitehost>
<blacklist check="false">
</blacklist>
</firewall>
-->
<user name="root" >
<property name="password">1234</property>
<property name="schemas">dsserver_db</property>
</user>
</mycat:server>
<?xml version="1.0" encoding="UTF-8"?>
<!-- - - Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License. - You
may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0
- - Unless required by applicable law or agreed to in writing, software -
distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the
License for the specific language governing permissions and - limitations
under the License. -->
<!DOCTYPE mycat:rule SYSTEM "rule.dtd">
<mycat:rule xmlns:mycat="http://io.mycat/">
<tableRule name="rule1">
<rule>
<!-- 真实分表字段,这里为路由字段 -->
<columns>Server_Time</columns>
<!-- 指定路由则规则所使用的算法 -->
<algorithm>partbymonth</algorithm>
</rule>
</tableRule>
<function name="partbymonth"
class="io.mycat.route.function.PartitionByDate">
<property name="dateFormat">yyyy-MM-dd</property>
<property name="sBeginDate">2021-01-25</property>
<property name="sPartionDay">1</property>
</function>
</mycat:rule>