简体   繁体   English

maxcrtl 无法连接到 maxscale

[英]maxcrtl cannot connect to maxscale

I have a k8s cluster on which I want to deploy the MariaDB cluster.我有一个 k8s 集群,我想在其上部署 MariaDB 集群。 I have master and slave pods and want to monitor them with a maxscale.我有 master 和 slave pod,想用 maxscale 监控它们。 The pod runs with its default config without any problem, but when I mount the volume in a type of configmap and run maxctrl list servers I get the below error: pod 使用其默认配置运行没有任何问题,但是当我将卷挂载到一种类型的 configmap 并运行maxctrl list servers时,我收到以下错误:

Error: Could not connect to MaxScale

The logs of the pod: pod的日志:

maxscale log最大对数

Deployment file:部署文件:

 --- apiVersion: apps/v1 kind: Deployment metadata: name: maxscale namespace: mariaDB-cluster spec: replicas: 2 selector: matchLabels: app: maxscale template: metadata: labels: app: maxscale spec: containers: - name: maxscale image: mariadb/maxscale:6.3.1 volumeMounts: - name: maxscale mountPath: /etc/maxscale.cnf.d/ ports: - name: mariadb containerPort: 3306 - name: restapi containerPort: 8989 volumes: - name: maxscale configMap: name: maxscale-test items: - key: "maxscale.cnf" path: "maxscale.cnf"

Configmap.yaml: Configmap.yaml:

 apiVersion: v1 kind: ConfigMap metadata: name: maxscale-test namespace: mariadb-cluster labels: app: maxscale app.kubernetes.io/name: maxscale data: maxscale.cnf: | [maxscale] threads=auto admin_enabled=false # Server definitions # # Set the address of the server to the network # address of a MariaDB server. # [server1] type=server address=127.0.0.1 port=3306 protocol=MariaDBBackend # Monitor for the servers # # This will keep MaxScale aware of the state of the servers. # MariaDB Monitor documentation: # https://mariadb.com/kb/en/maxscale-6-monitors/ [MariaDB-Monitor] type=monitor module=mariadbmon servers=server1 user=myuser password=mypwd monitor_interval=2000 # Service definitions # # Service Definition for a read-only service and # a read/write splitting service. # # ReadConnRoute documentation: # https://mariadb.com/kb/en/mariadb-maxscale-6-readconnroute/ [Read-Only-Service] type=service router=readconnroute servers=server1 user=myuser password=mypwd router_options=slave # ReadWriteSplit documentation: # https://mariadb.com/kb/en/mariadb-maxscale-6-readwritesplit/ [Read-Write-Service] type=service router=readwritesplit servers=server1 user=myuser password=mypwd # Listener definitions for the services # # These listeners represent the ports the # services will listen on. # [Read-Only-Listener] type=listener service=Read-Only-Service protocol=MariaDBClient port=4008 [Read-Write-Listener] type=listener service=Read-Write-Service protocol=MariaDBClient port=4006

I use the maxscale default config, but it does not work when I mount it to /etc/maxscale.cnf.d, so I think the problem is related to reading the config file.我使用的是maxscale默认配置,但是当我将它挂载到/etc/maxscale.cnf.d时它不起作用,所以我认为问题与读取配置文件有关。

Make sure to run the command inside the same container that the maxscale process is running on: by default it listens only for local connections on port 8989. If you want MaxScale to listen on all interfaces, not just the loopback interface, use admin_host=0.0.0.0 .确保在运行maxscale进程的同一容器内运行命令:默认情况下,它仅侦听端口 8989 上的本地连接。如果您希望 MaxScale 侦听所有接口,而不仅仅是环回接口,请使用admin_host=0.0.0.0 .

If you expose the REST API port of the container and want to connect to it from outside, use maxctrl -h address:port .如果你暴露了容器的 REST API 端口并想从外部连接到它,使用maxctrl -h address:port The address is the network address ( admin_host in maxscale.cnf ) and port is the network port it listens on ( admin_port in maxctrl.cnf ). address是网络地址( admin_host中的maxscale.cnf ), port是它监听的网络端口( admin_port中的maxctrl.cnf )。

For example, to connect to a MaxScale container at mxshost :例如,要连接到 mxshost 的mxshost容器:

maxctrl -h mxshost:8989 list servers

i found the answer.我找到了答案。 It was about the conflict in maxscale config.这是关于 maxscale 配置中的冲突。 i add a new config in maxscale.cnf and mount it to /etc/maxscale.cnf.d/.我在 maxscale.cnf 中添加了一个新配置并将其挂载到 /etc/maxscale.cnf.d/。 but I think this config was appended to /etc/maxscale.cnf, so when I have the below part in /etc/maxscale.cnf.d/maxscale.cnf again, it makes conflict:但我认为这个配置被附加到/etc/maxscale.cnf,所以当我再次在/etc/maxscale.cnf.d/maxscale.cnf中有以下部分时,它会产生冲突:

[maxscale]
    threads=auto
    admin_enabled=false

So I deleted this part from my configmap, and it worked.所以我从我的 configmap 中删除了这部分,它起作用了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM