首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >maxcrtl无法连接到maxscale。

maxcrtl无法连接到maxscale。
EN

Stack Overflow用户
提问于 2022-08-16 11:52:38
回答 2查看 148关注 0票数 0

我有一个k8s集群,我想在这个集群上部署MariaDB集群。我有主舱和奴隶舱,想用最大比例监视它们。pod以其默认配置运行,没有任何问题,但是当我在configmap类型中挂载卷并运行maxctrl list servers时,会得到以下错误:

代码语言:javascript
运行
复制
Error: Could not connect to MaxScale

吊舱的原木:

最大标度测井

部署文件:

代码语言:javascript
运行
复制
---
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:

代码语言:javascript
运行
复制
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

我使用maxscale默认配置,但是当我将它挂载到/etc/maxscale.cnf.d时,它不起作用,所以我认为问题与读取配置文件有关。

EN

回答 2

Stack Overflow用户

发布于 2022-08-29 07:51:03

确保在运行maxscale进程的同一个容器中运行命令:默认情况下,它只侦听端口8989上的本地连接。如果希望MaxScale侦听所有接口,而不仅仅是循环接口,请使用admin_host=0.0.0.0

如果您公开容器的REST端口并希望从外部连接到它,请使用maxctrl -h address:portaddress是网络地址(admin_host in maxscale.cnf),port是它侦听的网络端口(admin_port in maxctrl.cnf)。

例如,在MaxScale上连接到mxshost容器

代码语言:javascript
运行
复制
maxctrl -h mxshost:8989 list servers
票数 0
EN

Stack Overflow用户

发布于 2022-09-03 11:22:43

我找到了答案。它是关于maxscale配置中的冲突。我在maxscale.cnf中添加了一个新的配置,并将其挂载到/etc/maxscale.cnf.d/。但是,我认为这个配置被追加到/etc/maxscale.cnf,所以当我在/etc/maxScale.cnf中再次包含以下部分时,它会产生冲突:

代码语言:javascript
运行
复制
[maxscale]
    threads=auto
    admin_enabled=false

所以我从我的configmap中删除了这个部分,它起了作用。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73373555

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档