Elasticsearch listening on /127.0.0.1:9001 . Also shows Main PID: 12471 (code=exited, status=1/FAILURE) error messages- ubuntu server 16.04.3


(BSAI Techno Sales) #3

SonarQube is an open source platform for continuous inspection of code quality to perform automatic reviews with static analysis of code to detect bugs, code smells and security vulnerabilities


(David Pilato) #4

Please format your code. I edited your post.

What are elasticsearch logs?


(BSAI Techno Sales) #5

Please find the log output from below

**oot@storage:/opt/sonar/elasticsearch/logs# more elasticsearch.log**
[2018-01-09T17:10:20,404][ERROR][o.e.b.Bootstrap          ] Exception
java.lang.RuntimeException: can not run elasticsearch as root
	at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:106) ~[elasticsearch-5.6.3.jar:5.6.3]
	at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:195) ~[elasticsearch-5.6.3.jar:5.6.3]
	at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:342) [elasticsearch-5.6.3.jar:5.6.3]
	at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:132) [elasticsearch-5.6.3.jar:5.6.3]
	at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:123) [elasticsearch-5.6.3.jar:5.6.3]
	at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:70) [elasticsearch-5.6.3.jar:5.6.3]
	at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:134) [elasticsearch-5.6.3.jar:5.6.3]
	at org.elasticsearch.cli.Command.main(Command.java:90) [elasticsearch-5.6.3.jar:5.6.3]
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91) [elasticsearch-5.6.3.jar:5.6.3]
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84) [elasticsearch-5.6.3.jar:5.6.3]
[2018-01-09T17:10:20,409][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
	at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:136) ~[elasticsearch-5.6.3.jar:5.6.3]
	at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:123) ~[elasticsearch-5.6.3.jar:5.6.3]
	at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:70) ~[elasticsearch-5.6.3.jar:5.6.3]
	at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:134) ~[elasticsearch-5.6.3.jar:5.6.3]
	at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-5.6.3.jar:5.6.3]
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91) ~[elasticsearch-5.6.3.jar:5.6.3]
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84) ~[elasticsearch-5.6.3.jar:5.6.3]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
	at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:106) ~[elasticsearch-5.6.3.jar:5.6.3]
	at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:195) ~[elasticsearch-5.6.3.jar:5.6.3]
	at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:342) ~[elasticsearch-5.6.3.jar:5.6.3]
	at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:132) ~[elasticsearch-5.6.3.jar:5.6.3]
	... 6 more

root@storage:/opt/sonar/elasticsearch/logs# pwd
/opt/sonar/elasticsearch/logs

root@storage:/opt/sonar/elasticsearch/logs#

Just incase if you need to see sonar.log then below is here with

root@storage:/opt/sonar/logs# more sonar.log

--> Wrapper Started as Daemon
Launching a JVM...
Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
  Copyright 1999-2006 Tanuki Software, Inc.  All Rights Reserved.

2018.01.07 15:23:08 INFO  app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /opt/sonar/temp
2018.01.07 15:23:08 INFO  app[][o.s.a.es.EsSettings] Elasticsearch listening on /127.0.0.1:9001
2018.01.07 15:23:08 INFO  app[][o.s.a.p.ProcessLauncherImpl] Launch process[[key='es', ipcIndex=1, logFilenamePrefix=es]] from [/opt/sonar/elasticsea
rch]: /opt/sonar/elasticsearch/bin/elasticsearch -Epath.conf=/opt/sonar/temp/conf/es
_**2018.01.07 15:23:08 INFO  app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running**_
_**2018.01.07 15:23:08 INFO  app[][o.e.p.PluginsService] no modules loaded**_
_**2018.01.07 15:23:08 INFO  app[][o.e.p.PluginsService] loaded plugin [org.elasticsearch.transport.Netty4Plugin]**_
_**2018.01.07 15:23:08 WARN  app[][o.s.a.p.AbstractProcessMonitor] Process exited with exit value [es]: 1**_
_**2018.01.07 15:23:08 INFO  app[][o.s.a.SchedulerImpl] Process [es] is stopped**_
_**2018.01.07 15:23:08 INFO  app[][o.s.a.SchedulerImpl] SonarQube is stopped**_
<-- Wrapper Stopped
--> Wrapper Started as Daemon
Launching a JVM...
Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
  Copyright 1999-2006 Tanuki Software, Inc.  All Rights Reserved.

(David Pilato) #6

Please format your logs with </>.

Caused by: java.lang.RuntimeException: can not run elasticsearch as root

Don't run elasticsearch as root.


(BSAI Techno Sales) #7

Hi Dadoonet
I trigger as following commandfrom example user but it ask for root. How do
i change the user previlege so that i can run it from example user

example@storage:/opt/sonar/elasticsearch/bin$ /etc/init.d/elasticsearch
stopt
You need root privileges to run this script

example@storage:/opt/sonar/elasticsearch/bin$ /etc/init.d/elasticsearch stop
You need root privileges to run this script

example@storage:/opt/sonar/elasticsearch/bin$ /etc/init.d/elasticsearch
start
You need root privileges to run this script

example@storage:/opt/sonar/elasticsearch/bin$ sudo
/etc/init.d/elasticsearch start
[sudo] password for bsaitechnosales:
[ ok ] Starting elasticsearch (via systemctl): elasticsearch.service.
example@storage:/opt/sonar/elasticsearch/bin$

example@storage:/opt/sonar/elasticsearch/bin$ /etc/init.d/elasticsearch
status

You need root privileges to run this script

example@storage:/opt/sonar/elasticsearch/bin$ sudo
/etc/init.d/elasticsearch status

● elasticsearch.service - Elasticsearch
Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; disabled;
vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2018-01-10 17:53:34 +0545;
2min 34s ago
Docs: http://www.elastic.co
Process: 20633 ExecStart=/usr/share/elasticsearch/bin/elasticsearch
-Des.pidfile=${PID_DIR}/elasticsearch.pid -Des.default.path.home=${ES_HOME}
-Des.default.path.logs=${LOG_DIR} -Des.default.path.data=${DATA_DIR}
-Des.default.path.conf=${CONF_DIR} (code=exited, status=1/FAILURE)
Process: 20630
ExecStartPre=/usr/share/elasticsearch/bin/elasticsearch-systemd-pre-exec
(code=exited, status=0/SUCCESS)
Main PID: 20633 (code=exited, status=1/FAILURE)

Jan 10 17:53:33 storage systemd[1]: Starting Elasticsearch...
Jan 10 17:53:33 storage systemd[1]: Started Elasticsearch.
Jan 10 17:53:34 storage elasticsearch[20633]: Exception in thread "main"
SettingsException[Failed to load settings from [elasticsearch.yml]]; nest...
Jan 10 17:53:34 storage elasticsearch[20633]: in 'reader', line 96, column
1:
Jan 10 17:53:34 storage systemd[1]: elasticsearch.service: Main process
exited, code=exited, status=1/FAILURE
Jan 10 17:53:34 storage systemd[1]: elasticsearch.service: Unit entered
failed state.
Jan 10 17:53:34 storage systemd[1]: elasticsearch.service: Failed with
result 'exit-code'.
Hint: Some lines were ellipsized, use -l to show in full.
bsaitechnosales@storage:/opt/sonar/elasticsearch/bin$


(David Pilato) #8

Please format your code using </> icon as explained in this guide. It will make your post more readable.

Or use markdown style like:

```
CODE
```

(BSAI Techno Sales) #9

Is it ok if i paste in this way


(David Pilato) #10

Please don't post images of text as they are hardly readable and not searchable.

Instead paste the text and format it with </> icon. Check the preview window.


(BSAI Techno Sales) #11

Noted. Is it ok now ? Assume example as bsaitechnosales


(David Pilato) #12

Much better. Thanks.

Not sure how you installed elasticsearch. Did you follow all the steps mentioned in the installation guide?


(BSAI Techno Sales) #13

yes i did follow the steps. i followed online website for the installation


(David Pilato) #14

Can you tell me how you did install elasticsearch please?


(BSAI Techno Sales) #15

I follow the steps from this url


(Mark Walkom) #16

This is why.

That's ~3 years old. Check out https://www.elastic.co/guide/en/elastic-stack/current/installing-elastic-stack.html


(David Pilato) #17

I should have been more precise about "Did you follow all the steps mentioned in the installation guide?" :stuck_out_tongue:


(BSAI Techno Sales) #18

So how do i redo it again ? I am about to follow the below mentioned steps provided by this url https://www.elastic.co/guide/en/beats/libbeat/current/elasticsearch-installation.html

Let me know what you suggest ?

CODE

(BSAI Techno Sales) #19

Yes I did. I follow according to that url which i send you earlier


(BSAI Techno Sales) #20

Now I am getting following error. Please suggest


(David Pilato) #21

Actually when I said

Much better.

I was wrong. You are using the citation icon instead of </>.

So please fix the format. It should be like:

bsaitechnosales@storage:~/Downloads$ sudo /etc/init.d/elasticsearch start
Starting elasticsearch: /etc/init.d/elasticsearch: line 108: daemon:
command not found

bsaitechnosales@storage:~/Downloads$ sudo service elasticsearch status
● elasticsearch.service - Elasticsearch
Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2018-01-11 16:59:06 +0545; 8s ago
Docs: http://www.elastic.co
Process: 28630 ExecStart=/usr/share/elasticsearch/bin/elasticsearch -p ${PID_DIR}/elasticsearch.pid --quiet (code=exited, status=1/FAILURE)
Main PID: 28630 (code=exited, status=1/FAILURE)

Jan 11 16:59:06 storage systemd[1]: Started Elasticsearch.
Jan 11 16:59:06 storage elasticsearch[28630]: /usr/share/elasticsearch/bin/elasticsearch-env: line 70: /etc/sysconfig/elasticsearch: Permission denied
Jan 11 16:59:06 storage systemd[1]: elasticsearch.service: Main process exited, code=exited, status=1/FAILURE
Jan 11 16:59:06 storage systemd[1]: elasticsearch.service: Unit entered failed state.
Jan 11 16:59:06 storage systemd[1]: elasticsearch.service: Failed with result 'exit-code'.
...skipping...

Thanks.

Then about your question. This is important indeed:

line 70: /etc/sysconfig/elasticsearch: Permission denied

It indicates that this file can not be read by elasticsearch. Which probably means that you did not clean all the existing files before reinstalling.

I'd probably check the rights for this file.


(BSAI Techno Sales) #22

lets do from start. I have uninstall elasticsearch in following way. Now
let's start in a clean way. Please suggest me the steps for installing
elasticsearch. This time i would like to follow your instructions

(1) Remove previous versions of ElasticSearch:

sudo apt-get --purge autoremove elasticsearch

(2) Remove the ElasticSearch directories:

sudo rm -rf /var/lib/elasticsearch/
sudo rm -rf /etc/elasticsearch
sudo rm -rf /opt/sonar/elasticsearch
sudo rm -rf /usr/share/elasticsearch/

(3) Search and Remove
bsaitechnosales@storage:~$ sudo find / "elasticsearch" | grep "elasticsearch"
/etc/systemd/system/multi-user.target.wants/elasticsearch.service
/root/Downloads/elasticsearch-6.1.1.rpm
/root/Downloads/elasticsearch-2.3.1.deb
/home/bsaitechnosales/Downloads/elasticsearch-6.1.1.rpm
/tmp/hsperfdata_elasticsearch
find: ‘/run/user/1000/gvfs’: Permission denied
/opt/sonar/lib/common/elasticsearch-rest-client-5.6.3.jar
/opt/sonar/lib/common/elasticsearch-5.6.3.jar
/opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/peek-1.0.1/lib/peek/adapters/elasticsearch.rb
find: ‘elasticsearch’: No such file or directory
bsaitechnosales@storage:~$ sudo rm -rf /tmp/hsperfdata_elasticsearch
bsaitechnosales@storage:~$ sudo rm -rf etc/systemd/system/multi-user.target.wants/elasticsearch*