使用gitlab-ctl status命令查看GitLab各组件(如unicorn、nginx、postgresql等)的运行状态。若服务未运行,可通过gitlab-ctl start启动所有组件;若部分组件异常,可单独重启(如gitlab-ctl restart unicorn)。
GitLab日志集中存储在/var/log/gitlab目录下,涵盖应用、Nginx、数据库、Redis等组件。常用命令:
sudo gitlab-ctl tailsudo gitlab-ctl tail nginx/gitlab_error.logtail -f /var/log/gitlab/gitlab-rails/production.logGitLab依赖PostgreSQL(数据库)、Redis(缓存)、Nginx(Web服务)等组件,需确保它们均正常运行:
sudo systemctl status postgresqlsudo systemctl status redissudo systemctl status nginxsudo systemctl start <服务名>启动,并设置为开机自启(sudo systemctl enable <服务名>)。GitLab默认使用以下端口:
lsof -i :端口号),并通过防火墙开放:sudo firewall-cmd --permanent --add-service=http sudo firewall-cmd --permanent --add-service=https sudo firewall-cmd --permanent --add-service=ssh sudo firewall-cmd --reload 若使用SELinux,需调整上下文(sudo semanage fcontext -a -t httpd_sys_rw_content_t "/var/log/gitlab(/.*)?",sudo restorecon -Rv /var/log/gitlab)。GitLab主配置文件为/etc/gitlab/gitlab.rb,需检查以下关键配置:
external_url:设置为服务器公网IP或域名(如http://192.168.1.100),修改后需运行sudo gitlab-ctl reconfigure使配置生效。gitlab_rails['db_host']、gitlab_rails['db_username']、gitlab_rails['db_password']等参数正确。gitlab_rails['smtp_address']、gitlab_rails['smtp_port'])。GitLab对资源要求较高,需确保:
free -h查看内存使用,关闭不必要的服务或增加Swap分区。/)和/var/opt/gitlab(数据目录)需有足够空间(推荐至少100GB),使用df -h检查,清理无用文件(如/tmp目录)。/etc/gitlab/nginx/conf/gitlab-http.conf)中的upstream地址是否正确,或重启Nginx(gitlab-ctl restart nginx)。pg_hba.conf是否允许GitLab用户访问(如添加host all all 127.0.0.1/32 md5),并重启PostgreSQL。若以上步骤无法解决,建议查阅GitLab官方文档(https://docs.gitlab.com/ee/install/centos.html)或社区论坛(https://forum.gitlab.com/),获取针对性解决方案。对于复杂问题,可联系GitLab官方支持(需企业版订阅)。