Linux Centos7下安装Elasticsearch

2021/9/17 7:07:09

本文主要是介绍Linux Centos7下安装Elasticsearch,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

  1. 如果没有安装Java环境, 需要先安装。

通过yum list java* 查看需要安装的java版本。
image
这里安装 java-1.8.0-openjdk。 yum -y install java-1.8.0-openjdk
image
查看java版本是否安装成功。java -version
image

  1. 下载并安装GPG公共签名秘钥

rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch

  1. 添加 Elasticsearch 的 yum 仓库。vim /etc/yum.repos.d/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

  1. yum安装Elasticsearch.

yum install elasticsearch

  1. 配置Elasticsearch, 配置外网访问, 端口。vim /etc/elasticsearch/elasticsearch.yml

image

如果这里不设置 cluster.initial_master_nodes 节点,会报错如下:

bootstrap check failure [1] of [1]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_host...be configured
Sep 16 15:52:03 VM_0_8_centos systemd-entrypoint[19004]: ERROR: Elasticsearch did not exit normally - check the logs at /var/log/elasticsearch/elasticsearch.log
image

  1. 配置完成后,启动Elasticsearch.

systemctl restart elasticsearch.service

  1. 查看Elasticsearch的状态。绿色代表已启动了。

systemctl status elasticsearch.service

image

  1. 测试ES能否请求。curl localhost:9200, 或者用 postman用外网ip请求试试。
{
    "name": "node-1",
    "cluster_name": "elasticsearch",
    "cluster_uuid": "_na_",
    "version": {
        "number": "7.14.1",
        "build_flavor": "default",
        "build_type": "rpm",
        "build_hash": "66b55ebfa59c92c15db3f69a335d500018b3331e",
        "build_date": "2021-08-26T09:01:05.390870785Z",
        "build_snapshot": false,
        "lucene_version": "8.9.0",
        "minimum_wire_compatibility_version": "6.8.0",
        "minimum_index_compatibility_version": "6.0.0-beta1"
    },
    "tagline": "You Know, for Search"
}

image
image

至此,安装Elasticsearch的流程结束!



这篇关于Linux Centos7下安装Elasticsearch的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程