广告
返回顶部
首页 > 资讯 > 数据库 >proxysql的安装步骤
  • 751
分享到

proxysql的安装步骤

2024-04-02 19:04:59 751人浏览 独家记忆
摘要

本篇内容介绍了“proxysql的安装步骤”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!Mysql环境信息

本篇内容介绍了“proxysql的安装步骤”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

Mysql环境信息:

操作系统Centos release 6.9 

主库: 192.168.140.51

从库: 192.168.140.52 

从库: 192.168.16.150 

proxysql中间件: 192.168.140.52

备注:两个从库都需要开启read_only=on,命令为

mysql> set global read_only=on

编辑proxysql.repo文件

#vi /etc/yum.repos.d/proxysql.repo 

[proxysql_repo]

name= ProxySQL YUM repository

baseurl=Http://repo.proxysql.com/ProxySQL/proxysql-1.4.x/centos/$releasever

gpGCheck=1

gpgkey=http://repo.proxysql.com/ProxySQL/repo_pub_key

#yum install proxysql -y

Loaded plugins: fastestmirror

Setting up Install Process

Determining fastest mirrors

epel/metalink                                                                                                          | 8.9 kB     00:00     

 * base: mirrors.huaweicloud.com

 * epel: mirrors.ustc.edu.cn

 * extras: mirrors.huaweicloud.com

 * updates: mirrors.163.com

base                                                                                                                   | 3.7 kB     00:00     

epel                                                                                                                   | 3.2 kB     00:00     

epel/primary                                                                                                           | 3.2 MB     00:00     

epel                                                                                                                              12515/12515

extras                                                                                                                 | 3.4 kB     00:00     

percona                                                                                                                | 2.9 kB     00:00     

percona/primary_db                                                                                                     | 346 kB     00:09     

percona-release-noarch                                                                                                 | 2.9 kB     00:00     

percona-release-x86_64                                                                                                 | 2.9 kB     00:00     

percona-release-x86_64/primary_db                                                                                      | 346 kB     00:09     

proxysql_repo                                                                                                          | 2.9 kB     00:00     

proxysql_repo/primary_db                                                                                               |  12 kB     00:00     

updates                                                                                                                | 3.4 kB     00:00     

updates/primary_db                                                                                                     | 1.3 MB     00:00     

Resolving Dependencies

--> Running transaction check

---> Package proxysql.x86_64 0:1.4.12-1 will be installed

--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================================

 Package                          Arch                           Version                          Repository                             Size

==============================================================================================================================================

Installing:

 proxysql                         x86_64                         1.4.12-1                         proxysql_repo                         5.9 M

Transaction Summary

==============================================================================================================================================

Install       1 Package(s)

Total download size: 5.9 M

Installed size: 22 M

Downloading Packages:

proxysql-1.4.12-1-centos67.x86_64.rpm                                                                                  | 5.9 MB     00:09     

warning: rpmts_HdrFromFdno: Header V4 RSA/SHA256 Signature, key ID 79953b49: NOKEY

Retrieving key from http://repo.proxysql.com/ProxySQL/repo_pub_key

Importing GPG key 0x79953B49:

 Userid: "rene cannnao (Proxysql Repository) <rene.cannao@gmail.com>"

 From  : http://repo.proxysql.com/ProxySQL/repo_pub_key

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

  Installing : proxysql-1.4.12-1.x86_64                                                                                                   1/1 

  Verifying  : proxysql-1.4.12-1.x86_64                                                                                                   1/1 

Installed:

  proxysql.x86_64 0:1.4.12-1                                                                                                                  

Complete!

启动proxysql:

#service proxysql start

Starting ProxySQL: 2018-10-09 09:05:58 [INFO] Using config file /etc/proxysql.cnf

DONE!

查看版本信息:

#proxysql --version

ProxySQL version 1.4.12-9-g216b872, codename Truls

登陆proxysql:

设置prompt:

export MYSQL_PS1="\\u@\\h [\\d] \\r:\\m:\\s>>>"

进入ProxySQL:

#mysql -uadmin -padmin -h227.0.0.1 -P6032

admin@127.0.0.1 [(none)] 05:27:35>>>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)

备注:6032是proxysql的管理端口号.

数据库信息介绍:

main 内存配置数据库,表里存放后端db实例、用户验证、路由规则等信息。

disk 是持久化到硬盘的配置。

stats是统计信息的汇总,是proxysql运行抓取的统计信息,包括到后端各命令的执行次数、流量、processlist、查询种类汇总/执行时间等。

monitor是一些监控的收集信息,主要是对后端db的健康/延迟检查等。

在master上添加proxysql监控账号和对外访问账号:

mysql> create user monitor@'192.168.140.%' identified by '123456';

Query OK, 0 rows affected (0.29 sec)

mysql> 

mysql> create user monitor@'192.168.16.%' identified by '123456';

Query OK, 0 rows affected (0.01 sec)

mysql> grant all privileges on *.* to monitor@'192.168.140.%';

Query OK, 0 rows affected (0.04 sec)

mysql> grant all privileges on *.* to monitor@'192.168.16.%';

Query OK, 0 rows affected (0.00 sec)

mysql> 

mysql> create user dsf@'%' identified by 'dsf';

Query OK, 0 rows affected (0.09 sec)

mysql> grant all privileges on *.* to dsf@'%' with grant option;

Query OK, 0 rows affected (0.06 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.12 sec)

mysql> use main

Reading table infORMation for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

mysql> show tables;

+--------------------------------------------+

| tables                                     |

+--------------------------------------------+

| global_variables                           |

| mysql_collations                           |

| mysql_group_replication_hostgroups         |

| mysql_query_rules                          |

| mysql_query_rules_fast_routing             |

| mysql_replication_hostgroups               |

| mysql_servers                              |

| mysql_users                                |

| proxysql_servers                           |

| runtime_checksums_values                   |

| runtime_global_variables                   |

| runtime_mysql_group_replication_hostgroups |

| runtime_mysql_query_rules                  |

| runtime_mysql_query_rules_fast_routing     |

| runtime_mysql_replication_hostgroups       |

| runtime_mysql_servers                      |

| runtime_mysql_users                        |

| runtime_proxysql_servers                   |

| runtime_scheduler                          |

| scheduler                                  |

+--------------------------------------------+

20 rows in set (0.00 sec)

mysql> show create table mysql_servers \G

*************************** 1. row ***************************

       table: mysql_servers

Create Table: CREATE TABLE mysql_servers (

    hostgroup_id INT CHECK (hostgroup_id>=0) NOT NULL DEFAULT 0,

    hostname VARCHAR NOT NULL,

    port INT NOT NULL DEFAULT 3306,

    status VARCHAR CHECK (UPPER(status) IN ('ONLINE','SHUNNED','OFFLINE_SOFT', 'OFFLINE_HARD')) NOT NULL DEFAULT 'ONLINE',

    weight INT CHECK (weight >= 0) NOT NULL DEFAULT 1,

    compression INT CHECK (compression >=0 AND compression <= 102400) NOT NULL DEFAULT 0,

    max_connections INT CHECK (max_connections >=0) NOT NULL DEFAULT 1000,

    max_replication_lag INT CHECK (max_replication_lag >= 0 AND max_replication_lag <= 126144000) NOT NULL DEFAULT 0,

    use_ssl INT CHECK (use_ssl IN(0,1)) NOT NULL DEFAULT 0,

    max_latency_ms INT UNSIGNED CHECK (max_latency_ms>=0) NOT NULL DEFAULT 0,

    comment VARCHAR NOT NULL DEFAULT '',

    PRIMARY KEY (hostgroup_id, hostname, port) )

1 row in set (0.00 sec)

添加主从服务器信息列表:

mysql> insert into mysql_servers(hostgroup_id,hostname,port) values(10,'192.168.140.51',3306);

Query OK, 1 row affected (0.00 sec)

mysql> insert into mysql_servers(hostgroup_id,hostname,port) values(10,'192.168.140.52',3306);

Query OK, 1 row affected (0.00 sec)

mysql> insert into mysql_servers(hostgroup_id,hostname,port) values(10,'192.168.16.150',3306);

Query OK, 1 row affected (0.00 sec)

从memory加载到runtime:

mysql> load mySQL Servers to runtime;

Query OK, 0 rows affected (0.05 sec)

持久化到磁盘:

mysql> save mysql servers to disk;

Query OK, 0 rows affected (0.56 sec)

查看server状态信息,三台应该都是online:

mysql>  select * from mysql_servers;

+--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+

| hostgroup_id | hostname       | port | status | weight | compression | max_connections | max_replication_lag | use_ssl | max_latency_ms | comment |

+--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+

| 10           | 192.168.140.51 | 3306 | ONLINE | 1      | 0           | 1000            | 0                   | 0       | 0              |         |

| 10           | 192.168.140.52 | 3306 | ONLINE | 1      | 0           | 1000            | 0                   | 0       | 0              |         |

| 10           | 192.168.16.150 | 3306 | ONLINE | 1      | 0           | 1000            | 0                   | 0       | 0              |         |

+--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+

3 rows in set (0.00 sec)

为proxysql配置监控账号:

mysql> set mysql-monitor_username='monitor';

Query OK, 1 row affected (0.00 sec)

mysql> set mysql-monitor_passWord='123456';

Query OK, 1 row affected (0.00 sec)

mysql> load mysql variables to runtime;

Query OK, 0 rows affected (0.00 sec)

mysql> save mysql variables to disk;

Query OK, 97 rows affected (0.29 sec)

查看监控信息,监控正常,没有任何报错:

mysql> select * from monitor.mysql_server_connect_log order by time_start_us desc limit 6;

+----------------+------+------------------+-------------------------+---------------+

| hostname       | port | time_start_us    | connect_success_time_us | connect_error |

+----------------+------+------------------+-------------------------+---------------+

| 192.168.140.51 | 3306 | 1539064061326592 | 3513                    | NULL          |

| 192.168.140.52 | 3306 | 1539064060571978 | 2129                    | NULL          |

| 192.168.16.150 | 3306 | 1539064059817210 | 3859                    | NULL          |

| 192.168.140.52 | 3306 | 1539064000942524 | 1271                    | NULL          |

| 192.168.140.51 | 3306 | 1539064000379889 | 3259                    | NULL          |

| 192.168.16.150 | 3306 | 1539063999817183 | 2875                    | NULL          |

+----------------+------+------------------+-------------------------+---------------+

6 rows in set (0.01 sec)

配置读写分离:

设置proxysql主从分组信息:

mysql> show create table mysql_replication_hostgroups \G

*************************** 1. row ***************************

       table: mysql_replication_hostgroups

Create Table: CREATE TABLE mysql_replication_hostgroups (

    writer_hostgroup INT CHECK (writer_hostgroup>=0) NOT NULL PRIMARY KEY,

    reader_hostgroup INT NOT NULL CHECK (reader_hostgroup<>writer_hostgroup AND reader_hostgroup>0),

    comment VARCHAR NOT NULL DEFAULT '', UNIQUE (reader_hostgroup))

1 row in set (0.00 sec)

mysql> insert into mysql_replication_hostgroups values(10,20,'proxy info');

Query OK, 1 row affected (0.00 sec)

mysql> load mysql servers to runtime;

Query OK, 0 rows affected (0.00 sec)

mysql> 

mysql> save mysql servers to disk;

Query OK, 0 rows affected (0.47 sec)

mysql> select * from mysql_replication_hostgroups;

+------------------+------------------+------------+

| writer_hostgroup | reader_hostgroup | comment    |

+------------------+------------------+------------+

| 10               | 20               | proxy info |

+------------------+------------------+------------+

1 row in set (0.00 sec)

mysql> select * from mysql_servers;

+--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+

| hostgroup_id | hostname       | port | status | weight | compression | max_connections | max_replication_lag | use_ssl | max_latency_ms | comment |

+--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+

| 10           | 192.168.140.51 | 3306 | ONLINE | 1      | 0           | 1000            | 0                   | 0       | 0              |         |

| 20           | 192.168.16.150 | 3306 | ONLINE | 1      | 0           | 1000            | 0                   | 0       | 0              |         |

| 20           | 192.168.140.52 | 3306 | ONLINE | 1      | 0           | 1000            | 0                   | 0       | 0              |         |

+--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+

3 rows in set (0.00 sec)

备注:

proxysql会根据server的read_only的值将服务器自动进行分组,read_only=0的分到编号为10的写组,read_only=1的分到编号为20的读组。

配置对外访问账号,开启事务持久化保护:

mysql> insert into mysql_users(username,password,default_hostgroup) values('dsf','dsf',10);

Query OK, 1 row affected (0.00 sec)

mysql> update mysql_users set transaction_persistent=1 where username='dsf';

Query OK, 1 row affected (0.00 sec)

mysql> load mysql users to runtime;

Query OK, 0 rows affected (0.00 sec)

mysql> 

mysql> 

mysql> save mysql users to disk;

Query OK, 0 rows affected (0.10 sec)

验证主服务器,需要指定对外端口号6033:

#mysql -udsf -pdsf -h 192.168.140.52 -P 6033 -e "show slave hosts"

mysql: [Warning] Using a password on the command line interface can be insecure.

+-----------+------+------+-----------+--------------------------------------+

| Server_id | Host | Port | Master_id | Slave_UUID                           |

+-----------+------+------+-----------+--------------------------------------+

|     16150 |      | 3306 |     14051 | e982cd68-cac0-11e8-8cfc-525400a6c4f1 |

|     14052 |      | 3306 |     14051 | dab0225f-952d-11e8-ac10-52540098ed65 |

+-----------+------+------+-----------+--------------------------------------+

#mysql -udsf -pdsf -h 192.168.140.52 -P 6033 -e "select @@hostname"

mysql: [Warning] Using a password on the command line interface can be insecure.

+--------------------+

| @@hostname         |

+--------------------+

| test-140-51        |

+--------------------+

“proxysql的安装步骤”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注编程网网站,小编将为大家输出更多高质量的实用文章!

您可能感兴趣的文档:

--结束END--

本文标题: proxysql的安装步骤

本文链接: https://www.lsjlt.com/news/59621.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • proxysql的安装步骤
    本篇内容介绍了“proxysql的安装步骤”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!MySQL环境信息...
    99+
    2022-10-18
  • ProxySQL 2.0.X安装
    1. 设置proxysql 2.0.x的yum repocat <<EOF | tee /etc/yum.repos.d/proxysql.repo[proxysql_repo]name= Pr...
    99+
    2022-10-18
  • MySQL中搭建ProxySQL Cluster的详细步骤
    下文给大家带来关于MySQL中搭建ProxySQL Cluster的详细步骤,感兴趣的话就一起来看看这篇文章吧,相信看完MySQL中搭建ProxySQL Cluster的详细步骤对大家多少有点帮助吧。环境:...
    99+
    2022-10-18
  • jupyter的安装步骤
    1.安装python文件     首先去官网python去下载python的安装包,点击donwload,选择合适的系统。这里我是windown系统,点击进去,如图找到有installer的去下载。不...
    99+
    2023-09-15
    python jupyter numpy
  • 安装chromedriver的步骤
    安装chromedriver的步骤 1. 查看当前chrome的版本 # 在chrome中打开该网址,查看版本chrome://version/ 2. 下载对应chrome版本的chromedrive...
    99+
    2023-10-24
    python chrome
  • loadrunner12.6的安装步骤
    本篇内容主要讲解“loadrunner12.6的安装步骤”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“loadrunner12.6的安装步骤”吧!PS:如果遇到什么权限问题,请右键管理员权限进行...
    99+
    2023-06-05
  • CentOS的安装步骤
    本篇内容主要讲解“CentOS的安装步骤”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“CentOS的安装步骤”吧!对于CentOS的大量使用,可能会在CentOS安装中遇到问题。这里就很全面的讲...
    99+
    2023-06-16
  • oracle的安装步骤
    一、关于Oracle数据库 1、Oracle数据库的简介Oracle 是一个数据库管理系统,是Oracle公司的核心产品。其在数据安全性与安整性控制方面的优越性能,以及跨操作系统、跨硬件平台的数据操作能力。...
    99+
    2022-10-18
  • PXC5.7的安装步骤
    这篇文章主要介绍“PXC5.7的安装步骤”,在日常操作中,相信很多人在PXC5.7的安装步骤问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”PXC5.7的安装步骤”的疑惑有所帮...
    99+
    2022-10-18
  • greenplum4.3.33的安装步骤
    本篇内容介绍了“greenplum4.3.33的安装步骤”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!20...
    99+
    2022-10-18
  • Linux的安装步骤
    这篇文章主要讲解了“Linux的安装步骤”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“Linux的安装步骤”吧!操作系统的安装看似神秘,但其实很简单。以下是成功安装 Linux 的步骤。在 ...
    99+
    2023-06-15
  • Debian10的安装步骤
    本篇内容主要讲解“Debian10的安装步骤”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“Debian10的安装步骤”吧!Debian 项目发布了它的最新稳定版 Debian 10,其代号是 “...
    99+
    2023-06-16
  • TOMCAT的安装步骤
    TOMCAT的安装步骤:0、已经安装了APACHE及JDK。否则安装之。本机安装版本为1。3。JDK为1。4。01、下载TOMCAT安装包,目前最新版本为4。0,安装时使用的为正式发布版3。2。1,下载地址为:java.apache.org...
    99+
    2023-06-03
  • clip的安装步骤
    不能直接使用pip install clip,可遵循官方步骤,官方步骤出错,可按照我的安装步骤进行,亲试有效。 官方安装步骤: 安装相应的pytorch环境(torch要求1.7.0以上版本) 2. ...
    99+
    2023-09-05
    python
  • LDAP安装步骤
    LDAP(Lightweight Directory Access Protocol)是一种用于访问和维护分布式目录信息服务的协议。...
    99+
    2023-09-20
    LDAP
  • ESXI安装步骤
    第一步:通过带外登入界面进入命令行;登入界面后,通过远程控制,进入命令行 第二步:上传esx...
    99+
    2023-09-03
    linux 运维 服务器 Powered by 金山文档
  • mariadb 安装步骤
    下载地址:https://downloads.mariadb.org/mariadb/10.2.10/ ...
    99+
    2022-10-18
  • mysql8.0安装步骤
    打开下载的MySQL 8.0软件安装包,鼠标右击压缩包 选择【解压到当前文件夹】。 打开解压的【Mysql8.0】文件夹 鼠标右击【mysql-installer-community-8.0.17.0】安装程序,选择【以管理员身份运行...
    99+
    2023-09-14
    mysql 数据库
  • MySQL infobright的安装步骤
    整个安装过程过了一遍,感觉跟MySQL的安装差不太多。步骤如下: 1、使用"rpm -ivh  安装包"命令来安装一下rpm的包,如下: [root@tk01-dba-mysql dba_mysql]#...
    99+
    2022-05-22
    MySQL infobright infobright 安装
  • MYSQL MGR的安装步骤
    本篇内容介绍了“MYSQL MGR的安装步骤”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!########...
    99+
    2022-10-18
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作