Download | SonarQube | Sonar (sonarsource.com)
1.首先我的sonar版本为 10.4.1 ,java版本为17
2.sonar启动需要数据库,我先安装了mysql, 但是目前sonar从7.9开始不支持mysql,且java版本要最少11,推荐使用java17
3.安装postsql,创建sonar数据库
4.启动sonar发生错误
5.检查日志
首先检查sonar.log
再检查es.log
6.加大文件描述符数量和虚拟内存大小
临时修改文件描述符: ulimit -n 65535
永久修改文件描述符: cat >> /etc/security/limits.conf << EOF
* soft nofile 65535
* hard nofile 65535
EOF
临时修改虚拟内存大小 sysctl -w vm.max_map_count=262144
永久修改虚拟内存大小 cat >> /etc/sysctl.conf << EOF
vm.max_map_count=262144
EOF
sysctl -p
7. 再次查看日志
lsof /opt/sonar/data/es8/node.lock 查看是否被其他进程占用
ls -ld /opt/sonar/data/es8 检查是否有足够的权限
rm -rf /opt/sonar/data/es8/node.lock 删除该文件可能会解决问题
8.再次检查日志,发现没有任何错误,可能是版本问题(我安装的是最新版的sonar)
2024.04.11 10:21:09 INFO es[][o.e.n.Node] JVM home [/usr/lib/jvm/jdk-17-oracle-x64], using bundled JDK [false]
2024.04.11 10:21:09 INFO es[][o.e.n.Node] JVM arguments [-Des.networkaddress.cache.ttl=60, -Des.networkaddress.cache.negative.ttl=10, -Djava.security.manager=allow, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -XX:-OmitStackTraceInFastThrow, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Dlog4j2.formatMsgNoLookups=true, -Djava.locale.providers=SPI,COMPAT, --add-opens=java.base/java.io=org.elasticsearch.preallocate, -XX:+UseG1GC, -Djava.io.tmpdir=/opt/sonar/temp, -XX:ErrorFile=/opt/sonar/logs/es_hs_err_pid%p.log, -Xlog:disable, -Des.networkaddress.cache.ttl=60, -Des.networkaddress.cache.negative.ttl=10, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -Djna.tmpdir=/opt/sonar/temp, -XX:-OmitStackTraceInFastThrow, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dio.netty.allocator.numDirectArenas=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Dlog4j2.formatMsgNoLookups=true, -Djava.locale.providers=COMPAT, -Dcom.redhat.fips=false, -Des.enforce.bootstrap.checks=true, -Xmx512m, -Xms512m, -XX:MaxDirectMemorySize=256m, -XX:+HeapDumpOnOutOfMemoryError, -XX:G1HeapRegionSize=4m, -XX:InitiatingHeapOccupancyPercent=30, -XX:G1ReservePercent=15, -Des.distribution.type=tar, --module-path=/opt/sonar/elasticsearch/lib, --add-modules=jdk.net, --add-modules=ALL-MODULE-PATH, -Djdk.module.main=org.elasticsearch.server]
2024.04.11 10:21:11 INFO es[][o.e.p.PluginsService] loaded module [x-pack-core]
2024.04.11 10:21:11 INFO es[][o.e.p.PluginsService] loaded module [old-lucene-versions]
2024.04.11 10:21:11 INFO es[][o.e.p.PluginsService] loaded module [parent-join]
2024.04.11 10:21:11 INFO es[][o.e.p.PluginsService] loaded module [lang-painless]
2024.04.11 10:21:11 INFO es[][o.e.p.PluginsService] loaded module [rest-root]
2024.04.11 10:21:11 INFO es[][o.e.p.PluginsService] loaded module [x-pack-redact]
2024.04.11 10:21:11 INFO es[][o.e.p.PluginsService] loaded module [reindex]
2024.04.11 10:21:11 INFO es[][o.e.p.PluginsService] loaded module [analysis-common]
2024.04.11 10:21:11 INFO es[][o.e.p.PluginsService] loaded module [x-pack-security]
2024.04.11 10:21:11 INFO es[][o.e.p.PluginsService] loaded module [transport-netty4]
2024.04.11 10:21:11 INFO es[][o.e.p.PluginsService] loaded module [apm]
2024.04.11 10:21:11 INFO es[][o.e.p.PluginsService] loaded module [aggregations]
2024.04.11 10:21:16 INFO es[][o.e.e.NodeEnvironment] using [1] data paths, mounts [[/ (/dev/mapper/centos-root)]], net usable_space [12.7gb], net total_space [16.9gb], types [xfs]
2024.04.11 10:21:16 INFO es[][o.e.e.NodeEnvironment] heap size [512mb], compressed ordinary object pointers [true]
2024.04.11 10:21:16 INFO es[][o.e.n.Node] node name [sonarqube], node ID [0VhLHUqqTP2MePAyZ55RvQ], cluster name [sonarqube], roles [data_cold, data, remote_cluster_client, master, data_warm, data_content, transform, data_hot, ml, data_frozen, ingest]
2024.04.11 10:21:18 INFO es[][o.e.x.s.Security] Security is disabled
2024.04.11 10:21:19 INFO es[][o.e.t.n.NettyAllocator] creating NettyAllocator with the following configs: [name=unpooled, suggested_max_allocation_size=1mb, factors={es.unsafe.use_unpooled_allocator=null, g1gc_enabled=true, g1gc_region_size=4mb, heap_size=512mb}]
2024.04.11 10:21:19 INFO es[][o.e.i.r.RecoverySettings] using rate limit [40mb] with [default=40mb, read=0b, write=0b, max=0b]
2024.04.11 10:21:19 INFO es[][o.e.d.DiscoveryModule] using discovery type [single-node] and seed hosts providers [settings]
2024.04.11 10:21:20 INFO es[][o.e.n.Node] initialized
2024.04.11 10:21:20 INFO es[][o.e.n.Node] starting ...
2024.04.11 10:21:22 INFO es[][o.e.t.TransportService] publish_address {127.0.0.1:34806}, bound_addresses {127.0.0.1:34806}
2024.04.11 10:21:22 INFO es[][o.e.b.BootstrapChecks] explicitly enforcing bootstrap checks
2024.04.11 10:21:22 INFO es[][o.e.c.c.ClusterBootstrapService] this node is locked into cluster UUID [7GnAZLRhS5qMVgXaYkkG6g] and will not attempt further cluster bootstrapping
2024.04.11 10:21:23 INFO es[][o.e.c.s.MasterService] elected-as-master ([1] nodes joined in term 2)[_FINISH_ELECTION_, {sonarqube}{0VhLHUqqTP2MePAyZ55RvQ}{7twHHZMPRIKjHxwRYG01Yg}{sonarqube}{127.0.0.1}{127.0.0.1:34806}{cdfhilmrstw}{8.11.0}{7000099-8500003} completing election], term: 2, version: 6, delta: master node changed {previous [], current [{sonarqube}{0VhLHUqqTP2MePAyZ55RvQ}{7twHHZMPRIKjHxwRYG01Yg}{sonarqube}{127.0.0.1}{127.0.0.1:34806}{cdfhilmrstw}{8.11.0}{7000099-8500003}]}
2024.04.11 10:21:23 INFO es[][o.e.c.s.ClusterApplierService] master node changed {previous [], current [{sonarqube}{0VhLHUqqTP2MePAyZ55RvQ}{7twHHZMPRIKjHxwRYG01Yg}{sonarqube}{127.0.0.1}{127.0.0.1:34806}{cdfhilmrstw}{8.11.0}{7000099-8500003}]}, term: 2, version: 6, reason: Publication{term=2, version=6}
2024.04.11 10:21:23 INFO es[][o.e.c.f.AbstractFileWatchingService] starting file watcher ...
2024.04.11 10:21:23 INFO es[][o.e.c.c.NodeJoinExecutor] node-join: [{sonarqube}{0VhLHUqqTP2MePAyZ55RvQ}{7twHHZMPRIKjHxwRYG01Yg}{sonarqube}{127.0.0.1}{127.0.0.1:34806}{cdfhilmrstw}{8.11.0}{7000099-8500003}] with reason [completing election]
2024.04.11 10:21:23 INFO es[][o.e.c.f.AbstractFileWatchingService] file settings service up and running [tid=30]
2024.04.11 10:21:23 INFO es[][o.e.h.AbstractHttpServerTransport] publish_address {127.0.0.1:9001}, bound_addresses {127.0.0.1:9001}
2024.04.11 10:21:23 INFO es[][o.e.n.Node] started {sonarqube}{0VhLHUqqTP2MePAyZ55RvQ}{7twHHZMPRIKjHxwRYG01Yg}{sonarqube}{127.0.0.1}{127.0.0.1:34806}{cdfhilmrstw}{8.11.0}{7000099-8500003}{xpack.installed=true, rack_id=sonarqube}
2024.04.11 10:21:23 INFO es[][o.e.l.ClusterStateLicenseService] license [70360a8b-3b41-40b1-8b48-a9818b38d002] mode [basic] - valid
2024.04.11 10:21:23 INFO es[][o.e.g.GatewayService] recovered [0] indices into cluster_state
2024.04.11 10:21:23 INFO es[][o.e.h.n.s.HealthNodeTaskExecutor] Node [{sonarqube}{0VhLHUqqTP2MePAyZ55RvQ}] is selected as the current health node.
2024.04.11 10:21:29 INFO es[][o.e.n.Node] stopping ...
2024.04.11 10:21:29 INFO es[][o.e.c.f.AbstractFileWatchingService] shutting down watcher thread
2024.04.11 10:21:29 INFO es[][o.e.c.f.AbstractFileWatchingService] watcher service stopped
2024.04.11 10:21:29 INFO es[][o.e.n.Node] stopped
2024.04.11 10:21:29 INFO es[][o.e.n.Node] closing ...
2024.04.11 10:21:29 INFO es[][o.e.n.Node] closed
9.下载sonar低版本 sonar-9.9.4 Download | SonarQube | Sonar (sonarsource.com)
重新安装配置,发现sonar启动成功
10.总结
在sonar中环境和版本配置比较重要
#在sonar现在的版本中已经不支持mysql了,推荐使用postsql
推荐sonar 9.9.4 java 17 postsql 15
在安装过程中还有许多问题:
1. postsql的模式 建议删掉默认是public
#----- PostgreSQL 11 or greater
# By default the schema named "public" is used. It can be overridden with the parameter "currentSchema".
sonar.jdbc.url=jdbc:postgresql://localhost/sonar
2.sonar和es的启动要用 sonar或者其他用户启动,因为安全问题elasticsearch 不让用root用户直接运行
su sonar /opt/sonar/bin/linux-x86-64/sonar.sh start
3. sonar文件夹和文件下的内容必须要所属属于启动的的用于
chmod -R sonar:sonar /opt/sonar
4.可能端口被占用
5.内存不足
6.jdk不兼容
7.当重新启动后,发现sonar中的es还是启动不了文章来源:https://www.toymoban.com/news/detail-853908.html
解决办法 删除/opt/sonar/tmp/* 下的所有内容,删除临时文件,重新启动文章来源地址https://www.toymoban.com/news/detail-853908.html
到了这里,关于Sonar下启动发生错误,elasticsearch启动错误的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!