1. 解压mycat,不要放在有中文目录的地方  下载地址:http://dl.mycat.io/1.6-RELEASE/
2 .修改mycat解压目录下的conf文件夹中server.xml文件,配置账户

<!-- 添加user -->
<user name="mycat_master">
<property name="password">mycat_master</property>
<property name="schemas">mycat</property>
</user>

<!-- 添加user -->
<user name="mycat_slave">
<property name="password">mycat_slave</property>
<property name="schemas">mycat</property>
<property name="readOnly">true</property>
</user>

  


3. 配置schema.xml文件

<schema name="mycat" checkSQLschema="true" sqlMaxLimit="100">
<table name="t_users" primaryKey="user_id" dataNode="dn1" rule="rule1"/>
<table name="t_message" type="global" primaryKey="messages_id" dataNode="dn1" />
</schema>
<dataNode name="dn1" dataHost="jdbchost" database="weibo_simple" />

<dataHost name="jdbchost" maxCon="1000" minCon="10" balance="1"
writeType="0" dbType="mysql" dbDriver="native" switchType="1"
slaveThreshold="100">
<heartbeat>select user()</heartbeat> 
<writeHost host="hostMaster" url="192.168.7.11:3306" user="root" password="root">
</writeHost>
<writeHost host="hostSlave" url="192.168.7.22:3306" user="root" password="root"/>
</dataHost>

  


4. 配置rule.xml

<tableRule name="rule1">
<rule>
<columns>user_id</columns>
<algorithm>func1</algorithm>
</rule>
</tableRule>
<function name="func1" class="org.opencloudb.route.function.AutoPartitionByLong">
<property name="mapFile">autopartition-long.txt</property>
</function>

  


5. 配置启动日志

<level value="debug" />

  



6. 启动mycat 端口:8066
启动bin下startup_nowrap.bat

启动时如果报这个错:could not reserve enough space for 2097152KB object heap

可以参考这个博客:https://blog.csdn.net/Siphiababy/article/details/80167552

7.连接数据库

如果数据报这个 :3000 - No MyCAT Database selected

你有可能是你的数据库工具版本过低

posted on 2020-02-22 17:28  wishsaber  阅读(430)  评论(0编辑  收藏  举报