The last article introduced the theory foundation of ES, and then it introduced the construction of ES cluster, the construction of visual interaction Kibana, and the installation of ES monitoring and ES-head plug-in.

Install ElasticSearch on a single server

1. Download the ES

The official download address: www.elastic.co/cn/download…

2. Install the ES

This article uses the ES 7.x version as an example.

2.1 unzip

Tar -zvxf elasticsearch-7.6.1-linux-x86_64.tar.gz -c /soft/es
#optionalLn -s/soft/elasticsearch - 7.6.1 / soft/es/elasticsearchCopy the code

2.2 Modifying a Configuration File

2.2.1 Create data and log directories first

mkdir -p /soft/es/elasticsearch/data
mkdir -p /soft/es/elasticsearch/log
Copy the code

2.2.2 Modifying the ES Configuration File

cd /soft/es/elasticsearch/config

vim elasticsearch.yml
Copy the code

The modification is as follows:

cluster.name: moe-es
node.name: moe-es-node1

path.data: /soft/es/elasticsearch/data
path.logs: /soft/es/elasticsearch/log

network.host: 0.0. 0. 0
http.port: 9200
discovery.seed_hosts: ["s201"] # Corresponds to the local IP address
cluster.initial_master_nodes: ["moe-es-node1"]
Copy the code

2.2.3 Modifying JVM Configuration Parameters

vim jvm.options
Copy the code

The modification is as follows:

-Xms2g
-Xmx2g
Copy the code

3. Start the ES

cd /soft/es/elasticsearch/bin

#Start the es
./elasticsearch -d
Copy the code

4. To access the ES

http://ip:9200

Firewall such as the operation command, the reader to solve ha ~, not narrated.

Install ElasticSearch cluster

Prepare three nodes, of course, you can also build a pseudo cluster on a node, but the memory needs to be higher ha, ES more eat memory, memory is not enough, can not get up.

The core is to change the elasticSearch.yml configuration file.

Note: S201, S202, s203 are the hostname of each node

1. The node Node1

cluster.name: moe-es
node.name: moe-es-node1

path.data: /soft/es/elasticsearch/data
path.logs: /soft/es/elasticsearch/log

network.host: s201
http.port: 9200

discovery.seed_hosts: ["s201", "s202", "s203"]
cluster.initial_master_nodes: ["moe-es-node1", "moe-es-node2", "moe-es-node3"]

bootstrap.system_call_filter: false
bootstrap.memory_lock: false
http.cors.enabled: true
http.cors.allow-origin: "*"
Copy the code

2. 2

cluster.name: moe-es
node.name: moe-es-node2

path.data: /soft/es/elasticsearch/data
path.logs: /soft/es/elasticsearch/log

network.host: s202
http.port: 9200

discovery.seed_hosts: ["s201", "s202", "s203"]
cluster.initial_master_nodes: ["moe-es-node1", "moe-es-node2", "moe-es-node3"]

bootstrap.system_call_filter: false
bootstrap.memory_lock: false
http.cors.enabled: true
http.cors.allow-origin: "*"
Copy the code

3. The node Node3

cluster.name: moe-es
node.name: moe-es-node3

path.data: /soft/es/elasticsearch/data
path.logs: /soft/es/elasticsearch/log

network.host: s203
http.port: 9200

discovery.seed_hosts: ["s201", "s202", "s203"]
cluster.initial_master_nodes: ["moe-es-node1", "moe-es-node2", "moe-es-node3"]

bootstrap.system_call_filter: false
bootstrap.memory_lock: false
http.cors.enabled: true
http.cors.allow-origin: "*"
Copy the code

4. Start them separately

# s201
./elasticsearch -d

# s202
./elasticsearch -d

# s203
./elasticsearch -d
Copy the code

5. Check whether the access is ok

http://s201:9200

http://s201:9200

http://s201:9200

Install elasticSearch-head

Install it on one node.

1. What is es-head?

After the es service is started, the interface is ugly. To better view the information in the index library, you can install the Elasticsearch-head plug-in to make it easier to see the es management interface.

2. Es-head installation prerequisites

To install elasticSearch-head, install Node.js first

2.1 download nodejs

Wget https://npm.taobao.org/mirrors/node/v8.1.0/node-v8.1.0-linux-x64.tar.gz tar ZXVF - node - v8.1.0 - Linux - x64. Tar. Gz - C /soft/es/
#optionalLn -s/soft/es/node - v8.1.0 - Linux - x64 / soft/es/nodeCopy the code

2.2 Configuring environment Variables

vim /etc/profile

export NODE_HOME=/soft/es/node
export PATH=$PATH:$NODE_HOME/bin
Copy the code

2.3 Environment Takes Effect

source /etc/profile
Copy the code

2.4 Verifying the Installation

node -v
npm -v
Copy the code

3. The e-head

3.1 download

There are two ways to install elasticSearch-head.

  • Download source code package for compilation, time-consuming, the network is poor (scientific Internet ha), basically impossible to install successfully.
  • Search for the compiled Elasticsearch-head (compile-after-tar.gz) plugin online.

3.2 unzip

tar -zxvf elasticsearch-head-compile-after.tar.gz -C /soft/es/
Copy the code

3.3 modify Gruntfile. Js

cd /soft/es/elasticsearch-head

vim Gruntfile.js

connect: {
        server: {
                options: {
                        hostname: 's201',
                        port: 9100,
                        base: '.',
                        keepalive: true
                }
        }
}
Copy the code

3.4 modify the app. Js

cd /soft/es/elasticsearch-head/_site

vim app.js

#http://localhost:9200 is changed to http://s201:9200
this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://s201:9200";
Copy the code

3.5 Starting the ES-Head Service

Go to the /soft/es/ Elasticsearch-head /node_modules/grunt/bin directory

nohup ./grunt server >/dev/null 2>&1 &
Copy the code

3.6 Accessing the ES-Head interface

http://ip:9100

Four, Kibana installation

Install it on one node.

ES mainstream client Kibana, open 9200 port with graphical interface client interaction.

1. Install Kibana

Tar -zxvf Elasticsearch-7.6.1-linux-x86_64.tar. gz -c /soft/es/
#optionalLn -s/soft/es/kibana - 7.6.1 - Linux - x86_64 / soft/es/kibanaCopy the code

2. Modify the configuration file

cd /soft/es/kibana/config

vim kibana.yml

server.port: 5601
server.host: "s201"
elasticsearch.hosts: ["http://s201:9200"]
Copy the code

3. Start Kibana

cd /soft/es/kibana/bin

nohup ./kibana &
Copy the code

4. Visit Kibana

http://ip:5601/

Five, IK participle installation

IK for Elasticsearch You need to install IK for Elasticsearch separately.

1. Download

It is best to download the same version of IK as es.

Github.com/medcl/elast…

2. Install

2.1 Creating the Plugins directory

Create the plugins directory in the ES installation directory

The mkdir/soft/es/elasticsearch/plugins under decompressionCopy the code

2.2 unzip

The ik under/soft/es/elasticsearch/plugins decompression

Unzip elasticsearch - analysis - ik - 7.6.1. ZipCopy the code

2.3 restart the es

Six, summarized

This paper introduces the installation of SINGLE machine and cluster of ES, as well as the installation of ES-head and Kibana. If you want to do a good job, you must first sharpen its device. Only by building these environments can we further understand ES and learn it.

Finally prepare a picture, maybe useful!

Welcome to follow the wechat official account (MarkZoe) to learn from each other and communicate with each other.