安装ElasticSearch
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用户
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
-Xms512m
-Xmx512m
修改max file和max virtual memory参数,使用root或sudo用户:vim /etc/sysctl.conf,添加下面配置:
vm.max_map_count=655360
并执行命令:sysctl -p
配置文件
配置端口及跨域
vim /usr/local/elasticsearch-7.2.0/config/elasticsearch.yml
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主目录下运行下列命令来安装插件
su - es
bin/elasticsearch-plugin install xxx
启动ES
es用户启动
/usr/local/elasticsearch-7.2.0/bin/elasticsearch -d
root用户启动
su - es -c '/usr/local/elasticsearch-7.2.0/bin/elasticsearch -d'