安装elasticsearch
# 下载并安装GPG key
rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
# 在/etc/yum.repos.d文件夹下新增elasticsearch.repo文件
cd /etc/yum.repos.d mkdir elasticsearch.repo vi elasticsearch.repo # 将下面内容填入 elasticsearch.repo [elasticsearch-7.x] name=Elasticsearch repository for 7.x packages baseurl=https://artifacts.elastic.co/packages/7.x/yum gpgcheck=1 gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch enabled=1 autorefresh=1 type=rpm-md
# 安装elasticsearch
yum install elasticsearch
# 修改配置文件
# 查看安装目录 whereis elasticsearch # 编辑配置文件 vi /etc/elasticsearch/elasticsearch.yml # 名称 cluster.name: my-application # 地址 network.host: 0.0.0.0 # 端口 http.port: 9200
# 内存修改jvm.options
vi /etc/elasticsearch/jvm.options # 调整大小 -Xms256m -Xmx256m
# 启动
# 启动 systemctl start elasticsearch # 查看启动状态 systemctl status elasticsearch # 如果启动报错,在日志中可看到详细信息 vi /var/log/elasticsearch/elasticsearch.log
一般报错情况:
1、max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]
翻译:最大虚拟内存面积vm.max_map_count[65530]可能太低,至少增加到[262144]
解决办法:
vi /etc/sysctl.conf # 添加下面配置 vm.max_map_count= 262144 sysctl -p
翻译:群集中大多数符合主节点条件的节点
discovery.zen.ping.unicast.hosts: ["192.168.190.146"] discovery.zen.minimum_master_nodes: 1
# 访问
# 访问 curl -X GET localhost:9200