接上一篇:企业实战_21_MyCat_keepalived 安装配置验证
https://gblfy.blog.csdn.net/article/details/100073474
Mycat SQL拦截应用场景,可以指定监控的sql类型
文章目录
- 1. 在server.xml文件中添加sql拦截属性标签
- 2. 测试验证
- 3. 查看sql拦截监控日志
1. 在server.xml文件中添加sql拦截属性标签
cd /app/mycat/conf/
vim server.xml# 添加<property name="sqlInterceptor">io.mycat.server.interceptor.impl.StatisticsSqlInterceptor</property><property name="sqlInterceptorType">UPDATE,DELETE,INSERT</property><property name="sqlInterceptorFile">/app/sql.txt</property>
2. 测试验证
# 重启mycat
mycat restart# 使用mysql客户端连接登录mycat
mysql -uapp_imooc -p -h192.168.92.101 -P8066# 使用逻辑数据库
use imooc_db;# 随机查询一条数据
select * from order_master limit 1 \G# 插入一条数据
INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,district_money,shipping_money,payment_money,shipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_time) VALUES (1, 1, '雨昕', 1, 1, 1, '北京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0, NULL, '2021-07-11 20:20:25');#对这一条数据进行更新操作
update order_master set shipping_user = 'yuze' where order_id =2;
更新前:
进行更新操作后:
3. 查看sql拦截监控日志
#进入设置的sql拦截指定的日志储存目录
cd /app#查看日志内容
more /app/sql2021-07-13.txt
INSERT:INSERT INTO `order_master` (ORDER_ID,order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,district_money,shipping_money,payment_money,shipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_time) VALUES ( 2,1, 1, '雨昕', 1, 1, 1, '北京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0, NULL, '2021-07-11 20:20:25')
UPDATE:update order_master set shipping_user = “yuze” where order_id =2
UPDATE:update order_master set shipping_user = 'yuze' where order_id =2
下一篇:企业实战_23_MyCat SQL防火墙
https://gblfy.blog.csdn.net/article/details/100074335