1、创建服务
vi /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
/opt/sonarqube/bin/linux-x86-32/sonar.sh $*
2、增加执行权限
chmod +x /etc/init.d/sonar
3、添加服务
chkconfig --add sonar
4、配置服务启动时依赖的jdk
vi /opt/sonarqube/conf/wrapper.conf
修改wrapper.java.command=java,配置为jdk中java命令的绝对路径
wrapper.java.command=/opt/jdk1.7.0_07/bin/java
5、启动服务
service sonar start