Kibana 无法连接到elasticsearch localhost

0tdrvxhp  于 5个月前  发布在  Kibana
关注(0)|答案(1)|浏览(64)

我正在使用Elasticsearch_kibana。当我尝试创建索引时,它引发了超时错误,尽管我将request_timeout增加到30。有人能帮助我吗?我在window10上使用elasticsearch-8.11.3和kibana-8.11.3。下面是我的代码:

import os
import sys
import pandas as pd 
from elasticsearch import Elasticsearch
def connect_database():
    es = None
    es = Elasticsearch([{'host': 'localhost', 'port': 9200, 'scheme': 'http'}])
    if es.ping():
        print("Elastic search connected")
        print(es.cluster.health())

    else:
        print("Connect failed")
    return es

es = connect_database()
es.indices.create(index="mydatabasename", ignore=400, request_timeout=30)

字符串
和输出:

Elastic search connected
{'cluster_name': 'elasticsearch', 'status': 'green', 'timed_out': False, 'number_of_nodes': 1, 'number_of_data_nodes': 1, 'active_primary_shards': 29, 'active_shards': 29, 'relocating_shards': 0, 'initializing_shards': 0, 'unassigned_shards': 0, 'delayed_unassigned_shards': 0, 'number_of_pending_tasks': 13, 'number_of_in_flight_fetch': 0, 'task_max_waiting_in_queue_millis': 3050137, 'active_shards_percent_as_number': 100.0}

---------------------------------------------------------------------------
TimeoutError                              Traceback (most recent call last)
File ~\AppData\Roaming\Python\Python310\site-packages\urllib3\connectionpool.py:449, in HTTPConnectionPool._make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
    445         except BaseException as e:
    446             # Remove the TypeError from the exception chain in
    447             # Python 3 (including for exceptions like SystemExit).
    448             # Otherwise it looks like a bug in the code.
--> 449             six.raise_from(e, None)
    450 except (SocketTimeout, BaseSSLError, SocketError) as e:

File <string>:3, in raise_from(value, from_value)

File ~\AppData\Roaming\Python\Python310\site-packages\urllib3\connectionpool.py:444, in HTTPConnectionPool._make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
    443 try:
--> 444     httplib_response = conn.getresponse()
    445 except BaseException as e:
    446     # Remove the TypeError from the exception chain in
    447     # Python 3 (including for exceptions like SystemExit).
    448     # Otherwise it looks like a bug in the code.

File c:\Program Files\Python310\lib\http\client.py:1374, in HTTPConnection.getresponse(self)
   1373 try:
-> 1374     response.begin()
   1375 except ConnectionError:
...
--> 261         raise ConnectionTimeout("TIMEOUT", str(e), e)
    262     raise ConnectionError("N/A", str(e), e)
    264 # raise warnings if any from the 'Warnings' header.

ConnectionTimeout: ConnectionTimeout caused by - ReadTimeoutError(HTTPConnectionPool(host='localhost', port=9200): Read timed out. (read timeout=30))


下面是我的elasticsearch.yml:

# Enable security features
xpack.security.enabled: false

xpack.security.enrollment.enabled: false

# Enable encryption for HTTP API client connections, such as Kibana, Logstash, and Agents
xpack.security.http.ssl:
  enabled: false
  keystore.path: certs/http.p12

# Enable encryption and mutual authentication between cluster nodes
xpack.security.transport.ssl:
  enabled: false
  verification_mode: certificate
  keystore.path: certs/transport.p12
  truststore.path: certs/transport.p12
# Create a new cluster with the current node only
# Additional nodes can still join the cluster later
cluster.initial_master_nodes: ["MSI"]

# Allow HTTP API connections from anywhere
# Connections are encrypted and require user authentication
http.host: 0.0.0.0


我只是运行了elasticseach和kibana的默认命令,仍然可以访问http://localhost:9200/http://localhost:5601/

x0fgdtte

x0fgdtte1#

我修复了回滚到ES版本7.17.16,它工作得很好。我认为这个版本可能需要更严格地创建一个新的索引。

相关问题