CentOS下ElasticSearch快速安装

安装ElasticSearch

1
2
3
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.2.0.tar.gz
tar -zxf elasticsearch-7.2.0.tar.gz -C /usr/local/
mv /usr/local/elasticsearch-7.2.0 /usr/local/elasticsearch

创建es用户

1
2
3
4
groupadd es
useradd -g es -M -s /sbin/nologin es
chown -R es:es /usr/local/elasticsearch/
cd /usr/local/elasticsearch

配置环境

修改config/jvm.options为内存的一半大小:vim config/jvm.options

1
2
-Xms512m
-Xmx512m

修改max filemax virtual memory参数,使用root或sudo用户:vim /etc/sysctl.conf,添加下面配置:

1
vm.max_map_count=655360

并执行命令:sysctl -p

配置文件

配置端口及跨域

1
vim /usr/local/elasticsearch-7.2.0/config/elasticsearch.yml
1
2
3
4
5
6
7
8
9
cluster.name: elasticsearch
node.name: node-1
network.host: 0.0.0.0
http.port: 9200
node.max_local_storage_nodes: 2
http.cors.enabled: true
http.cors.allow-origin: "*"
node.master: true
node.data: true

安装插件

切换es用户,在Elasticsearch主目录下运行下列命令来安装插件

1
2
su - es
bin/elasticsearch-plugin install xxx

启动ES

es用户启动

1
/usr/local/elasticsearch-7.2.0/bin/elasticsearch -d

root用户启动

1
su - es -c '/usr/local/elasticsearch-7.2.0/bin/elasticsearch -d'

Powered by AppBlog.CN     浙ICP备14037229号

Copyright © 2012 - 2020 APP开发技术博客 All Rights Reserved.

访客数 : | 访问量 :