当前位置:网站首页>Production environment sonarqube installation
Production environment sonarqube installation
2022-06-28 22:47:00 【Chief prisoner】
Production environment sonarqube install ( A single node )
Install the Server
Install the Server as a Cluster
SonarQube Three elements

SonarQube server Run the following process
- SonarQube The user interface webserver
- Elasticsearch Search service
- Responsible for analyzing the code report and storing it in SonarQube Database compute engine
The database stores the following data
- Code quality and security metric And issue
- SonarQube Instance configuration information
Host and location
For performance reasons ,SonarQube And databases should be on different machines , also SonarQube server The server that should be exclusive , The database should be in the same network environment .
All host times must be synchronized .
Database installation
Linux downloads (Red Hat family)
# Install the repository RPM:
yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
# Install PostgreSQL:
yum install -y postgresql14-server
The default configuration file location is modified
# Default data location
# /var/lib/pgsql
# Modify the default data location
# mv /var/lib/pgsql /export/
# vim /usr/lib/systemd/system/postgresql-14.service
# It's not recommended to modify this file in-place, because it will be
# overwritten during package upgrades. It is recommended to use systemd
# "dropin" feature; i.e. create file with suffix .conf under
# /etc/systemd/system/postgresql-14.service.d directory overriding the
# unit's defaults. You can also use "systemctl edit postgresql-14"
# Look at systemd.unit(5) manual page for more info.
# Note: changing PGDATA will typically require adjusting SELinux
# configuration as well.
# Note: do not use a PGDATA pathname containing spaces, or you will
# break postgresql-14-setup.
[Unit]
Description=PostgreSQL 14 database server
Documentation=https://www.postgresql.org/docs/14/static/
After=syslog.target
After=network.target
[Service]
Type=notify
User=postgres
Group=postgres
# Note: avoid inserting whitespace in these Environment= lines, or you may
# break postgresql-setup.
# Location of database directory
Environment=PGDATA=/export/pgsql/14/data/
# Where to send early-startup messages from the server (before the logging
# options of postgresql.conf take effect)
# This is normally controlled by the global default set by systemd
# StandardOutput=syslog
# Disable OOM kill on the postmaster
OOMScoreAdjust=-1000
Environment=PG_OOM_ADJUST_FILE=/proc/self/oom_score_adj
Environment=PG_OOM_ADJUST_VALUE=0
ExecStartPre=/usr/pgsql-14/bin/postgresql-14-check-db-dir ${PGDATA}
ExecStart=/usr/pgsql-14/bin/postmaster -D ${PGDATA}
ExecReload=/bin/kill -HUP $MAINPID
KillMode=mixed
KillSignal=SIGINT
# Do not set any timeout value, so that systemd will not kill postmaster
# during crash recovery.
TimeoutSec=0
# 0 is the same as infinity, but "infinity" needs systemd 229
TimeoutStartSec=0
TimeoutStopSec=1h
[Install]
WantedBy=multi-user.target
Simple profile tuning
# vim /export/pgsql/14/data/postgresql.conf
listen_addresses = '0.0.0.0' # what IP address(es) to listen on;
max_connections = 1000 # (change requires restart)
shared_buffers = 1024MB # min 128kB
dynamic_shared_memory_type = posix # the default is the first option
max_wal_size = 30GB
min_wal_size = 80MB
log_destination = 'stderr' # Valid values are combinations of
logging_collector = on # Enable capturing of stderr and csvlog
log_directory = 'log' # directory where log files are written,
log_filename = 'postgresql-%a.log' # log file name pattern,
log_rotation_age = 1d # Automatic rotation of logfiles will
log_rotation_size = 0 # Automatic rotation of logfiles will
log_truncate_on_rotation = on # If on, an existing log file with the
log_line_prefix = '%m [%p] ' # special values:
log_timezone = 'Asia/Shanghai'
datestyle = 'iso, ymd'
timezone = 'Asia/Shanghai'
lc_messages = 'zh_CN.UTF-8' # locale for system error message
lc_monetary = 'zh_CN.UTF-8' # locale for monetary formatting
lc_numeric = 'zh_CN.UTF-8' # locale for number formatting
lc_time = 'zh_CN.UTF-8' # locale for time formatting
default_text_search_config = 'pg_catalog.simple'
Initialization and startup
# Optionally initialize the database and enable automatic start:
/usr/pgsql-14/bin/postgresql-14-setup initdb
systemctl enable postgresql-14
systemctl start postgresql-14
rpm Download and install
Create an empty schema and a sonarqube user. Grant this sonarqube user permissions to create, update, and delete objects for this schema.
Database creation user and authorization
# su - postgres
# psql
CREATE DATABASE sonar;
CREATE USER sonarqube WITH PASSWORD 'xxxxxx';
GRANT ALL PRIVILEGES ON DATABASE sonar TO sonarqube;
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO sonarqube;
postgresql Master-slave
Achieving PostgreSQL Master Slave Replication: 7 Easy Steps
zip Files installed SonarQube
useradd sonar
cd /usr/local
wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-9.4.0.54424.zip
unzip sonarqube-9.4.0.54424.zip
mv sonarqube-9.4.0.54424 sonarqube
chown -R sonar.sonar sonarqube
Kernel parameter settings
# vim /etc/sysctl.conf
vm.max_map_count=655360
# sysctl -p
Database settings
# vim /usr/local/sonarqube/conf/sonar.properties
# Example for PostgreSQL
sonar.jdbc.username=sonarqube
sonar.jdbc.password=xxxxxx
sonar.jdbc.url=jdbc:postgresql://localhost/sonar
SonarQube Other than oracle Database drivers other than , Don't change it .
Set up Elasticsearch Storage path for
By default ,Elasticsearch The storage path of is $SONARQUBE-HOME/data, The production environment should be modified .
# mkdir -p /export/sonarqube/{data, temp}
# chown -R sonar.sonar /export/sonarqube
# vim /usr/local/sonarqube/conf/sonar.properties
sonar.path.data=/export/sonarqube/data
sonar.path.temp=/export/sonarqube/temp
start-up webserver
The default port is 9000, The path is a /, Change the way
# vim /usr/local/sonarqube/conf/sonar.properties
sonar.web.host=0.0.0.0
sonar.web.port=9000
sonar.web.context=/
Starting mode
su - sonar
/usr/local/sonarqube/bin/linux-x86-64/sonar.sh start
change java edition ( Optional )
modify $SONARQUBE-HOME/conf/wrapper.conf
# vim /usr/local/sonarqube/conf/wrapper.conf
wrapper.java.command=/path/to/my/jdk/bin/java
Use systemd management SonarQube
# vim /etc/systemd/system/sonarqube.service
[Unit]
Description=SonarQube service
After=syslog.target network.target
[Service]
Type=simple
User=sonar
Group=sonar
PermissionsStartOnly=true
ExecStart=/usr/bin/nohup /usr/bin/java -Xms1G -Xmx32G -Djava.net.preferIPv4Stack=true -jar /usr/local/sonarqube/lib/sonar-application-9.4.0.54424.jar
StandardOutput=syslog
LimitNOFILE=131072
LimitNPROC=8192
TimeoutStartSec=5
Restart=always
SuccessExitStatus=143
[Install]
WantedBy=multi-user.target
java Process memory
4 There are signs of low memory
- Your monitoring tools show one or more of the SonarQube processes is reaching its memory limit
- Any of the SonarQube processes crashes and/or generates an out-of-memory error in the sonar.log file
- A SonarQube background task fails with an out-of-memory error in the background task log
- The store size of the Issues index of your Elasticsearch instance (visible in the System Info) is greater than or equal to the memory allocated to the Elasticsearch Java process
Can be in $SONARQUBE-HOME/conf/sonar.properties add -Xmx Memory
| Java Process | SonarQube Property | Notes |
|---|---|---|
| Compute Engine | sonar.ce.javaOpts | |
| Elasticsearch | sonar.search.javaOpts | It is recommended to set the min and max memory to the same value to prevent the heap from resizing at runtime, which diverts JVM resources and can greatly increase response times of in-flight requests. |
| Web | sonar.web.javaOpts |
边栏推荐
- Zadig 正式推出 VS Code 插件,本地开发更高效
- Explanation: Luogu p1762 even number /6.21 internal examination T2
- 微搭低代码中实现二维码生成
- Research Report on workers: middle-aged people account for the highest proportion of naked words
- C#/VB. Net to convert PDF to excel
- Code example of hiredis
- 共探数字技术与信息安全,第四届中俄数字论坛成功举办
- Windows mysql5.7 enable binlog log
- Flowable boundary timer
- 5毛VS600亿,食品安全问题是卫龙上市最大的拦路虎?
猜你喜欢

如何结合均线分析伦敦金行情走势线图

微搭低代码中实现二维码生成

深入虚拟内存(Virtual Memory,VM)

穿越过后,她说多元宇宙真的存在

Ansible production environment usage scenario (7): batch deployment of elk clients

WMS仓库管理系统模块之波次拣货

What does project management really manage?

共探数字技术与信息安全,第四届中俄数字论坛成功举办

The example application of histogram in data visualization makes the public performance results clear at a glance

How to advance data analysis from 1 to 10?
随机推荐
Business atlas in super factory
k线图基础知识图解——单根K线的含义
场景化接口开发利器,金蝶云苍穹新版OpenAPI引擎来了!
JS array common methods
Considerations on the construction of operation and maintenance system - stability
Zadig 正式推出 VS Code 插件,本地开发更高效
This simple little function saves 213 hours for our production research team in half a year
超级工厂里的生意图鉴
如何制作精美的图片
论文解读(DCN)《Towards K-means-friendly Spaces: Simultaneous Deep Learning and Clustering》
在产业互联网时代,传统意义上的互联网将会演变出来诸多新的形态
台式机没声音怎么样才能解决
torch. nn. Transformer import failed
The Best of Many Worlds_ Dual Mirror Descent for Online Allocation Problems
Mono 的执行流程
In the era of industrial Internet, the Internet in the traditional sense will evolve into many new forms
PyTorch搭建Transformer实现多变量多步长时间序列预测(负荷预测)
The love digital smart 2022 summit opens, sharing data strategy and building data-driven organization methodology
这个简单的小功能,半年为我们产研团队省下213个小时
In order to control the risks, how to choose a franchise company?