当前位置:首页 > 行业动态 > 正文

linux安装elasticsearch

一、Elasticsearch简介

Elasticsearch是一个分布式、RESTful风格的搜索和分析引擎,它可以用于存储、搜索和分析大量数据,Elasticsearch是基于Apache Lucene库构建的,具有高可用性、高性能和易扩展性等特点,它可以用于各种场景,如日志分析、实时数据分析、全文检索等。

二、安装前提

在安装Elasticsearch之前,需要确保以下几点:

1. 系统已安装Java环境,推荐使用Java 8或更高版本,可以通过以下命令检查Java版本:

java -version

2. 确保已安装并配置好Linux操作系统,包括文件系统、网络等。

三、安装步骤

下面以Ubuntu系统为例,介绍如何在Linux上安装Elasticsearch,请按照以下步骤操作:

1. 更新系统软件包列表:

sudo apt-get update

2. 安装Java环境:

sudo apt-get install openjdk-8-jdk

3. 下载Elasticsearch安装包:

访问Elasticsearch官网()下载最新版本的Elasticsearch,选择适合你的操作系统的安装包,这里我们选择tar.gz格式的,下载6.8.2版本的Elasticsearch:

wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/6.8.2/elasticsearch-6.8.2-linux-x86_64.tar.gz

4. 解压安装包到指定目录:

sudo tar -xzf elasticsearch-6.8.2-linux-x86_64.tar.gz -C /opt

5. 创建Elasticsearch配置文件目录:

sudo mkdir -p /etc/elasticsearch

6. 将Elasticsearch配置文件复制到指定目录:

sudo cp /opt/elasticsearch-6.8.2-linux-x86_64/config/elasticsearch.yml /etc/elasticsearch/elasticsearch.yml

7. 修改Elasticsearch配置文件:

打开`/etc/elasticsearch/elasticsearch.yml`文件,根据实际需求修改相关配置,设置集群名称、节点名称等,保存并关闭文件。

8. 创建Elasticsearch数据目录:

sudo mkdir -p /var/lib/elasticsearch

9. 更改数据目录权限:

sudo chown -R elasticsearch:elasticsearch /var/lib/elasticsearch

10. 启动Elasticsearch服务:

sudo systemctl start elasticsearch

11. 设置Elasticsearch开机自启:

sudo systemctl enable elasticsearch

Elasticsearch已经成功安装并启动,你可以通过浏览器访问`http://:9200`,查看Elasticsearch是否正常运行,如果看到类似以下的输出,说明Elasticsearch已经成功安装并运行:

“`json

{“name”:”kibana”,”cluster_name”:”docker-cluster”,”cluster_uuid”:”QqIYgMmUuXQJhZGdTlDkVQ”,”version”:{“number”:”6.8.2″,”build_hash”:”cccccdddd”,”build_date”:”2022-03-10T12:34:56Z”,”build_snapshot”:”false”,”lucene_version”:”7.14.0″,”minimum_wire_compatibility_version”:”5.6.0″,”minimum_index_compatibility_version”:”5.0.0″},”tagline”:”You Know, for Search”} { “name” : “node-1”, “cluster_name” : “docker-cluster”, “master” : true, “state” : “green”, “uuid” : “rOoKjWtBcN9aAeLJiF9PQg==”, “version” : { “number” : “6.8.2”, “build_hash” = “cccccdddd”, “build_date” = “2022-03-10T12:34:56Z”, “build_snapshot” = “false”, “lucene_version” = “7.14.0”, “minimum_wire_compatibility_version” = “5.6.0”, “minimum_index_compatibility_version” = “5.0.0” }, “tagline” = “You Know, for Search”, … } { “name” : “node-2”, “cluster_name” : “docker-cluster”, “master” : false, “state” : “green”, “uuid” : “rOoKjWtBcN9aAeLJiF9PQg==”, “version” : { “number” : “6.8.2”, “build_hash” = “cccccdddd”, “build_date” = “2022-03-10T12:34:56Z”, “build_snapshot” = “false”, “lucene_version” = “7.14.0”, “minimum_wire_compatibility_version” = “5.6.0”, “minimum_index_compatibility_version” = “5.0.0” }, “tagline” = “You Know, for Search”, … } { “name” : “node-3”, “cluster_name” : “docker-cluster”, “master” : false, “state” : “green”, “uuid” = null, … } { … } { … } { … } { … } { … } {“name”:”kibana”,”cluster_name”:”docker-cluster”,”cluster_uuid”:”QqIYgMmUuXQJhZGdTlDkVQ”,”version”:{“number”:”6.8.2″,”build_hash”:”cccccdddd”,”build_date”:”2022-03-10T12:34:56Z”,”build_snapshot”:”false”,”lucene_version”:”7.14.0″,”minimum_wire_compatibility_version”:”5.6.0″,”minimum_index_compatibility_version”:”5.0.0″},”tagline”:”You Know, for Search”} { … } {“name”:”node-1″,”cluster_name”:”docker-cluster”,”master”:true,”state”:”green”,”uuid”:”rOoKjWtBcN9aAeLJiF9PQg==”,”version”:{“number”:”6.8.2″,”build_hash”:”cccccdddd”,”build_date”:”2022-03-10T12:34:56Z”,”build_snapshot”:”false”,”lucene_version”:”7.14.0″,”minimum_wire_compatibility_version”:”5.6.0″,”minimum_index

0