proxysql 学习一 proxysql docker 运行试用
proxysql 是一个比较强大的mysql proxy 服务,支持动态mysql 实例调整,查询重写,查询cache,监控,数据镜像,读写分离
以及ha,最近已经发布了2.0 ,很值得试用下
环境准备
- docker-compose 文件
version: "3"
services:
mysql:
image: mysql:5.7.16
ports:
- 3306:3306
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
environment:
MYSQL_ROOT_PASSWORD: dalongrong
MYSQL_DATABASE: test
MYSQL_USER: test
MYSQL_PASSWORD: test
TZ: Asia/Shanghai
proxysql:
image: proxysql/proxysql:2.0.5
volumes:
- "./proxysql.cnf:/etc/proxysql.cnf"
ports:
- "6033:6033"
- "6032:6032"
- proxysql.cnf 文件
主要是关于proxysql 的一些运行是配置,同时我们也可以配置mysql server 实例,以下为了简单,直接使用配置文件的方式
datadir="/var/lib/proxysql"
admin_variables=
{
admin_credentials="admin:admin;radmin:radmin"
mysql_ifaces="0.0.0.0:6032"
}
mysql_variables=
{
threads=4
max_connections=2048
default_query_delay=0
default_query_timeout=36000000
have_compress=true
poll_timeout=2000
interfaces="0.0.0.0:6033"
default_schema="information_schema"
stacksize=1048576
server_version="5.5.30"
connect_timeout_server=3000
monitor_username="root"
monitor_password="dalongrong"
monitor_history=600000
monitor_connect_interval=60000
monitor_ping_interval=10000
monitor_read_only_interval=1500
monitor_read_only_timeout=500
ping_interval_server_msec=120000
ping_timeout_server=500
commands_stats=true
sessions_sort=true
connect_retries_on_failure=10
}
mysql_servers =
(
{
address="mysql"
port=3306
hostgroup=0
max_connections=200
}
)
mysql_users:
(
{
username = "root"
password = "dalongrong"
default_hostgroup = 0
max_connections=1000
default_schema="information_schema"
active = 1
}
)
启动&&简单操作
- 启动
docker-compose up -d
- 管理连接接口
mysql -h127.0.0.1 -P6032 -uradmin -pradmin --prompt "ProxySQL Admin>"
- 简单操作
show databases;
效果
ProxySQL Admin>show databases;
+-----+---------------+-------------------------------------+
| seq | name | file |
+-----+---------------+-------------------------------------+
| 0 | main | |
| 2 | disk | /var/lib/proxysql/proxysql.db |
| 3 | stats | |
| 4 | monitor | |
| 5 | stats_history | /var/lib/proxysql/proxysql_stats.db |
+-----+---------------+-------------------------------------+
5 rows in set (0.01 sec)
查询mysql server
select * from main.mysql_servers\G;
效果
select * from main.mysql_servers\G;
*************************** 1. row ***************************
hostgroup_id: 0
hostname: mysql
port: 3306
gtid_port: 0
status: ONLINE
weight: 1
compression: 0
max_connections: 200
max_replication_lag: 0
use_ssl: 0
max_latency_ms: 0
comment:
1 row in set (0.00 sec)
ERROR:
No query specified
查询运行时mysql server
select * from runtime_mysql_servers\G;
*************************** 1. row ***************************
hostgroup_id: 0
hostname: mysql
port: 3306
gtid_port: 0
status: ONLINE
weight: 1
compression: 0
max_connections: 200
max_replication_lag: 0
use_ssl: 0
max_latency_ms: 0
comment:
1 row in set (0.01 sec)
- 应用连接
应用连接的端口为6033
连接方式:
mysql -h127.0.0.1 -P6033 -uroot -pdalongrong
简单查询
select * from rongdemo.usersinfo;
+----------+--------+
| username | userid |
+----------+--------+
| dalong | 1 |
+----------+--------+
1 row in set (0.00 sec)
说明
proxysql 功能是比较强大的,性能也很不错,对于同时提供了管理以及连接地址,暴露为标准的mysql 协议,对于配置的生效
并不是添加mysql server 实例到main.mysql_servers 就可以了,需要到runtime
,同时还需要配置进行持久化,相关命令有
LOAD MYSQL USERS TO RUNTIME;
SAVE MYSQL USERS TO DISK;
LOAD MYSQL SERVERS TO RUNTIME;
SAVE MYSQL SERVERS TO DISK;
LOAD MYSQL QUERY RULES TO RUNTIME;
SAVE MYSQL QUERY RULES TO DISK;
LOAD MYSQL VARIABLES TO RUNTIME;
SAVE MYSQL VARIABLES TO DISK;
LOAD ADMIN VARIABLES TO RUNTIME;
SAVE ADMIN VARIABLES TO DISK;
对于proxysql,社区也提供了好多方便的监控工具,比如exporter ,方便与promethues 集成
对应官方的dockerfile 文件
FROM debian:stretch
MAINTAINER Nikolaos Vyzas <nick@proxysql.com>
RUN apt-get update && apt-get install -y wget lsb-release gnupg apt-transport-https ca-certificates && wget -O - 'https://repo.proxysql.com/ProxySQL/repo_pub_key' | apt-key add - && echo deb https://repo.proxysql.com/ProxySQL/proxysql-2.0.x/$(lsb_release -sc)/ ./ | tee /etc/apt/sources.list.d/proxysql.list && apt-get update && apt-get install proxysql=2.0.5 && rm -rf /var/lib/apt/lists/*
ENTRYPOINT ["proxysql", "-f", "-D", "/var/lib/proxysql"]
参考资料
https://github.com/sysown/proxysql/wiki/Configuring-ProxySQL
https://github.com/sysown/proxysql
https://github.com/rongfengliang/proxysql-docker-compose
https://hub.docker.com/r/proxysql/proxysql
proxysql 学习一 proxysql docker 运行试用的更多相关文章
- scylladb docker 运行试用
scylladb 是兼容cassandra 的数据存储系统,从官方的性能报告,比原生的apache cassandra 有好多 的提高 使用docker 运行,具体的也可以参考官方文档,后边会提供 ...
- workerman docker 运行试用
看到别人项目使用了workerman 作为webserver ,看了下介绍发现此框架还是挺强大的,比较喜欢使用 docker运行软件,所以基于php 7.3 的基础镜像简单使用下 环境准备 项目使用了 ...
- cronicle docker 运行试用
Cronicle 是一款基于nodejs 开发的分布式任务调度工具,包含了比较全的UI,使用也比较简单,为了 方便学习,简单制作了一个docker 镜像,方便使用 Dockerfile FROM ...
- torodb docker 运行试用
torodb 可以方便的让你迁移到pg,同时使用标准原生的sql 查询 使用官方的docker-compose 进行测试 环境准备 docker-compose 文件 wget https://raw ...
- ipfs docker 运行试用
ipfs 是一个分布式,p2p 的文件系统,参考了git.bt.sfs 以及web 的设计 环境准备 docker-compose 文件 version: "3" services ...
- Docker学习笔记之搭建Docker运行环境
0x00 概述 既然 Docker 是一款实用软件,我们就不得不先从它的安装说起,只有让 Docker 运行在我们的计算机上,才能更方便我们对 Docker 相关知识和使用方式的学习.得益于与商业性的 ...
- Singer 学习五 docker 运行说明
介绍过一个工具knots ,方便Singer 可视化开发的工具,但是默认这个工具包含的tap 以及target 比较少(可以自己扩展) 同时这个工具就是基于docker 运行的 docker 运行的几 ...
- deno学习四 docker 运行官方的一个http file server
github 上已经有人搞了一个deno 的docker 镜像,是基于源码编译的,挺好的 所以结合官方的http server demo 使用docker 运行 环境准备 docker-compose ...
- proxysql 学习二 admin-web 启用
proxysql 从1.4.4 开始内置了一个简单的http server,可以方便进行状态信息的查看,今天在 尝试通过配置参数以及update global_variables 没有生效,set 也 ...
随机推荐
- 不一样的go语言-玩转语法之一
这段时间为俗事所累,疲以应付,落下了不少想法,错过了更新的日子.这个专题开始之际,已经准备了不下十几个主题,而在写作的过程中,又有新想法与主题涌现出来.未来预计想写写的内容主要包括: 玩转语法系列 ...
- APIO2019题解
T1.桥梁(bridges/restriction) Subtask1:暴力,$O(n^2)$. #include<cstdio> #include<algorithm> #d ...
- Python调用Matlab2014b引擎
用惯Python的你,是不是早已无法忍受matplotlib那丑陋无比的图以及蛋疼无比部署依赖? 当当当当,Matlab2014b的Python Engine API现已加入豪华午餐. 上次写了一篇文 ...
- sleep方法动态打印 C语言
#include<Windows.h> #include<stdio.h> #include<stdlib.h> #include<string.h> ...
- C#服务器全面讲解与制作
C#服务器全面讲解与制作一 环境配置与基础架构 环境配置 基础的服务器架构 这里我会讲解高级的C#服务器的全面制作流程 会对大家有很大的帮助 不过在这个教程中主要是讲解服务器的制作,所以不会讲解客户端 ...
- URL不变的情况下,最实用的vue刷新当前页面,provide / inject 组合 方式实现vue页面刷新
原文:https://blog.csdn.net/Dream_xun/article/details/83024487 其他参考:https://blog.csdn.net/liyunkun888/a ...
- volatile-最轻量级的并发实现及其内存语义
原文连接:(http://www.studyshare.cn/blog/details/1163/0 ) 一.volatile定义 volatile是java并发编程中修饰类的成员变量.成员属性或者对 ...
- Shallow copy and Deep copy
Shallow copy and Deep copy 第一部分: 一.来自wikipidia的解释: Shallow copy One method of copying an object is t ...
- Linux--重要文件
目录 /etc/resolv.conf /etc/host /etc/sysconfig/network /etc/fstab /etc/rc.local /etc/profile /etc/bash ...
- MySQL/MariaDB数据库的用户和权限管理
MySQL/MariaDB数据库的用户和权限管理 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.元数据数据库(mysql) 系统授权表(均在mysql数据库中): db hos ...