首页 > 代码库 > elk systemd管理

elk systemd管理

1.logstash

/etc/systemd/system/logstash.service
Type=simple
User=logstash
Group=logstash
# Load env vars from /etc/default/ and /etc/sysconfig/ if they exist.
# Prefixing the path with ‘-‘ makes it try to load, but if the file doesn‘t
# exist, it continues onward.
EnvironmentFile=-/etc/default/logstash     #这个配置文件很重要,记得增加JAVACMD路径
EnvironmentFile=-/etc/sysconfig/logstash
ExecStart=/opt/app/logstash/bin/logstash "--path.settings" "/opt/app/logstash/config"
Restart=always
WorkingDirectory=/
Nice=19
LimitNOFILE=16384

[Install]
WantedBy=multi-user.target
/etc/default/logstash

JAVACMD="/opt/app/jdk/bin/java"
LS_HOME="/opt/app/logstash"
LS_SETTINGS_DIR="/opt/app/logstash/config"
LS_PIDFILE="/opt/app/logstash/run/logstash.pid"
LS_USER="logstash"
LS_GROUP="logstash"
LS_GC_LOG_FILE="/data/logs/logstash/gc.log"
LS_OPEN_FILES="16384"
LS_NICE="19"
SERVICE_NAME="logstash"
SERVICE_DESCRIPTION="logstash"

2.kibana

/etc/systemd/system/kibana5.service
[Unit]
Description=kibana

[Service]
Type=simple
User=kibana
Group=kibana
ExecStart=/opt/app/kibana/bin/kibana
Restart=always

[Install]
WantedBy=multi-user.target

3.elasticsearch

/etc/systemd/system/es5.service

[Unit]
Description=es5
#After=network.target

[Service]
Type=simple
User=es
Group=es
EnvironmentFile=-/etc/default/es5
ExecStart=/opt/app/es5/bin/elasticsearch
LimitNOFILE=655350
Restart=on-failure

[Install]
WantedBy=multi-user.target

/etc/default/es5

ES_USER="es"
ES_GROUP="es"
JAVA_HOME="/opt/app/jdk"
LOG_DIR="/data/logs/es5"
MAX_OPEN_FILES=655350
MAX_MAP_COUNT=262144
CONF_DIR="/opt/app/es5/config"
DATA_DIR="/data/es5"
#ES_JAVA_OPTS
#MAX_LOCKED_MEMORY
#RESTART_ON_UPGRADE

 

elk systemd管理