我试图在centos 7上使用postgres设置SonarQube 7.9.1社区版,但是当我启动该服务时,它会失败。
我想在centos 7上用postgres设置SonarQube,但是我不能。我已经尝试使用docker进行设置,并且得到了相同的结果。启动SonarQube的唯一方法是使用H2嵌入,但它仅用于测试目的。
这是日志显示的唯一错误
2019.07.17 05:52:11 INFO app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /opt/sonarqube/temp
2019.07.17 05:52:11 INFO app[][o.s.a.es.EsSettings] Elasticsearch listening on /127.0.0.1:9001
2019.07.17 05:52:12 INFO app[][o.s.a.ProcessLauncherImpl] Launch process[[key='es', ipcIndex=1, logFilenamePrefix=es]] from [/opt/sonarqube/elasticsearch]: /opt/sonarqube/elasticsearch/bin/elasticsearch
2019.07.17 05:52:12 INFO app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running
2019.07.17 05:52:12 INFO app[][o.e.p.PluginsService] no modules loaded
2019.07.17 05:52:12 INFO app[][o.e.p.PluginsService] loaded plugin [org.elasticsearch.transport.Netty4Plugin]
OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
ERROR: [1] bootstrap checks failed
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
2019.07.17 05:52:19 WARN app[][o.s.a.p.AbstractManagedProcess] Process exited with exit value [es]: 78
2019.07.17 05:52:19 INFO app[][o.s.a.SchedulerImpl] Process[es] is stopped
2019.07.17 05:52:19 INFO app[][o.s.a.SchedulerImpl] SonarQube is stopped
我不知道该服务为什么会失败,但我希望使用postgres设置该服务。
答案 0 :(得分:1)
错误:
loaded plugin [org.elasticsearch.transport.Netty4Plugin] ERROR: [1] bootstrap checks failed. max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144].
解决方案:
Elasticsearch使用MMap FS目录存储其索引。默认的操作系统对mmap计数的限制可能太低,这可能会导致内存不足异常。输入以下命令以使用sudo特权增加虚拟内存值,
$ sudo sysctl -w vm.max_map_count=262144
========================================
输出:
$ sudo sysctl -w vm.max_map_count=262144
vm.max_map_count = 262144
要永久设置值,请更新/etc/sysctl.conf中的vm.max_map_count值。要在重启后进行验证,
$ sysctl vm.max_map_count
答案 1 :(得分:0)
您的系统不允许根据行
为每个进程映射足够的内存[1]:最大虚拟内存区域vm.max_map_count [65530]太低,增加到至少[262144]
在尝试启动SonarQube或发出您的docker compose
命令之前,运行以下命令:
sysctl -w vm.max_map_count=262144
答案 2 :(得分:0)
此答案并未提供解决方案,但可能会阐明某些人为何无法启动elsaticsearch并在其虚拟服务器上运行的原因。
我有同样的问题,但是我无法更改值vm.max_map_count
。运行sysctl --system
并将vm.max_map_count=262144
添加到文件/usr/lib/sysctl.d/99-elasticsearch.conf
* Applying /usr/lib/sysctl.d/99-elasticsearch.conf ...
sysctl: setting key "vm.max_map_count": Datei oder Verzeichnis nicht gefunden
花了一些时间后,事实证明我的虚拟CentOS7服务器正在WSL上运行。而且WSL不支持所有内核参数的设置,vm.max_map_count
是其中之一(https://github.com/microsoft/WSL/issues/3126#issuecomment-396271872)。
答案 3 :(得分:0)
提供的答案显示了如何在主机系统上设置值。
我的答案显示了如何在主机系统本身上不能设置系统值的情况下如何在kubernetes初始化容器中设置值。
此解决方案取自sonarqube helm chart。 如果您正在使用头盔,则可能要使用声纳尔贝克头盔图表本身,其中已经包含了解决方案。
apiVersion: v1
kind: ConfigMap
metadata:
name: sonarqube-sonarqube-init-sysctl
labels:
app: sonarqube
data:
init_sysctl.sh: |-
if [[ "$(sysctl -n vm.max_map_count)" -lt 524288 ]]; then
sysctl -w vm.max_map_count=524288
fi
if [[ "$(sysctl -n fs.file-max)" -lt 131072 ]]; then
sysctl -w fs.file-max=131072
fi
if [[ "$(ulimit -n)" != "unlimited" ]]; then
if [[ "$(ulimit -n)" -lt 131072 ]]; then
echo "ulimit -n 131072"
ulimit -n 131072
fi
fi
if [[ "$(ulimit -u)" != "unlimited" ]]; then
if [[ "$(ulimit -u)" -lt 8192 ]]; then
echo "ulimit -u 8192"
ulimit -u 8192
fi
fi
---
...
initContainers:
- name: init-sysctl
image: busybox:1.32
imagePullPolicy: IfNotPresent
securityContext:
privileged: true
resources:
{}
command: ["sh",
"-e",
"/tmp/scripts/init_sysctl.sh"]
volumeMounts:
- name: init-sysctl
mountPath: /tmp/scripts/
containers:
- name: sonarqube
image: sonarqube:...
...
volumes:
- name: init-sysctl
configMap:
name: sonarqube-sonarqube-init-sysctl
items:
- key: init_sysctl.sh
path: init_sysctl.sh
- name: sonar-data
备注
此答案并不完全适用于该问题,但是可以在kubernetes中运行声纳曲比时解决相同的问题。
答案 4 :(得分:0)
我建议您在 k8s 清单中添加 args
<块引用>-Dsonar.search.javaAdditionalOpts=-Dnode.store.allow_mmap=false
例如:
spec:
containers:
- image: sonarqube:8.8-community
args:
- -Dsonar.web.context=/sonar
- -Dsonar.search.javaAdditionalOpts=-Dnode.store.allow_mmap=false