Deploy an Elasticsearch 6.8 cluster on 3 CentOS 7.8 servers that are not connected to the Internet

In order to deploy an Elasticsearch 6.8.23 cluster on 3 CentOS 7.8 servers that are not connected to the Internet, and taking into account the configuration of path.data and path.logs, we can follow the following steps To do:

1. Preparation

1.1 Download the RPM package of Elasticsearch 6.8.23 from a machine with network access:

https://www.elastic.co/downloads/past-releases/elasticsearch-6-8-23

1.2 In order to install dependent packages, you also need to download the following RPM packages:

  • java-1.8.0-openjdk

You can use the yum command to download:

yum install --downloadonly --downloaddir=/path_to_directory java-1.8.0-openjdk

1.3 Use a USB flash drive or other means to copy these RPM packages to 3 CentOS servers.

2. Installation

2.1 Install Java:

cd /path_to_directory
yum localinstall java-1.8.0-openjdk*.rpm

2.2 Install Elasticsearch:

cd /path_where_elasticsearch_rpm_is
yum localinstall elasticsearch-6.8.23.rpm

3. Configure Elasticsearch

3.1 Create directories for data and logs:

mkdir -p /data1/elasticsearch/data/
mkdir -p /data1/elasticsearch/log/

3.2 Set appropriate permissions:

chown -R elasticsearch:elasticsearch /data1/elasticsearch/data/
chown -R elasticsearch:elasticsearch /data1/elasticsearch/log/

3.3 Edit the /etc/elasticsearch/elasticsearch.yml file and set the following parameters:

cluster.name: my-cluster
node.name: node-1 # Set to node-2, node-3 on different servers
network.host: 0.0.0.0
http.port: 9200
discovery.zen.ping.unicast.hosts: ["server1_ip", "server2_ip", "server3_ip"]
discovery.zen.minimum_master_nodes: 2
path.data: /data1/elasticsearch/data/
path.logs: /data1/elasticsearch/log/

3.4 Start the Elasticsearch service:

systemctl enable elasticsearch
systemctl start elasticsearch

4. Open firewall

If the server has a firewall enabled, you need to allow access to the Elasticsearch port:

firewall-cmd --permanent --add-port=9200/tcp
firewall-cmd --permanent --add-port=9300/tcp
firewall-cmd --reload

5. Verify installation

Run the following command on any server to check the cluster health:

curl -X GET "localhost:9200/_cluster/health?pretty"

This is the single unit
curl -X GET 'http://localhost:9200'

The above steps should help you deploy an Elasticsearch 6.8.23 cluster on 3 CentOS 7.8 servers and configure the data and log paths correctly. Make sure to perform these steps on all 3 servers to ensure that each node of the cluster is configured correctly.

Note: The configuration and deployment of Elasticsearch involves many details and optimizations in a production environment. The above steps are only basic deployment. In a production environment, various issues such as data security, performance optimization, and backup need to be considered.

Configuration optimization
Modify memory
vim /etc/elasticsearch/jvm.options
Modify the following two items as needed according to the actual situation:
-Xms1g
-Xmx1g

ES configure IK word segmenter

Installation of IK word segmenter
1. Download address: Releases · medcl/elasticsearch-analysis-ik · GitHub

Note: When downloading, be sure to download the word segmenter version that is consistent with the current ES version to avoid other problems.

2. Unzip and upload

[root@localhost elasticsearch]# find / -name plugins
/usr/share/elasticsearch/plugins

Copy the decompressed elasticsearch-analysis-ik-6.8.2 folder to /usr/share/elasticsearch/plugins, and rename the folder to ik.
You can use the chown and chmod commands to modify the ownership and permissions of a directory.

First, make sure you have the appropriate permissions to change the properties of these directories. You may need to use sudo to execute these commands if you are root.

  1. Change the ownership of the directory and its subdirectories to the elasticsearch user group:
sudo chown -R :elasticsearch /usr/share/elasticsearch/plugins/ik

Here, -R means to recursively change the ownership of the specified directory and its subdirectories. There is no username specified before the colon, so only the group is modified, not the user.

  1. Set readable, writable, and executable permissions for the elasticsearch user group:
sudo chmod -R g + rwx /usr/share/elasticsearch/plugins/ik

Here, g + rwx means adding read (r), write (w) and execute (x) permissions to the user group (g stands for group).

After completing the above steps, the elasticsearch user group should have readable, writable, and executable permissions on /usr/share/elasticsearch/plugins/ik and its subdirectories.

3. Restart es to load the ik word segmenter.

 systemctl restart elasticsearch
  1. View log
tail -f /data1/elasticsearch/log/es-cluster.log

ES cluster setting password

2. Configuration steps
1. Enable x-pack verification in the elasticsearch configuration file of each node without restarting! ! ! ! !

xpack.security.enabled: true
xpack.license.self_generated.type: basic
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: elastic-certificates.p12

2. Execute the following command on any es member
When prompted to enter a password, press Enter directly. No need to enter a password! ! ! ! . The purpose is to generate the elastic-certificates.p12 file! ! !

/usr/share/elasticsearch/bin/elasticsearch-certutil cert -out /etc/elasticsearch/elastic-certificates.p12 -pass

3. Copy the certificate generated under /etc/elasticsearch/ to other cluster machines and modify the permissions, and then restart the cluster. (Note to ensure that the certificate permissions of each node are modified)

chmod 755 elastic-certificates.p12

Restart all servers! Restart node1 first,
systemctl restart elasticsearch
Log view
tail -f /data1/elasticsearch/log/es-cluster.log
If you don’t report an error, you are already more than half successful! ! ! !

3. Execute the command to set the user name and password on any es machine.
A total of 6 users need to set passwords: elastic, kibana, logstash_system, beats_system, apm_system, remote_monitoring_user.
Execute the following command

/usr/share/elasticsearch/bin/elasticsearch-setup-passwords interactive

Note: After this step, you need a password to access the elasticsearch of this server. If it is cluster mode, you need to do the following steps.

6. Use a browser to access elasticsearch
Verify whether each node requires verification of password login.

7. Modify the username and password of elasticsearch in the kibana configuration file. (can be ignored if not required)
and access connection verification


and restart kibana