1.下载,解压缩,命令行前不要留空格
官网下载地址: https://www.elastic.co/cn/downloads/elasticsearch
https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.2.2-linux-x86_64.tar.gz
tar -zxvf elasticsearch-8.2.0-linux-x86_64.tar.gz cd 到 cd /usr/local/elasticsearch-8.2.2/bin/去启动 ./elasticsearch [root@VM-4-3-centos bin]# ./elasticsearch
2.创建es用户 [root@VM-4-3-centos ~]# useradd es [root@VM-4-3-centos ~]# passwd es
[root@VM-4-3-centos ~]# id es uid=1001(es) gid=1001(es) groups=1001(es)
java.lang.RuntimeException: can not run elasticsearch as root
#使用root账号来创建用户 sudo adduser es #设置密码 sudo passwd 123456 对es用户授权,目录elasticsearch-8.2.0 (重要) 切换es命令来启动 sudo chown -R es:es elasticsearch-8.2.0
3.切换es账号,启动服务 su es ./bin/elasticsearch
后台运行,否则客户端退出了,服务就停止了。 ./bin/elasticsearch -d 出现started时启动完成
关闭ES服务 kill pid
说明: Elasticsearch端口9300、9200,其中: 9300是tcp通讯端口,集群ES节点之间通讯使用,9200是http协议的RESTful接口
4.启动报错,调整配置文件属性
解决内存不足问题,启动的时候卡住的原因了,warning: ignoring JAVA_HOME=/usr/local/jdk1.8.0_131; using bundled JDK 由于 elasticsearch 默认分配 jvm空间大小为2g,修改 jvm空间,如果Linux服务器本来配置就很高,可以不用修改。
修改jdk启动内存 vim /usr/local/elasticsearch-8.2.0/config/jvm.options
代码语言:javascript复制-Xms256m
-Xmx256m
报错:Native controller process has stopped - no new native processes can be started 继续配置文件:sudo vim /etc/security/limits.conf
代码语言:javascript复制* soft nofile 262144
* hard nofile 131072
* soft nproc 4096
* hard nproc 4096
报错信息 bootstrap check failure [1] of [3]: max number of threads [2048] for user [es] is too low, increase to at least [4096] bootstrap check failure [2] of [3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144] bootstrap check failure [3] of [3]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
soft nproc :单个用户可用的最大进程数量(超过会警告); hard nproc:单个用户可用的最大进程数量(超过会报错); soft nofile :可打开的文件描述符的最大数(超过会警告); hard nofile :可打开的文件描述符的最大数(超过会报错);
bootstrap check failure [1] of [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
在es bin目录 这样执行 修改 vim ../config/elasticsearch.yml
修改配置文件
代码语言:javascript复制cluster.name: es.study
node.name: node-1
network.host: 0.0.0.0
http.port: 9200
bootstrap.memory_lock: false
#system_call_filter启动报错,去掉
#bootstrap.system_call_filter: false
# 为Elasticsearch设置登录密码
xpack.security.enabled: false
cluster.initial_master_nodes: ["node-1"]
# error downloading geoip database [GeoLite2-Country.mmdb]
#关闭geoip数据库的更新
ingest.geoip.downloader.enabled: false
5.其他