一. 问题描述:
安装好 logstash-input-jdbc 插件,并且完成配置后,由于一些未知的操作,通过命令启动 logstash时
[root@tlxyxx-web1 logstash-5.5.0]# ./bin/logstash -f sql_data/jdbc.conf
出现了如下异常:
Sending Logstash logs to /opt/logstash-5.5.0/logs which is now configured via log4j2.properties
[2019-02-20T12:23:45,931][WARN ][logstash.config.source.multilocal] Ignoring the 'pipelines.yml' file because modules or command line options are specified
[2019-02-20T12:23:46,088][FATAL][logstash.runner ] Logstash could not be started because there is already another instance using the configured data directory. If you wish to run multiple instances, you must change the "path.data" setting.
[2019-02-20T12:23:46,130][ERROR][org.logstash.Logstash ] java.lang.IllegalStateException: Logstash stopped processing because of an error: (SystemExit) exit
根据异常信息可以看出,是因为已经有另一个使用已配置数据目录的实例。如果希望运行多个实例,则必须更改“path.data”设置。
二. 解决方式:
1. 首先找到logstash.yml ,该文件在logstash的安装目录下的config文件夹下
[root@tlxyxx-web1 logstash-5.5.0]# cd /opt/logstash-5.5.0/config/
[root@tlxyxx-web1 config]# ls
jvm.options log4j2.properties logstash.yml startup.options
2. 打开logstash.yml文件找到 Data path 的路径(默认在安装目录的data目录下)。
[root@tlxyxx-web1 config]# vi logstash.yml
# Settings file in YAML
#
# Settings can be specified either in hierarchical form, e.g.:
#
# pipeline:
# batch:
# size: 125
# delay: 5
#
# Or as flat keys:
#
# pipeline.batch.size: 125
# pipeline.batch.delay: 5
#
# ———— Node identity ————
#
# Use a descriptive name for the node:
#
# node.name: test
#
# If omitted the node name will default to the machine’s host name
#
# ———— Data path ——————
#
# Which directory should be used by logstash and its plugins
# for any persistent needs. Defaults to
LOGSTASH_HOME/data
#
# path.data:
#
# ———— Pipeline Settings ————–
#
3. 打开安装目录的data文件夹,看是否有 .lock 文件。
[root@tlxyxx-web1 data]# cd /opt/logstash-5.5.0/data
[root@tlxyxx-web1 data]# ls -a
. .. dead_letter_queue .lock queue uuid
4. 如果有.lock文件,删除即可。