功能
用于外网客户端连接内网的MySQL,将此工具安装在中转服务器上。
软件版本
mysql-proxy-0.8.1-linux-rhel5-x86-64bit.tar.gz
简单的配置过程
解压后有5个目录
bin include lib libexec share
进bin目录,查看mysql_proxy的使用帮助
[root@ora01 bin]# ./mysql-proxy --help-all
Usage:
mysql-proxy [OPTION...] - MySQL Proxy Help Options:
-?, --help Show help options
--help-all Show all help options
--help-admin Show options for the admin-module
--help-proxy Show options for the proxy-module admin-module
--admin-address=<host:port> listening address:port of the admin-server (default: :4041)
--admin-username=<string> username to allow to log in
--admin-password=<string> password to allow to log in
--admin-lua-script=<filename> script to execute by the admin plugin proxy-module
-P, --proxy-address=<host:port> listening address:port of the proxy-server (default: :4040)
-r, --proxy-read-only-backend-addresses=<host:port> address:port of the remote slave-server (default: not set)
-b, --proxy-backend-addresses=<host:port> address:port of the remote backend-servers (default: 127.0.0.1:3306)
--proxy-skip-profiling disables profiling of queries (default: enabled)
--proxy-fix-bug-25371 fix bug #25371 (mysqld > 5.1.12) for older libmysql versions
-s, --proxy-lua-script=<file> filename of the lua script (default: not set)
--no-proxy don't start the proxy-module (default: enabled)
--proxy-pool-no-change-user don't use CHANGE_USER to reset the connection coming from the pool (default: enabled) Application Options:
-V, --version Show version
--defaults-file=<file> configuration file
--verbose-shutdown Always log the exit code when shutting down
--daemon Start in daemon-mode
--user=<user> Run mysql-proxy as user
--basedir=<absolute path> Base directory to prepend to relative paths in the config
--pid-file=<file> PID file in case we are started as daemon
--plugin-dir=<path> path to the plugins
--plugins=<name> plugins to load
--log-level=(error|warning|info|message|debug) log all messages of level ... or higher
--log-file=<file> log all messages in a file
--log-use-syslog log all messages to syslog
--log-backtrace-on-crash try to invoke debugger on crash
--keepalive try to restart the proxy if it crashed
--max-open-files maximum number of open files (ulimit -n)
--event-threads number of event-handling threads (default: 1)
--lua-path=<...> set the LUA_PATH
--lua-cpath=<...> set the LUA_CPATH
应用
./mysql-proxy --admin-username='root' --admin-password='12345' --admin-lua-script=/opt/mysql-proxy-0.8.1-linux-rhel5-x86-64bit/lib/mysql-proxy/lua/admin.lua --proxy-backend-addresses=192.168.60.134:3306 --daemon
参数说明:
指定MySQL的用户名和密码、执行mysql-proxy工具的脚本、mysql服务器地址和端口、服务模式
测试
# netstat -tunlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:4040 0.0.0.0:* LISTEN 29237/mysql-proxy
tcp 0 0 0.0.0.0:4041 0.0.0.0:* LISTEN 29237/mysql-proxy
4040端口是默认的代理端口,客户端连接的时候直接指向此端口
4041是默认的管理模块端口
总结:现在就可以连接中转服务器的4040端口,访问内网的MySQL服务器。除了可以进行连接的转发外,还可以进行查询的监控、过滤、分析、负载均衡(Load Balance)、失败漂移(Failover)等,更多功能以后再研究。

mysql-proxy做客户端连接转发【外网访问内网mysql】的更多相关文章

  1. 外网访问内网的FTP服务器

    转自 外网访问内网的FTP服务器 首先感谢作者给出的总结,原文是介绍Serv-U的,我针对FileZilla Server进行了稍微修改,仅看操作可直接跳到分割线后第3部分. 1. 背景简介最近研究如 ...

  2. 简单物联网:外网访问内网路由器下树莓派Flask服务器

    最近做一个小东西,大概过程就是想在教室,宿舍控制实验室的一些设备. 已经在树莓上搭了一个轻量的flask服务器,在实验室的路由器下,任何设备都是可以访问的:但是有一些限制条件,比如我想在宿舍控制我种花 ...

  3. [笔记] 使用frp从外网访问内网

    之前尝试过otunnel,也记录过使用方法,见[笔记] 使用otunnel从外网访问内网,但是用了几天发现还是不够稳定. 然后尝试frp,发现性能稳定,够用,将过程及配置分享在这里吧. 需求 内网机器 ...

  4. 配置多层NAT和端口映射实现外网访问内网

    配置多层NAT和端口映射实现外网访问内网 背景和原理 通过配置NAT可以实现内网中不能直接访问外网的主机通过NAT代理访问内网,配置方法这里不再赘述(前文有介绍).本文以两层的NAT代理做模拟,通过端 ...

  5. [笔记] 使用otunnel从外网访问内网

    需求 内网机器没有公网IP,但是可以访问外网,现在需要从外网访问内网机器. 举例,在家里机器A访问公司内网机器B. 前提 需要一台有公网IP的服务器S做中转,这样就可以打通AB两端了. A <- ...

  6. 外网访问内网Docker容器

    外网访问内网Docker容器 本地安装了Docker容器,只能在局域网内访问,怎样从外网也能访问本地Docker容器? 本文将介绍具体的实现步骤. 1. 准备工作 1.1 安装并启动Docker容器 ...

  7. 外网访问内网SpringBoot

    外网访问内网SpringBoot 本地安装了SpringBoot,只能在局域网内访问,怎样从外网也能访问本地SpringBoot? 本文将介绍具体的实现步骤. 1. 准备工作 1.1 安装Java 1 ...

  8. 外网访问内网Elasticsearch WEB

    外网访问内网Elasticsearch WEB 本地安装了Elasticsearch,只能在局域网内访问其WEB,怎样从外网也能访问本地Elasticsearch? 本文将介绍具体的实现步骤. 1. ...

  9. 怎样从外网访问内网Rails

    外网访问内网Rails 本地安装了Rails,只能在局域网内访问,怎样从外网也能访问本地Rails? 本文将介绍具体的实现步骤. 1. 准备工作 1.1 安装并启动Rails 默认安装的Rails端口 ...

  10. 怎样从外网访问内网Memcached数据库

    外网访问内网Memcached数据库 本地安装了Memcached数据库,只能在局域网内访问,怎样从外网也能访问本地Memcached数据库? 本文将介绍具体的实现步骤. 1. 准备工作 1.1 安装 ...

随机推荐

  1. android开发之自定义圆形ImagView

    在日常使用中我们经常会使用到圆形的图片,但是android系统中并没有默认的圆形控件,所以我们需要自己来写一个自定义的ImagView来显示一张圆形的图片,下面先看效果 详细的方法是我们自定义一个类, ...

  2. VirtualBox – Error In supR3HardenedWinReSpawn

    Genymotion 模拟器安装好虚拟机后,启动时报错: ————————— VirtualBox – Error In supR3HardenedWinReSpawn ————————— <h ...

  3. 【SVN】删除SVN上的历史资源路径和SVN上的历史用户信息

    1.删除svn上历史资源路径 window--show view--other--svn资源库 可以右键选择删除 . ----------------------------------------- ...

  4. Camera setParameters(), getParameters(),unlock()三个方法之间的限制关系

    Camera mCamera = Camera.open(); // 第一次调用getParameters()需要在unlock()方法之前否则出现错误 Camera.Parameters param ...

  5. 机器学习算法实践:朴素贝叶斯 (Naive Bayes)(转载)

    前言 上一篇<机器学习算法实践:决策树 (Decision Tree)>总结了决策树的实现,本文中我将一步步实现一个朴素贝叶斯分类器,并采用SMS垃圾短信语料库中的数据进行模型训练,对垃圾 ...

  6. Flume推送数据到SparkStreaming案例实战和内幕源码解密

    本期内容: 1. Flume on HDFS案例回顾 2. Flume推送数据到Spark Streaming实战 3. 原理绘图剖析 1. Flume on HDFS案例回顾 上节课要求大家自己安装 ...

  7. zabbix日志监控

    一般情况下,日志最先反映出应用当前的问题,在海量日志里面找到我们异常记录,例如监控系统日志.nginx.Apache.业务日志,然后记录下来,并且根据情况报警. 1.日志监控项介绍 最主要的是监控日志 ...

  8. hdu 5012 bfs --- 慎用STL 比方MAP判重

    http://acm.hdu.edu.cn/showproblem.php?pid=5012 发现一个问题 假设Sting s = '1'+'2'+'3'; s!="123"!!! ...

  9. D3学习之:D3.js中的12中地图投影方式

    特别感谢:1.[张天旭]的D3API汉化说明.已被引用到官方站点: 2.[馒头华华]提供的ourd3js.com上提供的学习系列教程,让我们这些新人起码有了一个方向. 不得不说,学习国外的新技术真的是 ...

  10. 使用Java取得本机IP和机器名

    try { InetAddress addr = InetAddress.getLocalHost(); String ip=addr.getHostAddress().toString();//获得 ...