首页 技术 正文
技术 2022年11月8日
0 收藏 729 点赞 1,438 浏览 2423 个字

1.ProxySQL 介绍和安装

ProxySQL 是一种高性能、高可用的开源中间件,适用于mysql和相关的数据库,如MariaDB
官网:http://www.proxysql.com

安装

发行版本下载链接:https://github.com/sysown/proxysql/releases

Ubuntu / Debian:

添加源

apt-get install -y lsb-releasewget -O - 'http://repo.proxysql.com/ProxySQL/repo_pub_key' | apt-key add -echo deb http://repo.proxysql.com/ProxySQL/proxysql-1.4.x/$(lsb_release -sc)/ ./ \| tee /etc/apt/sources.list.d/proxysql.list

安装:

apt-get updateapt-get install proxysql OR apt-get install proxysql=version

Red Hat / CentOS:

添加源

cat <<EOF | tee /etc/yum.repos.d/proxysql.repo[proxysql_repo]name= ProxySQL YUM repositorybaseurl=http://repo.proxysql.com/ProxySQL/proxysql-1.4.x/centos/\$releasevergpgcheck=gpgkey=http://repo.proxysql.com/ProxySQL/repo_pub_keyEOF

安装

yum install proxysql OR yum install proxysql-version

proxysql开启/关闭/重启

开启service proxysql start关闭service proxysql stop重启service proxysql restart

管理员交互界面开启和关闭

进入管理界面# mysql -u admin -padmin -h 127.0.0.1 -P6032 --prompt='Admin> '开启Admin> proxysql start;Query OK,  rows affected (0.00 sec)关闭Admin> proxysql stop;ERROR  (HY000): Lost connection to MySQL server during query重启Admin> proxysql restart;ERROR  (HY000): Lost connection to MySQL server during query

Proxysql 架构以及在线修改配置

初识 Proxysql

Proxysql有三层架构,最底层是disk和config file,第二层是memory,最顶层是runtime

当第一次启动时,proxysql会抓取本地配置文件proxy.cnf并且加载至内存z中,并且最终加载到runtime生效,后续如果在线修改了配置后,需要load至runtime层使其生效,如果需要持久化保存,则需要save至磁盘即可

搭建一个最简单的Proxysql

预先安装好proxysql和mysql

proxysql按照上文安装方法就好

mysql安装:(https://www.cnblogs.com/wang-li/p/7726304.html)

进入proxysql管理界面

# mysql -u admin -padmin -h 127.0.0.1 -P6032 --prompt='Admin> 'mysql: [Warning] Using a password on the command line interface can be insecure.Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connectionServer version:  (ProxySQL Admin Module)Copyright (c) , , Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.Admin>

添加服务器的信息

Admin,);Query OK,  row affected (0.00 sec)

将数据推到runtime和保存至本地磁盘

Admin> LOAD MYSQL SERVERS TO RUNTIME;Query OK,  rows affected (0.00 sec)Admin> SAVE MYSQL SERVERS TO DISK;Query OK,  rows affected (0.04 sec)

添加用户信息

Admin);Query OK,  row affected (0.00 sec)

将数据推到runtime和保存至本地磁盘

Admin> LOAD MYSQL USERS TO RUNTIME;Query OK,  rows affected (0.00 sec)Admin> save mysql users to disk;Query OK,  rows affected (0.01 sec)

测试proxysql

# mysql -uroot -proot -h 127.0.0.1 -P6033 -e "SELECT @@port"mysql: [Warning] Using a password on the command line interface can be insecure.+--------+| @@port |+--------+|    |+--------+[root@MiWiFi-R3P-srv proxysql]# 
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,110
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,584
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,431
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,202
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,837
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,920