微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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的流程结束!

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐