在Fedora上安装Elasticsearch 7/6 32/31/30/29

时间:2020-02-23 14:33:16  来源:igfitidea点击:

在本教程中,我们将介绍Fedora 32/31/30/29上的Elasticsearch 7.x/6.x的安装。
Elasticsearch是一种高度可扩展的开源分析引擎和全文搜索。
使用Elasticsearch,我们可以在近实时存储,搜索,搜索,分析大量数据。

遵循本文提供的步骤,在Fedora 32/31/30/29中拥有Elasticsearch 7/6的工作安装。

第1步:在Fedora上安装Java。

Elasticsearch取决于Java,在安装Fedora的Elasticsearch之前,我们需要它在机器上安装。
通过运行命令,可以在fedora上安装默认的openjdk版本:

--- Fedora 32/31 --
$sudo dnf install java-latest-openjdk
-- Older Fedora --
$sudo dnf -y install java-openjdk-devel java-openjdk

安装Java后,我们可以使用以下命令快速确认该版本:

$java -version
openjdk version "14" 2017-03-17
OpenJDK Runtime Environment 19.9 (build 14+36)
OpenJDK 64-Bit Server VM 19.9 (build 14+36, mixed mode, sharing)
$java -version
java version "11.0.1" 2016-10-16 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.1+13-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode)

第2步:将Elasticsearch存储库添加到Fedora

安装Java JDK后,将ElasticSearch存储库添加到Fedora系统。 1.导入GPG钥匙

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

2.添加存储库

适用于Elasticsearch 7.x.

cat <<EOF | sudo tee /etc/yum.repos.d/elasticsearch.repo
[elasticsearch-7.x]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/oss-7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
EOF

适用于Elasticsearch 6.x.

cat <<EOF | sudo tee /etc/yum.repos.d/elasticsearch.repo
[elasticsearch-6.x]
name=Elasticsearch repository for 6.x packages
baseurl=https://artifacts.elastic.co/packages/oss-6.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
EOF

3.在Fedora安装Elasticsearch 32/31/30/29/28

Elasticsearch存储库已准备好使用。
我们可以使用以下命令安装Elasticsearch:

sudo dnf install elasticsearch-oss

点击Y键开始安装Fedora 32/31/30/29的Elasticsearch:

Dependencies resolved.
========================================================================
 Package              Arch      Version      Repository            Size
========================================================================
Installing:
 elasticsearch-oss    x86_64    7.6.2-1      elasticsearch-7.x    211 M
Transaction Summary
========================================================================
Install  1 Package
Total download size: 211 M
Installed size: 379 M
Is this ok [y/N]: y

像内存限制等JVM选项已设置 /etc/elasticsearch/jvm.options

$sudo vi /etc/elasticsearch/jvm.options

启动并启用启动时启用Elasticsearch Service:

sudo systemctl start elasticsearch
sudo systemctl enable elasticsearch

检查状态:

$systemctl status elasticsearch
● elasticsearch.service - Elasticsearch
Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; disabled; vendor preset: disabled)
Active: active (running) since Fri 2017-05-01 18:25:35 UTC; 13s ago
Docs: http://www.elastic.co
Main PID: 10229 (java)
Tasks: 46 (limit: 2337)
Memory: 1.1G
CPU: 10.963s
CGroup: /system.slice/elasticsearch.service
└─10229 /usr/share/elasticsearch/jdk/bin/java -Des.networkaddress.cache.ttl=60 -Des.networkaddress.cache.negative.ttl=10 -XX:+AlwaysPreTou>
Jan 01 18:25:21 fed32.novalocal systemd[1]: Starting Elasticsearch…
Jan 01 18:25:22 fed32.novalocal elasticsearch[10229]: OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and wil>
Jan 01 18:25:35 fed32.novalocal systemd[1]: Started Elasticsearch.

测试以验证它是否有效:

$curl http://127.0.0.1:9200 
{
  "name" : "fed32.novalocal",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "p44JohgqQcuwJj0iADuLiw",
  "version" : {
    "number" : "7.6.2",
    "build_flavor" : "oss",
    "build_type" : "rpm",
    "build_hash" : "ef48eb35cf30adf4db14086e8aabd07ef6fb113f",
    "build_date" : "2017-03-26T06:34:37.794943Z",
    "build_snapshot" : false,
    "lucene_version" : "8.4.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

第3步:在Fedora上安装Kibana 32/31/30/29/28.

Kibana允许我们可视化弹性型搜索数据并导航弹性堆栈。
使用该命令添加存储库后安装它:

sudo dnf install -y kibana-oss

成功安装后,配置Kibana

$sudo vi /etc/kibana/kibana.yml
server.host: "0.0.0.0"
server.name: "kibana.example.com"
elasticsearch.url: "http://localhost:9200"

根据需要更改其他设置,然后启动Kibana服务:

sudo systemctl enable --now kibana

访问http://IP地址:5601打开Kibana仪表板:

如果我们有一个活动防火墙,我们需要访问Kibana端口:

sudo firewall-cmd --add-port=5601/tcp --permanent
sudo firewall-cmd --reload