Can't run Sonar Server caused by Elasticsearch cannot running as root - linux

I'm trying to install SonarQube : i ve followed those steps :
Setting up SOnarQube Tuto : here
To summarize it :
Downloading Sonar and moving it to /opt/sonar
adding those coonfig steps to /opt/sonar/conf/sonar.properties :
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance
and
sonar.web.host=127.0.0.1
sonar.web.context=/sonar
sonar.web.port=9000
implementing sonar as a service:
sudo cp /opt/sonar/bin/linux-x86-64/sonar.sh /etc/init.d/sonar
sudo gedit /etc/init.d/sonar
Insert two new lines:
SONAR_HOME=/opt/sonar
PLATFORM=linux-x86-64
Modify the following lines:
WRAPPER_CMD="${SONAR_HOME}/bin/${PLATFORM}/wrapper"
WRAPPER_CONF="${SONAR_HOME}/conf/wrapper.conf"
...
PIDDIR="/var/run"
Register as a Linux service:
sudo update-rc.d -f sonar remove
sudo chmod 755 /etc/init.d/sonar
sudo update-rc.d sonar defaults
After those steps : i ve tried to run Sonar from : localhost:9000/sonar and after executing : sudo /etc/init.d/sonar start
`
Strangely , it didsn't run .
SO when i run `sudo /etc/init.d/sonar status , i discover that it goes steps after few seconds , and it throws some error in it log file , like the following :
es.log:
2017.12.09 18:05:14 ERROR es[][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]
2017.12.09 18:05:14 WARN es[][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
Any suggestions ??

SonarSource has upgraded the Elasticsearch tool used as a part of the latest SonarQube LTS version. As a result SonarQube cannot be run as a root. See this blog and the SonarQube 6.6 upgrade notes and this SO question.

Change the root access to the sonar file. Try running in normal user access.
chown <another user>:<user group> sonar.sh

I was facing the same issue and spend good amount of time before getting the solution.
Error was same as
2017.12.09 18:05:14 ERROR es[][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]
Solution
Create a ‘sonar’ user using adduser command //I was using linux system
chown -R sonar sonar-install-folder/
Edit the sonar.sh file sonar-install-folder/bin/linux-x86-6 in start script and change the #RUN_AS_USER to be RUN_AS_USER=sonar
And then use below commands
./sonar.sh stop
Gracefully stopping SonarQube...
SonarQube was not running.
./sonar.sh start
Starting SonarQube...
Started SonarQube.
./sonar.sh status
SonarQube is running (22100).
So, basically elastic search doesnt require to be run by root user. By default the RUN_AS_USER was commented in the startup script which was picking my current user which was root, and then some linux permission rules come into picture due to which elasticsearch process was not getting up and which was causing sonar process to go down as well.
It was evident from sonar.log
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
2020.05.08 06:36:36 WARN app[][o.s.a.p.AbstractManagedProcess] Process exited with exit value [es]: 78
2020.05.08 06:36:36 INFO app[][o.s.a.SchedulerImpl] Process[es] is stopped
2020.05.08 06:36:36 INFO app[][o.s.a.SchedulerImpl] SonarQube is stopped

Create new user to run the sonarQube or access the SonarQube dashboard
for ubuntu flavour user creation.
#sudo adduser sonar.
after executing the above command it will ask for passwd
#adduser sonar sudo
#adduser sonar admin
#sudo su sonar
chown sonar:sonar sonar.sh

Related

Failed to start Postgres on Debian

Postgres (13.5) cannot start after restarting server (Debian 4.19.208-1)
UPDATE 1
I changed user permissions and now I have another error on starting postgres:
systemctl status postgresql
FATAL: lock file "postmaster.pid" already exists
But I checked pg clusters and there exists only one:
Also I deleted postmaster.pid and there is no file any more:
So I have no errors details but postrges is shutting down.
Any ideas?
==============================================================
I'm trying to start manually sudo service postgresql start but got error:
Job for postgresql.service failed because the control process exited with error code. See "systemctl status postgresql.service" and "journalctl -xe" for details.
So then I ran systemctl status postgresql
Results:
FATAL: data directory "/var/lib/postgresql/13/main" has invalid permissions
DETAIL: Permissions should be u=rwx (0700) or u=rwx,g=rx (0750).
I modified permissions:
chmod u=rwx /var/lib/postgresql/13/main
chmod g=rx /var/lib/postgresql/13/main
But I still see the same error about permissions.
You can see whole results on screenshot
Sorry, I'm not so familiar with Linux
I fixed this problem. I ran postgres not as a service but with logs:
postgresql -D /var/lib/postgresql/13/main
And I saw in the log that problem was with pg_hba.conf. I opened this file - it was empty!
So I restored pg_hba.conf from backup and started postgres as service

getting "java.io.IOException: error=24, Too many open files" when I try to run BigBlueButton

I've installed a clean BigBlueButton on Ubuntu server but when I try to run it I can't and when I tried to debug I got this error.
java.io.IOException: error=24, Too many open files
Mar 12 05:35:11 NC-PH-2486 run-prod.sh[27006]: org.apache.catalina.LifecycleException: Failed to start component
Can anyone help?
Try changing LimitNOFILE=8024 from 1024 in /lib/systemd/system/bbb-web.service and then "sudo systemctl restart bbb-web".
Also note that BigBlueButton won't scale to use all of those cores.
Ref:
https://groups.google.com/forum/#!searchin/bigbluebutton-setup/LimitNOFILE|sort:date/bigbluebutton-setup/NkIt3Dq4HhY/nE0d31uoDgAJ

How to configure yb-cdc-connector to resume printing logs upon yugabyte db restart (stop and start)?

Following, How to capture data change in yugabyte db?
to publish the change logs.
It works properly. But, yb-connector.jar is not resuming the publishing change data logs, after restarting yugabyte db.
Commands Executed:
wget -O yb-cdc-connector.jar https://github.com/yugabyte/yb-kafka-connector/blob/master/yb-cdc/yb-cdc-connector.jar?raw=true
terminal1:
###start yugabyte db
/opt/yugabyte/yugabyte-2.0.10.0/bin/yb-ctl --data_dir "/opt/yugabyte/data" start
terminal2:
###start load generator
julia "/root/gen_users_yb.jl"
terminal3:
###publish change logs
java -jar ./yb-cdc-connector.jar --table_name yugastore.users --master_addrs 127.0.0.1:7100 --log_only
terminal1:
###stop yugabyte db
/opt/yugabyte/yugabyte-2.0.10.0/bin/yb-ctl --data_dir "/opt/yugabyte/data" stop
(Note: upon LibPQ Exception load generator exits and yb-connector waits)
terminal2:
###restarting load generator
julia "/root/gen_users_yb.jl"
Observation: No resumption in publishing logs on terminal 3
Please help me in configure yb-cdc-connector resume printing logs upon yb-ctl restart (stop and start).
This isn't yet supported. Can you create an issue on github https://github.com/yugabyte/yugabyte-db/issues ?

Job for httpd.service failed

I am getting this error and sites are not opening now
Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.
I got this problem after doing this
yum remove php php-cli php-common php-gd php-ldap php-mysql php-odbc php-pdo php-pear php-pecl-apc php-pecl-memcache php-pgsql php-soap php-xml php-xmlrpc
Most probably there is a configuration file left for php in /etc/httpd/conf.d/ that is loaded by default by apache (having the .conf extension). Since you have removed php, php module can't be loaded and httpd throws that error being unable to start.
So go to /etc/httpd/conf.d, see what .conf files you have there and either remove the php.conf file or at least comment the php module in it so it won't be loaded when apache is restarted. Then try again to restart apache by issuing systemctl restart httpd

Elasticsearch error to start service

I have problems starting elasticsearch, the command to start is:
cd /etc/init.d && ./elasticsearch start
Out put.
/opt/jdk1.8.0_77 uno
JAVA /opt/jdk1.8.0_77/bin/java
Starting elasticsearch: [ OK ]
but executed status I get: "elasticsearch dead but subsys locked"
I tried deleting "elasticsearch", in /var/lock/subsys but, this file is generated again.
In the log says.
java.lang.RuntimeException: Java version: 1.7.0_40 suffers from critical bug https://bugs.openjdk.java.net/browse/JDK-8024830 which can cause data corruption.
Please upgrade the JVM, see http://www.elastic.co/guide/en/elasticsearch/reference/current/_installation.html for current recommendations.
If you absolutely cannot upgrade, please add -XX:-UseSuperWord to the JVM_OPTS environment variable.
Upgrading is preferred, this workaround will result in degraded performance.
But the process is started with java 8,
elasticsearch 26918 0.8 1.0 30526952 724324 ? Sl Jul03 1:29 /opt/jdk1.8.0_77/bin/java -Xms256m -Xmx1g -Djava.awt.headless=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError -XX:+DisableExplicitGC -Dfile.encoding=UTF-8 -Delasticsearch -Des.foreground=yes -Des.path.home=/opt/elasticsearch -cp :/opt/elasticsearch/lib/elasticsearch-1.7.0.jar:/opt/elasticsearch/lib/*:/opt/elasticsearch/lib/sigar/* org.elasticsearch.bootstrap.Elasticsearch
Any help would be appreciated.
Verify java selection
alternatives --config java
Make sure java 8 is in use. Elasticsearch requires at least Java 8.
Please try setting up the variables in /etc/elasticsearch/elasticsearch.yml:
path.data: path/to/data
path.work: path/to/work
path.logs: /var/log/elasticsearch
path.conf: /etc/elasticsearch
Note: Give access to user "elasticsearch" for folder that
elasticsearch uses:
chown -R elasticsearch /path/to/data
chown -R elasticsearch /path/to/work

Resources