一、安装与配置问题
policycoreutils-python、openssh-server、postfix等依赖包报错。解决方法:使用系统包管理器安装缺失依赖(如CentOS下sudo yum install -y policycoreutils-python openssh-server postfix);若遇libsemanage-static或libsemanage-devel缺失(常见于SELinux配置错误),需安装对应包并重新配置。/etc/gitlab/gitlab.rb(如设置external_url)时,语法错误或配置项无效会导致服务异常。解决方法:仔细检查配置文件格式(如引号、缩进),修改后执行sudo gitlab-ctl reconfigure重新应用配置。netstat -tulnp | grep 端口号确认端口占用进程,修改/etc/gitlab/gitlab.rb中的端口设置(如nginx['listen_port'] = 9099),然后重启GitLab服务。sudo firewall-cmd --permanent --add-service=https --add-service=http),然后sudo firewall-cmd --reload。二、权限与认证问题
/var/opt/gitlab/git-data/repositories),使用chown -R git:git /path/to/repo将所有权赋予Git用户,或用chmod调整权限(如chmod 755 /path/to/dir)。ssh-keygen -t rsa -b 4096 -C "your_email@example.com"),将公钥(~/.ssh/id_rsa.pub)添加到GitLab用户设置的SSH Keys中。/var/log/gitlab/gitlab-rails/production.log)定位具体错误(如数据库连接失败、代码异常),根据日志修复问题。三、性能问题
top、htop命令查看资源占用,关闭不必要的进程;增加服务器资源(如升级CPU、内存);启用Swap分区(sudo fallocate -l 2G /swapfile,sudo chmod 600 /swapfile,sudo mkswap /swapfile,sudo swapon /swapfile)。gitlab-rake gitlab:db:gc);优化数据库索引(使用EXPLAIN ANALYZE分析慢查询);调整PostgreSQL配置(如shared_buffers设为内存的25%-40%,work_mem设为4MB-16MB)。gitlab_rails['redis_cache_instance'] = "redis://127.0.0.1:6379");优化GitLab配置(如调整unicorn['worker_processes']为CPU核心数的1-2倍,unicorn['worker_timeout']设为60秒);使用CDN加速静态资源。四、日常运维问题
sudo gitlab-ctl status查看服务状态,停止所有服务(sudo gitlab-ctl stop),删除阻塞文件(如/var/opt/gitlab/gitaly/gitaly.pid),再重新启动(sudo gitlab-ctl start)。/etc/gitlab/gitlab.rb中的gitlab_rails['log_rotate_frequency'] = 'daily',gitlab_rails['log_max_size'] = '200MB'),然后sudo gitlab-ctl reconfigure;定期清理过期日志(sudo find /var/log/gitlab -type f -name "*.log" -mtime +7 -delete)。sudo gitlab-rake gitlab:backup:create),设置备份目录(gitlab_rails['backup_path'] = '/var/opt/gitlab/backups'),定期测试恢复流程(sudo gitlab-rake gitlab:backup:restore BACKUP=timestamp)。