ELK_Elasticsearch environment construction

Table of contents

1. Install elasticsearch on Windows

1. Install JDK

2. Download and decompress

3. Configuration file

4. Start

5. Check whether ES starts successfully

6. Browser access

Two, Windows installation Kibana


1. Install elasticsearch on Windows

1. Install JDK

Install JDK , at least version 1.8.0_73 or above, verify: java -version .

2. Download and decompress

Download and decompress the Elasticsearch installation package, and view the directory structure.

https://www.elastic.co/cn/downloads/elasticsearch

bin: script directory, including: start, stop and other executable scripts

config: configuration file directory

data: index directory, where index files are stored

logs: log directory

modules: module directory, including the functional modules of es

plugins : plugin directory, es supports plugin mechanism

3. Configuration file

Location:

  • The address of the ES configuration file varies according to the installation form:
  • Use zip and tar to install, and the address of the configuration file is under config in the installation directory.
  • Use RPM to install, and the configuration file is under /etc/elasticsearch.
  • Using MSI installation, the address of the configuration file is under the config of the installation directory, and the address of the config directory will be automatically written into the environment variable ES_PATH_CONF.

elasticsearch.yml

The configuration format is YAML, which can be used in the following two ways:

Method 1 : Hierarchical method

path:

    data: /var/lib/elasticsearch

    logs: /var/log/elasticsearch

Method 2 : Attribute method

path.data: /var/lib/elasticsearch

path.logs: /var/log/elasticsearch

Commonly used configuration items are as follows

cluster.name: Configure the cluster name of elasticsearch , the default is elasticsearch . It is recommended to change it to a meaningful name.

node.name: node name, usually a physical server is a node, es will randomly specify a name by default, it is recommended to specify a meaningful name, it is convenient to manage one or more nodes to form a cluster cluster, cluster is a logical concept , the node is a physical concept, which will be introduced in detail in the following chapters.

path.conf: Set the storage path of the configuration file, tar or zip package installation defaults to the config folder under the es root directory, rpm installation defaults to /etc/elasticsearch

path.data: Set the storage path of the index data, the default is the data folder under the es root directory, you can set multiple storage paths, separated by commas.

path.logs: Set the storage path of log files, the default is the logs folder under the es root directory

path.plugins: Set the storage path of the plugin, the default is the plugins folder in the es root directory

bootstrap.memory_lock: true Set to true to lock the memory used by ES to avoid exchanging data between the memory and the swap partition.

network.host: Set the ip address of the binding host . Setting it to 0.0.0.0 means binding any ip and allowing external network access. It is recommended to set it to a specific ip in the production environment .

http.port: 9200 Set the http port for external services , the default is 9200 .

transport.tcp.port:  communication port between 9300 cluster nodes

node.master: Specifies whether the node is eligible to be elected as the master node. The default is true . If the original master goes down, a new master will be re-elected .

node.data: Specifies whether the node stores index data, the default is true .

discovery.zen.ping.unicast.hosts: ["host1:port", "host2:port", "..."] Set the initial list of master nodes in the cluster .

discovery.zen.ping.timeout: 3s Set the timeout time for ES to automatically discover node connections. The default is 3 seconds. If the network delay is high, it can be set larger.

discovery.zen.minimum_master_nodes: The minimum value of the number of master nodes . The formula for this value is: (master_eligible_nodes / 2) + 1. For example: if there are 3 master nodes that meet the requirements, then set it to 2 here .

node.max_local_storage_nodes: 单机允许的最大存储结点数,通常单机启动一个结点建议设置为1,开发环境如果单机启动多个节点可设置大于1

jvm.options

设置最小及最大的JVM堆内存大小:在jvm.options中设置 -Xms和-Xmx:

1) 两个值设置为相等

2) 将Xmx 设置为不超过物理内存的一半。

log4j2.properties

日志文件设置,ES使用log4j,注意日志级别的配置。

4、启动

启动Elasticsearch:bin\elasticsearch.bat,es的特点就是开箱即,无需配置,启动即可。

注意:es7 windows版本不支持机器学习,所以elasticsearch.yml中添加如下几个参数:

node.name: node-1 

cluster.initial_master_nodes: ["node-1"] 

xpack.ml.enabled: false

http.cors.enabled: true

http.cors.allow-origin: /.*/

5、检查ES是否启动成功

检查ES是否启动成功:http://localhost:9200/?Pretty

{

    "name": "node-1",

    "cluster_name": "elasticsearch",

    "cluster_uuid": "HqAKQ_0tQOOm8b6qU-2Qug",

    "version": {

        "number": "7.3.0",

        "build_flavor": "default",

        "build_type": "zip",

        "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"

}

解释:

name: node名称,取自机器的hostname

cluster_name: 集群名称(默认的集群名称就是elasticsearch)

version.number: 7.3.0,es版本号

version.lucene_version:封装的lucene版本号

6、浏览器访问

浏览器访问http://localhost:9200/_cluster/health查询集群状态

{

    "cluster_name": "elasticsearch",

    "status": "green",

    "timed_out": false,

    "number_of_nodes": 1,

    "number_of_data_nodes": 1,

    "active_primary_shards": 0,

    "active_shards": 0,

    "relocating_shards": 0,

    "initializing_shards": 0,

    "unassigned_shards": 0,

    "delayed_unassigned_shards": 0,

    "number_of_pending_tasks": 0,

    "number_of_in_flight_fetch": 0,

    "task_max_waiting_in_queue_millis": 0,

    "active_shards_percent_as_number": 100

}

解释:

Status:集群状态。Green 所有分片可用。Yellow所有主分片可用。Red主分片不可用,集群不可用。

二、 Windows安装Kibana

1、kibana是es数据的前端展现,数据分析时,可以方便地看到数据。作为开发人员,可以方便访问es。

2、下载,解压kibana。

3、启动Kibana:bin\kibana.bat

4、浏览器访问 http://localhost:5601 进入Dev Tools界面。像plsql一样支持代码提示。

5、发送get请求,查看集群状态GET _cluster/health。相当于浏览器访问。

总览

​ Dev Tools界面

​ 监控集群界面(展示集群状态--搜索速率、索引速率等)

Guess you like

Origin blog.csdn.net/wanghaiping1993/article/details/129097336