1安装
# 进入需要安装es的位置
cd /soft
# 下载es
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.15.1-linux-x86_64.tar.gz
# 解压es
tar -zxvf elasticsearch-8.15.1-linux-x86_64.tar.gz
# 新增管理es的用户,不设置密码
useradd es
# 操作权限交给es
chown -R es:es /soft/elasticsearch-8.15.1
2修改配置
config/elasticsearch.yml
cluster.name: elasticsearch
#数据存放路径
path.data: /soft/elasticsearch-8.15.1/data
#日志存放路径
path.logs: /soft/elasticsearch-8.15.1/logs
node.name: node-1
#本机IP地址(设置可以访问的ip地址)
network.host: 0.0.0.0
#es暴露对外的端口
http.port: 9200
config/jvm.options(可选,配置es使用的内存,根据实际情况配置)
-Xms256m
-Xmx256m
3启动
cd elasticsearch-8.15.1/bin
./elasticsearch
启动会报错,
bootstrap check failure [1] of [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]; for more information see [https://www.elastic.co/guide/en/elasticsearch/reference/8.15/_maximum_map_count_check.html]
ERROR: Elasticsearch did not exit normally - check the logs at /soft/elasticsearch-8.15.1/logs/elasticsearch.log
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144];
用root编辑/etc/sysctl.conf,修改内容,没有就新增
vm.max_map_count=262144
执行如下命令刷新生效
sysctl -p
经过一系列调整后,成功启动,成功的日志如下:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✅ Elasticsearch security features have been automatically configured!
✅ Authentication is enabled and cluster connections are encrypted.
ℹ️ Password for the elastic user (reset with `bin/elasticsearch-reset-password -u elastic`):
9Ob4QT88888888p77l5I
ℹ️ HTTP CA certificate SHA-256 fingerprint:
e05e2ba78888888888888b1d66f4387fdbc5a84876240bba
ℹ️ 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):
eyJ2ZXIiOiI4LjE0LjAiLCJhZHIiOlsiMTAuMi4yMC4yOjkyMDAiXSwiZmdyIjoiZTA1ZTJiYTcyMzYxMmJjYjhkYjkzMzM3Zjg1Mz88888888888888888888884NDg3NjI0MGJiYSIsImtleSI6ImpfQVBHcElCTE5qVHlNQ0Z4dEFWOjBEN3ZacjZHU1JDQWlic2JsT3NydXcifQ==
ℹ️ 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):
eyJ2ZXIiOiI4LjE0LjAiLCJhZHIiOlsiMTAuMi4yMC4yOjkyMDAiXSwiZmdyIjoiZTA1ZTJiYTcyMzYxMmJjYjhkYjkzMzM3Zjg1Mz88888888888888888888888WE4NDg3NjI0MGJiYSIsImtleSI6ImpmQVBHcElCTE5qVHlNQ0Z4ZER1OktmaU4wb1dTUUlHSkMzb0NJYW9fSHcifQ==
If you're running in Docker, copy the enrollment token and run:
`docker run -e "ENROLLMENT_TOKEN=<token>" docker.elastic.co/elasticsearch/elasticsearch:8.15.1`
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
然后就可以重新用后台启动了
./elasticsearch -d
设置密码 ./elasticsearch-reset-password -u elastic
4安装界面管理工具kibana
cd /soft
wget https://artifacts.elastic.co/downloads/kibana/kibana-8.15.1-linux-x86_64.tar.gz
tar -xvf kibana-8.15.1-linux-x86_64.tar.gz
chown -R es:es kibana-8.15.1
调整内存占用,kibana-8.15.1/config/node.options
--max-old-space-size=256
配置es和kibana启动端口
server:
port: 9100
host: "0.0.0.0"
elasticsearch:
hosts: ["http://localhost:9200"]
启动
nohup ./kibana &
打开页面,需要输入es的token
curl -X POST "http://localhost:9200/_security/oauth2/token" -H "Content-Type: application/json" -d '{
"grant_type": "password",
"username": "elastic",
"password": "Uftc1pFx=joKRoBFJbfN"
}'
curl -u elastic:Uftc1pFx=joKRoBFJbfN -X POST "http://localhost:9200/_security/oauth2/token"
curl -u elastic:Uftc1pFx=joKRoBFJbfN -X GET "http://localhost:9200/_license"