Gitlab 快速部署及日常维护 (二)
一、概述
上一篇我们将Gitlab的安装部署和初始化设置部分全部讲解完成了,接下来我们介绍Gitlab在日常工作中常遇见的问题进行梳理说明。
二、Gitlab的安装和维护过程中常见问题
1、Gitlab访问出现403"Forbidden"现象
问题原因分析:
可能因较多的并发导致的访问被拒绝, Gitlab使用rack_attack做了并发访问的限制!
解决办法:
打开/etc/gitlab/gitlab.rb文件,查找 gitlab_rails['rack_attack_git_basic_auth'] 关键词,取消注释,
修改ip_whitelist白名单属性,加入Gitlab部署的IP地址。
[root@gitlab ~]# vim /etc/gitlab/gitlab.rb
......
gitlab_rails['rack_attack_git_basic_auth'] = {
'enabled' => true,
'ip_whitelist' => ["127.0.0.1","172.16.60.222"], //把gitlab服务器IP地址添加
'maxretry' => 10,
'findtime' => 60,
'bantime' => 3600
}
然后进行重新配置
[root@gitlab ~]# gitlab-ctl reconfigure
2、Gitlab访问出现502的现象
Gitlab访问出现:Whoops, GitLab is taking too much time to respond.
问题原因分析:
1)unicorn原8080默认端口被容器中别的进程已经占用,必须调整为没用过的
2)gitlab的timeout设置过小,默认为60
解决办法:
1)关闭gitlab服务
[root@gitlab ~]# gitlab-ctl stop
2)选择一个没有被系统占用的端口作为unicorn端口,比如8877端口(lsof -i:8877 确认此端口没有被占用)
[root@gitlab ~]# vim /etc/gitlab/gitlab.rb
unicorn['port'] = 8877
gitlab_workhorse['auth_backend'] = "http://localhost:8877"
3)重新生成配置,并进行重启。
[root@gitlab ~]# gitlab-ctl reconfigure
[root@gitlab ~]# gitlab-ctl restart
3、Gitlab启动失败,或重新安装时出现卡的状态
问题现象:在卸载gitlab然后再次安装执行sudo gitlab-ctl reconfigure的时候往往会出现:ruby_block[supervise_redis_sleep] action run,会一直卡无法往下进行!
解决办法:
1)按ctrl + c 强制结束
2)执行"systemctl restart gitlab-runsvdir" 命令
3)接着再执行"gitlab-ctl reconfigure"
如果Gitlab服务器重启后,启动"gitlab-ctl start"失败,解决办法相同。
[root@gitlab ~]# systemctl restart gitlab-runsvdir
[root@gitlab ~]# gitlab-ctl reconfigure
[root@gitlab ~]# gitlab-ctl start
4、Gitlab异常关机,导致gitlab启动失败!gitlab-runsvdir方式启动没反应(僵尸状态)
问题现象:Gitlab部署的服务器异常断电,机器重启后,尝试启动gitlab服务,启动失败!通过gitlab-runsvdir方式启动一直没有反应!一直在卡顿状态!日志也没有任务输入!
执行下面的启动命令报错:
[root@gitlab ~]# gitlab-ctl start // 或者 "gitlab-ctl restart"
fail: alertmanager: runsv not running
fail: gitaly: runsv not running
fail: gitlab-monitor: runsv not running
fail: gitlab-workhorse: runsv not running
fail: logrotate: runsv not running
fail: nginx: runsv not running
fail: node-exporter: runsv not running
fail: postgres-exporter: runsv not running
fail: postgresql: runsv not running
fail: prometheus: runsv not running
报错说"runsv not running"
那么尝试通过supervisor进程方式启动gitlab,发现一直在卡顿中,根本没有任何反应![root@gitlab ~]# systemctl restart gitlab-runsvdir
查看日志,发现也没有任务启动信息打印到日志中 (日志都是之前的)
[root@gitlab ~]# /usr/bin/gitlab-ctl tail
gitlab-runsvdir启动在卡顿中,gitlab服务也没有起来
[root@gitlab ~]# ps -ef|grep gitlab
解决方法:
通过Gitlab自己原生命令去启动服务:/opt/gitlab/embedded/bin/runsvdir-startroot@gitlab ~]# cat /etc/systemd/system/multi-user.target.wants/gitlab-runsvdir.service
[Unit]
Description=GitLab Runit supervision process
After=multi-user.target [Service]
ExecStart=/opt/gitlab/embedded/bin/runsvdir-start #最后通过这条命令启动了Gitlab
Restart=always [Install]
WantedBy=multi-user.target 执行下面的启动,虽然发现这个也会一直在卡顿中,但是不影响gitlab服务启动。
[root@gitlab ~]# /opt/gitlab/embedded/bin/runsvdir-start 重新打开一个终端窗口,发现gitlab已经有新的日志信息打入了,gitlab也服务已经起来了
[root@gitlab ~]# /usr/bin/gitlab-ctl tail
[root@gitlab ~]# ps -ef|grep gitlab 这时候关闭上面执行"/opt/gitlab/embedded/bin/runsvdir-start"的卡顿的终端窗口,发现gitlab也还是启动状态(ps -ef|grep gitlab)
[root@gitlab ~]# ps -ef|grep gitlab
[root@gitlab ~]# lsof -i:80
[root@gitlab ~]# gitlab-ctl status
run: alertmanager: (pid 29804) 1640s; run: log: (pid 29789) 1640s
run: gitaly: (pid 29795) 1640s; run: log: (pid 29781) 1640s
run: gitlab-monitor: (pid 29799) 1640s; run: log: (pid 29785) 1640s
run: gitlab-workhorse: (pid 29794) 1640s; run: log: (pid 29780) 1640s
run: logrotate: (pid 29798) 1640s; run: log: (pid 29783) 1640s
run: nginx: (pid 29800) 1640s; run: log: (pid 29786) 1640s
run: node-exporter: (pid 29802) 1640s; run: log: (pid 29788) 1640s
run: postgres-exporter: (pid 29805) 1640s; run: log: (pid 29790) 1640s
run: postgresql: (pid 29796) 1640s; run: log: (pid 29782) 1640s
run: prometheus: (pid 29797) 1640s; run: log: (pid 29784) 1640s
run: redis: (pid 29818) 1640s; run: log: (pid 29793) 1640s
run: redis-exporter: (pid 29817) 1640s; run: log: (pid 29792) 1640s
run: sidekiq: (pid 29801) 1640s; run: log: (pid 29787) 1640s
run: unicorn: (pid 29807) 1640s; run: log: (pid 29791) 1640s 查看日志也有新信息写入,一切正常了!
[root@gitlab ~]# /usr/bin/gitlab-ctl tail
5、Gitlab重新安装,在执行"gitlab-ctl reconfigure"配置环节出现了下面报错:
[root@gitlab ~]# gitlab-ctl reconfigure
.........
.........
STDERR: sysctl: cannot open "/etc/sysctl.d/90-omnibus-gitlab-kernel.sem.conf": No such file or directory
sysctl: cannot open "/etc/sysctl.d/90-omnibus-gitlab-net.core.somaxconn.conf": No such file or directory
---- End output of sysctl -e --system ----
Ran sysctl -e --system returned 255
问题原因分析:
丢失了报错中的这两个配置文件,进入/etc/sysctl.d目录发现,这两个文件都是通过链接到/opt/gitlab/embedded/etc/目录下。
然而/opt/gitlab/embedded/etc/确实没有这两个文件。
[root@gitlab ~]# ll /etc/sysctl.d/
total 0
lrwxrwxrwx 1 root root 58 Nov 10 22:23 90-omnibus-gitlab-kernel.sem.conf -> /opt/gitlab/embedded/etc/90-omnibus-gitlab-kernel.sem.conf
lrwxrwxrwx 1 root root 61 Nov 10 22:23 90-omnibus-gitlab-kernel.shmall.conf -> /opt/gitlab/embedded/etc/90-omnibus-gitlab-kernel.shmall.conf
lrwxrwxrwx 1 root root 61 Nov 10 22:23 90-omnibus-gitlab-kernel.shmmax.conf -> /opt/gitlab/embedded/etc/90-omnibus-gitlab-kernel.shmmax.conf
lrwxrwxrwx 1 root root 66 Nov 10 22:25 90-omnibus-gitlab-net.core.somaxconn.conf -> /opt/gitlab/embedded/etc/90-omnibus-gitlab-net.core.somaxconn.conf
lrwxrwxrwx. 1 root root 14 Oct 30 09:13 99-sysctl.conf -> ../sysctl.conf [root@gitlab ~]# ll /opt/gitlab/embedded/etc
total 12
-rw-r--r-- 1 root root 24 Apr 12 23:18 90-omnibus-gitlab-kernel.shmall.conf
-rw-r--r-- 1 root root 28 Apr 12 23:17 90-omnibus-gitlab-kernel.shmmax.conf
-rwxr-xr-x 1 root root 196 Apr 12 23:16 gitconfig [root@gitlab ~]# ll /opt/gitlab/embedded/etc/90-omnibus-gitlab-kernel.sem.conf
ls: cannot access /opt/gitlab/embedded/etc/90-omnibus-gitlab-kernel.sem.conf: No such file or directory
[root@gitlab ~]# ll /opt/gitlab/embedded/etc/90-omnibus-gitlab-net.core.somaxconn.conf
ls: cannot access /opt/gitlab/embedded/etc/90-omnibus-gitlab-net.core.somaxconn.conf: No such file or directory 解决方法一:
从别的备份机(或者在别的机器上重新安装一次,"gitlab-ctl reconfigure"之后生成这两个文件)将这两个文件拷贝回来! 解决方法二:
[root@gitlab ~]# vim /etc/gitlab/gitlab.rb
# unicorn['port'] = 8080
修改为:
unicorn['port'] = 8090 之后重新加载配置文件
[root@gitlab ~]# gitlab-ctl reconfigure 再次会报错,然后再修改/etc/gitlab/gitlab.rb,修改为原来的配置
[root@gitlab ~]# vim /etc/gitlab/gitlab.rb
# unicorn['port'] = 8080 再次重新加载配置文件就OK了!
[root@gitlab ~]# gitlab-ctl reconfigure 再次查看,发现上面配置中报错的两个文件已经存在了
[root@gitlab ~]# ll /opt/gitlab/embedded/etc/
total 20
-rw-r--r-- 1 root root 30 Apr 12 23:33 90-omnibus-gitlab-kernel.sem.conf
-rw-r--r-- 1 root root 24 Apr 12 23:18 90-omnibus-gitlab-kernel.shmall.conf
-rw-r--r-- 1 root root 28 Apr 12 23:17 90-omnibus-gitlab-kernel.shmmax.conf
-rw-r--r-- 1 root root 26 Apr 12 23:35 90-omnibus-gitlab-net.core.somaxconn.conf
-rwxr-xr-x 1 root root 196 Apr 12 23:16 gitconfig
[root@gitlab ~]# ll /opt/gitlab/embedded/etc/90-omnibus-gitlab-kernel.sem.conf
-rw-r--r-- 1 root root 30 Apr 12 23:33 /opt/gitlab/embedded/etc/90-omnibus-gitlab-kernel.sem.conf
[root@gitlab ~]# ll /opt/gitlab/embedded/etc/90-omnibus-gitlab-net.core.somaxconn.conf
-rw-r--r-- 1 root root 26 Apr 12 23:35 /opt/gitlab/embedded/etc/90-omnibus-gitlab-net.core.somaxconn.conf 最后再启动gitlab
[root@gitlab ~]# gitlab-ctl start
6、Gitlab更改默认Nginx
更换gitlab自带Nginx,使用自行编译Nginx来管理gitlab服务。
自行编译的nginx服务和gitlab在同一台机器上
1)编辑gitlab配置文件禁用自带Nignx服务器
[root@gitlab ~]# vim /etc/gitlab/gitlab.rb
...
#设置nginx为false,关闭自带Nginx
nginx['enable'] = false
... 2)检查默认nginx配置文件,并迁移至新Nginx服务 (即将下面两个gitlab自带nginx的配置文件迁移到自行编译的新的nginx配置中)
/var/opt/gitlab/nginx/conf/nginx.conf #nginx配置文件,包含gitlab-http.conf文件
/var/opt/gitlab/nginx/conf/gitlab-http.conf #gitlab核心nginx配置文件 [root@gitlab ~]# cp /var/opt/gitlab/nginx/conf/nginx.conf /etc/nginx/conf.d/
[root@gitlab ~]# cp /var/opt/gitlab/nginx/conf/gitlab-http.conf /etc/nginx/conf.d/ 3)重启gitlab服务
[root@gitlab ~]# gitlab-ctl reconfigure
[root@gitlab ~]# gitlab-ctl restart 重启自行编译的nginx服务
[root@gitlab ~]# service nginx restart 如果访问报502。原因是nginx用户无法访问gitlab用户的socket文件。
重启gitlab需要重新授权
[root@gitlab ~]# chmod -R o+x /var/opt/gitlab/gitlab-rails
-----------------------------------------------------------书山有路勤为径,学海无涯苦作舟-------------------------------------------------------------
Gitlab 快速部署及日常维护 (二)的更多相关文章
- Gitlab 快速部署及日常维护 (一)
一.GitLab简介GitLab 是一个用于仓库管理系统的开源项目,使用Git作为代码管理工具,并在此基础上搭建起来的web服务 二.GitLab系统架构git用户的主目录通常是/home/git(~ ...
- 【gitlab】gitlab快速部署教程
gitlab快速部署教程 部署环境 Ubuntu 16.04(亲测可用) 开始部署 安装依赖 sudo apt-get install curl openssh-server ca-certifica ...
- Oracle 11.2.0.4.0 Dataguard部署和日常维护(7) - Dataguard Flashback篇
1. 设置备库的闪回目录 show parameter db_recovery_file; NAME TYPE VALUE ------------------------------------ - ...
- Oracle 11.2.0.4.0 Dataguard部署和日常维护(6)-Dataguard Snapshot篇
1. 检查当前主备库同步状态 on primary select ads.dest_id,max(sequence#) "Current Sequence", max(log_se ...
- Oracle 11.2.0.4.0 Dataguard部署和日常维护(6)-Active Dataguard篇
1. 检查主备库的状态 on primary column DATABASE_ROLE format a20 column OPEN_MODE format a15 column PROTECTION ...
- Oracle 11.2.0.4.0 Dataguard部署和日常维护(5)-Datauard 主备切换和故障转移篇
1. dataguard主备切换 1.1. 查看当前主备库是否具备切换条件 on slave select sequence#,first_time,next_time,archived,appl ...
- Oracle 11.2.0.4.0 Dataguard部署和日常维护(4)-Datauard Gap事件解决篇
Oracle dataguard主库删除备库需要的归档时,会导致gap事情的产生,或者备库由于网络或物理故障原因,倒是备库远远落后于主库,都会产生gap事件,本例模拟gap事件的产生以及处理. 1. ...
- Oracle 11.2.0.4.0 Dataguard部署和日常维护(3)-Datauard监控篇
1. v$database 查看当前数据库的角色和保护模式 primary库查看 column NAME format a10 column PROTECTION_MODE format a2 ...
- Oracle 11.2.0.4.0 Dataguard部署和日常维护(2)-Datauard部署篇
1. primary库设置dataguard相关参数 1.1. 强制primay库在任何状态下必须记录日志 SYS@userdata>select FORCE_LOGGING from v$ ...
随机推荐
- 目录遍历 - Pikachu
概述: 在web功能设计中,很多时候我们会要将需要访问的文件定义成变量,从而让前端的功能便的更加灵活. 当用户发起一个前端的请求时,便会将请求的这个文件的值(比如文件名称)传递到后台,后台再执行其对应 ...
- apijson简单使用
apijson简单使用 介绍 APIJSON 是一种专为 API 而生的 JSON 网络传输协议 以及 基于这套协议实现的 ORM 库.为简单的增删改查.复杂的查询.简单的事务操作 提供了完全自动化的 ...
- new String("ab")到底创建了几个对象说明
new String("ab")到底创建了几个对象? 之前一直被这个问题困扰,网上一些描述的都不是很清楚,自己看了一些资料可算搞清楚了,那就在博客上记录一下吧! String st ...
- uni-app通过canvas实现手写签名
分享一个uni-app实现手写签名的方法 具体代码如下: <template> <view > <view class="title">请在下面 ...
- Apache Unomi 远程代码执行漏洞复现(CVE-2020-13942)
一.漏洞描述 Apache Unomi 是一个基于标准的客户数据平台(CDP,Customer Data Platform),用于管理在线客户和访客等信息,以提供符合访客隐私规则的个性化体验.在Apa ...
- mysqldump导出数据库导入数据库
使用mysqldump命令导出数据库,格式如下,请按实际要求对参数进行替换: mysqldump -u 用户名 -p 数据库名 > 导出的文件名 比如导出数据库business_db: mysq ...
- Bitter.Core系列 十二 :Bitter ORM NETCORE ORM 全网最粗暴简单易用高性能的 NETCore 之 支持的 where 条件表达式
Bitter.Core 内置了支持大部分的 linq 的条件表达式.基本上符合我们 where 条件所需.Bitter.Core 的支持 表达式内置 扩展 有: EndsWith 在Sql 解 ...
- go语言rpc学习
rpc 就是 远程过程调用 指的是调用远端服务器上的程序的方法整个过程. rpc 理论 RPC技术在架构设计上有四部分组成,分别是:客户端.客户端存根.服务端.服务端存根. 客户端:服务调用发 ...
- 符号表 symbol table 符号 地址 互推
https://zh.wikipedia.org/wiki/符号表 https://en.wikipedia.org/wiki/Symbol_table 在计算机科学中,符号表是一种用于语言翻译器(例 ...
- DPDK CAS(compare and set)操作
前言 rte_ring是一个无锁队列,无锁队列的出队入队操作是rte_ring实现的关键.因此,本文主要讲解dpdk是怎样使用无锁机制实现rte_ring的多生产者入队操作. rte_atomic32 ...