我正在尝试在Kubernetes集群中设置我的mosquitto服务器,并且某种程度上我遇到了以下错误,但我不知道为什么。 有人可以帮我吗?
错误:
1551171948: mosquitto version 1.4.10 (build date Wed, 13 Feb 2019 00:45:38 +0000) starting
1551171948: Config loaded from /etc/mosquitto/mosquitto.conf.
1551171948: |-- *** auth-plug: startup
1551171948: |-- ** Configured order: http
1551171948: |-- with_tls=false
1551171948: |-- getuser_uri=/api/mosquitto/users
1551171948: |-- superuser_uri=/api/mosquitto/admins
1551171948: |-- aclcheck_uri=/api/mosquitto/permissions
1551171948: |-- getuser_params=(null)
1551171948: |-- superuser_params=(null)
1551171948: |-- aclcheck_paramsi=(null)
1551171948: Opening ipv4 listen socket on port 1883.
1551171948: Error: Cannot assign requested address
Mosquitto.conf:
allow_duplicate_messages false
connection_messages true
log_dest stdout stderr
log_timestamp true
log_type all
persistence false
listener 1883 mosquitto
allow_anonymous true
# Public
# listener 8883 0.0.0.0
listener 9001 0.0.0.0
protocol websockets
allow_anonymous false
auth_plugin /usr/lib/mosquitto-auth-plugin/auth-plugin.so
auth_opt_backends http
auth_opt_http_ip 127.0.0.1
auth_opt_http_getuser_uri /api/mosquitto/users
auth_opt_http_superuser_uri /api/mosquitto/admins
auth_opt_http_aclcheck_uri /api/mosquitto/permissions
auth_opt_acl_cacheseconds 1
auth_opt_auth_cacheseconds 0
Kubernetes.yaml:
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: mosquitto
spec:
replicas: 1
template:
metadata:
labels:
app: mosquitto
spec:
imagePullSecrets:
- name: abb-login
containers:
- name: mosquitto
image: ****mosquitto:develop
imagePullPolicy: Always
ports:
- containerPort: 9001
protocol: TCP
- containerPort: 1883
protocol: TCP
- containerPort: 8883
protocol: TCP
resources: {}
---
apiVersion: v1
kind: Service
metadata:
name: mosquitto
spec:
ports:
- name: "9001"
port: 9001
targetPort: 9001
protocol: TCP
- name: "1883"
port: 1883
targetPort: 1883
protocol: TCP
- name: "8883"
port: 8883
targetPort: 8883
protocol: TCP
selector:
app: mosquitto
答案 0 :(得分:1)
问题在于端口1883上的侦听器,可以确定,因为日志尚未到达9001侦听器。
此问题最有可能是因为mosquitto无法解析主机名mosquitto
的IP地址。传递主机名时,该名称必须解析为有效的IP地址。 this最近的答案中讨论了相同的问题。也可能是mosquitto
解析为未绑定到实际计算机上任何接口的地址(例如,如果正在使用地址转换)。
对于9001侦听器,除了传递0.0.0.0
之外,您不能仅包含绑定地址,并且默认值是在所有接口上侦听。