当前位置: 首页 > 知识库问答 >
问题:

在K8s错误上运行ElasticSearch和Kibana-Kibana未正确加载。有关更多信息,请查看服务器输出

向弘懿
2023-03-14

我试图在Kubernetes集群(同名空间)上运行Elasticsearch和Kibana。我为Elasticsearch和Kibana创建了Pod和服务。当我进入elasticsearch网站时(http://localhost:8001/api/v1/namespaces/default/pods/elasticsearch/proxy/),一切似乎都很好,但当我进入Kibana的网站时,我看到“Kibana没有正确加载。有关更多信息,请检查服务器输出。”。

Kibana吊舱的日志如下:

{"type":"error","@timestamp":"2019-03-04T19:27:21Z","tags":["warning","stats-collection"],"pid":1,"level":"error","error":{"message":"Request Timeout after 30000ms","name":"Error","stack":"Error: Request Timeout after 30000ms\n    at /usr/share/kibana/node_modules/elasticsearch/src/lib/transport.js:355:15\n    at Timeout.<anonymous> (/usr/share/kibana/node_modules/elasticsearch/src/lib/transport.js:384:7)\n    at ontimeout (timers.js:436:11)\n    at tryOnTimeout (timers.js:300:5)\n    at listOnTimeout (timers.js:263:5)\n    at Timer.processTimers (timers.js:223:10)"},"message":"Request Timeout after 30000ms"}

这些是yaml文件:

deployment_elasticsearch.yaml:

apiVersion: v1
kind: Pod
metadata:
  name: elasticsearch
  labels:
    service: elasticsearch
spec:
  ports:
  containers:
  - name: elasticsearch
    image: elasticsearch:6.6.1
    ports:
    - containerPort: 9200
    - containerPort: 9300
    env:
    - name: discovery.type
      value: "single-node"

部署弹性搜索服务。亚马尔:

apiVersion: v1
kind: Service
metadata:
  name: elasticsearch
  labels:
    service: elasticsearch
spec:
  ports:
  - port: 9200
    name: serving
  - port: 9300
    name: node-to-node
  selector:
    service: elasticsearch

deployment_kibana.yaml:

apiVersion: v1
kind: Pod
metadata:
  name: kibana
  labels:
    service: kibana
spec:
  ports:
  containers:
  - name: kibana
    image: kibana:6.6.1
    ports:
    - containerPort: 5601

部署kibana_服务。亚马尔:

apiVersion: v1
kind: Service
metadata:
  name: kibana
  labels:
    service: kibana
spec:
  ports:
  - port: 5601
    name: serving
  selector:
    service: kibana

还有,当我进入kibana pod,运行“$curl”http://elasticsearch:9200“,我得到了elasticsearch主页(因此我认为kibana可以访问elasticsearch)。

编辑这是kibana的grep错误日志:

{"type":"log","@timestamp":"2019-03-04T22:41:16Z","tags":["status","plugin:index_management@6.6.1","error"],"pid":1,"state":"red","message":"Status changed from green to red - Request Timeout after 30000ms","prevState":"green","prevMsg":"Ready"}
{"type":"log","@timestamp":"2019-03-04T22:41:16Z","tags":["status","plugin:index_lifecycle_management@6.6.1","error"],"pid":1,"state":"red","message":"Status changed from green to red - Request Timeout after 30000ms","prevState":"green","prevMsg":"Ready"}
{"type":"log","@timestamp":"2019-03-04T22:41:16Z","tags":["status","plugin:rollup@6.6.1","error"],"pid":1,"state":"red","message":"Status changed from green to red - Request Timeout after 30000ms","prevState":"green","prevMsg":"Ready"}
{"type":"log","@timestamp":"2019-03-04T22:41:16Z","tags":["status","plugin:remote_clusters@6.6.1","error"],"pid":1,"state":"red","message":"Status changed from green to red - Request Timeout after 30000ms","prevState":"green","prevMsg":"Ready"}
{"type":"log","@timestamp":"2019-03-04T22:41:16Z","tags":["status","plugin:cross_cluster_replication@6.6.1","error"],"pid":1,"state":"red","message":"Status changed from green to red - Request Timeout after 30000ms","prevState":"green","prevMsg":"Ready"}
{"type":"log","@timestamp":"2019-03-04T22:41:16Z","tags":["status","plugin:reporting@6.6.1","error"],"pid":1,"state":"red","message":"Status changed from green to red - Request Timeout after 30000ms","prevState":"green","prevMsg":"Ready"}
{"type":"log","@timestamp":"2019-03-04T22:41:34Z","tags":["spaces","error"],"pid":1,"message":"Unable to navigate to space \"default\", redirecting to Space Selector. Error: Request Timeout after 30000ms"}
{"type":"log","@timestamp":"2019-03-04T22:41:41Z","tags":["spaces","error"],"pid":1,"message":"Unable to navigate to space \"default\", redirecting to Space Selector. Error: Request Timeout after 30000ms"}

通过在线调查,我认为问题在于els和kibana不能相互交谈。你知道为什么吗?

编辑2,描述日志:

kubectl describe pod kibana
Name:               kibana
Namespace:          default
Priority:           0
PriorityClassName:  <none>
Node:               minikube/10.0.2.15
Start Time:         Tue, 05 Mar 2019 00:21:23 +0200
Labels:             service=kibana
Annotations:        <none>
Status:             Running
IP:                 172.17.0.5
Containers:
  kibana:
    Container ID:   docker://7eecb30b2f197120706d790e884db44696d5d1a30d3ec48a9ca2a6255eca7e8a
    Image:          kibana:6.6.1
    Image ID:       docker-pullable://kibana@sha256:a2b329d8903978069632da8aa85cc5199c5ab2cf289c48b7851bafd6ee58bbea
    Port:           5601/TCP
    Host Port:      0/TCP
    State:          Running
      Started:      Tue, 05 Mar 2019 00:21:24 +0200
    Ready:          True
    Restart Count:  0
    Environment:
      ELASTICSEARCH_URL:  http://elasticsearch:9200
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-q25px (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             True 
  ContainersReady   True 
  PodScheduled      True 
Volumes:
  default-token-q25px:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-q25px
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:
  Type    Reason     Age   From               Message
  ----    ------     ----  ----               -------
  Normal  Scheduled  51m   default-scheduler  Successfully assigned default/kibana to minikube
  Normal  Pulled     51m   kubelet, minikube  Container image "kibana:6.6.1" already present on machine
  Normal  Created    51m   kubelet, minikube  Created container
  Normal  Started    51m   kubelet, minikube  Started container

共有1个答案

冯嘉荣
2023-03-14

我在集群中复制了你的设置。kibana和elasticsearch之间的连接很好。

NAME                                READY   STATUS    RESTARTS   AGE   IP            NODE        NOMINATED NODE   READINESS GATES
elasticsearch                       1/1     Running   0          37m   10.244.1.8    worker-12   <none>           <none>
kibana                              1/1     Running   0          25m   10.244.3.10   worker-14   <none>           <none>

ping从kibana到elasticsearch

bash-4.2$ ping 10.244.1.8
PING 10.244.1.8 (10.244.1.8) 56(84) bytes of data.
64 bytes from 10.244.1.8: icmp_seq=1 ttl=62 time=0.705 ms
64 bytes from 10.244.1.8: icmp_seq=2 ttl=62 time=0.501 ms

从elasticsearch Ping到kibana

[root@elasticsearch elasticsearch]# ping 10.244.3.10
PING 10.244.3.10 (10.244.3.10) 56(84) bytes of data.
64 bytes from 10.244.3.10: icmp_seq=1 ttl=62 time=0.444 ms
64 bytes from 10.244.3.10: icmp_seq=2 ttl=62 time=0.462 ms

您面临的问题是因为使用了主机名。基巴纳。yml在弹性URL中使用“弹性搜索”——http://elasticsearch:9200 --. kibana容器无法解析名称“elasticsearch”。

因此,您必须在 /etc/hosts文件中添加一个条目,提及“elasticsearch”的IP地址。例如,在我的情况下,在 /etc/hosts

# Kubernetes-managed hosts file.
127.0.0.1       localhost
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
fe00::0 ip6-mcastprefix
fe00::1 ip6-allnodes
fe00::2 ip6-allrouters
10.244.3.10     kibana
10.244.1.8 elasticsearch

这应该能解决你的问题。

但是,这并不容易,您将无法更改该文件,您必须重建映像或使用--add-host选项运行容器。在这里查找--add-host

一个更简单的解决方法是改变kibana。嗯,看起来像这样,

# Default Kibana configuration from kibana-docker.

server.name: kibana
server.host: "0"
elasticsearch.url: http://10.244.1.8:9200 #enter your elasticsearch container IP
xpack.monitoring.ui.container.elasticsearch.enabled: true

配置elasticsearch容器的正确IP地址,并重新启动kibana容器。反之亦然,适用于elasticsearch容器。

你挑吧。

进一步编辑。

要从k8s yml更改主机文件,

提前启动弹性服务/集群,

[root@controller-11 test-dir]# kubectl get services elasticsearch -o wide
NAME            TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)             AGE    SELECTOR
elasticsearch   ClusterIP   10.103.254.157   <none>        9200/TCP,9300/TCP   153m   service=elasticsearch

然后继续使用elasticsearch服务的IP地址编辑kibana.yml文件。它看起来像这样,

apiVersion: v1
kind: Pod
metadata:
  name: kibana
  labels:
    service: kibana
spec:
  hostAliases:
  - ip: "10.103.254.157"
    hostnames:
    - "elasticsearch"
  ports:
  containers:
  - name: kibana
    image: kibana:6.6.1
    ports:
    - containerPort: 5601

登录到kibana容器并签出/etc/hosts文件,如下所示,

bash-4.2$ cat /etc/hosts
# Kubernetes-managed hosts file.
127.0.0.1       localhost
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
fe00::0 ip6-mcastprefix
fe00::1 ip6-allnodes
fe00::2 ip6-allrouters
10.244.2.2      kibana

# Entries added by HostAliases.
10.103.254.157      elasticsearch

然后试着联系弹性服务器,它看起来像这样,

bash-4.2$ curl http://elasticsearch:9200
{
  "name" : "tyqNRro",
  "cluster_name" : "docker-cluster",
  "cluster_uuid" : "tFmM2Nq9RDmGlDy6G2FUZw",
  "version" : {
    "number" : "6.6.1",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "1fd8f69",
    "build_date" : "2019-02-13T17:10:04.160291Z",
    "build_snapshot" : false,
    "lucene_version" : "7.6.0",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

我想应该是这样。

进一步编辑。

经过进一步调查,看起来您使用的配置应该可以在没有我建议的任何更改的情况下工作。看起来您的k8s弹性搜索服务配置不正确。如果服务配置正确,那么我们应该找到配置到您的弹性搜索容器的endpoint。它应该看起来像这样,

root@server1d:~# kubectl describe service elasticsearch
Name:              elasticsearch
Namespace:         default
Labels:            service=elasticsearch
Annotations:       kubectl.kubernetes.io/last-applied-configuration:
                     {"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"labels":{"service":"elasticsearch"},"name":"elasticsearch","namespace"...
Selector:          service=elasticsearch
Type:              ClusterIP
IP:                10.102.227.86
Port:              serving  9200/TCP
TargetPort:        9200/TCP
Endpoints:         10.244.1.9:9200
Port:              node-to-node  9300/TCP
TargetPort:        9300/TCP
Endpoints:         10.244.1.9:9300
Session Affinity:  None
Events:            <none>
 类似资料:
  • 我想通过http://IP:80.然而,当我访问页面时,我会发现以下错误: 需要升级您的Elasticsearch版本太旧。Kibana需要Elasticsearch 0.90.9或以上。 和 错误无法到达http://localhost:80/_nodes.如果您正在使用代理,请确保它配置正确 我一直在网上查找这些问题,我已经把这些行包括在内,但没有成功。。。 我的Elasticsearch版本

  • "无法加载脚本。请确保您运行的是metrserver(运行'react-native-start'),或者您的包'index.android.bundle'已正确打包以供发布。" 我正在将我的代码从Expo CLI迁移到React Native CLI。我只是在移动我的资产、组件和js文件,我也在向RN CLI添加所有包。 我已经被困在这个上面大约10个小时了,搜索了弹出的每一个错误。我现在终于经

  • 开始使用 Kibana 前,需要告诉 Kibana 您想要探索的 Elasticsearch 索引。第一次访问 Kibana 时,会提示您定义一个 index pattern(索引模式) 匹配一个或多个索引。这就是初次使用 Kibana 时所有需要配置的。任何时候都可以在 Management 页面增加索引模式。 提示:默认情况下,Kibana 会连接运行在 localhost 上的 Elasti

  • 我的elasticsearch服务器运行时有索引,比如说服务器XX。XXX。XXX。XXX:9200。 我在服务器ES集群XX中有索引。XXX。XXX。XXX:9200,我正试图在本地主机5601(Kibana)中为其创建仪表盘 在我的kibana.yml我有这样的配置: 在弹性搜索中。yml我有这个配置: 但我在运行kibana时遇到了这个错误。yml: 连接ECONNREFUSED超文本传输协

  • 当我尝试npx npx react-native run-android时,我坚持了这个错误

  • 我在一个实例中安装了elasticsearch,在另一个实例中安装了kibana。这两个服务都在运行,我可以使用curl将elasticsearch及其实例公共ip连接到端口9200版本:7.9.2都假设:公共ip elasticsearch-x.x.x kibana-y.y.y 问题:无法将kibana实例与其curl和公共ip连接到端口5601错误:无法连接到y.y.y.y端口5601:连接被