Logstash: how to reset everything - logstash

I'm new to Logstash and Elasticsearch.
After some tests I want to restart and make a new index.
However, I'm getting this:
root#imageoffice:/etc/logstash/conf.d# sudo -Hu root /usr/share/logstash/bin/logstash --path.settings /etc/logstash/
Sending Logstash logs to /usr/share/logstash/logs which is now configured via log4j2.properties
[2019-04-22T17:00:04,910][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-04-22T17:00:04,965][ERROR][org.logstash.Logstash ] java.lang.IllegalStateException: Logstash stopped processing because of an error: (SystemExit) exit
How can I simple reset everything and run the sudo -Hu root /usr/share/logstash/bin/logstash --path.settings /etc/logstash/ command succesfull?

The error message tells you that there's already a logstash running on your machine. If you don't want the old one running, shut it down or kill it.
Typically, logstash is managed through a startup script (systemd, etc).

Removed the .lock file from bin/data and the error was gone.

Related

logstash load plugin configuration on server restart

so if I understand correctly to load logstash with some input config I need to run
bin/logstash -f logstash-simple.conf
how I automate this process so if my server will restart it will auto load some configs?
the docs not talking about this at all
edit: I am not 100% sure but it looks like the configs files shout be on /etc/logstash/conf.d/
use this command for systems that use upstart
sudo systemctl start logstash.service
The required configuration file for upstart systems is
/etc/init/logstash.conf

Filebeat command not found

I am running ELK in a docker container at localhost, I am trying to start filebeat (not through docker container) but I am receiving the error below.
/etc/init.d/filebeat: command not found
Has anyone had similar issues or any idea how to resolve this?
Also they have mentioned:
If you use an init.d script to start Filebeat on deb or rpm, you can’t specify command line flags (see Command Line Options). To specify flags, start Filebeat in the foreground.
But don't understood. I have checked a lot but nothing helped. I am running this in ubuntu 16.10
Sounds like you want to start filebeat on the host but you don't have it installed
https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-installation.html
Since you are using a Linux distribution with systemd, have you tried starting filebeat as a systemd service? Check the status:
systemctl status -l filebeat
If that returns info about the service, then filebeat is set up to be a systemd service, not an init.d spawn. Enable it to have it persist after reboot with:
sudo systemctl enable filebeat
And start it with:
sudo systemctl start filebeat

How to reload nginx config if it is running or start if it's stopped?

I update nginx config files periodically and due to technical issues sometimes it can happen that nginx is not running.
In this case if I run nginx -s reload, I see this error:
nginx: [error] open() "/run/nginx.pid" failed (2: No such file or directory)
How can I reload nginx config with the command from above if it's running or start if it's not running without seeing that error?
If you can't count on the fact that nginx is already running then you should just restart it. But, if you really want the above, assuming you're running on linux/unix and it looks like you are then you can create a tiny shell script. Again, assuming your default shell is bash or bash compatible (other shells would have to be ported) you could do something like this:
#!/bin/sh
if [ -f /run/nginx.pid ]; then
/path/to/nginx -s reload
else
/path/to/whatever/command/starts/nginx
fi
You can take the above to a whole new level by using inotify. Again, assuming you're running a Linux distribution, you can install your OS distribution's inotify-tools package and automate running the above script file every time your config files change. See this for more info on using inotify:
How to execute a command when a file changes

apache2 cannot be restarted :Action 'start' failed

I have a linux server that contains many websites under vhosts, once I deleted an alt site the apache2 coud not be restarted indecating this message in the error log:
#eror log
(2)No such file or directory: apache2: could not open error log file /var/www/vhosts/deleted_Site/logs/error.log.
Unable to open logs
How can I stop that so I can start my apache2
You should modify your apache configuration, for instance in conf.d/, all configuration related to your old website, especially for error logs (look for access logs and errors logs directives specification, somewhere in your conf files, apache2.conf, httpd.conf, sites-enabled, mods or what/wherever it is).
To resolve this error, you need to stop other process using same port. In some of cases it is nginx. you can stop it
sudo /etc/init.d/nginx stop
Turn off any servers using the same port. For example to turn off nginx try this:
sudo systemctl stop nginx

ActiveMQ seems to start but then I can't see it with netstat or ps

I start up ActiveMQ anid this is the output:
INFO: Loading '/etc/default/activemq'
INFO: Using java '/usr/bin/java'
INFO: Starting - inspect logfiles specified in logging.properties and log4j.properties to get details
INFO: pidfile created : '/opt/activemq/data/activemq-localhost.pid' (pid '5282')
But then netstat -a | grep 61616 returns nothing, and the pid that it named when it started is not included when I run the ps command. What could be causing this to happen?
To debug startup failures is good to run the broker in foreground mode via:
./activemq console
This will cause errors to be logged on the console. You can also check the logfile in the data folder in your activemq installation dir.
Two things that I use.
1) What Tim said in his answer. Set your activemq instance to start in console mode via activemq console. Other wise it will start logging to /dev/null \
2) Crank yoru debug output level up so you can see more detail via log4j.logger.org.apache.activemq=DEBUG
You should try to delete (or better rename to .old like suggested earlier) the /etc/default/activemq file. This fixed the problem for me.

Resources