centos - Sonarqube - 服务 Sonar 在 centos 7 中不支持 chkconfig

标签 centos sonarqube centos7 sonarqube-ops

按照以下链接中的 Sonar 设置说明进行操作。但执行 chkconfig 命令失败。它阻止我在 centos7 中启动 sonarqube 作为服务。

http://docs.sonarqube.org/display/SONAR/Running+SonarQube+as+a+Service+on+Linux

http://devopscube.com/setup-and-configure-sonarqube-on-linux/

[build@inches-jenkins-master ~]$ cat /etc/init.d/sonar
#! /usr/bin/sh

/usr/bin/sonar $*

[build@inches-jenkins-master ~]$ which sh
/usr/bin/sh

[build@inches-jenkins-master ~]$ ls -lrt /usr/bin/sonar
lrwxrwxrwx. 1 root root 50 Aug 30 16:59 /usr/bin/sonar -> /usr/local/sonarqube-6.0/bin/linux-x86-64/sonar.sh

[build@inches-jenkins-master init.d]$ sudo chkconfig --add sonar
service sonar does not support chkconfig

手动启动时没有问题。
[build@inches-jenkins-master init.d]$ sudo sonar start
Starting SonarQube...
Started SonarQube.
[build@inches-jenkins-master init.d]$

最佳答案

您的/etc/init.d/sonar 文件不正确,应该是:

#!/bin/sh
#
# rc file for SonarQube
#
# chkconfig: 345 96 10
# description: SonarQube system (www.sonarsource.org)
#
### BEGIN INIT INFO
# Provides: sonar
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
# Short-Description: SonarQube system (www.sonarsource.org)
# Description: SonarQube system (www.sonarsource.org)
### END INIT INFO

/usr/bin/sonar $*

我刚刚在 CentOS 7.2 机器上对其进行了测试,它开箱即用:
wget https://sonarsource.bintray.com/Distribution/sonarqube/sonarqube-6.0.zip
unzip sonarqube-6.0.zip
sudo mv sonarqube-6.0 /opt
sudo ln -s /opt/sonarqube-6.0/bin/linux-x86-64/sonar.sh /usr/bin/sonar
sudo tee /etc/init.d/sonar <<-'EOF'
#!/bin/sh
#
# rc file for SonarQube
#
# chkconfig: 345 96 10
# description: SonarQube system (www.sonarsource.org)
#
### BEGIN INIT INFO
# Provides: sonar
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
# Short-Description: SonarQube system (www.sonarsource.org)
# Description: SonarQube system (www.sonarsource.org)
### END INIT INFO

/usr/bin/sonar $*

EOF

sudo chmod 755 /etc/init.d/sonar
# Enable sonar service
sudo chkconfig --add sonar

# Start service (systemd delegate to initd)
sudo service sonar start
# Stop service (systemd delegate to initd)
sudo service sonar stop
# Check Sonarqube log
sudo tail -3 /opt/sonarqube-6.0/logs/sonar.log

关于centos - Sonarqube - 服务 Sonar 在 centos 7 中不支持 chkconfig,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39226917/

相关文章:

java - 在 CentOS 6 中设置 JAVA_HOME 和 CLASSPATH

java - Tomcat 在 CentO 上不起作用 - ExecStop=/bin/kill -15 $MAINPID (code=exited, status=1/FAILURE)

bash - SCP 进度条,如 bash 脚本中的 WGET

c - 没有 udev 或 libusb 的 linux 上的 usb 连接事件

java - Sonar 分析失败无法创建符号表

web-services - 如何在 Sonar REST api 中获取特定指标的所有值

mysql - centos 7 5.5.56-MariaDB 错误 2013 (HY000) : Lost connection to MySQL server during query

java - SonarQube - 无法连接到 > localhost/0 :0:0:0:0:0:0:1:9000

Kubernetes CoreDNS pod 不断重启

kubernetes - Kubeadm和在主节点上调度Pod的风险(Pod始终处于等待状态)