1.在安装之前先安装好jdk以及环境变量配置
2.下载es安装包并解压
访问 Elasticsearch 官网 https://www.elastic.co/cn/downloads/elasticsearch 下载安装包:
tar -zxvf elasticsearch-7.1.0-darwin-x86_64.tar.gz
3.运行es,切换到bin目录下执行(注意不要用root)
./elasticsearch
运行成功如下
4.有可能遇到的问题
(1)在启动时提示无权限访问es配置文件等信息,需要为当前用户授权
chown glr /usr/local/es/elasticsearch-7.12.0 -R
(2) ERROR: bootstrap checks failed[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
解决方案:
# 切换到root用户修改
vim /etc/security/limits.conf
# 在最后面追加下面内容
* soft nofile 65536
* hard nofile 65536
* soft nproc 4096
* hard nproc 4096
# 退出重新登录检测配置是否生效:
ulimit -Hn
ulimit -Sn
ulimit -Hu
ulimit -Su
(3)ERROR: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决方案:
vim /etc/sysctl.conf
vm.max_map_count=655360
#执行以下命令生效:
sysctl -p
(4)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
解决方案:
修改elasticsearch.yml
取消注释保留一个节点
cluster.initial_master_nodes: ["node-1"]
打开node.name