Elasticsearch 是一个开源全文搜索和分析引擎工具,用于存储、搜索和分析大量数据近实时的数据。搜索引擎运行速度非常快,可用于搜索大量数据(大数据),并支持分布式架构以实现高可用性。Elasticsearch 与 Kibana 和 Logstash 一起构成了Elastic Stack。
步骤 1. 首先,让我们先确保您的系统是最新的。
sudo dnf update sudo dnf install epel-release sudo dnf --enablerepo=epel group
步骤 2. 安装 Java。
Elasticsearch 依赖于 Java,它必须使用以下命令安装到系统上:
sudo dnf install java-11-openjdk-devel
安装完成后检查Java版本:
[root@idroot.us ~]# java -version openjdk version \"11.0.11\" 2021-06-04 LTS OpenJDK Runtime Environment 18.9 (build 11.0.11+9-LTS) OpenJDK 64-Bit Server VM 18.9 (build 11.0.11+9-LTS, mixed mode, sharing)
步骤 3. 在 AlmaLinux 8 上安装 Elasticsearch。
现在为 Elasticsearch rpm 包安装 GPG 密钥:
rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
然后,为 Elasticsearch 创建一个 yum 存储库文件:
nano /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
完成后,使用以下命令安装 Elasticsearch 包:
sudo dnf update sudo dnf install elasticsearch
步骤 4. 配置 Elasticsearch。
安装完成后,编辑 Elasticsearch 配置文件“ ”并将 network.host 设置为 localhost:/etc/elasticsearch/elasticsearch.yml
nano /etc/elasticsearch/elasticsearch.yml
添加以下行:
cluster.name: Idroot-Cluster node.name: node-1 path.data: /var/lib/elasticsearch network.host: 127.0.0.1
安装过程完成后,Elasticsearch 服务不会自动启动。启动服务并使服务运行:
sudo systemctl enable elasticsearch sudo systemctl start elasticsearch
步骤 5. 测试 Elasticsearch。
现在一切都在您的系统上启动并运行 ElasticSearch,是时候检查它是否工作正常。因此,为了测试它,我们使用curl
.
curl -X GET \"localhost:9200/\"
输出:
[root@vps ~]# curl -X GET \"localhost:9200/\" { \"name\" : \"node-1\", \"cluster_name\" : \"Idroot-Cluster\", \"cluster_uuid\" : \"5uoMXG0det2TETVNMeiUw\", \"version\" : { \"number\" : \"7.13.0\", \"build_flavor\" : \"default\", \"build_type\" : \"rpm\", \"build_hash\" : \"5ca8591c6fcdbgodet95b08a8e023559635c6f3\", \"build_date\" : \"2021-06-04T22:22:26.081971460Z\", \"build_snapshot\" : false, \"lucene_version\" : \"8.8.2\", \"minimum_wire_compatibility_version\" : \"6.8.0\", \"minimum_index_compatibility_version\" : \"6.0.0-beta1\" }, \"tagline\" : \"You Know, for Search\" }
恭喜!您已成功安装 Elasticsearch。感谢您使用本教程在您的 AlmaLinux 8 系统上安装 Elasticsearch。如需其他帮助或有用信息,我们建议您查看Elasticsearch 官方网站。