Elasticsearch8安装配置(前提:jdk 17+)

99 阅读3分钟

官网
www.elastic.co/cn/
www.elastic.co/cn/elastic-…

准备

下载

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.0.0-linux-x86_64.tar.gz
wget https://artifacts.elastic.co/downloads/kibana/kibana-8.0.0-linux-x86_64.tar.gz

创建用户与文件夹

groupadd es
useradd es -g es
passwd es
> ...

mkdir /opt/data/{eslogs,esdata}
chown es:es -R /opt/data/eslogs
chown es:es -R /opt/data/esdata

vim /etc/hosts
---
本地ip   myali #将myali 指向当前主机ip

解压与授权

tar zxvf elasticsearch-8.0.0-linux-x86_64.tar.gz
tar zxvf elasticsearch-8.0.0-linux-x86_64.tar.gz

chown es:es -R elasticsearch-8.0.0 -R
chown es:es -R kibana-8.0.0
chmod 755 -R kibana-8.0.0
chmod 755 -R elasticsearch-8.0.0

ElasticSearch 安装配置与启动

elasticsearch配置

cluster.name: es-application
node.name: node-1
path.data: /opt/data/esdata
path.logs: /opt/data/eslogs
bootstrap.memory_lock: false

network.host: 192.168.1.22
http.port: 9200
transport.port: 9300
#transport.tcp.compress: true
http.cors.enabled: true
http.cors.allow-origin: "*"
http.host: [_local_, _site_]

# 将节点名称解开注释并重命名(单台部署可以使用默认名称,集群部署注意集群中的名称不能重复), 和network.host一致
discovery.seed_hosts: ["192.168.1.22"]
#将集群主节点列表解开注释,使用当前节点为主节点,  和node.name一致
#cluster.initial_master_nodes: ["node-1"]

启动

cd bin && su es
chown es:es -R /opt/data/esdata
./elasticsearch

--校验 (进程与端口有存在,则说明配置成功)
ps -ef|grep elasticsearch
netstat -an|grep 9200

控制台输出分析

[2022-02-22T19:40:42,600][INFO ][o.e.h.AbstractHttpServerTransport] [node-1] publish_address {192.168.1.22:9200}, bound_addresses {[::1]:9200}, {127.0.0.1:9200}, {192.168.1.22:9200} 
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✅ Elasticsearch security features have been automatically configured!
✅ Authentication is enabled and cluster connections are encrypted.

#默认登录用户与密码 bin/elasticsearch-reset-password -u elastic 可修改
ℹ️  Password for the elastic user (reset with `bin/elasticsearch-reset-password -u elastic`):  03RFsycEjMDQytoK7AlD

ℹ️  HTTP CA certificate SHA-256 fingerprint:
  d0158c847ec807c16d7f20ce38a97a333588aa1d7e7972ecab982a62c3a30312

# Kibana 本置es的认证信息,通过bin/elasticsearch-create-enrollment-token -s kibana可修改
ℹ️  Configure Kibana to use this cluster:
• Run Kibana and click the configuration link in the terminal when Kibana starts.
• Copy the following enrollment token and paste it into Kibana in your browser (valid for the next 30 minutes): eyJ2ZXIiOiI4LjAuMCIsImFkciI6WyIxOTIuMTY4LjEuMjI6OTIwMCJdLCJmZ3IiOiJkMDE1OGM4NDdlYzgwN2MxNmQ3ZjIwY2UzOGE5N2EzMzM1ODhhYTFkN2U3OTcyZWNhYjk4MmE2MmMzYTMwMzEyIiwia2V5IjoiakF4UElYOEItclo3N1BpYU9qdEU6ZHNyOTlmNW5UczJuSC1zZnJaTGtkdyJ9

#  节点加入集群的配置token, 通过bin/elasticsearch-create-enrollment-token -s node
可获取
ℹ️ Configure other nodes to join this cluster:
• Copy the following enrollment token and start new Elasticsearch nodes with `bin/elasticsearch --enrollment-token <token>` (valid for the next 30 minutes):
  eyJ2ZXIiOiI4LjAuMCIsImFkciI6WyIxOTIuMTY4LjEuMjI6OTIwMCJdLCJmZ3IiOiJkMDE1OGM4NDdlYzgwN2MxNmQ3ZjIwY2UzOGE5N2EzMzM1ODhhYTFkN2U3OTcyZWNhYjk4MmE2MmMzYTMwMzEyIiwia2V5Ijoiamd4UElYOEItclo3N1BpYV9UdVU6b3BPV3BWZFlST1dUSWVVYzdyd3ZaUSJ9

  If you're running in Docker, copy the enrollment token and run:
  `docker run -e "ENROLLMENT_TOKEN=<token>" docker.elastic.co/elasticsearch/elasticsearch:8.0.0`
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Kibana

配置

cd config
vim kibana.yml
--------------
server.port: 18791 #默认5601
server.host: 0.0.0.0

启动

cd bin && su es
./kibana

--查看进程
netstat -ano|grep 5601

浏览器访问并配置

访问http://localhost:5601 查看es控制台
---
提示输入token
1. 将刚刚控制台输出的“Configure Kibana to use this cluster”'s token复制到对话框中
2. 等待初始化
3. 提示用户与密码
   输入启动es时提示的默认用户和密码
elastic/03RFsycEjMDQytoK7AlD