ThoughtWorks GoCd Server服务端问题排查
本文地址https://www.cnblogs.com/slankka/p/13921657.html
摘要
在开发持续交付-持续集成系统的过程中,后端使用了ThoughtWorks公司出的Gocd,Gocd经过验证发现系统非常易于部署,完备性高,可用性高,诊断问题较为方便。这篇文章主要讲解了两个问题,第一如何查看系统日志,以便于诊断问题;第二如何找出基于Postgresql数据库的部署备份出错的原因,并解决。
如何查看系统具体某些行为日志
在/etc/go/新建logback-include.xml
<?xml version="1.0" encoding="UTF-8"?>
<included>
<appender name="debug-appender" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${gocd.server.log.dir:-logs}/debug.log</file>
<!-- Use `C:\Program Files\Go Server\logs\` on windows and `~/Library/Application Support/Go Server/logs/` on Mac OS for log directory path. -->
<encoder>
<pattern>%date{ISO8601} %-5level [%thread] %logger{0}:%line - %msg%n</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${gocd.server.log.dir:-logs}/debug.log.%d{yyyy-MM-dd}.%i.gz</fileNamePattern>
<!-- Use `C:\Program Files\Go Server\logs\` on windows and `~/Library/Application Support/Go Server/logs/` on Mac OS for log directory path. -->
<maxFileSize>10 MB</maxFileSize>
<maxHistory>10</maxHistory>
<totalSizeCap>512 MB</totalSizeCap>
</rollingPolicy>
</appender>
<logger name="org.eclipse.jetty.server.RequestLog" level="DEBUG" additivity="false">
<appender-ref ref="WebRequestsFileAppender" />
</logger>
<logger name="com.thoughtworks.go.server.service.AgentService" level="OFF" additivity="false">
<appender-ref ref="debug-appender" />
</logger>
<logger name="com.thoughtworks.go.server.database.pg.PostgresqlBackupProcessor" level="DEBUG" additivity="false">
<appender-ref ref="debug-appender" />
</logger>
<logger name="org.zeroturnaround.exec.ProcessExecutor" level="DEBUG" >
<appender-ref ref="debug-appender" />
</logger>
<logger name="com.thoughtworks.go.server.newsecurity" level="OFF" additivity="false">
<appender-ref ref="debug-appender" />
</logger>
<logger name="com.thoughtworks.go.domain.AccessToken" level="OFF" additivity="false">
<appender-ref ref="debug-appender" />
</logger>
</included>
无需重启,GoCD 的go-server自动发现这个文件,且自动刷新
PostgreSQL数据库备份失败,如何查看错误的真实原因
Failed to perform backup. Reason: java.lang.RuntimeException: There was an error backing up the database using `pg_dump`. The `pg_dump` process exited with status code 1. Please see the server logs for more errors.
PostgresqlBackupProcessor 是PostGres数据库Backup进程的logger。
结论
2020-11-03 17:55:48,477 DEBUG [115@MessageListener for ServerBackupListener] ProcessExecutor:42 - Executing [pg_dump, --no-password, --host=xx.xx.xx.xxx, --port=5432, --username=gocd_database_user, gocd, --file=/var/lib/go-server/artifacts/serverBackups/backup_20201103-175548/db.gocd] with environment {PGPASSWORD=xxxxx}.
2020-11-03 17:55:48,480 DEBUG [115@MessageListener for ServerBackupListener] ProcessExecutor:42 - Started Process[pid=33721, exitValue="not exited"]
2020-11-03 17:55:48,497 DEBUG [Thread-103112] PostgresqlBackupProcessor:35 - pg_dump: server version: 13.0; pg_dump version: 9.2.24
2020-11-03 17:55:48,497 DEBUG [Thread-103112] PostgresqlBackupProcessor:35 - pg_dump: aborting because of server version mismatch
2020-11-03 17:55:48,500 WARN [115@MessageListener for ServerBackupListener] PostgresqlBackupProcessor:47 - There was an error backing up the database using `pg_dump`. The `pg_dump` process exited with status code
此问题解决方案
- yum list installed |grep postgres 查看系统安装的PostgreSQL Client版本
- yum remove postgres 删除旧版本的Postgres
- yum install/reinstall postgres13 安装最新版本的PostgreSQL Client(日志对应13.0)