Kubesphere installs elasticsearch cluster and kibana

Table of contents

foreword

1. Write configuration files

2. Create a service node

 3. Install the IK tokenizer (so all nodes must be installed)

 4. Test cluster

Five, kibana installation

 1. Write a configuration file

2. Create a service


 


foreword

Due to the machine configuration, elasticsearch only installs two nodes here, and both nodes assume the functions of master and data.






1. Write configuration files

  • Configuration center on the left - configuration - create, fill in the basic information, the next step
  • Fill in the configuration, each individual configuration

  •  Configuration item (es-node1 node)
#集群名称,同名称的可以加入同一个集群
cluster.name: es-cluster
#节点名称
node.name: es-node1
network.host: 0.0.0.0
#主节点
node.master: true
#数据节点
node.data: true
#集群中节点的初始列表,可以通过这些节点来自动发现其他节点加入集群。
discovery.seed_hosts: es-node1.mall-project:9300,es-node2.mall-project:9300
#新集群初始节点的候选节点
cluster.initial_master_nodes: es-node1

 Tip: discovery.seed_hosts: The domain name in the configuration item is the DNS generated by kubesphere. This domain name is automatically generated after the node is created (as shown in the figure below). Its generation rule is <node name>.<project name>, so we have agreed in advance that the next two nodes will be called es-node1 and es-node2.

 

  •   Configuration item (es-node2 node)

The content is roughly the same as es-node1, just change node.name to es-node2

cluster.name: es-cluster
node.name: es-node2
network.host: 0.0.0.0
node.master: true
node.data: true
discovery.seed_hosts: es-node1.mall-swarm-project:9300,es-node2.mall-swarm-project:9300
cluster.initial_master_nodes: es-node1





2. Create a service node

  • Create es-node1 node

Create a stateful service

 Fill in the name, which must be the same as the domain name in the configuration file discovery.seed_hosts in the previous step es-node1

 The number of copies is 1

Add container elasticsearch:7.6.2 Select the default port

 Set environment variables, reference configuration files, and reference all configuration items.

 deployment mode

  • mount storage

Add storage template

Mount to /usr/share/elasticsearch/data directory 

 Mount another storage to /usr/share/elasticsearch/plugins

 The session is maintained, and the node scheduling can specify the running node to make the two es run on different service nodes.

  • created successfully

 Note: The DNS of the image must be consistent with the discovery.seed_hosts configuration item in the configuration file. If it is inconsistent, you can modify the configuration file and redeploy.

  • Create es-node2 node

The same as creating the es-node1 node, is to replace the environment variable with the configuration file of node2

 3. Install the IK tokenizer (so all nodes must be installed)

  • Enter the es container group - view the scheduling information and record which node the scheduling is on

 

 This example is scheduled to the second node

  • View resource status - remember container name

  •  Connect to the host of the corresponding node (node2 in this example), and find the id of the corresponding container

docker ps |grep 容器名
  • into the corresponding container

docker exec -it 容器id /bin/bash
  •  Download the ik tokenizer. and reboot
    
    #此命令需要在容器中运行
    elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.6.2/elasticsearch-analysis-ik-7.6.2.zip
    docker restart elasticsearch

 4. Test cluster

  • Enter the terminal of any node

  •  Access the two nodes through DNS to view the names of the two nodes and the cluster name

curl es-node1.mall-swarm-project:9200
curl es-node2.mall-swarm-project:9200
  •  View cluster nodes

* represents the master node - represents the data node

Five, kibana installation

 1. Write a configuration file

server.name: kibana
server.host: "0"
elasticsearch.hosts: [ "http://es-node1.mall-swarm-project:9200","http://es-node2.mall-swarm-project:9200" ]
xpack.monitoring.ui.container.elasticsearch.enabled: true

Tip: elasticsearch.hosts fills in the DNS of the es node

2. Create a service

kibana is stateless, choose stateless service and fill in the basic information

 

 Choose 1 copy

 Select the mirror kibana:7.6.2, which is consistent with the version of elasticsearch. Use the default port and set resource usage.

 Mount configuration files, mount directory /usr/share/kibana/config/


 Because you need to log in to kibana externally, you need to set the external network access access method: NodePort

 After the creation is successful, you will see the exposed ports.

It can be accessed through any cluster IP+port number.

 visit kibana

192.168.56.102 is the IP address of my virtual machine, and my machine can connect to the virtual machine through this address.

It may take a long time for kibana to start, if the connection is not available, wait a little longer.

Guess you like

Origin blog.csdn.net/qq_31277409/article/details/120449561