ElasticSearch为何部署不成功?

我已经安装了ElasticSearch.

wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg
sudo apt-get install apt-transport-https
echo "deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/8.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-8.x.list
sudo apt-get update && sudo apt-get install elasticsearch

也开启了防火墙

sudo firewall-cmd --add-port=9200/tcp --permanent
sudo firewall-cmd --reload
sudo  firewall-cmd --list-all
public
  target: default
  icmp-block-inversion: no
  interfaces: 
  sources: 
  services: dhcpv6-client ssh
  ports: 9200/tcp
  protocols: 
  forward: yes
  masquerade: no
  forward-ports: 
  source-ports: 
  icmp-blocks: 
  rich rules:

启动

sudo systemctl start  elasticsearch.service
sudo systemctl status  elasticsearch.service
● elasticsearch.service - Elasticsearch
     Loaded: loaded (/lib/systemd/system/elasticsearch.service; disabled; preset: enabled)
     Active: active (running) since Thu 2025-01-02 16:31:43 HKT; 12min ago
       Docs: https://www.elastic.co
   Main PID: 16692 (java)
      Tasks: 88 (limit: 9323)
     Memory: 4.3G
        CPU: 1min 24.794s
     CGroup: /system.slice/elasticsearch.service
             ├─16692 /usr/share/elasticsearch/jdk/bin/java -Xms4m -Xmx64m -XX:+UseSerialGC -Dcli.name=server -Dcli.script=/usr/share/elasticsearch/bin/elasticsearch -Dcli.l>
             ├─16751 /usr/share/elasticsearch/jdk/bin/java -Des.networkaddress.cache.ttl=60 -Des.networkaddress.cache.negative.ttl=10 -XX:+AlwaysPreTouch -Xss1m -Djava.awt.>
             └─16771 /usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/bin/controller

我的本机ip

ifconfig 
inet 192.168.1.3
有很多省略

于是,我写这样的配置
sudo vim /etc/elasticsearch/elasticsearch.yml

cluster.name: my-application
node.name: node-1
node.attr.rack: r1
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
network.host: 192.168.1.3
http.port: 9200
discovery.seed_hosts: ["host1", "host2"]


xpack.security.enabled: true

xpack.security.enrollment.enabled: true

xpack.security.http.ssl:
  enabled: true
  keystore.path: certs/http.p12

xpack.security.transport.ssl:
  enabled: true
  verification_mode: certificate
  keystore.path: certs/transport.p12
  truststore.path: certs/transport.p12
cluster.initial_master_nodes: ["MiWiFi-R4A-srv"]

http.host: 0.0.0.0
transport.host: 0.0.0.0

也设置了账号,密码

adduser elasticsearch
passwd elasticsearch

用浏览器打开
image.png

image.png

为何部署不成功?
image.png
我输入了正确的账号,密码,cluster.initial_master_nodes: ["node-1"],为何还是无法登录呢?

阅读 216
1 个回答

建议是贴一下启动日志会比较好。


根据已经有的信息,我猜你应该是要在浏览器中打开 https://192.168.1.3:9200 ,而不是 http://192.168.1.3:9200 (配置文件里面是开启 SSL ,所以这里应该是要用 https 协议访问)

另外 cluster.initial_master_nodes: ["MiWiFi-R4A-srv"] 这一行配置也存疑,这里应该是要设置成 ["node-1"] ,否则可能会导致启动时出现问题,因为设置错了会没法找到初始化的主节点。我猜测主要是因为这个原因导致了没有启动完成,所以这里能看到浏览器提示 ERR_ENPTY_RESPONSE。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
宣传栏