云主机debian安装elasticsearch8笔记

本文记录了一台腾讯云2c2g服务器上安装Elasticsearch的过程,包括安装Java8、添加Elasticsearch的GPG密钥和APT源,调整内存配置防止OOM,禁用xpack.security.enabled以进行本地测试,并通过curl检查服务状态。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在腾讯云订了2c2g的云服务器,最近想学习一下elasticsearch,以下是安装笔记

1、确保已经安装了java8+

 2、下载sign key

wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -

3、安装apt-transport-https

apt-get install apt-transport-https

4、保存apt源

echo “deb https://artifacts.elastic.co/packages/8.x/apt stable main” | sudo tee /etc/apt/sources.list.d/elastic-8.x.list

5、更新并安装elastiscsearch

apt-get update && apt-get install elasticsearch

6、修改配置

        elasticsearch默认8g内存,我的服务器配置非常低,所以要修改内存配置,修改es安装目录下的jvm.options,限制内存使用为500m,不要会被OOM killer干掉

################################################################
## IMPORTANT: JVM heap size
################################################################
##
## The heap size is automatically configured by Elasticsearch
## based on the available memory in your system and the roles
## each node is configured to fulfill. If specifying heap is
## required, it should be done through a file in jvm.options.d,
## which should be named with .options suffix, and the min and
## max should be set to the same value. For example, to set the
## heap to 4 GB, create a new file in the jvm.options.d
## directory containing these lines:
##
-Xms500m
-Xmx500m

7、启动

systemctl start elasticsearch

8、查看es运行状态

systemctl status elasticsearch

9、测试

curl -X GET "localhost:9200"

curl: (3) URL using bad/illegal format or missing URL

         发现响应的数据不对,应该是端口限制了或者防火墙的问题。

        修改配置:elasticsearch.yml,把xpack.security.enabled的值改为false:

         再次测试:

root@VM-12-8-debian:/etc/elasticsearch# curl -X GET "localhost:9200"
{
  "name" : "VM-12-8-debian",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "ExJ9j_u-S4upDCkkWLDvpQ",
  "version" : {
    "number" : "8.7.0",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "09520b59b6bc1057340b55750186466ea715e30e",
    "build_date" : "2023-03-27T16:31:09.816451435Z",
    "build_snapshot" : false,
    "lucene_version" : "9.5.0",
    "minimum_wire_compatibility_version" : "7.17.0",
    "minimum_index_compatibility_version" : "7.0.0"
  },
  "tagline" : "You Know, for Search"
}

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值