天天看點

Elasticsearch(安裝篇):Windows下安裝和運作Elasticsearch

前期準備

JAVA環境

lasticsearch至少需要Java 8.具體到撰寫本文時,為了更加适配新版ElasticSearch,建議大家使用Oracle JDK版本1.8.0以上。Java安裝因平台而異,是以我們不會在此處詳細介紹。可以在Oracle的網站上找到Oracle推薦的安裝文檔。

首先,在安裝Elasticsearch之前 先看一下 是否安裝過JDK,以及JDK版本是否符合這次安裝(然後根據需要進行相應的安裝/更新):

Elasticsearch(安裝篇):Windows下安裝和運作Elasticsearch

ElasticSearch安裝

下載下傳Elasticsearch

設定好Java,我們就可以下載下傳并運作Elasticsearch。二進制檔案可以https://www.elastic.co/downloads/elasticsearch與過去釋出的所有版本一起提供。對于每個版本,您可以選擇zip或tar存檔,包DEB或RPM包,或Windows MSI安裝包。

百度雲下載下傳位址 連結:https://pan.baidu.com/s/1K-gtBmobNtaIm0I2ff-mVQ

提取碼:fuzx

Elasticsearch(安裝篇):Windows下安裝和運作Elasticsearch
下載下傳好後解壓即可使用
Elasticsearch(安裝篇):Windows下安裝和運作Elasticsearch
編輯config/elasticsearch.yml

# ======================== Elasticsearch Configuration =========================

#

# NOTE: Elasticsearch comes with reasonable defaults for most settings.

# Before you set out to tweak and tune the configuration, make sure you

# understand what are you trying to accomplish and the consequences.

# The primary way of configuring a node is via this file. This template lists

# the most important settings you may want to configure for a production cluster.

# Please consult the documentation for further information on configuration options:

# https://www.elastic.co/guide/en/elasticsearch/reference/index.html

# ---------------------------------- Cluster -----------------------------------

# Use a descriptive name for your cluster:

cluster.name: my-application

# ------------------------------------ Node ------------------------------------

# Use a descriptive name for the node:

node.name: node-1

# Add custom attributes to the node:

#node.attr.rack: r1

# ----------------------------------- Paths ------------------------------------

# Path to directory where to store the data (separate multiple locations by comma):

#path.data: /path/to/data

# Path to log files:

#path.logs: /path/to/logs

# ----------------------------------- Memory -----------------------------------

# Lock the memory on startup:

#bootstrap.memory_lock: true

# Make sure that the heap size is set to about half the memory available

# on the system and that the owner of the process is allowed to use this

# limit.

# Elasticsearch performs poorly when the system is swapping the memory.

# ---------------------------------- Network -----------------------------------

# By default Elasticsearch is only accessible on localhost. Set a different

# address here to expose this node on the network:

network.host: 127.0.0.1

# By default Elasticsearch listens for HTTP traffic on the first free port it

# finds starting at 9200. Set a specific HTTP port here:

http.port: 9200

# For more information, consult the network module documentation.

# --------------------------------- Discovery ----------------------------------

# Pass an initial list of hosts to perform discovery when this node is started:

# The default list of hosts is ["127.0.0.1", "[::1]"]

discovery.seed_hosts: ["127.0.0.1"]

# Bootstrap the cluster using an initial set of master-eligible nodes:

cluster.initial_master_nodes: ["node-1"]

# For more information, consult the discovery and cluster formation module documentation.

# ---------------------------------- Various -----------------------------------

# Require explicit names when deleting indices:

#action.destructive_requires_name: true

# 設定證書

xpack.license.self_generated.type: basic

xpack.security.enabled: false

#是否支援跨域,預設為false

http.cors.enabled: true

#當設定允許跨域,預設為*,表示支援所有域名,如果我們隻是允許某些網站能通路,那麼可以使用正規表達式。比如隻允許本地位址。 /https?:\/\/localhost(:[0-9]+)?/

http.cors.allow-origin: "*"

#這是為elasticsearch增加自動建立索引功能

action.auto_create_index: .security,.monitoring*,.watches,.triggered_watches,.watcher-history*,test_*

啟動

Elasticsearch(安裝篇):Windows下安裝和運作Elasticsearch

如果一切順利安裝,你應該看到一堆如下所示的消息: