在腾讯云订了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"
}