Elasticsearch Single Node
| Server IP | Host Role |
|---|---|
| 192.168.10.10 | Elasticsearch Server |
Elasticsearch Node01
-
Download the Elasticsearch installation package
- Server with Internet Access
- Server without Internet Access
wget https://pdpublic.mingdao.com/private-deployment/offline/common/elasticsearch-8.19.8-linux-x86_64.tar.gz# Elasticsearch installation package download link, upload to the deployment server after downloadinghttps://pdpublic.mingdao.com/private-deployment/offline/common/elasticsearch-8.19.8-linux-x86_64.tar.gz -
Download the elasticsearch-ik plugin package
- Server with Internet Access
- Server without Internet Access
wget https://pdpublic.mingdao.com/private-deployment/offline/common/elasticsearch-analysis-ik-8.19.8.zip# Elasticsearch-ik plugin package download link, upload to the deployment server after downloadinghttps://pdpublic.mingdao.com/private-deployment/offline/common/elasticsearch-analysis-ik-8.19.8.zip -
Extract Elasticsearch to the installation directory
tar xf elasticsearch-8.19.8-linux-x86_64.tar.gzmv elasticsearch-8.19.8 /usr/local/elasticsearch -
Extract the elasticsearch-ik plugin to the installation directory
mkdir /usr/local/elasticsearch/plugins/elasticsearch-analysis-ikunzip elasticsearch-analysis-ik-8.19.8.zip -d /usr/local/elasticsearch/plugins/elasticsearch-analysis-ik/ -
Adjust system environment parameters
echo 'vm.max_map_count=262144' >> /etc/sysctl.d/99-sysctl.confecho 'vm.swappiness=1' >> /etc/sysctl.d/99-sysctl.confecho 'net.ipv4.tcp_retries2=5' >> /etc/sysctl.d/99-sysctl.confsysctl -pecho "* soft nofile 65536" >> /etc/security/limits.confecho "* hard nofile 65536" >> /etc/security/limits.confulimit -n 65536 -
Modify the Elasticsearch configuration file
cat > /usr/local/elasticsearch/config/elasticsearch.yml <<'EOF'cluster.name: md-elasticsearch-privatenode.name: elasticsearch-1node.roles: [master,data]network.host: 0.0.0.0http.port: 9200transport.port: 9300path.data: /data/elasticsearch/datapath.logs: /data/elasticsearch/logsingest.geoip.downloader.enabled: falsexpack.security.enabled: truexpack.security.http.ssl.enabled: falsexpack.security.transport.ssl.enabled: falsecluster.max_shards_per_node: 20000discovery.type: single-nodeEOF -
Modify the Elasticsearch JVM memory limit to 4g
sed -ri "s/##[, ]*(-Xm[s|x])[0-9]g/\14g/g" /usr/local/elasticsearch/config/jvm.options -
Create data directories
mkdir -p /data/elasticsearch/{data,logs} -
Create the Elasticsearch user and grant directory permissions
useradd -M -s /sbin/nologin elasticsearchchown -R elasticsearch:elasticsearch /data/elasticsearch /usr/local/elasticsearch -
Configure systemd management
cat > /etc/systemd/system/elasticsearch.service <<'EOF'[Unit]Description=Elasticsearch[Service]User=elasticsearchGroup=elasticsearchLimitNOFILE=102400ExecStart=/usr/local/elasticsearch/bin/elasticsearchExecStop=/usr/bin/kill $MAINPIDRestart=on-failure[Install]WantedBy=multi-user.targetEOF -
Start the Elasticsearch service and enable it to start on boot
systemctl start elasticsearchsystemctl enable elasticsearch -
Configure authentication
/usr/local/elasticsearch/bin/elasticsearch-reset-password -u elastic -i# The password 123456 will not be displayed when entered in the terminal; you can paste it or type it in normally.# In an actual deployment, you must change it to a strong password. If the password contains special characters, only `-` or `_` are allowed. Avoid using characters like `@ ! # &` to prevent compatibility issues.# If resetting the password non-interactively, please ensure the Elasticsearch service is already started:ss -lnt | grep 9200elastic_pwd=123456echo -e "y\n${elastic_pwd}\n${elastic_pwd}" | /usr/local/elasticsearch/bin/elasticsearch-reset-password -u elastic -i
Status Check
Check the service status
systemctl status elasticsearch
Check the Elasticsearch node status
curl -u elastic:123456 127.0.0.1:9200/_cat/health?v
Check installed plugins on the node
curl -u elastic:123456 127.0.0.1:9200/_cat/plugins