2.1下载elasticsearch
sudo wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.17.0-linux-x86_64.tar.gz
2.2.解压
sudo tar -xvf elasticsearch-7.17.0-linux-x86_64.tar.gz
2.3授权
sudo chmod -R 777 elasticsearch-7.17.0
2.4修改配置文件
vim elasticsearch-7.17.0/config/jvm.options
es启动使用内存大小,最好不要超过服务器总内存数的一半
-Xms6g
-Xmx6g
vim elasticsearch-7.17.0/config/elasticsearch.yml
cluster.name: my-application
network.host: 0.0.0.0
http.port: 9200
transport.tcp.port: 9300
network.publish_host: 192.168.10.xxx
<集群必须配置>
discovery.zen.ping.unicast.hosts: [“192.168.10.xxx:9300”,“192.168.10.xxx:9300”]
cluster.initial_master_nodes: [“node-1”, “node-2”]
http.cors.enabled: true
http.cors.allow-origin: “*”
http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type
thread_pool.search.size: 96
thread_pool.search.queue_size: 1200
2.5修改系统文件权限
sudo vim /etc/security/limits.conf
增加如下配置
-
soft nproc 65536
-
hard nproc 65536
-
soft nofile 65536
-
hard nofile 65536
sudo vim /etc/sysctl.conf
增加如下配置
vm.max_map_count=262144
生效
sudo sysctl -p
2.6关闭防火墙
sudo systemctl stop firewalld.service
2.7启动elasticsearch
./bin/elasticsearch -d
2.8验证集群状态
http://ip:9200/_cluster/health?pretty=true
curl -XGET “http://ip:9200/_cluster/health?pretty=true”