0%

elasticsearch安装

elasticsearch安装

导入秘钥

1
rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch

下载rpm包

1
wget  https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.1.1-x86_64.rpm

安装

1
rpm -ivh elasticsearch-7.1.1-x86_64.rpm

这里会自动在/usr/lib/systemd/system中生成一个开机自动启动的elasticsearch.service

1
2
3
4
5
6
7
8
# 启动
systemctl start elasticsearch.service

# 开机自启
systemctl enable elasticsearch.service

# 查看状态
systemctl status elasticsearch.service

错误

启动报错: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

解决方法:

在/etc/sysctl.conf文件最后添加一行 vm.max_map_count=655360 添加完毕之后,执行命令:

1
sysctl -p

配置调整

1
2
3
# 默认只能本地访问,改成0.0.0.0可远程访问
network.host: 0.0.0.0
discovery.seed_hosts: ["0.0.0.0"]

验证

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
curl --location --request GET '192.168.1.220:9200?pretty'

{
"name": "oeTRcb8",
"cluster_name": "elasticsearch",
"cluster_uuid": "HWMo_L0QQBC2I6SKt3FWNQ",
"version": {
"number": "6.8.23",
"build_flavor": "default",
"build_type": "rpm",
"build_hash": "4f67856",
"build_date": "2022-01-06T21:30:50.087716Z",
"build_snapshot": false,
"lucene_version": "7.7.3",
"minimum_wire_compatibility_version": "5.6.0",
"minimum_index_compatibility_version": "5.0.0"
},
"tagline": "You Know, for Search"
}