--- title: 'Ubuntu 22.04 Install SonarQube 9.9(Java 17)' tags: ubuntu,sonarqube description: Ubuntu 22.04 Install SonarQube 9.9(Java 17) --- # Ubuntu 22.04 Install SonarQube 9.9(Java 17) --- [TOC] --- ## 使用的技術&工具 - Ubuntu 22.04 - SonarQube 9.9 - Java 17 - PostgreSQL --- ## Ubuntu 環境設定 ``` terminal sudo vim /etc/security/limits.conf ....第二行插入 * soft nproc 655350 * hard nproc 655350 * soft nofile 655350 * hard nofile 655350 ``` ``` terminal sudo vim /etc/sysctl.conf ....第一行插入 vm.max_map_count=655360 fs.file-max=35942900 ``` 重開機 ``` terminal sudo reboot ``` ``` terminal ulimit -n 131072 ulimit -u 8192 ``` ``` terminal sudo apt-get update ``` ``` terminal sudo apt-get install wget unzip -y ``` --- ## 安裝Java 17 ``` terminal sudo apt-get install openjdk-17-jdk -y ``` ``` terminal java -version ```  --- ## Install PostgreSQL ``` terminal sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list' ``` ``` terminal wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | sudo apt-key add - ``` ``` terminal sudo apt-get -y install postgresql postgresql-contrib ``` ``` terminal sudo systemctl start postgresql sudo systemctl enable postgresql ``` 預設密碼 ``` terminal sudo passwd postgres ```  登入 ``` terminal su - postgres ```  ``` terminal createuser sonar ``` ``` terminal psql ```  ``` terminal ALTER USER sonar WITH ENCRYPTED password 'sonar'; CREATE DATABASE sonarqube OWNER sonar; grant all privileges on DATABASE sonarqube to sonar; ``` 登出 ``` terminal \q exit ``` --- ## Install SonarQube Download SonarQube ``` terminal cd /tmp sudo wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-9.9.0.65466.zip ``` ``` terminal sudo unzip sonarqube-9.9.0.65466.zip -d /opt sudo mv /opt/sonarqube-9.9.0.65466 /opt/sonarqube ``` Create Group and User ``` terminal sudo groupadd sonar sudo useradd -c "user to run SonarQube" -d /opt/sonarqube -g sonar sonar sudo chown sonar:sonar /opt/sonarqube -R ``` ``` terminal sudo vim /opt/sonarqube/conf/sonar.properties ... sonar.jdbc.username=sonar sonar.jdbc.password=sonar sonar.jdbc.url=jdbc:postgresql://localhost:5432/sonarqube ```  ``` terminal sudo vim /opt/sonarqube/bin/linux-x86-64/sonar.sh ... RUN_AS_USER=sonar ```  --- ## Start SonarQube ``` terminal sudo su sonar ``` ``` terminal cd /opt/sonarqube/bin/linux-x86-64/ ./sonar.sh start ```  ``` terminal ./sonar.sh status ```  ``` terminal ./sonar.sh status ``` ``` terminal exit ``` ``` terminal cd /opt/sonarqube/bin/linux-x86-64/ sudo ./sonar.sh stop ``` ``` terminal sudo vim /etc/systemd/system/sonar.service ... [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 User=sonar Group=sonar Restart=always LimitNOFILE=65536 LimitNPROC=4096 [Install] WantedBy=multi-user.target ``` ``` terminal sudo systemctl start sonar sudo systemctl enable sonar sudo systemctl status sonar ```  --- ## Web view ``` terminal http://server_IP:9000 OR http://localhost:9000 ``` 預設帳密 account: admin password: admin  --- ## 參考連結 https://www.fosstechnix.com/how-to-install-sonarqube-on-ubuntu-22-04-lts/ https://blog.csdn.net/weixin_42789427/article/details/102488235 https://medium.com/@d101201007/elk%E6%95%99%E5%AD%B8-%E8%A7%A3%E6%B1%BA-max-virtual-memory-areas-vm-max-map-count-1b48fc85da48 ---
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up