Installation java
- Download openjdk11 from azul
https://www.azul.com/downloads/?version=java-11-lts&os=ubuntu&architecture=x86-64-bit&package=jdk
Downloads
Free for evaluation and development
www.azul.com
- extract tar file and rename directory
root@dintvmsonar01:/home/ubuntu# mv zulu11.56.19-ca-jdk11.0.15-linux_x64.tar.gz /data/
root@dintvmsonar01:/home/ubuntu# cd /data/
root@dintvmsonar01:/data# tar zxvf zulu11.56.19-ca-jdk11.0.15-linux_x64.tar.gz
root@dintvmsonar01:/data# chown -R ubuntu:ubuntu zulu11.56.19-ca-jdk11.0.15-linux_x64/
root@dintvmsonar01:/data# mv zulu11.56.19-ca-jdk11.0.15-linux_x64/ jdk11
Installation sonarQube
Download the sonarQube zip file
http://www.sonarqube.org/downloads/
Download | SonarQube
Get the latest LTS and version of SonarQube the leading product for Code Quality and Security from the official download page.
www.sonarqube.org
Transfer sonarQube zip file in the directory
ubuntu@dintvmsonar01:/data/engn001$ pwd
/data/engn001
ubuntu@dintvmsonar01:/data/engn001$ ll
total 280932
drwxr-xr-x 2 ubuntu ubuntu 4096 May 6 03:47 ./
drwxr-xr-x 5 root root 4096 May 6 03:46 ../
-rw-rw-r-- 1 ubuntu ubuntu 287666040 May 6 03:35 sonarqube-9.4.0.54424.zip
Unzip sonarQube zip file
root@dintvmsonar01:/data/engn001$ unzip sonarqube-9.4.0.54424.zip
root@dintvmsonar01:/data/engn001# mv sonarqube-9.4.0.54424 sonarqube
Add sonarQube group and user
- Create a sonar group
root@dintvmsonar01:/data/engn001# sudo groupadd sonar
- Create a sonar user and set /data/engn001/sonarqube as the home directory
root@dintvmsonar01:/data/engn001# sudo useradd -d /data/engn001/sonarqube/ -g sonar sonar
- Grant the sonar user access to the /data/engn001/sonarqube directory
root@dintvmsonar01:/data/engn001# sudo chown sonar:sonar /data/engn001/sonarqube/ -R
Configure database for sonarQube in postgreSQL
- Change the default PostgreSQL password
ubuntu@dintvmsonar01:/$ sudo passwd postgres
New password: Passw0rd
Retype new password: Passw0rd
passwd: password updated successfully
ubuntu@dintvmsonar01:/$ su - postgres
Password:
postgres@dintvmsonar01:~$
- Make tablesapce directory
root@dintvmsonar01:/data# mkdir -p data001/dat
root@dintvmsonar01:/data# mkdir -p data001/idx
root@dintvmsonar01:/data# chown -R postgres:postgres data001
- Create database
root@dintvmsonar01:/data/data001# sudo -u postgres psql
psql (14.2 (Ubuntu 14.2-1.pgdg20.04+1+b1))
Type "help" for help.
postgres=#
postgres=# CREATE TABLESPACE TS_SONARD001 OWNER sonar LOCATION '/data/data001/dat';
CREATE TABLESPACE
postgres=# CREATE TABLESPACE TS_SONARI001 OWNER sonar LOCATION '/data/data001/idx';
CREATE TABLESPACE
postgres=# CREATE DATABASE sonarqube WITH ENCODING='UTF8' OWNER=sonar CONNECTION LIMIT=-1 TABLESPACE=TS_SONARD001;
CREATE DATABASE
postgres=# GRANT ALL ON TABLESPACE TS_SONARD001 TO sonar;
GRANT
postgres=# GRANT ALL ON TABLESPACE TS_SONARI001 TO sonar;
GRANT
postgres=#
Setting the access to the Database
- Edit the sonarQube configuration file
sudo vi /data/engn001/sonarqube/conf/sonar.properties
- Uncomment the lines, and add the database user and password
sonar.jdbc.username=sonar
sonar.jdbc.password=Passw0rd
- Add the sonar.jdbc.url
sonar.jdbc.url=jdbc:postgresql://localhost:5432/sonarqube
Setup the run as user
- Edit the sonar script file
sudo vi /data/engn001/sonarqube/bin/linux-x86-64/sonar.sh
- Uncomment the line and change it
RUN_AS_USER=sonar
Adjusting the Java installation
- Edit the wrapper.conf
cd /data/engn001/sonarqube/conf
vi wrapper.conf
- configure wrapper.java.command
wrapper.java.command=/data/jdk11/bin/java
Modify kernel system limit
- Edit the sysctl configuration file
sudo vi /etc/sysctl.conf
- Add the following lines
vm.max_map_count=262144
fs.file-max=65536
ulimit -n 65536
ulimit -u 4096
- Reboot the system to apply the changes
sudo reboot
Setup systemd service
- Create a systemd service file to start sonarQube at system boot
root@dintvmsonar01:/data/engn001/sonarqube/bin/linux-x86-64# vi /etc/systemd/system/sonar.service
- Paste the following lines to the file
[Unit]
Description=SonarQube service
After=syslog.target network.target
[Service]
Type=forking
ExecStart=/data/engn001/sonarqube/bin/linux-x86-64/sonar.sh start
ExecStop=/data/engn001/sonarqube/bin/linux-x86-64/sonar.sh stop
User=sonar
Group=sonar
Restart=always
LimitNOFILE=65536
LimitNPROC=4096
[Install]
WantedBy=multi-user.target
- Enable the sonarQube service to run at system startup
root@dintvmsonar01:/data/engn001/sonarqube/bin/linux-x86-64# systemctl enable sonar
Created symlink /etc/systemd/system/multi-user.target.wants/sonar.service → /etc/systemd/system/sonar.service.
- Start the sonarQube service and check the service status
ubuntu@dintvmsonar01:~$ sudo systemctl start sonar
ubuntu@dintvmsonar01:~$ sudo systemctl status sonar
● sonar.service - SonarQube service
Loaded: loaded (/etc/systemd/system/sonar.service; enabled; vendor preset:>
Active: active (running) since Fri 2022-05-06 06:31:58 UTC; 20s ago
Process: 3515 ExecStart=/data/engn001/sonarqube/bin/linux-x86-64/sonar.sh s>
Main PID: 3574 (wrapper)
Tasks: 33 (limit: 19168)
Memory: 87.5M
CGroup: /system.slice/sonar.service
├─3574 /data/engn001/sonarqube/bin/linux-x86-64/./wrapper /data/en>
└─3576 /data/jdk11/bin/java -Dsonar.wrapped=true -Djava.awt.headle>
May 06 06:31:57 dintvmsonar01 systemd[1]: Starting SonarQube service...
May 06 06:31:57 dintvmsonar01 sonar.sh[3515]: Starting SonarQube...
May 06 06:31:58 dintvmsonar01 sonar.sh[3515]: Started SonarQube.
May 06 06:31:58 dintvmsonar01 systemd[1]: Started SonarQube service.
Ref
https://www.cherryservers.com/blog/how-to-install-and-setup-postgresql-server-on-ubuntu-20-04
How to Install and Setup PostgreSQL server on Ubuntu 20.04 - Cherry Servers
#Introduction PostgreSQL is a fully featured database management system (DBMS) with a strong emphasis on extensibility and SQL compliance. It is backed by 20 years of open-source development, and supports both SQL (relational) and JSON (non-relational) que
www.cherryservers.com
https://www.vultr.com/docs/install-sonarqube-on-ubuntu-20-04-lts/#8__Access_SonarQube_Web_Interface
Install SonarQube on Ubuntu 20.04 LTS
We are simplifying the cloud. One Login, 16 Countries, 25 Cities, Infinite Possibilities.
www.vultr.com
'Security > SonarQube' 카테고리의 다른 글
Integration with jenkins (0) | 2022.05.09 |
---|---|
Install SonarQube (0) | 2022.05.05 |