进入usr/local目录,新建elastic文件夹,下载压缩包
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.0.1-linux-x86_64.tar.gz
解压
tar -zxvf elasticsearch-8.0.1-linux-x86_64.tar.gz
进入config目录,编辑elasticsearch.yml文件 vi elasticsearch.yml,放开network.host和http.port 将network.host改为自己服务器的IP地址,云服务器network.host设置为0.0.0.0,放开 discovery.seed_hosts并改为自己服务器的IP
es不支持root用户启动,增加 elastic用户
增加分组
groupadd elastic
增加用户并指定分组和密码
useradd elastic -g elastic -p elastic
授权新用户
chown -R elastic:elastic /usr/local/elastic
切换用户
su elastic
进入bin目录启动es
./elasticsearch
启动报错
ERROR: [3] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
[2]: max number of threads [3829] for user [elastic] is too low, increase to at least [4096]
[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
ERROR: Elasticsearch did not exit normally - check the logs at /usr/local/elastic/elasticsearch-7.11.2/logs/elasticsearch.log
切换到root用户,vi /etc/sysctl.conf,新增
vm.max_map_count=262144
vi /etc/security/limits.conf
* sosft nofile 262144
* hard nofile 524288
* soft nproc 6000
* hard nproc 4096
重启服务器,再次启动