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.18.1-linux-x86_64.tar.gz
# Download link for the Elasticsearch installation package, upload it to the deployment server after downloading
https://pdpublic.mingdao.com/private-deployment/offline/common/elasticsearch-8.18.1-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.18.1.zip
# Download link for the elasticsearch-ik plugin package, upload it to the deployment server after downloading
https://pdpublic.mingdao.com/private-deployment/offline/common/elasticsearch-analysis-ik-8.18.1.zip -
Extract Elasticsearch to the installation directory
tar xf elasticsearch-8.18.1-linux-x86_64.tar.gz
mv elasticsearch-8.18.1 /usr/local/elasticsearch -
Extract the
elasticsearch-ik
plugin to the installation directorymkdir /usr/local/elasticsearch/plugins/elasticsearch-analysis-ik
unzip elasticsearch-analysis-ik-8.18.1.zip -d /usr/local/elasticsearch/plugins/elasticsearch-analysis-ik/ -
Adjust system environment parameters
echo 'vm.max_map_count=262144' >> /etc/sysctl.conf
echo 'vm.swappiness=1' >> /etc/sysctl.conf
echo 'net.ipv4.tcp_retries2=5' >> /etc/sysctl.conf
sysctl -p
echo "* soft nofile 65536" >> /etc/security/limits.conf
echo "* hard nofile 65536" >> /etc/security/limits.conf
ulimit -n 65536 -
Modify the Elasticsearch configuration file
cat > /usr/local/elasticsearch/config/elasticsearch.yml <<EOF
cluster.name: md-elasticsearch-private
node.name: elasticsearch-1
node.roles: [master,data]
network.host: 0.0.0.0
http.port: 9200
transport.port: 9300
path.data: /data/elasticsearch/data
path.logs: /data/elasticsearch/logs
ingest.geoip.downloader.enabled: false
xpack.security.enabled: true
xpack.security.http.ssl.enabled: false
xpack.security.transport.ssl.enabled: false
cluster.max_shards_per_node: 20000
discovery.type: single-node
EOF -
Change Elasticsearch JVM memory limits 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 elasticsearch
chown -R elasticsearch:elasticsearch /data/elasticsearch /usr/local/elasticsearch -
Configure
systemd
managementcat > /etc/systemd/system/elasticsearch.service <<EOF
[Unit]
Description=Elasticsearch
[Service]
User=elasticsearch
Group=elasticsearch
LimitNOFILE=102400
ExecStart=/usr/local/elasticsearch/bin/elasticsearch
ExecStop=/usr/bin/kill \$MAINPID
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF -
Start Elasticsearch service and enable it at startup
systemctl start elasticsearch
systemctl enable elasticsearch -
Configure authentication
/usr/local/elasticsearch/bin/elasticsearch-reset-password -u elastic -i
# The password 123456 will not be displayed on the terminal after entering; normally paste or type it
# Or configure non-interactively, ensuring the service is in a running state first
ss -lnt|grep 9200
elastic_pwd=123456
echo -e 'y\n'$elastic_pwd'\n'$elastic_pwd'' | /usr/local/elasticsearch/bin/elasticsearch-reset-password -u elastic -i