目录
1.为了测试读写分离将数据库中双机热备关系挡掉(各自执行stop slave)
1.在配置文件中在writeType是0是对balance的值从0-3配置测试
2.schema.xml中配置writeHost readHost url指定错误
一.简介
一个mycat中维护的各种不同结构的主从,分布式对应的所有标签含义

二.非分片表配置
1.在数据库中使用单个节点
数据库mysql01,表格student();

2.server.xml在之前时就配置完毕了

3.schema.xml配置
<mycat:schema xmlns:mycat="http://org.opencloudb/" >
#创建一个逻辑库mytest 自动追加逻辑库名 最大查询数
<schema name="mytest" checkSQLschema="true" sqlMaxLimit="100">
#创建一个非分片表 主键默认ID 一个分片
<table name="student" primaryKey="ID" dataNode="dn1"/>
</schema>
#真实存在的数据库名 mysql01
<dataNode name="dn1" dataHost="localhost1" database="mysql01" />
<dataHost name="localhost1" maxCon="1000" minCon="10" balance="0"
writeType="0" dbType="mysql" dbDriver="native" switchType="1" slaveThreshold="100">
#sql语句
<heartbeat>select user()</heartbeat>
<writeHost host="hostM1" url="10.42.60.249:3306" user="root"
password="root"/>
#后端Mycat连接数据库
</dataHost>
</mycat:schema>
4.修改配置模板

IP需要换一下
5.修改xml

6.历经九九八十一难,终于过了,浪费我一个小时。

7.老是卡在一个警告上面,又浪费我半个小时
Warning: Using a password on the command line interface can be insecure.
ERROR 1045 (HY000): Access denied for user 'root' with host '10.42.60.249'
PS:2019-7-31:补充解决方案
先关闭[root@liuyong mycat]# bin/mycat console 在运行即可 今天又遇到这个坑,忘记记录解决方法 现在补充下

十万个曹尼玛在崩腾

- show databases;
- use mytest;
- show tables;
- select * from student;

8.查看数据库内容

9.添加语句

10.测试案例的读写分离(多个节点)
dataHost中添加多个数据库多个writeHost readHost

11.模板,修改并存
<schema name="mytest" checkSQLschema="true" sqlMaxLimit="100">
<table name="student" primaryKey="ID" dataNode="dn1"/>
</schema>
<dataNode name="dn1" dataHost="localhost1" database="mysql01" />
<dataHost name="localhost1" maxCon="1000" minCon="10" balance="0"
writeType="0" dbType="mysql" dbDriver="native" switchType="1" slaveThreshold="100">
<heartbeat>select user()</heartbeat>
<writeHost host="hostM1" url="10.9.151.60:3306" user="root"
password="root"/>
<writeHost host="hostM2" url="10.9.104.184:3306" user="root"
password="root"/>
</dataHost>

本文详细介绍了Mycat数据库中间件的实战配置过程,包括非分片表与分片表的设置,读写分离的实现,以及常见问题的解决方法。通过具体步骤和案例,展示了Mycat在数据库分片、负载均衡和读写分离方面的强大功能。
最低0.47元/天 解锁文章
823





