首页 > 其他分享 >安装 SonarQube后sonarqube-sonarqube无法启动的问题解决

安装 SonarQube后sonarqube-sonarqube无法启动的问题解决

时间:2023-09-27 16:23:06浏览次数:31  
标签:INFO 38 06 sonarqube 27 SonarQube postgresql 安装

1. 前言

我的环境:k8s集群(version 1.23.6),安装了Kubesphere(version v3.4)作为可视化界面,最近想要推动团队走CICD,于是在Kubesphere中启用了devops组件,参考:https://kubesphere.io/zh/docs/v3.4/pluggable-components/devops/ 。

组件安装完成后,需要将Sonarqube集成到流水线中,于是又安装了Sonarqube,参考:https://kubesphere.io/zh/docs/v3.4/devops-user-guide/how-to-integrate/sonarqube/ 。

按照步骤走完之后,不出意外的话意外又发生了,有两个工作负载没起来,分别是:

  • sonarqube-sonarqube
  • sonarqube-postgresql

通过查看Kubesphere观察,发现sonarqube-sonarqube一直在重启,于是我把存活探针与就绪探针暂时都去掉了。最后在日志发现报错如:

2020.11.27 09:55:47 INFO  web[][o.sonar.db.Database] Create JDBC data source for jdbc:postgresql://sonarqube-postgresql:5432/sonarDB
2020.11.27 09:55:47 ERROR web[][o.s.s.p.PlatformImpl] Web server startup failed
java.lang.IllegalStateException: Fail to connect to database

可以定位到时Postgresql有问题导致的,于是查看Postgresql服务的日志,发现:

Kubesphere sonarqube postgresql DETAIL:  Role "sonarUser" does not exist

如果分析sonarqube-sonarqube和sonarqube-postgresql这两个工作负载配置文件可以发现,这个用户是sonarqube-postgresql在启动的时候创建的用户名,sonarqube-sonarqube也使用这个用户名去连接sonarqube-postgresql,密码存放在保密字典sonarqube-postgresql中。

通过上面的现象,可以分析出根本原因是sonarqube-postgresql在启动的时候根本没有创建sonarUser这个用户(可以通过sonarqube-postgresql的终端去验证)。

但是为什么sonarqube-postgresql没有成功创建出这个用户呢?

2. 原因分析

首先我把sonarqube-postgresql的两个探针都去掉了,重启,还是报同样的错误。

然后我把env中的POSTGRES_USER,POSTGRES_PASSWORD,POSTGRES_DB这三个值都改成新的值,重启,进入终端,发现还是无法创建用户。

这就很难办,最后通过查询,获得一个关键的信息(参考[1]):

Warning: the Docker specific variables will only have an effect if you start the container with a data directory that is empty; any pre-existing database will be left untouched on container startup.

也就是说,之前第一次启动的时候,sonarqube-postgresql还没有初始化完,就给就绪探针给干掉了,导致只做了部分初始化而没有创建用户,重启的时候由于绑定的pv已经存在数据库了,于是又无法创建用户,整个过程如下:

3. 解决

要解决上面创建用户失败的问题,首先需要延长探针的时间或者直接把探针先去掉,等创建完用户之后,再重新加进去,同时需要先删除已有的数据库,也就是说pv也要删除,要删除pv,必须先删除绑定的pvc,要删除pvc也要先删除绑定的pod,由于stateful的重启策略无法设定为Never,因此无法通过停止pod来删除pvc。套娃套到这里,就只能先保存sonarqube-postgresql的配置(如Postgresql.yaml),然后把这个statefulset先删除了,然后删除pvc和pv。

具体删除通过Kubesphere进行删除即可。

然后删除Postgresql.yaml中的两个探针,重新创建statefulset,可以看到初始化过程还是很久的,在我的机器上差不多用了6分钟,日志如下:

 postgresql 06:38:52.24 
 postgresql 06:38:52.24 Welcome to the Bitnami postgresql container
 postgresql 06:38:52.25 Subscribe to project updates by watching https://github.com/bitnami/bitnami-docker-postgresql
 postgresql 06:38:52.25 Submit issues and feature requests at https://github.com/bitnami/bitnami-docker-postgresql/issues
 postgresql 06:38:52.25 Send us your feedback at [email protected]
 postgresql 06:38:52.25 
 postgresql 06:38:52.26 INFO  ==> ** Starting PostgreSQL setup **
 postgresql 06:38:52.34 INFO  ==> Validating settings in POSTGRESQL_* env vars..
 postgresql 06:38:52.35 INFO  ==> Loading custom pre-init scripts...
 postgresql 06:38:52.36 INFO  ==> Initializing PostgreSQL database...
 postgresql 06:38:52.50 INFO  ==> postgresql.conf file not detected. Generating it...
 postgresql 06:38:52.51 INFO  ==> pg_hba.conf file not detected. Generating it...
 postgresql 06:38:52.51 INFO  ==> Generating local authentication configuration
 postgresql 06:43:21.36 INFO  ==> Starting PostgreSQL in background...
 postgresql 06:44:38.05 INFO  ==> Creating user sonarUser
 postgresql 06:44:38.14 INFO  ==> Grating access to "sonarUser" to the database "sonarDB"
 postgresql 06:44:38.23 INFO  ==> Configuring replication parameters
 postgresql 06:44:38.28 INFO  ==> Configuring fsync
 postgresql 06:44:38.41 INFO  ==> Loading custom scripts...
 postgresql 06:44:38.42 INFO  ==> Enabling remote connections
 postgresql 06:44:38.44 INFO  ==> Stopping PostgreSQL...
 postgresql 06:44:41.46 INFO  ==> ** PostgreSQL setup finished! **
 postgresql 06:44:41.54 INFO  ==> ** Starting PostgreSQL **

回到sonarqube-sonarqube服务,发现已经可以连接上了,并开始了初始化进程,观察日志:

 2023.09.27 07:16:21 INFO  web[][o.sonar.db.Database] Create JDBC data source for jdbc:postgresql://sonarqube-postgresql:5432/sonarDB
 2023.09.27 07:16:21 INFO  web[][o.s.s.p.ServerFileSystemImpl] SonarQube home: /opt/sonarqube
 2023.09.27 07:16:21 INFO  web[][o.s.s.u.SystemPasscodeImpl] System authentication by passcode is disabled
 2023.09.27 07:16:21 WARN  web[][o.s.s.p.DatabaseServerCompatibility] The database must be manually upgraded. Please backup the database and browse /setup. For more information: https://docs.sonarqube.org/latest/setup/upgrading
 2023.09.27 07:16:21 WARN  app[][startup] ################################################################################
 2023.09.27 07:16:21 WARN  app[][startup] The database must be manually upgraded. Please backup the database and browse /setup. For more information: https://docs.sonarqube.org/latest/setup/upgrading
 2023.09.27 07:16:21 WARN  app[][startup] ################################################################################

连是连上了,但是要升级数据库,开源组件就是让人心累……

4. 参考

[1] SonarQube Community Edition on k8s Role “sonarUser” does not exist

 

标签:INFO,38,06,sonarqube,27,SonarQube,postgresql,安装
From: https://www.cnblogs.com/harrymore/p/17732986.html

相关文章

  • logwatch日志分析工具安装与使用
    Linux日志分析工具(logwatch)安装及使用运维网工 2023-09-1209:00 发表于重庆收录于合集#运维工程师185个#Linux运维19个#linux运维23个#运维工具96个链接:http://c.biancheng.net/view/1108.htmlLinux日志分析工具(logwatch)安装及使用日志是非常重要的系统文......
  • clickhouse linux 客户端安装和使用
    clickhouselinux客户端安装步骤1:上传安装文件到服务器目录(可以使用正常用户上传)2:使用root用户安装,否则会提示权限不够报错,此外非X86架构服务器也可能会报错(如linuxone服务器报错:packageclickhouse-common-static-0:23.3.6.7-1.x86_64isintendedforadifferentarchitect......
  • Pycharm安装bs4第三方库出错
    昨日正好写的demo需要bs4包,然而安装该库出现了许多问题,下面是复盘以及解决方式(最后直达)。直接安装:点击file(文件)->setting设置进入下界面后,找到自己的项目中的PythonInterperter,发现确实没有bs4,当然就想到进行安装。 点击右上角的加号进入AvailablePackages界面,即可寻找......
  • Ubuntu虚拟机保姆级安装教程
    一、准备工作①下载软件首先打开链接下载VMwareWorkstationPro和Ubuntu需要的镜像文件https://www.123pan.com/s/SaYRVv-MI2g3.html②登录完就开始下载了③最后得到的是这两个文件二、安装工作双击打开这个软件1.下一步2.3.输入密钥JU090-6039P-08409-8J0Q......
  • macOS下安装python3
    使用brew安装python3brewinstallpython3Running`brewupdate--auto-update`...==>Downloadinghttps://ghcr.io/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:61029cec31c68a1fae1fa90fa876adf43d0becff777da793f9b5c5577f00567a#########################......
  • CentOS7下yum安装php7
    1.安装epel-releaseEPEL(ExtraPackagesforEnterpriseLinux)存储库提供了标准RedHat和CentOS存储库中未包含的其他软件包。EPEL存储库的创建是因为Fedora贡献者希望使用他们在RedHatEnterpriseLinux(RHEL)及其衍生产品(如CentOS,OracleLinux和ScientificLinux)上维护的软......
  • diffusers[torch]==0.21.2 torch==2.0.1+cu117 安装失败解决办法
    安装失败主要原因是pip源使用索引为官方使用清华源设置如下pipinstall-rrequirements.txt\--extra-index-urlhttps://download.pytorch.org/whl/cu117\-ihttps://pypi.tuna.tsinghua.edu.cn/simple......
  • python2.7 pip install pyyaml 安装出现错误
    conda环境python2.7 安装pyyaml:pipinstallpyyaml错误如下: ERROR:Commanderroredoutwithexitstatus1:  command:bin/python2.7/python2.7/site-packages/pip/_vendor/pep517/_in_process.pyget_requires_for_build_wheel/tmp/tmp4If62U    估计是......
  • linux安装tff格式字体(转载)
    记录下Linux系统装字体的步骤。把字体放到/usr/share/fonts下(可以自己在这个目录下新建一个子目录放进去)fc-cache-fv结束。转载自:https://blog.csdn.net/ouyangzhenxin/article/details/82387632......
  • 如何创建可引导的 macOS Sonoma 安装介质
    2023年9月26日(北京时间27日凌晨)macOSSonoma正式版现已发布。如何创建可引导的macOSSonoma安装介质如何创建可引导的macOS安装器|如何制作macOSUSB启动盘请访问原文链接:https://sysin.org/blog/macos-createinstallmedia/,查看最新版。原创作品,转载请保留出处......