Deploying Elasticsearch
Obtain the Elasticsearch 8.10.1 software package from the open source website, configure related files and SSL certificates, create an Elasticsearch user, and start Elasticsearch.
- Download Elasticsearch 8.10.1.
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.10.1-linux-aarch64.tar.gz --no-check-certificate
- Upload the installation package to a server and extract the file. Assume that the code is stored in /path/to/.
tar -zxvf elasticsearch-8.10.1-linux-aarch64.tar.gz
- Modify the elasticsearch.yml configuration file.
- Go to the directory where the configuration file is stored and open the elasticsearch.yml configuration file.
cd /path/to/elasticsearch-8.10.1/config vim elasticsearch.yml
- Press i to enter the insert mode and add the following configuration information.
cluster.initial_master_nodes: ["localhost"] node.name: localhost network.host: 0.0.0.0 http.port: 9200 http.cors.enabled: true http.cors.allow-origin: "*" discovery.seed_hosts: ["localhost"] xpack.security.enabled: false xpack.security.enrollment.enabled: false xpack.security.http.ssl: enabled: true keystore.path: certs/http.p12 xpack.security.transport.ssl: enabled: true verification_mode: certificate keystore.path: certs/elastic-certificates.p12 truststore.path: certs/elastic-certificates.p12
- Press Esc, type :wq!, and press Enter to save the file and exit.
- Go to the directory where the configuration file is stored and open the elasticsearch.yml configuration file.
- Configure the SSL certificates.
- Go to the Elasticsearch installation directory.
cd /path/to/elasticsearch-8.10.1
- Run the following command:
./bin/elasticsearch-certutil http
- Perform the following operations.
Generate a CSR: Click N. Use an existing CA: Click N. Do you wish to change any of these options? Click N. For how long should your certificate be valid: Enter 5Y. Generate a certificate per node: Click N. Enter all the hostnames that you need, one per line: Enter a server IP address. Enter a server IP address. If you do not need to configure the CA password, press Enter.
- Create the certs folder.
mkdir /path/to/elasticsearch-8.10.1/config/certs
- Unzip the resulting elasticsearch-ssl-http.zip archive to obtain the http.p12 certificate from the elasticsearch folder, and copy the certificate to the /path/to/elasticsearch-8.10.1/config/certs folder.
unzip elasticsearch-ssl-http.zip cp ./elasticsearch/http.p12 /path/to/elasticsearch-8.10.1/config/certs
- Go to the Elasticsearch installation directory.
- Enable authentication via x-pack_xpack.security.transport.ssl.
- Go to the bin directory in the Elasticsearch installation directory.
cd /path/to/elasticsearch-8.10.1/bin
- Run the following commands:
echo 'export PATH=/path/to/elasticsearch-8.10.1/bin:$PATH' >> ~/.bashrc source ~/.bashrc elasticsearch-certutil ca elasticsearch-certutil cert --ca elastic-stack-ca.p12
Enter the following path when prompted with "Please enter the desired output file [elastic-certificates.p12]:"./path/to/elasticsearch-8.10.1/config/certs/elastic-certificates.p12
- Go to the bin directory in the Elasticsearch installation directory.
- Modify the limits.conf configuration file.
- Open the limits.conf file.
vim /etc/security/limits.conf
- Press i to enter the insert mode and add the following four lines:
* soft nofile 65536 * hard nofile 131072 * soft nproc 4096 * hard nproc 65536
- Press Esc, type :wq!, and press Enter to save the file and exit.
- Open the limits.conf file.
- Modify the sysctl.conf configuration file.
- Open the sysctl.conf file.
vim /etc/sysctl.conf
- Press i to enter the insert mode and add the following configuration:
vm.max_map_count=655360
- Press Esc, type :wq!, and press Enter to save the file and exit.
- Run the following command:
sysctl -p
- Open the sysctl.conf file.
- Create an Elasticsearch user and grant permissions to the user.
adduser elasticsearch passwd elasticsearch chown -R elasticsearch:elasticsearch /path/to/elasticsearch-8.10.1
- Switch to the Elasticsearch user.
su - elasticsearch
- Start Elasticsearch.
- Go to the Elasticsearch installation directory.
cd /path/to/elasticsearch-8.10.1
- Start Elasticsearch with 16 cores bound.
numactl -C 0-15 -m 0 ./bin/elasticsearch -d
- Go to the Elasticsearch installation directory.
Parent topic: Installing and Configuring the Environment