How To Install ProxySQL on Amazon Linux 2

Posted on 192 views

ProxySQL is a free and open source high performance, high availability, database protocol aware proxy for MySQL. You can think of it as a Load Balancer which understands MySQL protocol providing end-to-end MySQL connection handling, real-time statistics and database traffic inspection. In this short guide we will be looking at how you can install ProxySQL on Amazon Linux 2.

Features of ProxySQL:

  • Zero-downtime Changes: Dynamically configure everything in-memory, persist to disk and push to runtime, all with zero-downtime.
  • Database Firewall: ProxySQL acts as a gatekeeper between the application and the database, allowing DBAs to safeguard the database from malicious activity or problematic application deployments.
  • Advanced Query Rules: Solve your query routing problems with ProxySQL’s rich query rule definitions to efficiently distribute and cache your data to maximize your database service efficiency.
  • Data Sharding & Transformation: Scale out by sharding your database across multiple servers based on schema, table or user. Implement advanced query rules to rewrite your data on-the-fly for transformations or data masking.
  • Failover Detection: ProxySQL automatically detects replication topology changes by continuously monitoring the database backends and re-routing traffic to healthy nodes as the topology changes.
  • Application Layer proxy: ProxySQL is more than a load balancer, it understands the MySQL protocol providing end-to-end MySQL connection handling, real-time statistics and database traffic inspection.

Here is a list of backends supported by ProxySQL:

  • Amazon (AWS) Aurora & RDS
  • ClickHouse
  • Galera Cluster
  • MySQL / MariaDB Server
  • Oracle MySQL InnoDB Cluster & Group Replication
  • Oracle NDB Cluster
  • Percona Server & XtraDB Cluster
  • SQLite (embedded)

Install ProxySQL on Amazon Linux 2

ProxySQL packages are available in the repository for Debian and Red Hat based Linux distributions. But first add the package repository to your local system.

sudo tee /etc/yum.repos.d/proxysql.repo<

Update YUM package index to confirm the repository is working:

$ sudo yum makecache
Loaded plugins: dkms-build-requires, langpacks, priorities, update-motd
amzn2-core                                               | 3.7 kB     00:00
amzn2extra-docker                                        | 3.0 kB     00:00
proxysql_repo                                            | 2.9 kB     00:00
(1/10): amzn2-core/2/x86_64/primary_db                     |  44 MB   00:01
(2/10): amzn2-core/2/x86_64/other_db                       |  507 B   00:01
(3/10): amzn2extra-docker/2/x86_64/updateinfo              |   76 B   00:01
(4/10): amzn2extra-docker/2/x86_64/filelists_db            |  13 kB   00:01
(5/10): amzn2extra-docker/2/x86_64/primary_db              |  68 kB   00:00
(6/10): amzn2extra-docker/2/x86_64/other_db                |  507 B   00:01
(7/10): proxysql_repo/filelists_db                         | 3.0 kB   00:01
(8/10): proxysql_repo/primary_db                           |  15 kB   00:01
(9/10): proxysql_repo/other_db                             | 1.5 kB   00:00
(10/10): amzn2-core/2/x86_64/filelists_db                  |  34 MB   00:09
Metadata Cache Created

Install ProxySQL package on Amazon Linux 2 Linux by running the commands below.

sudo yum install proxysql

Review dependency tree and agree to the installation prompt:

Dependencies Resolved

==================================================================================================================================================================
 Package                                       Arch                         Version                                     Repository                           Size
==================================================================================================================================================================
Installing:
 proxysql                                      x86_64                       2.0.14-1                                    proxysql_repo                        12 M
Installing for dependencies:
 gnutls                                        x86_64                       3.3.29-9.amzn2                              amzn2-core                          673 k
 nettle                                        x86_64                       2.7.1-8.amzn2.0.2                           amzn2-core                          329 k
 perl-Compress-Raw-Bzip2                       x86_64                       2.061-3.amzn2.0.2                           amzn2-core                           32 k
 perl-Compress-Raw-Zlib                        x86_64                       1:2.061-4.amzn2.0.2                         amzn2-core                           58 k
 perl-DBD-MySQL                                x86_64                       4.023-6.amzn2                               amzn2-core                          141 k
 perl-DBI                                      x86_64                       1.627-4.amzn2.0.2                           amzn2-core                          804 k
 perl-Data-Dumper                              x86_64                       2.145-3.amzn2.0.2                           amzn2-core                           48 k
 perl-IO-Compress                              noarch                       2.061-2.amzn2                               amzn2-core                          260 k
 perl-Net-Daemon                               noarch                       0.48-5.amzn2                                amzn2-core                           51 k
 perl-PlRPC                                    noarch                       0.2020-14.amzn2                             amzn2-core                           36 k
 trousers                                      x86_64                       0.3.14-2.amzn2.0.2                          amzn2-core                          294 k

Transaction Summary
==================================================================================================================================================================
Install  1 Package (+11 Dependent packages)

Total download size: 15 M
Installed size: 52 M
Is this ok [y/d/N]: y

Also import GPG key when prompted:

Total                                                                                                                             1.1 MB/s |  15 MB  00:00:13
Retrieving key from https://repo.proxysql.com/ProxySQL/repo_pub_key
Importing GPG key 0x79953B49:
 Userid     : "rene cannnao (Proxysql Repository) "
 Fingerprint: 1448 bf69 3ca6 00c7 99eb 9358 04a5 62fb 7995 3b49
 From       : https://repo.proxysql.com/ProxySQL/repo_pub_key
Is this ok [y/N]: y

After installation the service is not started. The freedom is all yours.

$ systemctl status proxysql
● proxysql.service - High Performance Advanced Proxy for MySQL
   Loaded: loaded (/etc/systemd/system/proxysql.service; enabled; vendor preset: disabled)
   Active: inactive (dead)

To start the service use the command.

sudo systemctl enable --now proxysql

Visit the Configuring ProxySQL page to get you started with ProxySQL configuration.

coffee

Gravatar Image
A systems engineer with excellent skills in systems administration, cloud computing, systems deployment, virtualization, containers, and a certified ethical hacker.