System Preparation
To streamline the installation process on Ubuntu 24.04, organize the required binary distributions and the IK Analysis plugin into a unified archive. Ensure the following files are prepared in your working directory:
- elasticsearch-8.13.4-linux-x86_64.tar.gz
- kibana-8.13.4-linux-x86_64.tar.gz
- elasticsearch-anlaysis-ik-8.13.4.zip
- Corresponding SHA512 checksum files
Management Script Architecture
The following modular script provides a centralized interface for managing Elasticsearch and Kibana lifecycles, including installation, service control, and security credential management.
#!/bin/bash
# Configuration settings
readonly ES_VER="8.13.4"
readonly INSTALL_BASE="/opt/elastic_stack"
function deploy_elasticsearch() {
useradd -m es_service
mkdir -p "$INSTALL_BASE"
tar -xzf elasticsearch-${ES_VER}-linux-x86_64.tar.gz -C "$INSTALL_BASE"
# Install IK Plugin
local plugin_dir="${INSTALL_BASE}/elasticsearch-${ES_VER}/plugins/ik"
mkdir -p "$plugin_dir"
unzip elasticsearch-analysis-ik-${ES_VER}.zip -d "$plugin_dir"
chown -R es_service:es_service "$INSTALL_BASE"
# Systemd service setup
cat > /etc/systemd/system/elasticsearch.service <<EOL
[Unit]
Description=Elasticsearch Service
After=network-online.target
[Service]
User=es_service
Group=es_service
ExecStart=${INSTALL_BASE}/elasticsearch-${ES_VER}/bin/elasticsearch
LimitNOFILE=65536
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOL
systemctl daemon-reload
systemctl start elasticsearch
}
# Add logic for Kibana and additional maintenance options as required
Verifying IK Analyzer
After deployment, confirm the IK analsyis plugin is active by indexing a test document and verifying tokenization:
PUT /analyzer_test
{
"settings": {
"analysis": {
"analyzer": {
"custom_ik": { "tokenizer": "ik_max_word" }
}
}
}
}
POST /analyzer_test/_analyze
{
"analyzer": "custom_ik",
"text": "Elasticsearch distributed search engine"
}
Clustered Deployment
For high availability, distribute the configuration across multiple nodes. Use the following YAML snippet as a template for elasticsearch.yml on each node:
cluster.name: production-cluster
node.name: node-01
network.host: 0.0.0.0
discovery.seed_hosts: ["192.168.1.10:9300", "192.168.1.11:9300"]
cluster.initial_master_nodes: ["node-01", "node-02"]
xpack.security.enabled: true
Monitoring with Metricbeat
To monitor your cluster health, deploy Metricbeat to collect node-level metrics:
# Extract and configure
tar xzvf metricbeat-8.13.4-linux-x86_64.tar.gz
./metricbeat modules enable elasticsearch
# Update modules.d/elasticsearch.yml
- module: elasticsearch
metricsets: ["node", "cluster_stats", "index"]
hosts: ["http://localhost:9200"]
period: 10s
# Launch background service
./metricbeat setup
./metricbeat -e