翻译进度
5
分块数量
2
参与人数

如何在 Ubuntu 18.04 和 16.04 LTS 中安装 Elasticsearch?

这是一篇协同翻译的文章,你可以点击『我来翻译』按钮来参与翻译。


Ubuntu

Elasticsearch是一种灵活、功能强大的开源、分布式实时搜索分析引擎。使用一组简单的api,它提供了全文搜索的能力。在Apache 2许可下,弹性搜索是免费的,它提供了最大的灵活性。

本教程将帮助您在Ubuntu18.04&16.04 LTS系统上安装Elasticsearch。

Step 1 – 预置

使用sudo权限登录到您的Ubuntu系统。使用ssh访问远程Ubuntu服务器。Windows用户可以使用putty或其他方法登录Ubuntu系统。

在任何系统上运行Elasticsearch都需要Java。通过运行以下命令确保您的系统已安装Java。这个命令将显示当前的Java版本。

java -version

java version "11.0.2" 2019-01-15 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.2+9-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.2+9-LTS, mixed mode)

此外,请确保您的JAVA_HOME环境变量配置:

echo $JAVA_HOME

/usr/lib/jvm/java-11-oracle
kuibatian 翻译于 2周前

Step 2 – Install Elasticsearch on Ubuntu

The Elasticsearch official team provides an apt repository to install Elasticsearch on Ubuntu Linux system. After install below package and import GPG key for Elasticsearch packages.

sudo apt-get install apt-transport-https
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -

Then configure the apt repository on your Debian system. The below command will add a repository to install latest Elasticsearch 6.X on your Ubuntu system.

add-apt-repository "deb https://artifacts.elastic.co/packages/7.x/apt stable main"

After adding the repository to your system. Run the following commands to update cache and then install Elasticsearch packages on your system.

sudo apt-get update
sudo apt-get install elasticsearch

Step 3 – Configure Elasticsearch

The Elasticsearch has been installed on your system. You can customize this by editing the Elasticsearch configuration file. Edit configuration file in your favorite text editor and update it:

sudo nano /etc/elasticsearch/elasticsearch.yml

Change the following values:

/etc/elasticsearch/elasticsearch.yml

 network.host: 0.0.0.0
 cluster.name: myCluster1
 node.name: "myNode1"
  • network.host – Set the network host to 0.0.0.0 to listen on all interfaces and make it publically available. You can use your LAN address for LAN access only.
  • cluster.name – Name of the cluster. For the multi-node cluster, all the nodes must use the same cluster name.
  • node.name – Set the unique name of the node to identify in a cluster.

Step 4 – Launch Elasticsearch

To configure Elasticsearch to start automatically when the system boots up, run the following commands:

sudo /bin/systemctl enable elasticsearch.service

Elasticsearch can be started and stopped as follows:

sudo systemctl start elasticsearch.service
sudo systemctl stop elasticsearch.service

Step 5 – Test Setup

The Elasticsearch service is ready to use. You can test it using curl command-line utility. Run the simple GET command using curl to verify the setup. You will see the Elasticsearch cluster details with the version on your screen.

curl -X GET "http://localhost:9200/?pretty"

Console Output

{
  "name" : "myNode1",
  "cluster_name" : "myCluster1",
  "cluster_uuid" : "YLBEZHdqQ2W_gMiDUJXJyw",
  "version" : {
    "number" : "7.3.0",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "de777fa",
    "build_date" : "2019-07-24T18:30:11.767338Z",
    "build_snapshot" : false,
    "lucene_version" : "8.1.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

本文章首发在 LearnKu.com 网站上。
本文中的所有译文仅用于学习和交流目的,转载请务必注明文章译者、出处、和本文链接
我们的翻译工作遵照 CC 协议,如果我们的工作有侵犯到您的权益,请及时联系我们。

原文地址:https://tecadmin.net/setup-elasticsearch...

译文地址:https://learnku.com/ubuntu/t/37012

参与译者:2
讨论数量: 1

今天累了,明天来翻译。先签到一下。

2周前 评论

请勿发布不友善或者负能量的内容。与人为善,比聪明更重要!