Azure中MariaDB TX 2.0集群连接失败排查求助
Let's break down your issues and fix them step by step—your log messages already point straight to the root causes!
Core Issues Identified
- MaxScale Listeners Fail to Start: The error "both 'socket' and 'port' are defined. Only either one is allowed" means your listener configurations are invalid, so MaxScale can't open the TCP ports you're trying to connect to externally.
- Deprecated Protocol Module: The
mysqlbackendmodule is outdated, which might cause unexpected behavior even if it works temporarily. - Maxadmin Connection Failure: This is a side effect of MaxScale failing to start properly due to the listener errors—no running MaxScale instance means no
/tmp/maxadmin.sockfile exists.
Step 1: Fix Listener Configuration Errors
Open your /etc/maxscale.cnf file and locate all listener sections (e.g., Read-Connection-Listener, Write-Connection-Listener, RW-Split-Listener). For each listener:
- Since you need public network access via the Azure load balancer, remove the
socketparameter entirely and keep only theport(andaddressif you want to bind to a specific IP for security). - Example valid listener config:
[Read-Connection-Listener] type=listener service=Read Connection Router protocol=mysqlclient port=4006 address=0.0.0.0 # Bind to all network interfaces (adjust if needed)
Repeat this fix for all listeners that throw the "socket + port" error.
Step 2: Replace Deprecated Protocol Module
In the same config file, find any service sections using protocol=mysqlbackend (these are typically the services connecting to your MariaDB backend nodes) and replace it with the recommended module:
protocol=mariadbbackend
Step 3: Restart MaxScale and Validate
After updating the config, restart MaxScale to apply changes:
systemctl restart maxscale
- Check if MaxScale is running successfully:
systemctl status maxscale
- Now try connecting with
maxadmin(the socket file should be created once MaxScale starts properly):
maxadmin -u admin -p # Omit the password here to enter it securely
- Finally, test your external connection again (skip putting the password directly in the command line to avoid the insecure warning):
mysql -h mymariadb.westus.cloudapp.azure.com -P 4006 -u myapp -p mydb
Step 4: Verify Azure Network Settings
If you still can't connect externally after fixing MaxScale:
- Confirm your Azure Load Balancer has an inbound rule forwarding port 4006 to the MaxScale node's port 4006.
- Check that the MaxScale node's OS firewall (iptables/ufw) allows incoming traffic on port 4006.
- Ensure the load balancer's public hostname/IP resolves correctly (use
nslookup mymariadb.westus.cloudapp.azure.comto test).
内容的提问来源于stack exchange,提问作者sokolata

