Azure Maria DB TX 2.0连接不起作用

时间:2018-05-09 08:02:40

标签: mysql azure mariadb mariadb-connect-engine

我正在尝试连接到Azure中的MariaDB TX 2.0群集,但它不起作用。 我在配置步骤中创建了一个公共负载均衡器,在部署之后,我获得了一个ip地址和一个主机名。

例如

mysql: [Warning] Using a password on the command line interface can be insecure.
**ERROR 2003 (HY000): Can't connect to MySQL server on 'mymariadb.westus.cloudapp.azure.com' (110)**

mysql connect string:

Unable to connect to MaxScale at /tmp/maxadmin.sock: No such file or directory

我收到此错误:

2018-05-15 20:18:03   error  : Creation of listener 'Read-Connection-Listener' for service 'Read Connection Router' failed, because both 'socket' and 'port' are defined. Only either one is allowed.
2018-05-15 20:18:03   error  : Creation of listener 'Write-Connection-Listener' for service 'Write Connection Router' failed, because both 'socket' and 'port' are defined. Only either one is allowed.
2018-05-15 20:18:03   error  : Creation of listener 'RW-Split-Listener' for service 'RW Split Router' failed, because both 'socket' and 'port' are defined. Only either one is allowed.

为什么我无法连接到MariaDB群集的任何想法?

我还尝试连接到maxscaller之一并从那里连接到一个数据库服务器 - >这很有效。

谢谢!

更新

谢谢你的帖子。 首先,我无法运行maxadmin:

2018-05-15 20:18:03   warning: Protocol module 'mysqlbackend' has been deprecated, use 'mariadbbackend' instead.

我检查日志并注意到侦听器存在问题

[CLI]
type=service
router=cli


[RW Split Listener]
type=listener
service=RW Split Router
protocol=MySQLClient
port=4006
socket=/var/lib/maxscale/rwsplit.sock

[Write Connection Listener]
type=listener
service=Write Connection Router
protocol=MySQLClient
port=4007
socket=/var/lib/maxscale/writeconn.sock

[Read Connection Listener]
type=listener
service=Read Connection Router
protocol=MySQLClient
port=4008
socket=/var/lib/maxscale/readconn.sock

[CLI Listener]
type=listener
service=CLI
protocol=maxscaled
socket=/tmp/maxadmin.sock

[MaxInfo]
type=service
router=maxinfo

[MaxInfo JSON Listener]
type=listener
service=MaxInfo
protocol=HTTPD
port=8003
address=localhost


[db1]
type=server
address=172.16.4.4
port=3306
protocol=MySQLBackend

[db2]
type=server
address=172.16.4.5
port=3306
protocol=MySQLBackend

[db3]
type=server
address=172.16.4.6
port=3306
protocol=MySQLBackend

也找到了这个:

2018-05-18 07:12:58   error  : Creation of listener 'Read-Connection-Listener' for service 'Read Connection Router' failed, because both 'socket' and 'port' are defined. Only either one is allowed.
2018-05-18 07:12:58   error  : Creation of listener 'Write-Connection-Listener' for service 'Write Connection Router' failed, because both 'socket' and 'port' are defined. Only either one is allowed.
2018-05-18 07:12:58   error  : Creation of listener 'RW-Split-Listener' for service 'RW Split Router' failed, because both 'socket' and 'port' are defined. Only either one is allowed.
2018-05-18 07:12:58   notice : Monitor 'Galera-Monitor' is missing the 'journal_max_age' parameter, using default value of 28800 seconds.
2018-05-18 07:12:58   notice : Monitor 'Galera-Monitor' is missing the 'script_timeout' parameter, using default value of 90 seconds.
2018-05-18 07:12:58   error  : 3 errors were encountered while processing the configuration file '/etc/maxscale.cnf'.
2018-05-18 07:12:58   error  : Failed to open, read or process the MaxScale configuration file /etc/maxscale.cnf. Exiting.
2018-05-18 07:12:58   MariaDB MaxScale is shut down.
----------------------------------------------------
me@mdbec-max1:~$ maxadmin
Unable to connect to MaxScale at /tmp/maxadmin.sock: No such file or directory

希望您(作为MariaDB专家)可以帮助我解决这个问题!

谢谢你,问候!

更新2

这是我的cnf文件(我没有做任何更改)。这应该是正确的并且正常工作,对吧?

[maxscale]
threads=4
datadir=/var/lib/maxscale/data/


#[MySQL Monitor]
#type=monitor
#module=mysqlmon
#servers=server1,server2,server3
#user=myuser
#passwd=mypwd
#monitor_interval=10000
#backend_connect_timeout=
#backend_read_timeout=
#backend_write_timeout=
#detect_replication_lag=
#detect_stale_master=

[Galera Monitor]
type=monitor
module=galeramon
servers=db1,db2,db3
user=maxscalemonitor
passwd=I-DELETE-THIS-LINE
monitor_interval=1000
#disable_master_failback=


[qla]
type=filter
module=qlafilter
filebase=/tmp/QueryLog

[fetch]
type=filter
module=regexfilter
match=fetch
replace=select

[hint]
type=filter
module=hintfilter



[Write Connection Router]
type=service
router=readconnroute
servers=db1,db2,db3
user=maxscalemonitor
passwd=I-DELETE-THIS-LINE
router_options=master
localhost_match_wildcard_host=1
version_string=10.2.14-MariaDB Cluster

[Read Connection Router]
type=service
router=readconnroute
servers=db1,db2,db3
user=maxscalemonitor
passwd=I-DELETE-THIS-LINE
router_options=synced
localhost_match_wildcard_host=1
version_string=10.2.14-MariaDB Cluster

[RW Split Router]
type=service
router=readwritesplit
servers=db1,db2,db3
user=maxscalemonitor
passwd=I-DELETE-THIS-LINE
max_slave_connections=100%
localhost_match_wildcard_host=1
version_string=10.2.14-MariaDB Cluster
router_options=disable_sescmd_history=true
#use_sql_variables_in=master
#max_slave_replication_lag=21
#filters=hint|fetch|qla
#router_options=slave_selection_criteria=LEAST_CURRENT_OPERATIONS


[CLI]
type=service
router=cli


[RW Split Listener]
type=listener
service=RW Split Router
protocol=MySQLClient
port=4006
socket=/var/lib/maxscale/rwsplit.sock

[Write Connection Listener]
type=listener
service=Write Connection Router
protocol=MySQLClient
port=4007
socket=/var/lib/maxscale/writeconn.sock

[Read Connection Listener]
type=listener
service=Read Connection Router
protocol=MySQLClient
port=4008
socket=/var/lib/maxscale/readconn.sock

[CLI Listener]
type=listener
service=CLI
protocol=maxscaled
socket=/tmp/maxadmin.sock

[MaxInfo]
type=service
router=maxinfo

[MaxInfo JSON Listener]
type=listener
service=MaxInfo
protocol=HTTPD
port=8003
address=localhost


[CLIUnixListener]
type=listener
service=CLI
protocol=maxscaled
socket=default

[CLIInetListener]
type=listener
service=CLI
protocol=maxscaled
address=localhost
port=6603


[db1]
type=server
address=172.16.4.4
port=3306
protocol=MySQLBackend

[db2]
type=server
address=172.16.4.5
port=3306
protocol=MySQLBackend

[db3]
type=server
address=172.16.4.6
port=3306
protocol=MySQLBackend

更新3:

我进行了您建议的更改,并尝试使用maxadmin命令:

function getFacebookVideoFromUrl($url) {
    $context = [
        'http' => [
        'method' => 'GET',
        'header' => "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.47 Safari/537.36",
        ],
    ];
    $context = stream_context_create($context);
    $data = file_get_contents($url, false, $context);

    $regex = '/hd_src_no_ratelimit:"([^"]+)"/';
    if (preg_match($regex, $data, $match)) {
        return $match[1];
    } else {
        $regex = '/sd_src_no_ratelimit:"([^"]+)"/';
        if (preg_match($regex, $data, $match)) {
            return $match[1];
        }
    }

    return false;
}

更新4

{{1}}

4 个答案:

答案 0 :(得分:0)

您能否暂时启用Maxscale实例上的log_info并再次尝试连接?启用log_info后,它将向Maxscale日志(/var/log/maxscale/maxscale.log)添加事件,该日志显示有关请求无法路由到后端的更多详细信息。

以下命令将动态启用日志:

$ maxadmin enable log-priority info

以下命令将动态禁用日志:

$ maxadmin disable log-priority info

期待您的回复。

答案 1 :(得分:0)

要运行Maxadmin客户端,首先,您需要为该路由器分配CLI路由器和侦听器,如下所述:

https://mariadb.com/kb/en/mariadb-enterprise/mariadb-maxscale-21-maxscale-21-cli/

要添加到/etc/maxscale.cnf的配置如下:

[CLI]
type=service
router=cli

[CLIUnixListener]
type=listener
service=CLI
protocol=maxscaled
socket=default

[CLIInetListener]
type=listener
service=CLI
protocol=maxscaled
address=localhost
port=6603

将以上内容添加到/etc/maxscale.cnf并重新启动maxscale。之后,他们采用以下方法:

$ maxadmin -uadmin -pmariadb

$ sudo maxadmin

关于创建监听器时的错误,请你在这里分享Maxscale配置文件然后,我可以看一下吗?检查Maxscale是否可以创建我上面建议的CLI路由器监听器。

期待您的回复。

答案 2 :(得分:0)

Sokolata,

我发现了你的配置问题。请从收听者的片段中删除端口或套接字。如果您希望拥有网络侦听器的端口和localhost连接的套接字,则需要创建单独的代码段。下面,我为你的实验室调整了一些你的配置,它的工作正如你所见:

<强> maxscale.cnf

[maxscale]
threads=4
#datadir=/var/lib/maxscale/data/

[Galera Monitor]
type=monitor
module=galeramon
servers=db1,db2,db3
user=maxmon
passwd=2C894F278CEC5B974966EC969E006E37
monitor_interval=1000

[qla]
type=filter
module=qlafilter
filebase=/tmp/QueryLog

[fetch]
type=filter
module=regexfilter
match=fetch
replace=select

[hint]
type=filter
module=hintfilter

[Write Connection Router]
type=service
router=readconnroute
servers=db1,db2,db3
user=maxusr
passwd=2C894F278CEC5B974966EC969E006E37
router_options=master
localhost_match_wildcard_host=1
version_string=10.2.14-MariaDB Cluster

[Read Connection Router]
type=service
router=readconnroute
servers=db1,db2,db3
user=maxusr
passwd=2C894F278CEC5B974966EC969E006E37
router_options=synced
localhost_match_wildcard_host=1
version_string=10.2.14-MariaDB Cluster

[RW Split Router]
type=service
router=readwritesplit
servers=db1,db2,db3
user=maxusr
passwd=2C894F278CEC5B974966EC969E006E37
max_slave_connections=100%
localhost_match_wildcard_host=1
version_string=10.2.14-MariaDB Cluster
router_options=disable_sescmd_history=true

[CLI]
type=service
router=cli

[RW Split Listener]
type=listener
service=RW Split Router
protocol=MySQLClient
port=4006
#socket=/var/lib/maxscale/rwsplit.sock

[Write Connection Listener]
type=listener
service=Write Connection Router
protocol=MySQLClient
port=4007
#socket=/var/lib/maxscale/writeconn.sock

[Read Connection Listener]
type=listener
service=Read Connection Router
protocol=MySQLClient
port=4008
#socket=/var/lib/maxscale/readconn.sock

[CLI Listener]
type=listener
service=CLI
protocol=maxscaled
socket=/tmp/maxadmin.sock

[CLIUnixListener]
type=listener
service=CLI
protocol=maxscaled
socket=default

[CLIInetListener]
type=listener
service=CLI
protocol=maxscaled
address=localhost
port=6603

[db1]
type=server
address=10.136.85.157
port=3306
protocol=MySQLBackend

[db2]
type=server
address=10.136.87.40
port=3306
protocol=MySQLBackend

[db3]
type=server
address=10.136.80.203
port=3306
protocol=MySQLBackend

<强> maxscale.log

MariaDB MaxScale  /var/log/maxscale/maxscale.log  Sun May 20 13:30:49 2018
----------------------------------------------------------------------------
2018-05-20 13:30:49   notice : Working directory: /var/log/maxscale
2018-05-20 13:30:49   notice : The collection of SQLite memory allocation statistics turned off.
2018-05-20 13:30:49   notice : Threading mode of SQLite set to Multi-thread.
2018-05-20 13:30:49   notice : MariaDB MaxScale 2.2.5 started
2018-05-20 13:30:49   notice : MaxScale is running in process 24042
2018-05-20 13:30:49   notice : Configuration file: /root/maxscale/configs/test.cnf
2018-05-20 13:30:49   notice : Log directory: /var/log/maxscale
2018-05-20 13:30:49   notice : Data directory: /var/lib/maxscale
2018-05-20 13:30:49   notice : Module directory: /usr/lib64/maxscale
2018-05-20 13:30:49   notice : Service cache: /var/cache/maxscale
2018-05-20 13:30:49   notice : Loading /root/maxscale/configs/test.cnf.
2018-05-20 13:30:49   warning: Number of threads set to 4, which is greater than the number of processors available: 1
2018-05-20 13:30:49   warning: Whitespace in object names is deprecated, converting to hyphens: Galera Monitor
2018-05-20 13:30:49   warning: Whitespace in object names is deprecated, converting to hyphens: Write Connection Router
2018-05-20 13:30:49   warning: Whitespace in object names is deprecated, converting to hyphens: Read Connection Router
2018-05-20 13:30:49   warning: Whitespace in object names is deprecated, converting to hyphens: RW Split Router
2018-05-20 13:30:49   warning: Whitespace in object names is deprecated, converting to hyphens: RW Split Listener
2018-05-20 13:30:49   warning: Whitespace in object names is deprecated, converting to hyphens: Write Connection Listener
2018-05-20 13:30:49   warning: Whitespace in object names is deprecated, converting to hyphens: Read Connection Listener
2018-05-20 13:30:49   warning: Whitespace in object names is deprecated, converting to hyphens: CLI Listener
2018-05-20 13:30:49   notice : /root/maxscale/configs/test.cnf.d does not exist, not reading.
2018-05-20 13:30:49   notice : [cli] Initialise CLI router module
2018-05-20 13:30:49   notice : Loaded module cli: V1.0.0 from /usr/lib64/maxscale/libcli.so
2018-05-20 13:30:49   notice : [readwritesplit] Initializing statement-based read/write split router module.
2018-05-20 13:30:49   notice : Loaded module readwritesplit: V1.1.0 from /usr/lib64/maxscale/libreadwritesplit.so
2018-05-20 13:30:49   notice : [readconnroute] Initialise readconnroute router module.
2018-05-20 13:30:49   notice : Loaded module readconnroute: V1.1.0 from /usr/lib64/maxscale/libreadconnroute.so
2018-05-20 13:30:49   notice : Loaded module hintfilter: V1.0.0 from /usr/lib64/maxscale/libhintfilter.so
2018-05-20 13:30:49   notice : Loaded module regexfilter: V1.1.0 from /usr/lib64/maxscale/libregexfilter.so
2018-05-20 13:30:49   notice : Loaded module qlafilter: V1.1.1 from /usr/lib64/maxscale/libqlafilter.so
2018-05-20 13:30:49   notice : [galeramon] Initialise the MySQL Galera Monitor module.
2018-05-20 13:30:49   notice : Loaded module galeramon: V2.0.0 from /usr/lib64/maxscale/libgaleramon.so
2018-05-20 13:30:49   warning: Protocol module 'mysqlbackend' has been deprecated, use 'mariadbbackend' instead.
2018-05-20 13:30:49   notice : Loaded module mariadbbackend: V2.0.0 from /usr/lib64/maxscale/libmariadbbackend.so
2018-05-20 13:30:49   notice : Loaded module MySQLBackendAuth: V1.0.0 from /usr/lib64/maxscale/libmysqlbackendauth.so
2018-05-20 13:30:49   notice : Loaded module maxscaled: V2.0.0 from /usr/lib64/maxscale/libmaxscaled.so
2018-05-20 13:30:49   notice : Loaded module MaxAdminAuth: V2.1.0 from /usr/lib64/maxscale/libmaxadminauth.so
2018-05-20 13:30:49   warning: Protocol module 'mysqlclient' has been deprecated, use 'mariadbclient' instead.
2018-05-20 13:30:49   notice : Loaded module mariadbclient: V1.1.0 from /usr/lib64/maxscale/libmariadbclient.so
2018-05-20 13:30:49   notice : Loaded module MySQLAuth: V1.1.0 from /usr/lib64/maxscale/libmysqlauth.so
2018-05-20 13:30:49   notice : Monitor 'Galera-Monitor' is missing the 'journal_max_age' parameter, using default value of 28800 seconds.
2018-05-20 13:30:49   notice : Monitor 'Galera-Monitor' is missing the 'script_timeout' parameter, using default value of 90 seconds.
2018-05-20 13:30:49   notice : No query classifier specified, using default 'qc_sqlite'.
2018-05-20 13:30:49   notice : Loaded module qc_sqlite: V1.0.0 from /usr/lib64/maxscale/libqc_sqlite.so
2018-05-20 13:30:49   warning: Removing stale journal file for monitor 'Galera-Monitor'.
2018-05-20 13:30:49   notice : Using encrypted passwords. Encryption key: '/var/lib/maxscale/.secrets'.
2018-05-20 13:30:49   notice : Starting a total of 4 services...
2018-05-20 13:30:49   notice : [MySQLAuth] [Write-Connection-Router] Loaded 7 MySQL users for listener Write-Connection-Listener.
2018-05-20 13:30:49   notice : Listening for connections at [::]:4007 with protocol MySQL
2018-05-20 13:30:49   notice : Service 'Write-Connection-Router' started (1/4)
2018-05-20 13:30:49   notice : [MySQLAuth] [Read-Connection-Router] Loaded 7 MySQL users for listener Read-Connection-Listener.
2018-05-20 13:30:49   notice : Listening for connections at [::]:4008 with protocol MySQL
2018-05-20 13:30:49   notice : Service 'Read-Connection-Router' started (2/4)
2018-05-20 13:30:49   warning: [readwritesplit] Router options for readwritesplit are deprecated.
2018-05-20 13:30:49   notice : [MySQLAuth] [RW-Split-Router] Loaded 7 MySQL users for listener RW-Split-Listener.
2018-05-20 13:30:49   notice : Listening for connections at [::]:4006 with protocol MySQL
2018-05-20 13:30:49   notice : Service 'RW-Split-Router' started (3/4)
2018-05-20 13:30:49   notice : Listening for connections at [/tmp/maxadmin.sock]:0 with protocol MaxScale Admin
2018-05-20 13:30:49   notice : Listening for connections at [/tmp/maxadmin.sock]:0 with protocol MaxScale Admin
2018-05-20 13:30:49   notice : Listening for connections at [localhost]:6603 with protocol MaxScale Admin
2018-05-20 13:30:49   notice : Service 'CLI' started (4/4)
2018-05-20 13:30:49   notice : Started MaxScale log flusher.
2018-05-20 13:30:49   notice : Started REST API on [127.0.0.1]:8989
2018-05-20 13:30:49   notice : MaxScale started with 4 worker threads, each with a stack size of 8388608 bytes.
2018-05-20 13:30:50   notice : Server changed state: db1[10.136.85.157:3306]: new_master. [Running] -> [Master, Synced, Running]
2018-05-20 13:30:50   notice : Server changed state: db2[10.136.87.40:3306]: new_slave. [Running] -> [Slave, Synced, Running]
2018-05-20 13:30:50   notice : Server changed state: db3[10.136.80.203:3306]: new_slave. [Running] -> [Slave, Synced, Running]

我测试了与三个听众的连接:

<强> 4006

[root@mxs01 ~]# for i in {1..10}; do mysql -ubianchi -p -h10.136.72.138 -P 4006 -e "select @@hostname\G"; done
*************************** 1. row ***************************
@@hostname: n02
*************************** 1. row ***************************
@@hostname: n02
*************************** 1. row ***************************
@@hostname: n02
*************************** 1. row ***************************
@@hostname: n02
*************************** 1. row ***************************
@@hostname: n02
*************************** 1. row ***************************
@@hostname: n02
*************************** 1. row ***************************
@@hostname: n02
*************************** 1. row ***************************
@@hostname: n02
*************************** 1. row ***************************
@@hostname: n02
*************************** 1. row ***************************
@@hostname: n02

<强> 4007

[root@mxs01 ~]# for i in {1..10}; do mysql -ubianchi -p -h10.136.72.138 -P 4007 -e "select @@hostname\G"; done
*************************** 1. row ***************************
@@hostname: n01
*************************** 1. row ***************************
@@hostname: n01
*************************** 1. row ***************************
@@hostname: n01
*************************** 1. row ***************************
@@hostname: n01
*************************** 1. row ***************************
@@hostname: n01
*************************** 1. row ***************************
@@hostname: n01
*************************** 1. row ***************************
@@hostname: n01
*************************** 1. row ***************************
@@hostname: n01
*************************** 1. row ***************************
@@hostname: n01
*************************** 1. row ***************************
@@hostname: n01

<强> 4008

[root@mxs01 ~]# for i in {1..10}; do mysql -ubianchi -p -h10.136.72.138 -P 4008 -e "select @@hostname\G"; done
*************************** 1. row ***************************
@@hostname: n02
*************************** 1. row ***************************
@@hostname: n03
*************************** 1. row ***************************
@@hostname: n02
*************************** 1. row ***************************
@@hostname: n03
*************************** 1. row ***************************
@@hostname: n02
*************************** 1. row ***************************
@@hostname: n03
*************************** 1. row ***************************
@@hostname: n02
*************************** 1. row ***************************
@@hostname: n03
*************************** 1. row ***************************
@@hostname: n02
*************************** 1. row ***************************
@@hostname: n03

尝试一下,让我们知道它是怎么回事,欢呼!

答案 3 :(得分:0)

支持人员告诉您,您的意思是,Microsoft Azure支持,对吧?顺便说一句,我的建议是你有一个小项目,在Azure上设置你自己的VNet,为4个新的虚拟机,1个Maxscale和3个其他的MariaDB集群。定义了VM后,在所有服务器上设置MariaDB官方回购:

curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash

设置MariaDB服务器和MariaDB Maxscale,设置群集,创建Maxscale用户并使用我们在此定义的配置使其工作。

去玩得开心。