linux安装es

 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"

### 如何在 Linux 系统中安装 Elasticsearch #### 下载并解压 Elasticsearch 可以通过下载 Elasticsearch 的压缩包来完成安装。访问官方文档中的说明,可以从存档文件手动安装 Elasticsearch[^1]。 ```bash wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.17.0-linux-x86_64.tar.gz tar -xzf elasticsearch-7.17.0-linux-x86_64.tar.gz cd elasticsearch-7.17.0/ ``` #### 验证软件包的安全性 为了确保安装过程更加安全,在安装之前导入 GPG 密钥以验证 Elasticsearch 软件包的来源和完整性[^2]: ```bash rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch ``` 此命令会将 Elastic 提供的公钥导入到系统中,从而允许 RPM 或其他工具验证签名。 #### 使用 Docker 容器运行 Elasticsearch 如果希望利用容器化技术简化部署流程,可以借助 Docker 来启动 Elasticsearch 实例。通过挂载配置文件的方式实现自定义设置[^3]: ```dockerfile docker run -d \ --name elasticsearch \ -p 9200:9200 \ -p 9300:9300 \ -e "discovery.type=single-node" \ -v /usr/local/docker/es/data:/usr/share/elasticsearch/data \ -v /usr/local/docker/es/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \ elasticsearch:7.17.0 ``` 上述脚本展示了如何创建一个单节点模式下的 Elasticsearch 容器实例,并绑定必要的端口和服务路径。 #### 停止与重启服务 当需要停止正在运行的服务时,可通过查询进程 ID 并发送终止信号的方法操作。例如,先找到对应的进程编号再执行强制关闭指令[^4]: ```bash ps -ef | grep elasticsearch kill -9 <PID> ``` 这里 `<PID>` 是指代实际获取到的那个数值型进程标识符。 --- ####
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值