Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ProxySQL does not resolve DNS records in runtime #4788

Open
metanovii opened this issue Jan 16, 2025 · 0 comments
Open

ProxySQL does not resolve DNS records in runtime #4788

metanovii opened this issue Jan 16, 2025 · 0 comments

Comments

@metanovii
Copy link

metanovii commented Jan 16, 2025

Hello, I am observing an issue that prevents the proper use of ProxySQL in conjunction with HashiCorp Consul.
I am announcing databases as Consul services and adding them to ProxySQL.
The problem is that ProxySQL resolves the DNS of the service only when it is added to mysql_servers.
P.S. The monitor is disabled.
My Configuration:

ProxySQL is launched with the -M flag, version 2.7.1.
Ubuntu 24.04

datadir="/var/lib/proxysql"

mysql_variables=
{
    monitor_enabled="false"
    max_connections="20"
    interfaces="127.0.0.1:6401;127.0.0.1:6402;/var/run/proxysql/proxysql_master.socks"
    free_connections_pct="60"
    ssl_p2s_cert="/etc/ssl/certs/client-cert.pem"
    ssl_p2s_key="/etc/ssl/certs/client-key.pem"
    ssl_p2s_ca="/etc/ssl/certs/cacert.pem"

}

mysql_users=
(
    {
        username = "svc_users_service_test"
        password = ""
        active = 1
        use_ssl = 1
        schema_locked = 0
        transaction_persistent = 1
        fast_forward = 0
        backend = 1
        frontend = 1
        max_connections = 10000
    },
    {
        username = "test"
        password = ""
        active = 1
        use_ssl = 0
        schema_locked = 0
        transaction_persistent = 1
        fast_forward = 0
        backend = 1
        frontend = 1
        max_connections = 10000
    }
)

mysql_servers=(
    {
        hostgroup_id = 100
        hostname = "stand-mysql-rw.service.stand.consul"
        gtid_port = 0
        status = "ONLINE"
        weight = 1
        compression = 0
        max_connections = 1000
        max_replication_lag = 0
        use_ssl = 1
        max_latency_ms = 0
        comment = "rw"
    },
    {
        hostgroup_id = 102
        hostname = "stand-mysql-ro.service.stand.consul"
        gtid_port = 0
        status = "ONLINE"
        weight = 1
        compression = 0
        max_connections = 1000
        max_replication_lag = 0
        use_ssl = 1
        max_latency_ms = 0
        comment = "ro"
    }
)

mysql_query_rules=
(
    {
        rule_id = 5
        active = 1
        proxy_port = 6401
        re_modifiers = "CASELESS"
        destination_hostgroup = 100
        apply = 1
    },
    {
        rule_id = 6
        active = 1
        proxy_port = 6402
        re_modifiers = "CASELESS"
        destination_hostgroup = 102
        apply = 1
    }
)
mysql_hostgroup_attributes=
(
    {
        hostgroup_id = 100
        max_num_online_servers = 1000000
        autocommit = -1
        free_connections_pct = 10
        multiplex = 1
        connection_warming = 0
        throttle_connections_per_sec = 1000000
        servers_defaults = "{\"max_connections\":1000,\"use_ssl\":1}"
    },
    {
        hostgroup_id = 102
        max_num_online_servers = 1000000
        autocommit = -1
        free_connections_pct = 10
        multiplex = 1
        connection_warming = 0
        throttle_connections_per_sec = 1000000
        servers_defaults = "{\"max_connections\":1000,\"use_ssl\":1}"
    }
)

Server Addresses:

  • stand-mysql-test-01 192.168.0.111
  • stand-mysql-test-02 192.168.0.112
  • stand-mysql-test-03 192.168.0.113

Checking the Current State:

root@stand-cli:~# dig stand-mysql-rw.service.stand.consul @127.0.0.1 +short
192.168.0.112

Query via ProxySQL:

root@stand-cli:~# mysql -h127.0.0.1 -P6401 -usvc_users_service_test -p -e "select @@hostname"
mysql: [Warning] Using a password on the command line interface can be insecure.
+---------------------+
| @@hostname          |
+---------------------+
| stand-mysql-test-02 |
+---------------------+

Now I change the master server and check:

root@stand-cli:~# dig stand-mysql-rw.service.stand.consul @127.0.0.1 +short
192.168.0.113

As you can see, the master server address has changed.

Query via ProxySQL:

root@stand-cli:~# mysql -h127.0.0.1 -P6401 -usvc_users_service_test -p -e "select @@hostname"
mysql: [Warning] Using a password on the command line interface can be insecure.
+---------------------+
| @@hostname          |
+---------------------+
| stand-mysql-test-02 |
+---------------------+

The server has not changed.

Lets restart:

root@stand-cli:~# systemctl restart proxysql
root@stand-cli:~# mysql -h127.0.0.1 -P6401 -usvc_users_service_test -p -e "select @@hostname"
mysql: [Warning] Using a password on the command line interface can be insecure.
+---------------------+
| @@hostname          |
+---------------------+
| stand-mysql-test-03 |
+---------------------+
@metanovii metanovii changed the title ProxySQL does not resolve DNS records. ProxySQL does not resolve DNS records in runtime Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant