Unable to run logstash config file (permission

2019-09-09 03:49发布

问题:

my config file is stored in

/etc/logstash/ 

and I ran the command

$ /etc/logstash -f /etc/logstash/logstash.conf

as root.

However, they told me that permission denied when I tried to do that. Is there any way to solve this?

回答1:

As said, you need to run /opt/logstash/bin/logstash -f /etc/logstash/logstash.conf instead of /etc/logstash -f /etc/logstash/logstash.conf.

This is caused by the default directory structure of your Linux system which logstash uses to put its files in. Wikipedia: Filesystem Hierarchy Standard

/opt stands for optional and contains third party packages which are not part of the default linux distribution. Therefore logstash puts its binaries and some dependencies there (e.g. jRuby stuff). Here you can find the logstash program /opt/logstash/bin/logstash or the plugin manager /opt/logstash/bin/plugin.

/etc means et cetera and is often used for configuration files (like logstash uses it).

There are also other system folders which are used by logstash. For example /var/log/logstash where you can find logstash's own logs. So, when you run the logstash installation (in Ubuntu perhaps with apt-get or dpkg) it puts all the needed files in folders corresponding to the directory structure of your OS.

As you see, you cannot run /etc/logstash -f /etc/logstash/logstash.conf because /etc/logstash is not an executable but a directory.

However, if you run logstash in a command prompt you may also specify other paths for your config file (e.g. /opt/logstash/bin/logstash -f /home/user/logstash.conf). If you run it as a service you cannot provide a path to your config file. Then the default behaviour of logstash is to look for config files in /etc/logstash/



回答2:

Just a complement to the accepted answer. Perhaps you could check another two places:

  1. the right absoluate file path provided in your *.conf input;
  2. try to start by sudo bin/logstash -f your_config_file;