请求提供安装SonarQube 7.9.1 LTS的Bash/Shell引导脚本
Got it, let's get you set up with SonarQube 7.9.1 LTS instead of the outdated 7.1 version you're currently getting. The core issue here is that the SourceForge repo you're using hasn't been updated with newer SonarQube releases. Here's a reliable, step-by-step revised script and process:
Step 1: Clean Up Old SonarQube Install & Repo
First, remove the existing 7.1 installation and outdated repo to avoid conflicts:
sudo yum remove -y sonar sudo rm -f /etc/yum.repos.d/sonar.repo
Step 2: Install Required Dependencies
SonarQube 7.9.1 requires Java 8, so we'll install that along with other necessary tools:
sudo yum -y update sudo yum -y install java-1.8.0-openjdk wget nfs-utils unzip
Step 3: Download & Extract SonarQube 7.9.1 LTS
Since the official yum repos no longer host older LTS versions directly, we'll download the binary package directly from SonarSource:
# Create a dedicated directory for SonarQube sudo mkdir -p /opt/sonarqube cd /opt/sonarqube # Download the 7.9.1 LTS package sudo wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-7.9.1.zip # Extract the package and clean up sudo unzip sonarqube-7.9.1.zip sudo mv sonarqube-7.9.1/* . sudo rm -rf sonarqube-7.9.1 sonarqube-7.9.1.zip
Step 4: Create a Dedicated User for SonarQube
SonarQube should not run as root for security reasons, so we'll create a system user:
sudo useradd -r sonarqube -s /sbin/nologin sudo chown -R sonarqube:sonarqube /opt/sonarqube
Step 5: Set Up Systemd Service (For Easy Management)
Create a systemd service file to manage SonarQube as a background service:
sudo tee /etc/systemd/system/sonarqube.service <<EOF [Unit] Description=SonarQube service After=syslog.target network.target [Service] Type=forking ExecStart=/opt/sonarqube/bin/linux-x86-64/sonar.sh start ExecStop=/opt/sonarqube/bin/linux-x86-64/sonar.sh stop ExecReload=/opt/sonarqube/bin/linux-x86-64/sonar.sh restart User=sonarqube Group=sonarqube Restart=always LimitNOFILE=65536 LimitNPROC=4096 [Install] WantedBy=multi-user.target EOF
Then reload systemd, enable the service on boot, and start it:
sudo systemctl daemon-reload sudo systemctl enable sonarqube sudo systemctl start sonarqube
Step 6: Verify Installation
Wait 2-3 minutes for the service to fully start, then navigate to http://your-server-ip:9000 in your browser. The default credentials are admin/admin.
Why Your Original Script Didn't Work
The SourceForge repo you used (http://downloads.sourceforge.net/project/sonar-pkg/rpm/sonar.repo) hasn't been updated since SonarQube 7.1—SonarSource no longer maintains this third-party repo. Direct binary download is the most reliable way to install specific older LTS versions like 7.9.1.
内容的提问来源于stack exchange,提问作者asur

