Rootop 服务器运维与web架构

DBProxy实现禁止不带where条件的delete、update语句

github地址:https://github.com/Meituan-Dianping/DBProxy
官方安装文档:https://github.com/Meituan-Dianping/DBProxy/blob/master/doc/QUICK_START.md

环境:centos7
建议独立机器或在docker中运行。

# 克隆代码

[root@localhost ~]# git clone https://github.com/Meituan-Dianping/DBProxy.git

# 安装percona yum源rpm包

[root@localhost ~]# wget -c https://www.percona.com/redir/downloads/percona-release/redhat/latest/percona-release-0.1-4.noarch.rpm
[root@localhost ~]# rpm -ivh percona-release-0.1-4.noarch.rpm

# 安装依赖包

[root@localhost ~]# yum install -y Percona-Server-devel-55.x86_64 Percona-Server-client-55.x86_64 Percona-Server-shared-55 jemalloc jemalloc-devel libevent libevent-devel openssl openssl-devel lua lua-devel bison flex libtool.x86_64 libffi-devel

# 安装glib 不要按照github文档装

[root@localhost ~]# wget -c https://src.fedoraproject.org/repo/pkgs/mingw-glib2/glib-2.42.0.tar.xz/71af99768063ac24033ac738e2832740/glib-2.42.0.tar.xz
[root@localhost ~]# cd glib-2.42.0
[root@localhost glib-2.42.0]# ./configure --prefix=/usr/ --libdir=/usr/lib64/
[root@localhost glib-2.42.0]# make && make install

# 安装dbproxy

[root@localhost ~]# cd /root/DBProxy/
[root@localhost DBProxy]# sh autogen.sh
[root@localhost DBProxy]# sh bootstrap.sh
[root@localhost DBProxy]# make && make install

# 创建配置文件目录及配置文件

[root@localhost DBProxy]# mkdir /usr/local/mysql-proxy/conf
[root@localhost DBProxy]# cp script/source.cnf.samples /usr/local/mysql-proxy/conf/source.cnf

配置文件中有中文解释。根据自己情况修改。

# 启动服务

[root@localhost ~]# /usr/local/mysql-proxy/bin/mysql-proxy --defaults-file=/usr/local/mysql-proxy/conf/source.cnf

github上说,仅支持mysql5.5、5.6版本。
这里我只用dbproxy中的”不支持没有where条件的update、delete操作”这个功能。
代理了一个mysql5.7的版本,测试更新删除阻断没问题。其它功能就不清楚。

原创文章,转载请注明。本文链接地址: https://www.rootop.org/pages/4041.html

作者:Venus

服务器运维与性能优化

评论已关闭。