Skip to content

Latest commit

 

History

History
345 lines (261 loc) · 9.73 KB

File metadata and controls

345 lines (261 loc) · 9.73 KB
Title 🧠 Cerebro
Group Monitoring
Icon 🧠
Order 9
tags
monitoring
sysadmin
linux

Cerebro (Elasticsearch Admin) Sysadmin Cheatsheet

Cerebro is an open-source web administration tool for Elasticsearch clusters, developed by Leonardo Menezes. It is the successor to the deprecated Elasticsearch Kopf plugin. Cerebro provides a visual interface for cluster monitoring, index management, node operations, and REST API queries.

Common use cases / Типичные сценарии: Elasticsearch cluster health monitoring, index management (create, delete, open/close), shard visualization, alias management, template editing, snapshot management, REST API exploration.

Status / Статус: Cerebro is still functional but no longer actively maintained (last release 0.9.4 in 2021). Modern alternatives include Kibana (official Elastic UI with full management), Elasticsearch Head (Chrome extension), ElasticVue (modern Vue.js-based UI), OpenSearch Dashboards (for OpenSearch clusters).

Default port / Порт по умолчанию: 9000/tcp (Cerebro UI)


📚 Table of Contents


1. Installation & Configuration

Install Cerebro

# Download latest release
RELEASE="0.9.4"
wget "https://github.com/lmenezes/cerebro/releases/download/v${RELEASE}/cerebro-${RELEASE}.tgz"
tar -xzf cerebro-${RELEASE}.tgz
mv cerebro-${RELEASE} /opt/cerebro

Install via Docker

# Run Cerebro in Docker
docker run -d --name cerebro \
  -p 9000:9000 \
  -e CEREBRO_PORT=9000 \
  lmenezes/cerebro:latest

# Or with custom config
docker run -d --name cerebro \
  -p 9000:9000 \
  -v /etc/cerebro/application.conf:/opt/cerebro/conf/application.conf:ro \
  lmenezes/cerebro:latest

Main Configuration

/opt/cerebro/conf/application.conf

# Server settings
play {
  server.http.port = 9000
}

# Elasticsearch cluster connections
hosts = [
  {
    host = "http://<ES_HOST_1>:9200"
    name = "Production Cluster"
  },
  {
    host = "http://<ES_HOST_2>:9200"
    name = "Staging Cluster"
  }
]

# Authentication (optional)
auth = {
  type: "basic"
  settings {
    username = "<USER>"
    password = "<PASSWORD>"
  }
}

# LDAP authentication
# auth = {
#   type: "ldap"
#   settings {
#     url = "ldap://<LDAP_HOST>:389"
#     base-dn = "dc=example,dc=com"
#     method = "simple"
#     user-template = "uid=%s,ou=users,dc=example,dc=com"
#   }
# }

Systemd Service

/etc/systemd/system/cerebro.service

[Unit]
Description=Cerebro - Elasticsearch Web Admin
After=network.target

[Service]
Type=simple
User=cerebro
Group=cerebro
WorkingDirectory=/opt/cerebro
ExecStart=/opt/cerebro/bin/cerebro -Dconfig.file=/opt/cerebro/conf/application.conf
Restart=always
LimitNOFILE=65536

[Install]
WantedBy=multi-user.target
# Create user and set permissions
useradd -r -s /sbin/nologin cerebro
chown -R cerebro:cerebro /opt/cerebro

# Enable and start
systemctl daemon-reload
systemctl enable --now cerebro

2. Core Management

Web UI Access

http://<HOST>:9000    # Cerebro dashboard / Панель Cerebro

On first access, enter your Elasticsearch cluster URL to connect. / При первом доступе введите URL вашего кластера Elasticsearch.

Cerebro UI Features

Feature Description / Описание
Overview Cluster health, nodes, shards visual map / Здоровье кластера, узлы, визуальная карта шардов
Nodes Node stats (heap, CPU, disk, load) / Статистика узлов
Rest Execute Elasticsearch REST API queries / Выполнение REST-запросов к ES
Aliases Manage index aliases / Управление алиасами индексов
Templates View/edit index templates / Просмотр/редактирование шаблонов
Cluster Settings View/modify cluster-level settings / Настройки кластера
Index Settings Per-index settings, replicas, routings / Настройки индексов
Snapshots Manage repository snapshots / Управление snapshot-репозиториями
Cat API Visual /_cat API browser / Визуальный браузер Cat API

Useful Elasticsearch API Queries via Cerebro

# Cluster health
GET /_cluster/health

# Node stats
GET /_nodes/stats

# Index list
GET /_cat/indices?v&s=store.size:desc

# Shard allocation
GET /_cat/shards?v&s=store:desc

# Pending tasks
GET /_cluster/pending_tasks

# Check disk allocation
GET /_cat/allocation?v

3. Sysadmin Operations

Service Management

systemctl start cerebro      # Start / Запустить
systemctl stop cerebro       # Stop / Остановить
systemctl restart cerebro    # Restart / Перезапустить
systemctl enable cerebro     # Enable on boot / Автозапуск
systemctl status cerebro     # Check status / Проверить статус

Important Paths

Path Description / Описание
/opt/cerebro/ Cerebro installation directory / Каталог установки
/opt/cerebro/conf/application.conf Main configuration / Основной конфиг
/opt/cerebro/logs/ Application logs / Логи приложения

JVM Tuning

/opt/cerebro/conf/jvm.options or environment variable:

# Set JVM heap size
export JAVA_OPTS="-Xms256m -Xmx512m"

# Or in systemd override
# /etc/systemd/system/cerebro.service.d/override.conf
# [Service]
# Environment="JAVA_OPTS=-Xms256m -Xmx512m"

Firewall Configuration

# Allow Cerebro port
firewall-cmd --permanent --add-port=9000/tcp
firewall-cmd --reload

Tip

For security, do not expose Cerebro to the public internet. Use a VPN or SSH tunnel. / Не выставляйте Cerebro в публичный интернет. Используйте VPN или SSH-туннель.


4. Security

Authentication Types

Type Description / Описание Best For / Лучше для
None No auth (default) / Без аутентификации Development / Разработка
Basic Username/password in config / Логин/пароль в конфиге Small teams / Маленькие команды
LDAP Corporate directory integration / Интеграция с каталогом Enterprise / Корпоративное

Reverse Proxy with TLS

/etc/nginx/conf.d/cerebro.conf

server {
    listen 443 ssl;
    server_name cerebro.<DOMAIN>;

    ssl_certificate     /etc/ssl/certs/cerebro.crt;
    ssl_certificate_key /etc/ssl/private/cerebro.key;

    location / {
        proxy_pass http://127.0.0.1:9000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

Warning

Cerebro has full access to your Elasticsearch cluster. Anyone with Cerebro access can delete indices, change settings, and modify data. / Cerebro имеет полный доступ к кластеру Elasticsearch. Обеспечьте надлежащую защиту.


5. Troubleshooting & Tools

Common Issues

1. Cerebro Cannot Connect to Elasticsearch / Cerebro

# Check Elasticsearch connectivity
curl -s http://<ES_HOST>:9200/_cluster/health | jq .

# Check Cerebro logs
tail -50 /opt/cerebro/logs/application.log

# Verify network
curl -v http://<ES_HOST>:9200

2. Cerebro UI Loads Slowly

# Check JVM heap usage
jcmd $(pgrep -f cerebro) VM.heap_info 2>/dev/null

# Increase JVM heap
# Set JAVA_OPTS="-Xms512m -Xmx1g"

3. Cluster Shows Red/Yellow Status

This is an Elasticsearch issue, not Cerebro. Use Cerebro's UI to diagnose: / Это проблема Elasticsearch, не Cerebro. Используйте Cerebro для диагностики:

# In Cerebro REST tab
GET /_cluster/health
GET /_cat/shards?v&h=index,shard,prirep,state,unassigned.reason&s=state
GET /_cluster/allocation/explain
Status Description / Описание Action / Действие
Green / Зелёный All shards assigned / Все шарды назначены None / Ничего
Yellow / Жёлтый Primary OK, replicas unassigned / Первичные ОК, реплики не назначены Add nodes or reduce replicas / Добавить узлы или уменьшить реплики
Red / Красный Primary shards unassigned / Первичные шарды не назначены Immediate investigation / Срочное расследование

6. Logrotate Configuration

/etc/logrotate.d/cerebro

/opt/cerebro/logs/*.log {
    daily
    rotate 7
    compress
    delaycompress
    missingok
    notifempty
    create 640 cerebro cerebro
}

Documentation Links