mycat1.6 Implementation Library Sub-table #

Source: Internet
Author: User
Tags mysql version wrapper

1, download mycat1.6 (http://dl.mycat.io/1.6-RELEASE/"Select the win version 6th file is")
2, replace the server.xml,rule.xml,schema.xml,wrapper.conf with the following configuration
3, in MySQL to create the library name TESTDB2 and then run the SQL provided under the article
4, restart the Mycat
5, with Navicat login Mycat execute 3 insert insert INTO T_order (id,name,t_user_id) VALUES (1, ' dd1 ', 1); , observe the Server.xml under
Dome GitHub Https://github.com/gyn781369549/MyCat1.6dome
mycat\conf under the table effect

<?xml version= "1.0" encoding= "UTF-8"?> <!----licensed under the Apache License, version 2.0 (the "License"); -' may not ' use ' this file except in compliance with the License. -Obtain a copy of the License at-http://www.apache.org/licenses/LICENSE-2.0-unless required by Applicable or agreed to in writing, software-distributed under the License are distributed on ' as is ' basis, -Without warranties or CONDITIONS of any KIND, either express or implied. -The License for the specific language governing permissions and-limitations the under. --> <! DOCTYPE mycat:server SYSTEM "Server.dtd" > <mycat:server xmlns:mycat= "http://io.mycat/" > <system> &L T;property name= "Usesqlstat" >0</property> <!--1 for open real-time statistics, 0 for shutdown--> <property name= "Useglobletableche CK ">0</property> <!--1 for opening full overtime consistency detection, 0 for closing--> <property name=" Sequncehandlertype ">2</property> <!--<property name= "usecompression" >1</property>--> <!--1 for open MySQL compression protocol--> <!--<property name= "fakemysqlversion" >5.6.20</property>--> <!--setting analog MySQL version number--> <!- -<property name= "Processorbufferchunk" >40960</property>--> <!--<property name= "processors" ">1</property> <property name=" Processorexecutor ">32</property>--> <!--defaults to T Ype 0:directbytebufferpool | Type 1 bytebufferarena--> <property name= "Processorbufferpooltype" >0</property> <!--default is 6
        5535 64K Maximum text length for SQL parsing--> <!--<property name= "Maxstringliterallength" >65535</property>--> <!--<property name= "Sequncehandlertype" >0</property>--> <!--<property name= "Backsoc Ketnodelay ">1</property>--> <!--<property name=" Frontsocketnodelay ">1</property>--> <!--<property name= "Processorexecutor" >16</property>--> <!--&LT;PR Operty name= "ServerPort" >8066</property> <property name= "Managerport" >9066</property> &L 
            T;property name= "IdleTimeout" >300000</property> <property name= "Bindip" >0.0.0.0</property> <property name= "Frontwritequeuesize" >4096</property> <property name= "processors" >32</
        Property>--> <!--distributed transaction switches, 0 for not filtering distributed transactions, 1 for filtering distributed transactions (if only global tables are involved in a distributed transaction, not filtering), 2 for not filtering distributed transactions, but for logging distributed transaction logs--> <property name= "Handledistributedtransactions" >0</property> <!--off heap for Merg

        E/order/group/limit 1 Open 0--> <property name= "Useoffheapformerge" >1</property> <!--unit is m--> <property name= "Memorypagesize" >1m</property> & lt;! --The Unit is K; <property name= "Spillsfilebuffersize" >1k</property> <property name= "Usestreamoutput" >0</prop erty> <!--unit is m--> <property name= "Systemreservememorysize" >384m</

    Property> <!--whether to use zookeeper coordinated switching--> <property name= "Usezkswitch" >false</property>
          </system> <!--Global SQL Firewall settings--> <!--<firewall> <whitehost>  

Rule.xml mycat\conf rules by id per cent

<?xml version= "1.0" encoding= "UTF-8"?> <!----licensed under the Apache License, version 2.0 (the "License"); -' may not ' use ' this file except in compliance with the License. -Obtain a copy of the License at-http://www.apache.org/licenses/LICENSE-2.0-unless required by Applicable or agreed to in writing, software-distributed under the License are distributed on ' as is ' basis, -Without warranties or CONDITIONS of any KIND, either express or implied. -The License for the specific language governing permissions and-limitations the under. --> <! DOCTYPE mycat:rule SYSTEM "Rule.dtd" > <mycat:rule xmlns:mycat= "http://io.mycat/" > <tablerule name= "Mod-lo" 
            ng "> <rule> <!--by ID table--> <columns>id</columns> <algorithm>mod-long</algorithm> </rule> </tableRule> <function NamE= "Mod-long" class= "Io.mycat.route.function.PartitionByMod" > <!--corresponds to the number of tables in an average distribution--> <prop

 Erty name= "Count" >3</property> </function> </mycat:rule>

The Schema.xml schema under

mycat\conf is configured mycat logical libraries correspond to database table names

<?xml version= "1.0"?> <! DOCTYPE mycat:schema SYSTEM "Schema.dtd" > <mycat:schema xmlns:mycat= "http://io.mycat/" > <!--name= "TestDB" "is configured in Server.xml <property name=" schemas ">TESTDB</property>--> <schema name=" TestDB " Checksqlschema= "false" sqlmaxlimit= > <!--corresponds to the table name in the MySQL database subtables= "T_order$1-3" is the corresponding MySQL t_or of the configuration table The primarykey= "id" of the Der1,t_order2,t_order3 table is the primary key ID--> <table name= "T_order" primarykey= "id" aut  Oincrement= "true" subtables= "T_order$1-3" datanode= "dn1" rule= "Mod-long" > </table> <table Name= "T_user" primarykey= "id" autoincrement= "true" datanode= "dn1"/> </schema> <!--configure MySQL data Library TESTDB2 mycat Logical library named dn1--> <datanode name= "dn1" datahost= "Localhost1" database= "Testdb2"/> <!--configuration data Type balance= "0" read-write--> <datahost name= "Localhost1" maxcon= "1000" mincon= "ten" balance= "0" writetype= "0" dbtype= "MySQL"  dbdriver= "native" switchtype= "1" slavethreshold= "> <!--Heartbeat pack-->  

wrapper.conf wrapper.java.command= configuration Java

under mycat\conf

#******************************************************************** # wrapper Properties #********************** # Java Application wrapper.java.command=d:\java\jdk1.7.0_67\bin\

Java.exe wrapper.working.dir=.  # Java Main class.  This class must implement the Wrapperlistener interface # or guarantee the Wrappermanager class is initialized.  Helper # Classes are provided to does this for you.
The Integration section # of the documentation for details. Wrapper.java.mainclass=org.tanukisoftware.wrapper.wrappersimpleapp Set.default.repo_dir=lib set.

App_base=. # Java Classpath (include Wrapper.jar) Add class path elements as # needed starting from 1 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=-server wrapper.java.additional.3=-xx:maxpermsize=64m wrapper.java.additional.4=-XX:+ Aggressiveopts wrapper.java.additional.5=-xx:maxdirectmemorysize=2g wrapper.java.additional.6=-
Dcom.sun.management.jmxremote wrapper.java.additional.7=-dcom.sun.management.jmxremote.port=1984 Wrapper.java.additional.8=-dcom.sun.management.jmxremote.authenticate=false wrapper.java.additional.9=- Dcom.sun.management.jmxremote.ssl=false wrapper.java.additional.10=-xmx4g wrapper.java.additional.11=-xms1g # Initial Java Heap size (in MB) #wrapper. java.initmemory=3 # Maximum Java Heap size (in MB) #wrapper. java.maxmemory=64 #  Application parameters. ADD parameters as needed starting from 1 Wrapper.app.parameter.1=io.mycat.mycatstartup wrapper.app.parameter.2=start #* # wrapper Logging Properties #***************** # Format of output for the conSole.  [Docs for formats] WRAPPER.CONSOLE.FORMAT=PM # LOG level for console output.
(Docs for log levels) Wrapper.console.loglevel=info # log file to use for wrapper output logging.  Wrapper.logfile=logs/wrapper.log # Format of output for the log file.  [Docs for formats] WRAPPER.LOGFILE.FORMAT=LPTM # Log level for log file output. (Docs for log levels) Wrapper.logfile.loglevel=info # Maximum size that the log file would be allowed to grow-to befor E # The log is rolled.  The Size is specified in bytes.  The default value # of 0, disables log rolling.  May abbreviate with the ' K ' (KB) or # ' m ' (MB) suffix.
For example:10m = ten megabytes.  Wrapper.logfile.maxsize=0 # Maximum Number of rolled log files which'll be allowed before old # files are deleted.
The default value of 0 implies no limit.  Wrapper.logfile.maxfiles=0 # Log level for sys/event log output. (Docs for log levels) Wrapper.syslog.loglevel=none #*************************************************# wrapper Windows Properties #***************************************************************** # Title to use when running as a console wrapper.console.title=mycat-server #**************************************** # wrapper Windows nt/2000/xp Service Properties #*************************************** # warning-do not modify any of the above properties when a application # using this Configur
ation file has been installed as a service.  # Please uninstall the service before modifying.

The # service can then be reinstalled. # Name of the service Wrapper.ntservice.name=mycat # Display name of the service Wrapper.ntservice.displayname=mycat-serv  ER # Description of the service Wrapper.ntservice.description=the project of Mycat-server # service dependencies.  ADD dependencies as needed starting from 1 wrapper.ntservice.dependency.1= # Mode into which the service is installed. Auto_start or DEMAnd_start Wrapper.ntservice.starttype=auto_start # Allow The service to interact with the desktop.
 Wrapper.ntservice.interactive=false wrapper.ping.timeout=120 configuration.directory.in.classpath.first=conf

New data name is TESTDB2, this is the table required in the library

DROP TABLE T_user;
DROP TABLE T_order1;
DROP TABLE T_order2;
DROP TABLE T_order3;
CREATE TABLE ' t_user ' (
  ' id ' int () NOT NULL auto_increment,
  ' name ' varchar (255) NOT NULL,
  PRIMARY KEY (' id ')
) Engine=innodb auto_increment=11 DEFAULT Charset=utf8;
CREATE TABLE ' t_order1 ' (
  ' id ' int () NOT NULL auto_increment,
  ' name ' varchar (255) is not NULL,
  ' t_user_id ' I NT (one) not NULL,
  PRIMARY KEY (' id ')
) Engine=innodb auto_increment=10 DEFAULT Charset=utf8;
CREATE TABLE ' t_order2 ' (
  ' id ' int () NOT NULL auto_increment,
  ' name ' varchar (255) NOT NULL,
  ' t_user_id ' Int (one) not NULL,
  PRIMARY KEY (' id ')
) Engine=innodb auto_increment=10 DEFAULT Charset=utf8;
CREATE TABLE ' T_order3 ' (
  ' id ' int () NOT NULL auto_increment,
  ' name ' varchar (255) NOT NULL,
  ' t_user_id ' Int (one) not NULL,
  PRIMARY KEY (' id ')
) Engine=innodb auto_increment=10 DEFAULT Charset=utf8;

Since 1.6 is already release, the existing 1.6 branches are developed as 1.6.5 and cannot be modified, so the use of the table can only be replaced with class or jar:
Replace Mycat-server in Jar:lib directory: (Based on 1.6.5 Development Board) Http://songwie.com/attached/mycat/Mycat-server-1.6.5-DEV.jar

Java Program Connection Mycat, and the same as the connection to MySQL, you can directly connect with Navicat direct mycat and connection to MySQL, mycat default port 8066

Datasource.url=jdbc:mysql://localhost:8066/testdb?useunicode=true&characterencoding=utf-8

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.