Manual mounting version

Install ES

  • Es installation package download

Download link

  • Run the rz command to upload the file to the server

  • Unpack the

Tar - XVF elasticsearch 7.15.0 - Linux - x86_64. Tar. GzCopy the code
  • Configure the JDK

Because the JDK comes with the DECOMpressed ES, you do not need to download the JDK separately. You only need to configure the Java environment in the Linux service

Modify the vim /etc/profile file

JAVA_HOME=/data/ elasticSearch -7.15.0/ JDK PATH=$PATH:./:$JAVA_HOME/bin export PATH JAVA_HOMECopy the code

Configuration file source /etc/profile

  • Create a user

Because ES does not run under root

Groupadd te useradd te -g te chown -r te:te /data/ ElasticSearch -7.15.0/Copy the code
  • Start the es

Go to te su te and run./bin/ elasticSearch under es

2. Build a cluster

  • You need to prepare three servers first

  • Upload the package in the first step of installation and configure the JDK environment

  • Modify the configuration file required for running

Modify the file vim/etc/security/limits the conf in the last line add the following:

* soft nofile 65536
* hard nofile 131072
* soft nproc 4096
* hard nproc 4096
Copy the code

Modify the vim /etc/sysctl.conf file and add the following:

vm.max_map_count=655360
Copy the code

The effective file is sysctl -p

  • Example Modify the ES configuration file

Modify the configuration file of the primary node as follows: vim config/ elasticSearch. yml

Cluster. name: es-cluster node.name: es01 path.data: /data/ elasticSearch-7.15.0 /data path.logs: /data/ elasticSearch-7.15.0 /data path.logs: /data/ elasticSearch-7.15.0 /logs bootstrap.memory_lock: false bootstrap.system_call_filter: false network.host: /data/ elasticSearch-7.15.0 /logs bootstrap.memory_lock: false bootstrap.system_call_filter: false network.host: Port: 9200 transport.tcp.port: 9300 discovery.seed_hosts: 0.0.0.0 http.port: 9200 transport.tcp.port: 9300 discovery.seed_hosts: ["192.168.64.129", "192.168.64.130","192.168.64.131"] cluster.initial_Master_Nodes: [" ES01 "] http.cers.enabled: true http.cors.allow-origin: "*"Copy the code

Other node configuration files need to be modified node.name

If the operation process to ensure that several machines can communicate, and closed the firewall

  • access

Install the header plug-in

  • Download the elasticsearch – head – master. Zip

Download: github.com/mobz/elasti…

git clone git://github.com/mobz/elasticsearch-head.git
Copy the code
  • Copy the package to the plug-ins directory of ES
Mv elasticsearch - head/data/elasticsearch - 7.15.0 / plugins/CD/data/elasticsearch - 7.15.0 / plugins/elasticsearch - headCopy the code
  • Download the node. Js
elasticsearch-head-master]# curl --silent --location https://rpm.nodesource.com/setup_10.x | bash -
 
elasticsearch-head-master]# yum install -y nodejs
Copy the code
  • Check whether the installation is successful:
Elasticsearch-head-master]# node -v v10.16.0 elasticSearch-head-master]# NPM -v 6.9.0Copy the code
  • The installation of grunt
elasticsearch-head-master]# npm install -g grunt-cli
 
elasticsearch-head-master]# npm install
Copy the code
  • Modify es configuration and add the following information
http.cors.enabled: true
http.cors.allow-origin: "*"
Copy the code
  • Modifying the HEAD Configuration

Open elasticSearch-head-master/gruntfile.js and find the connect property

Server: {options: {hostname: '127.0.0.1', port: 9100, base: '.', keepalive: true}}Copy the code
  • Start the Head plugin
grunt server
Copy the code
  • access

Install Kibana

  • download

www.elastic.co/cn/download…

  • Upload and unzip
Tar -xvf kibana-7.15.0-linux-x86_64.tar.gz -c /data/Copy the code
  • Modifying a Configuration File

Vim config/kibana.yml Modify the following two parameters

  • Start the
./bin/kibana --allow-root
Copy the code

Docker installed version

First, pull the mirror image

Mainly pull the following Docker image

Docker Pull ElasticSearch :7.6.2 Docker Pull Mobz/ElasticSearch -head:5 Docker Pull Kibana :7.6.2Copy the code

2. Create a configuration file

The ES cluster built here

  • Configuration file of the active node

Prepare the ES1. yML file

Cluster. name: elasticsearch-cluster node.name: es-node1 net. bind_host: 0.0.0.0 net. publish_host: elasticsearch-cluster node.name: es-node1 net. bind_host: 0.0.0.0 net. publish_host: _eth0_ http.port: 9200 transport.tcp.port: 9300 http.cors.enabled: true http.cors.allow-origin: "*" node.master: true node.data: true discovery.seed_hosts: ["ES01:9300","ES02:9301","ES03:9302"] cluster.initial_master_nodes: ["es-node1","es-node2","es-node3"] discovery.zen.minimum_master_nodes: 1Copy the code
  • From the node

The configuration file of the secondary node is the same as that of the primary node, with a different node.name: the name of the responding node

Docker-comemage. yml

Version: '3.7' Services: ES1: image: ElasticSearch :7.6.2 container_name: ES01 environment: - ES_JAVA_OPTS=-Xms256m -Xmx256m ports: - "9200:9200" - "9300:9300" volumes: - D:/es/config/es1.yml:/usr/share/elasticsearch/config/elasticsearch.yml - D:/es/data1:/usr/share/elasticsearch/data Networks: -es-net ES2: image: ElasticSearch :7.6.2 container_name: ES02 environment: - ES_JAVA_OPTS=-Xms256m -Xmx256m ports: - "9201:9200" - "9301:9300" volumes: - D:/es/config/es2.yml:/usr/share/elasticsearch/config/elasticsearch.yml - D:/es/data2:/usr/share/elasticsearch/data Networks: -es-net ES3: image: ElasticSearch :7.6.2 container_name: ES03 environment: - ES_JAVA_OPTS=-Xms256m -Xmx256m ports: - "9202:9200" - "9302:9300" volumes: - D:/es/config/es3.yml:/usr/share/elasticsearch/config/elasticsearch.yml - D:/es/data3:/usr/share/elasticsearch/data networks: - es-net es-head: image: mobz/elasticsearch-head:5 ports: - "9100:9100" kibana: image: Kibana: 7.6.2 container_name: kibana environment: - SERVER_NAME=kibana - ELASTICSEARCH_URL=http://es1:9200 - ELASTICSEARCH_HOSTS=http://es1:9200 - XPACK_MONITORING_ENABLED=true ports: - 5601:5601 networks: - es-net depends_on: - es1 external_links: - es1 networks: es-net: driver: bridgeCopy the code

Explanation: The es mount directory needs attention, it is best to hold on

4. Run the build

docker-composer up -d
Copy the code

Configure access rights for the ES cluster

1.1 Generating A Key

Bin /elasticsearch-certutil cert-out config/ elastics-certificate. p12-pass""
Copy the code
SCP config/ elasticate-certificates. p12 wenfeng@192.16864.130.:/data/elasticsearch-7.15. 0/config

scp config/elastic-certificates.p12 wenfeng@192.16864.131.:/data/elasticsearch-7.15. 0/config
Copy the code

1.2 Modifying the ES Configuration File

Add the following information to the ES configuration files of the three hosts

Allow-headers: http.cers.allow-headers: Authorization, x-requested-with, content-length, content-type # configure access key xpack.security.enabled:true
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: /data/elasticsearch-7.15. 0/config/elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: /data/elasticsearch-7.15. 0/config/elastic-certificates.p12

Copy the code

1.3 Initializing the Password

bin/elasticsearch-setup-passwords interactive
Copy the code

This command requires you to manually set several initialization passwords

1.3 Configuring Kibana Access

Modify the Kibana configuration file

elasticsearch.username: "elastic"
elasticsearch.password: "elastic"
Copy the code

The password for this place is the same password that was initialized in the previous step

1.4 Header plug-in access

http://192.168.64.129:9100/?auth_user=elastic&auth_password=elastic
Copy the code

To access the Header plug-in, the user name and password must be appended to the request