首页 > 系统相关 >Linux安装gitlab(yum方式、rpm方式)

Linux安装gitlab(yum方式、rpm方式)

时间:2023-03-07 15:02:13浏览次数:60  
标签:opt Gitlab gitlab rails yum Linux ctl root

目录

一、概述

二、安装

0、前置条件

1、配置yum源

2、更新本地yum缓存

3、安装gitlab社区版

 4、更改配置文件参数

1)更改默认端口

2)配置邮箱

3)修改root管理员密码

4)性能优化

5、重新启动

6、其他命令 

三、使用

 1、更改语言

 2、更改用户注册设置


 

一、概述

Gitlab 是一个开源分布式的版本控制系统。 Ruby语言开发完成。
Gitlab 主要实现的功能:
1.管理项目源代码。
2.对源代码进行版本控制。
Gitlab 的优势:
1.开源免费,搭建简单、维护成本较低、适合中小型公司。
2.权限管理,能实现代码对部分人可见,确保项目的安全性
3.离线同步,保证我们不在实时依赖网络环境进行代码提交

二、安装

0、前置条件

关闭防火墙,查看防火墙状态,如果开启就stop关闭一下

systemctl status firewalld.service
 

1、配置yum源

vim /etc/yum.repos.d/gitlab-ce.repo
 

复制以下内容,然后 :wq! 保存退出 

  1. [gitlab-ce]
  2. name=Gitlab CE Repository
  3. baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/
  4. gpgcheck=0
  5. enabled=1

2、更新本地yum缓存

yum makecache
 

3、安装gitlab社区版

  1. #自动安装最新版本并安装相关依赖
  2. yum install gitlab-ce

也可以下载想要安装的gitlab版本,使用rpm命令安装

下载地址:Index of /gitlab-ce/yum/el7/ | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror

  1. #下载最新版本
  2. wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-15.2.0-ce.0.el7.x86_64.rpm --no-check-certificate
  3. #使用rpm安装需要手动解决依赖问题
  4. #前置条件依赖policycoreutils-python、openssh-server设置开机自启
  5. yum -y install policycoreutils-python openssh-server
  6. systemctl enable sshd
  7. systemctl start sshd
  8.  
  9. #还缺啥安装时会有提示,缺啥安装啥就行
  10. rpm -Uvh gitlab-ce-15.2.0-ce.0.el7.x86_64.rpm
  11.  
  12. #安装成功后启动
  13. gitlab-ctl reconfigure
  14.  
  15. gitlab-ctl restart

 4、更改配置文件参数

默认安装完成后安装目录

  1. gitlab组件日志路径:/var/log/gitlab
  2. gitlab配置路径:/etc/gitlab/ 路径下有gitlab.rb配置文件
  3. 应用代码和组件依赖程序:/opt/gitlab
  4. 各个组件存储路径: /var/opt/gitlab/
  5. 仓库默认存储路径 /var/opt/gitlab/git-data/repositories
  6. 版本文件备份路径:/var/opt/gitlab/backups/
  7. nginx安装路径:/var/opt/gitlab/nginx/
  8. redis安装路径:/var/opt/gitlab/redis

要更改配置文件我们需要修改/etc/gitlab/gitlab.rb

1)更改默认端口

  1. #ip为你服务器ip port你想要修改的端口号
  2. #修改如下:
  3. external_url 'http://ip:port'
  4. nginx['listen_https'] = false
  5. nginx['listen_port'] = port
  6. nignx['listen_address'] = ['*']
  7. #同时还需要修改nginx配置文件
  8. vim /var/opt/gitlab/nginx/conf/gitlab-http.conf
  9. #修改如下
  10. server {
  11. listen *:port;
  12. server_name ip
  13. if ($http_host = ""){
  14. set $http_host_with_default "ip:port";
  15. }
  16. }

2)配置邮箱

前置条件:需要安装postfix邮箱 

  1. #安装
  2. yum install -y postfix
  3. #设置开机自启
  4. systemctl enable postfix
  5. #启动
  6. systemctl start postfi
  7. #修改以下内容
  8. gitlab_rails['gitlab_email_enabled'] = true
  9. gitlab_rails['gitlab_email_from'] = '发信邮箱'
  10. gitlab_rails['gitlab_email_display_name'] = 'xxx'
  11.  
  12. gitlab_rails['smtp_enable'] = true
  13. gitlab_rails['smtp_address'] = "smtp.163.com"
  14. gitlab_rails['smtp_port'] = 465
  15. gitlab_rails['smtp_user_name'] = "发信邮箱"
  16. gitlab_rails['smtp_password'] = "smtp客户端授权码"
  17. gitlab_rails['smtp_domain'] = "163.com"
  18. gitlab_rails['smtp_authentication'] = "login"
  19. gitlab_rails['smtp_enable_starttls_auto'] = true
  20. gitlab_rails['smtp_tls'] = true
  21. gitlab_rails['smtp_openssl_verify_mode'] = 'none'

 以163为例

  


 修改完成后重新加载配置文件

gitlab-ctl reconfigure
 

如果修改了邮箱配置,测试邮箱是否生效

  1. [root@localhost gitlab]# gitlab-rails console
  2. --------------------------------------------------------------------------------
  3. Ruby: ruby 2.7.5p203 (2021-11-24 revision f69aeb8314) [x86_64-linux]
  4. GitLab: 15.2.0 (a876afc5fd8) FOSS
  5. GitLab Shell: 14.9.0
  6. PostgreSQL: 13.6
  7. ------------------------------------------------------------[ booted in 14.38s ]
  8. Loading production environment (Rails 6.1.4.7)
  9. irb(main):001:0> Notify.test_email('[email protected]','test','gitlab').deliver_now
  10. Delivered mail [email protected] (1078.9ms)
  11. => #<Mail::Message:290380, Multipart: false, Headers: <Date: Thu, 28 Jul 2022 15:27:20 +0800>, <From: lick <[email protected]>>, <Reply-To: xxx <noreply@xxx>>, <To: [email protected]>, <Message-ID: <[email protected]>>, <Subject: test>, <Mime-Version: 1.0>, <Content-Type: text/html; charset=UTF-8>, <Content-Transfer-Encoding: 7bit>, <Auto-Submitted: auto-generated>, <X-Auto-Response-Suppress: All>>

 3)修改root管理员密码

 ps:初始密码可以查看

cat /etc/gitlab/initial_root_password

 

#登录控制台

 

 

gitlab-rails console

 

 

#查找切换账号

 

 

u=User.where(id:1).first

 

 

#修改密码

 

 

u.password='更改后的密码'

 

 

#再次确认密码

 

 

u.password='更改后的密码'

 

 

#保存

 

 

u.save!

 

 4)性能优化

  1. unicorn['worker_processes'] = 2 #官方建议值为CPU核数+1(服务器只部署gitLab的情况下),可提高服务器响应速度,此参数最小值为2,设为1服务器可能卡死
  2. unicorn['work_timeout'] = 60 #设置超时时间
  3. unicorn['worker_memory_limit_min'] = "200 * 1 << 20" #减少最小内存
  4. unicorn['worker_memory_limit_max'] = "300 * 1 << 20" #减少最大内存
  5. postgresql['shared_buffers'] = "128MB" #减少数据库缓存
  6. postgresql['max_worker_processes'] = 6 #减少数据库并发数
  7. sidekiq['concurrency'] = 15 #减少sidekiq并发数

由于 Gitlab 核心功能是代码托管,所以有些额外的组件比较浪费资源,所以可以考虑关闭。 

  1. prometheus['enable'] = false
  2. prometheus['monitor_kubernetes'] = false
  3. alertmanager['enable'] = false
  4. node_exporter['enable'] = false
  5. redis_exporter['enable'] = false
  6. postgres_exporter['enable'] = false
  7. gitlab_exporter['probe_sidekiq'] = false
  8. prometheus_monitoring['enable'] = false
  9. grafana['enable'] = false

 以上就是修改配置文件!

5、重新启动

  1. sudo gitlab-ctl reconfigure
  2. sudo gitlab-ctl restart

6、其他命令 

  1. gitlab-ctl start #启动全部服务
  2. gitlab-ctl restart#重启全部服务
  3. gitlab-ctl stop #停止全部服务
  4. gitlab-ctl restart nginx #重启单个服务,如重启nginx
  5. gitlab-ctl status #查看服务状态
  6. gitlab-ctl reconfigure #使配置文件生效
  7. gitlab-ctl show-config #验证配置文件
  8. gitlab-ctl uninstall #删除gitlab(保留数据)
  9. gitlab-ctl cleanse #删除所有数据,从新开始
  10. gitlab-ctl tail <service name>查看服务的日志
  11. gitlab-ctl tail nginx #如查看gitlab下nginx日志
  12. gitlab-rails console #进入控制台
  13. gitlab-ctl help #查看gitlab帮助信息

三、使用

安装完成后输入服务器地址和端口号就可以进行访问

 1、更改语言

root登陆后点击preferences,进入偏好设置。在这里可以设置主题颜色、语言等选项,下滑找到localization,选择中文,保存后,重新刷新页面即可

 

更改后界面:

 2、更改用户注册设置

默认勾选前两个,如果是公司内网团队开发,可以设置为勾选1,3即可

 

 以上就是本文的全部内容了,感谢您的观看,希望对您有所帮助!

 

 

出处:https://blog.csdn.net/weixin_38489509/article/details/126034654

=======================================================================================

gitlab安装rpm方式

##  安装依赖

yum -y install policycoreutils openssh-server openssh-clients postfix

yum -y install policycoreutils-python

# 设置ssh开机自启并启动

systemctl enable sshd && sudo systemctl start sshd

systemctl status sshd  # 查看ssh服务

# 设置postfix开机自启并启动(有发信功能)

systemctl enable postfix && systemctl start postfix

# 下载gitlab rpm安装包并安装

wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-15.2.2-ce.0.el7.x86_64.rpm

rpm -ivh gitlab-ce-15.2.2-ce.0.el7.x86_64.rpm

# 修改gitlab配置

vim /etc/gitlab/gitlab.rb

 

## 加入如下

# gitlab访问地址,可以写域名。如果端口不写的话默认为80端口

external_url 'http://主机ip(172.16.137.187):端口(81)'

# 让配置生效

gitlab-ctl reconfigure

 

# 重新加载配置启动gitlab

gitlab-ctl reconfigure

gitlab-ctl restart

 

# 登录控制台修改初始密码

# 进入控制台

gitlab-rails console -e production

# 查询id为1的用户,id为1的用户是超级管理员

user = User.where(id:1).first

# 修改密码为lqz123456

user.password='#Ab123456'

# 保存

user.save!

# 退出

exit

 

# 登录gitla

http://gitlab地址

#账号 root 密码  #Ab123456

 

遇到的问题

# 报错502,其中问题解决

puma['port'] = 8181  # 使用一个未使用的端口

 

 

出处:https://blog.csdn.net/love_THL/article/details/127431077

=======================================================================================

gitlab rpm包安装方法

gitlab rpm包安装方法
当前安装方式适合centOs7版本,需要有root权限,如果当前用户不是root用户,需要配置当前用户的sudo
1. yum install -y curl policycoreutils-python openssh-server
2. systemctl enable sshd && systemctl start sshd
3. firewall-cmd --permanent --add-service=http
  在执行这条命令后如果报FirewallD is not running这个错误,说明防火墙没有启动,使用systemctl start firewalld启动防火墙
4. firewall-cmd --permanent --add-service=https
5. 指定一个端口作为后续在web端访问gitlab的端口并且打开这个端口对外访问。
  5.1. firewall-cmd --zone=public --list-ports 查询当前都有哪些端口可以通过外部访问
  5.2. firewall-cmd --zone=public --add-port=80/tcp --permanent 打开你需要打开的端口
6. systemctl reload firewalld 重启防火墙
7. yum install postfix 安装邮件服务
8. systemctl enable postfix && systemctl start postfix
9. 使用rpm包安装命令安装gitlab的rpm包,
下载地址为https://packages.gitlab.com/gitlab/gitlab-ce社区版本
或者使用清华大学镜像https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/
rpm -ivh ...rpm
10. vim /etc/gitlab/gitlab.rb 修改文件中的external_url 'http://地址:端口',改为可以访问到的地址和端口
11. gitlab-ctl reconfigure:初始化gitlab配置信息并启动每一个组件,
接下来就可以在web浏览器端进行访问了。

gitlab的初始化账号为root,密码为:5iveL!fe

gitlab常用命令
 1. gitlab-ctl start:启动gitlab,
 2. gitlab-ctl stop:停止gitlab。
 3. gitlab-ctl status:查看gitlab状态
 4. gitlab-ctl restart:重启服务

 

 

出处:https://www.ngui.cc/zz/2220867.html?action=onClick

=======================================================================================

Gitlab环境快速部署(RPM包方式安装)

之前梳理了一篇Gitlab的安装CI持续集成系统环境---部署Gitlab环境完整记录,但是这是bitnami一键安装的,版本比较老。下面介绍使用rpm包安装Gitlab,下载地址:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/,针对centos6和centos7的各版本Gitlab下载。如果下载不下来或者下载巨慢,可以尝试:清华大学镜像

一、GitLab简介
GitLab 是一个用于仓库管理系统的开源项目,使用Git作为代码管理工具,并在此基础上搭建起来的web服务

二、GitLab系统架构
git用户的主目录通常是/home/git(~git表示主目录路径),GitLab主要以/home/git用户身份安装在用户主目录中git。在主目录中是gitlabhq服务器软件所在的位置以及存储库(尽管存储库位置是可配置的)。裸存储库位于/home/git/repositories。GitLab是一个ruby on rails应用程序,因此可以通过研究ruby on rails应用程序的工作原理来学习内部工作的细节。为了通过SSH提供存储库,有一个名为gitlab-shell的附加应用程序,它安装在/home/git/gitlab-shell。

GitLab 应用程序是下面所述的所有组件的集合:

1. repository:代码库,可以是硬盘或 NFS 文件系统
2. Nginx:Web 入口
3. 数据库:包含以下信息:
    - repository 中的数据(元数据,issue,合并请求 merge request 等)
    - 可以登录 Web 的用户(权限)
4. Redis:缓存,负责分发任务
5. sidekiq:后台任务,主要负责发送电子邮件。任务需要来自 Redis
6. Unicorn:Gitlab 自身的 Web 服务器,包含了 Gitlab 主进程,负责处理快速/一般任务,与 Redis 一起工作。工作内容包括:
    -  通过检查存储在 Redis 中的用户会话来检查权限
    -  为 Sidekiq 制作任务
    -  从仓库(warehouse)取东西或在那里移动东西
7. gitlab-shell:用于 SSH 交互,而不是 HTTP。gitlab-shell 通过 Redis 与 Sidekiq 进行通信,并直接或通过 TCP 间接访问 Unicorn
8. gitaly:后台服务,专门负责访问磁盘以高效处理 git 操作,并缓存耗时操作。所有的 git 操作都通过 Gitaly 处理
9. gitlab-workhorse:反向代理服务器,可以处理与 Rails 无关的请求(磁盘上的CSS、JS 文件等),处理Git Push/Pull 请求,处理到Rails的连接(修改由Rails发送的响应或发送给 Rails 的请求,管理 Rails 的长期 WebSocket 连接等)。
10. mail_room:处理邮件请求。回复 GitLab 发出的邮件时,GitLab 会调用此服务

Sidekiq. Unicorn 和 GitLab-shell 是GitLab中处理任务的 3 个程序。

三、Gitlab安装、配置、启动管理
安装Gitlab必要的依赖项,还将在系统防火墙中打开HTTP和SSH访问
安装命令:yum install -y curl policycoreutils-python openssh-server
激活命令:systemctl enable sshd
启用命令:systemctl start sshd
防火墙命令:firewall-cmd --permanent--add-service=http && systemctl reload firewalld

安装Postfix以发送通知电子邮件
安装命令:yum install postfix
激活命令:systemctl enable postfix
启用命令:systemctl start postfix

下载GitLab软件包(社区版),地址:https://packages.gitlab.com/gitlab/gitlab-ce

查看Gitlab相关目录,命令:find / -name gitlab

Gitlab目录结构
/opt/gitlab/         # 主目录
/etc/gitlab/         # 放置配置文件
/var/opt/gitlab/   # 各个组件
/var/log/gitlab/   # 放置日志文件
/var/opt/gitlab/git-data/repositories    #数据库的地址  
/var/opt/gitlab/postgresql/data          #gitlab组和项目的地址
/etc/gitlab/gitlab.rb                              #gitlab配置文件

初始化Gitlab命令(保存配置或重新载入配置):gitlab-ctl reconfigure

Gitlab服务的启停管理
启动服务: gitlab-ctl start
停止服务: gitlab-ctl stop
重启服务: gitlab-ctl restart
查看状态: gitlab-ctl status

Gitlab的supervisor方式启动服务
服务启动命令:   systemctl start gitlab-runsvdir.service
服务停止命令:   systemctl stop gitlab-runsvdir.service
服务重启命令:   systemctl restart gitlab-runsvdir.service
服务开机启动命令:   systemctl enable gitlab-runsvdir.service
取消开机启动命令:   systemctl disable gitlab-runsvdir.service
服务查看命令:   systemctl list-unit-files

Gitlab服务日志查看:/usr/bin/gitlab-ctl tail         #可以查看到gitlab所有插件的日志情况

四、Centos下Gitlab快速安装的操作记录
1. Gitlab安装过程(最好找一台环境比较干净的机器):

?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 1)配置系统防火墙,把HTTP和SSH端口开放(关闭iptables或者开放ssh). [root@gitlab ~]# /etc/init.d/iptables stop [root@gitlab ~]# yum install curl openssh-server postfix cronie policycoreutils-python [root@gitlab ~]# service postfix start [root@gitlab ~]# chkconfig postfix on [root@gitlab ~]# lokkit -s http -s ssh        //如果iptables关闭了,这条命令就无需执行了。这条命令是用来设置防火墙的,开放http和ssh访问端口   2)下载gitlab的rpm安装包 已提前下载放到百度云里: http://pan.baidu.com/s/1c2EPRLQ 提前密码:qys2 [root@gitlab ~]# rpm -ivh gitlab-ce-9.4.5-ce.0.el6.x86_64.rpm --force   安装后的gitlab默认路径是/opt/gitlab(程序路径)、 /var/opt/gitlab(配置文件路径)。   3) 接着进行配置 [root@gitlab ~]# gitlab-ctl reconfigure   上面配置命令执行后,如没有报错,就说明gitlab配置成功。配置后会生成各应用服务配置文件,放在/opt/gitlab/etc下,日志路径为/var/log/gitlab/   4)然后启动gitlab [root@gitlab ~]# gitlab-ctl start [root@gitlab ~]# gitlab-ctl status   5)最后就可以使用http://localhost顺利访问Gitlab了。整个安装过程大概10分钟搞定(rpm包下载比较费时间)

将ip访问修改为域名访问的更改方法:

?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1)首先将/etc/gitlab/gitlab.rb文件中的192.168.1.24全部替换为gitlab.kevin.com [root@code-server gitlab]# vim /etc/gitlab/gitlab.rb external_url 'http://192.168.1.24' 改为: external_url 'http://gitlab.kevin.com'     2)其次将下面两文件中的192.168.1.24全部替换为gitlab.kevin.com /var/opt/gitlab/gitlab-shell/config.yml /var/opt/gitlab/gitlab-rails/etc/gitlab.yml     下面两文件都是上面两文件的软链接,修改上面两个文件即可 [root@code-server gitlab]# ll /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml lrwxrwxrwx 1 root root 43 Nov  9 18:00 /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml -> /var/opt/gitlab/gitlab-rails/etc/gitlab.yml [root@code-server gitlab]# ll /opt/gitlab/embedded/service/gitlab-shell/config.yml lrwxrwxrwx. 1 root root 39 Jun 11 20:04 /opt/gitlab/embedded/service/gitlab-shell/config.yml -> /var/opt/gitlab/gitlab-shell/config.yml   3)然后将下面文件中的192.168.1.24全部替换为gitlab.kevin.com /var/opt/gitlab/nginx/conf/gitlab-http.conf     4)最后执行"gitlab-ctl reconfigure"命令使之配置生效(注意最好不要执行"gitlab-ctl restart",只执行本命令即可)

2. Gitlba安装后的几个细节的配置

?
1 Gitlab如果是编译安装的默认管理员账号密码是:admin@local.host|5iveL!fe,如果是 rpm包安装则管理员账号密码是root|5iveL!fe

Gitlab安装后,http://localhost访问,首次访问的时候,如果不知道管理员账号和密码,尽管可以注册用户,但注册的用户都不是管理员。这个时候,可以重置管理员的密码,管理员默认是root。
重置管理员密码(密码要是8位)的方法如下:

?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 [root@gitlab ~]# gitlab-rails console production Loading production environment (Rails 4.1.1) irb(main):001:0> user = User.where(id:1).first irb(main):002:0> user.password='12345678' irb(main):003:0> user.save!   这样,Gitlab管理员的登录权限就是:root/12345678,管理员的默认邮箱是部署机的本机邮箱,也是从本机发的邮件。这也就是为什么在开头要安装postfix。   修改下面几处,否则邮件发出后,点击会报错。下面的192.168.1.24是部署机ip。   [root@gitlab ~]# cd /opt/gitlab/ [root@gitlab gitlab]# cat embedded/service/gitlab-rails/config/gitlab.yml|grep 192.168.1.24     host: 192.168.1.24     email_from: [email protected]   [root@gitlab gitlab]# cd /var/opt/gitlab/ [root@gitlab gitlab]# cat ./gitlab-rails/etc/gitlab.yml|grep 192.168.1.24     host: 192.168.1.24     email_from: [email protected]   最后重启gitlab-ctl生效 [root@gitlab gitlab]# gitlab-ctl restart

在管理员账号(root)登录后,先把"注册"功能关了,这样就只能在管理员账号下创建用户。关闭注册功能方法
访问http://192.168.1.24/admin/application_settings,如下:

关闭"Sign-up enabled"功能(特别注意:Sign-in enabled登录功能不要关闭了,看清楚!)

3. Gitlab批量添加账号

?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 [root@gitlab ~]# cat gitlab.sh #!/bin/bash #批量创建gitlab用户 userinfo="userinfo.text" while read line do     password=`echo $line | awk '{print $1}'`     mail=`echo $line | awk '{print $2}'`     username=`echo $line | awk '{print $3}'`     name=`echo $line | awk '{print $4}'`     curl -d "reset_password=$password&email=$mail&username=$username&name=$name&private_token=ucUctguWU6-2qrvRnGiB" "http://192.168.1.24/api/v4/users"   done <$userinfo   [root@gitlab ~]# cat userinfo.text [email protected] zhanjiang.feng zhanjiang.feng [email protected] hongkang.yan hongkang.yan [email protected] yansong.wang yansong.wang [email protected] bo.xue bo.xue [email protected] junlong.li junlong.li [email protected] luyu.cao luyu.cao [email protected] xueqing.wang xueqing.wang [email protected] xu.guo xu.guo [email protected] bing.xing bing.xing [email protected] linan linan

注意:上面userinfo.text文件里的四行分别表示密码,邮箱,用户名,别名。上面命令执行后,就可以批量创建用户了!
其中密码用1表示重置密码,也就是用户创建之后,会给用户邮箱发送两封邮件:
-> 一封确认绑定邮箱的邮件,一定要点击这个邮件里的confirm确认地址(否则登录无效);
-> 另一封是重置用户密码的邮件。重置后就可以使用邮箱或用户名登陆了。

 注意上面脚本中的private_token(这个很重要,否则批量创建不了用户)的值是从gitlab的管理员账号登录后的"settings-Account"界面里找到的,如下:

 访问脚本中gitlab的用户接口地址http://192.168.1.24/api/v4/users,试试能否访问!

                                                              Email的smtp设置                                                                  

?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 上面默认是用部署机本地的postfix发邮件。如果要想使用第三方邮箱发邮件,这就需要修改/var/opt/gitlab/gitlab-rails/etc/unicorn.rb文件: [root@gitlab ~]# # cat /etc/gitlab/gitlab.rb|grep -v "^#"|grep -v "^$" external_url 'http://192.168.1.24' gitlab_rails['gitlab_email_from'] = '[email protected]' gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.163.com" gitlab_rails['smtp_port'] = 25 gitlab_rails['smtp_user_name'] = "[email protected]" gitlab_rails['smtp_password'] = "*******" gitlab_rails['smtp_domain'] = "163.com" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true user['git_user_email'] = "[email protected]"   由于该文件会影响gitlab-ctl指令,如果改动了则需要重新运行配置。 注意这个重新配置的动作要在上面细节配置之前,否则上面的配置在reconfigure之后就会被覆盖到默认状态! [root@gitlab ~]#  gitlab-ctl reconfigure   -------------------------------------------------------------------------------------------- 上面使用的是163邮箱,下面再贴下公司企业邮箱(用的是Coremail论客邮件系统,注意邮箱的smtp地址要正确)的配置: [root@gitlab ~]# cat /etc/gitlab/gitlab.rb|grep -v "^#"|grep -v "^$" external_url 'http://192.168.1.24' gitlab_rails['gitlab_email_from'] = '[email protected]' gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.icoremail.net" gitlab_rails['smtp_port'] = 25 gitlab_rails['smtp_user_name'] = "[email protected]" gitlab_rails['smtp_password'] = "notice@123" gitlab_rails['smtp_domain'] = "icoremail.net" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true user['git_user_email'] = "[email protected]"

                                                 修改Gitlab登录界面                                                         

选择gitlab新的主题风格,新主题会在左边栏展示选择项

经过上面修改后,看下新的登录界面

                                                                       Gitlab整合Ldap(或AD域)                                                                      

?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 如上已经顺利部署了Gitlab环境,又在一台空闲的Windows server 2008上安装了AD域。 现在需要在Gitlab上整合AD域,实现Gitlab只能使用AD域里面的账号登录。配置记录如下:   AD域的信息: 主机地址:192.168.10.141 端口:389   配置如下: [root@gitlab ~]# vim /etc/gitlab/gitlab.rb ...... gitlab_rails['ldap_enabled'] = true gitlab_rails['ldap_servers'] = YAML.load <<-EOS # remember to close this block with 'EOS' below main: # 'main' is the GitLab 'provider ID' of this LDAP server   label: '哈哈集团-Gitlab登录入口'   host: '192.168.10.141'   port: 389   uid: 'userPrincipalName'   method: 'plain' # "tls" or "ssl" or "plain"   allow_username_or_email_login: false   bind_dn: 'cn=王一,ou=技术运维部,dc=kevin,dc=com'   password: '9oGlYkgDzhp5k6JZ'   active_directory: true   base: 'ou=技术运维部,dc=kevin,dc=com'   user_filter: '' EOS   接着执行下面命令,使上面配置生效: [root@gitlab ~]# gitlab-ctl reconfigure        //这里最好使用该命令,表示重载配置。不要使用"gitlab-ctl restart"重启服务,否则可能出现500报错!   然后执行下面命令,检查LDAP信息是否成功同步过来 [root@gitlab ~]# gitlab-rake gitlab:ldap:check Checking LDAP ...   Server: ldapmain LDAP authentication... Success LDAP users with access to your GitLab server (only showing the first 100 results)   DN: CN=李某某,OU=技术运维部,DC=kevin,DC=com  userPrincipalName: [email protected]   DN: CN=李二,OU=技术运维部,DC=kevin,DC=com   userPrincipalName: [email protected]   DN: CN=lier1,OU=技术运维部,DC=kevin,DC=com   userPrincipalName: [email protected]   DN: CN=test,OU=技术运维部,DC=kevin,DC=com   userPrincipalName: test@kevin.com   DN: CN=王一,OU=技术运维部,DC=kevin,DC=com  userPrincipalName: [email protected]   DN: CN=张三,OU=技术运维部,DC=kevin,DC=com   userPrincipalName: [email protected]   DN: CN=张三,OU=网络,OU=技术运维部,DC=kevin,DC=com   userPrincipalName: [email protected]   DN: CN=赵四,OU=网络,OU=技术运维部,DC=kevin,DC=com   userPrincipalName: [email protected]   Checking LDAP ... Finished     ========================================================================================= 注意: 如上配置中,随便使用AD域中的一个有读权限的账号和其密码进行配置就行了,即将其他账号读出来! AD域或Openldap搭建的时候,域名最好用邮箱域名。 uid表示属性   uid: 'uid'                       //默认配置是这个,如果不改,上面check ldap就不会成功,即不能成功同步ldap账号信息。 uid: 'cn'                        //这个表示可以使用cn名称登录,比如王一,如果cn名称是英文名(比如test),则还可以使用带域名形式登录(比如test@kevin.com) uid: 'Samaccountname'            //这个表示可以使用wangyi或[email protected]登录   如果uid配置成上面的cn和Samaccountname,那么下面的 allow_username_or_email_login: true   label: '哈哈集团-Gitlab登录入口'      该配置表示使用LDAP账号登录时显示的界面提示信息。

取消Gitlab默认的登录窗口,访问http://192.168.1.24/admin/application_settings (注意不要勾选下面的"Sign-in enabled"选择)

                               Gitlab访问出现403"Forbidden"现象                               
出现的可能原因:较多的并发导致的访问被拒绝, Gitlab使用rack_attack做了并发访问的限制!

解决办法:
打开/etc/gitlab/gitlab.rb文件,查找 gitlab_rails['rack_attack_git_basic_auth'] 关键词,取消注释,
修改ip_whitelist白名单属性,加入Gitlab部署的IP地址。

修改如下(192.168.1.24):

?
1 2 3 4 5 6 7 8 9 [root@gitlab ~]# vim /etc/gitlab/gitlab.rb ......  gitlab_rails['rack_attack_git_basic_auth'] = {    'enabled' => true,    'ip_whitelist' => ["127.0.0.1","192.168.1.24"],    'maxretry' => 10,    'findtime' => 60,    'bantime' => 3600  }

然后重载配置

?
1 [root@gitlab ~]# gitlab-ctl reconfigure

最后再在浏览器里访问gitlab就OK了!

                                                 Gitlab访问出现502的现象                                                             
Gitlab访问出现:Whoops, GitLab is taking too much time to respond.

?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 产生原因: 1)unicorn原8080默认端口被容器中别的进程已经占用,必须调整为没用过的 2)gitlab的timeout设置过小,默认为60   解决办法: 1)关闭gitlab服务 # gitlab-ctl stop 2)选择一个没有被系统占用的端口作为unicorn端口,比如8877端口(lsof -i:8877 确认此端口没有被占用) # vim /etc/gitlab/gitlab.rb unicorn['port'] = 8877 gitlab_workhorse['auth_backend'] = "http://localhost:8877" 3)重新生成配置 # gitlab-ctl reconfigure 4)重启gitlab服务 # gitlab-ctl restart

                                                  Gitlab启动失败,或重新安装时出现卡的状态                                                                 

?
1 2 3 4 5 6 7 8 9 10 在卸载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-ctl start"失败,解决办法: # systemctl restart gitlab-runsvdir # gitlab-ctl reconfigure # gitlab-ctl start

                               Gitlab异常关机,导致gitlab启动失败!gitlab-runsvdir方式启动没反应(僵尸状态)                           
Gitlab部署的服务器异常断电,机器重启后,尝试启动gitlab服务,启动失败!通过gitlab-runsvdir方式启动一直没有反应!一直在卡顿状态!日志也没有任务输入!

?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 执行下面的启动命令报错: [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 fail: redis: runsv not running fail: redis-exporter: runsv not running fail: registry: runsv not running fail: sidekiq: runsv not running fail: unicorn: 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-start [root@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

                               Gitlab忘记root用户密码,重置用户密码和查看用户ID号方法                           

?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 一、Gitlab查看用户id号的方法 1)方法1:通过api接口查询 接口查询地址:http://gitlab的url/api/v4/users?username=用户名   比如查看gitlab的root用户id 在浏览器页面里直接访问"http://172.16.60.237/api/v4/users?username=root" 或者 在linux终端命令行里直接通过curl命令进行访问 [root@localhost ~]# curl http://172.16.60.237/api/v4/users?username=root [{"id":1,"name":"Administrator","username":"root","state":"active","avatar_url":"https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80\u0026d=identicon","web_url":"http://gitlab.example.com/root"}]   2)方法2:进入gitlab数据库查询 [root@localhost ~]# gitlab-rails dbconsole psql (10.9) Type "help" for help.   gitlabhq_production=> \l                                              List of databases         Name         |    Owner    | Encoding |   Collate   |    Ctype    |        Access privileges ---------------------+-------------+----------+-------------+-------------+---------------------------------  gitlabhq_production | gitlab      | UTF8     | en_US.UTF-8 | en_US.UTF-8 |  postgres            | gitlab-psql | UTF8     | en_US.UTF-8 | en_US.UTF-8 |  template0           | gitlab-psql | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/"gitlab-psql"               +                      |             |          |             |             | "gitlab-psql"=CTc/"gitlab-psql"  template1           | gitlab-psql | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/"gitlab-psql"               +                      |             |          |             |             | "gitlab-psql"=CTc/"gitlab-psql" (4 rows)   ## 连接数据库 gitlabhq_production=> \c gitlabhq_production You are now connected to database "gitlabhq_production" as user "gitlab". gitlabhq_production=> select id,name,username from users;  id |     name      | username ----+---------------+----------   1 | Administrator | root (1 row) ## 查找账户id gitlabhq_production=> select id from users where username = 'root';  id ----   1 (1 row)   ============================================================================================== 二、忘记Gitlab的root用户密码的重置方法 如果忘记了Gitlab的root用户密码,则可以在服务器上面直接修改数据: # gitlab-rails console production      #然后以此执行下面命令(需要提前查询用户的id号) ...> user = User.where(id: 1).first ...> user.password = 'secret_pass' ...> user.password_confirmation = 'secret_pass' ...> user.save!   例如重置root用户密码为root@123,root用户id为1 [root@localhost ~]# gitlab-rails console production DEPRECATION WARNING: Passing the environment's name as a regular argument is deprecated and will be removed in the next Rails version. Please, use the -eoption instead. (called from require at bin/rails:4) --------------------------------------------------------------------------------  GitLab:       12.2.0 (1c1d47c5974)  GitLab Shell: 9.3.0  PostgreSQL:   10.9 -------------------------------------------------------------------------------- Loading production environment (Rails 5.2.3) irb(main):001:0> user = User.where(id: 1).first => #<User id:1 @root> irb(main):002:0> user.password = 'root@123' => "root@123" irb(main):003:0> user.password_confirmation = 'root@123' => "root@123" irb(main):004:0> user.save! Enqueued ActionMailer::DeliveryJob (Job ID: e562694d-2a1b-4bad-843b-d8567ac51077) to Sidekiq(mailers) with arguments: "DeviseMailer", "password_change", "deliver_now", #<GlobalID:0x00007fae7e55bcc8 @uri=#<URI::GID gid://gitlab/User/1>> => true irb(main):005:0> quit [root@localhost ~]#

五、Gitlab日常维护:备份、迁移、升级
1. Gitlab备份
使用Gitlab一键安装包安装Gitlab非常简单, 同样的备份恢复与迁移也非常简单. 使用一条命令即可创建完整的Gitlab备份

?
1 2 3 4 5 6 7 8 # gitlab-rake gitlab:backup:create   比如使用以上命令会在/var/opt/gitlab/backups目录下创建一个名称类似为1481598919_gitlab_backup.tar的压缩包, 这个压缩包就是Gitlab整个的完整部分, 其中开头的1481598919是备份创建的日期。   /etc/gitlab/gitlab.rb 配置文件须备份 /var/opt/gitlab/nginx/conf nginx配置文件 /etc/postfix/main.cfpostfix 邮件配置备份

1)1.1Gitlab备份目录
可以通过/etc/gitlab/gitlab.rb配置文件来修改默认存放备份文件的目录

?
1 2 gitlab_rails['backup_path'] = "/var/opt/gitlab/backups" /var/opt/gitlab/backups修改为你想存放备份的目录即可, 修改完成之后使用gitlab-ctl reconfigure命令重载配置文件即可.

2)Gitlab自动备份
实现每天凌晨2点进行一次自动备份:通过crontab使用备份命令实现

?
1 0 2 * * * /opt/gitlab/bin/gitlab-rake gitlab:backup:create

2. Gitlab恢复
Gitlab的从备份恢复也非常简单:

?
1 2 3 4 5 6 7 8 9 1)停止相关数据连接服务 # gitlab-ctl stop unicorn # gitlab-ctl stop sidekiq   2)从1481598919编号备份中恢复 # gitlab-rake gitlab:backup:restore BACKUP=1481598919   3)启动Gitlab # gitlab-ctl start

3. Gitlab迁移
要求:新服务器的gitlab版本与旧的服务器相同。

迁移如同备份与恢复的步骤一样, 只需要将老服务器/var/opt/gitlab/backups目录下的备份文件拷贝到新服务器上的/var/opt/gitlab/backups即可(如果你没修改过默认备份目录的话).

但是需要注意的是:
新服务器上的Gitlab的版本必须与创建备份时的Gitlab版本号相同. 比如新服务器安装的是最新的7.60版本的Gitlab, 那么迁移之前, 最好将老服务器的Gitlab 升级为7.60在进行备份.

/etc/gitlab/gitlab.rb                  这个gitlab配置文件须迁移,迁移后需要调整数据存放目录
/var/opt/gitlab/nginx/conf        这个nginx配置文件目录须迁移

/etc/gitlab/gitlab-secrets.json       #复制新服务器相同的目录下
/etc/ssh/*key*                               #复制到新服务器相同目录下,解决ssh key认证不成功问题

?
1 2 3 4 # gitlab-ctl stop unicorn # gitlab-ctl stop sidekiq # chmod 777 /var/opt/gitlab/backups/1481598919_gitlab_backup.tar  # 或 chown git:git /var/opt/gitlab/backups/1481598919_gitlab_backup.tar # gitlab-rake gitlab:backup:restore BACKUP=1481598919

4. Gitlab升级

?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 1.关闭gitlab服务 # gitlab-ctl stop unicorn # gitlab-ctl stop sidekiq # gitlab-ctl stop nginx   2.备份gitlab # gitlab-rake gitlab:backup:create   3.下载gitlab的RPM包并进行升级 # curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash # yum update gitlab-ce   或者直接安装高版本 #yum install gitlab-ce-12.1.12-ce.0.el7.x86_64   或者上官网下载最新版本 gitlab对应软件包                                     gitlab官网地址: https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/7/gitlab-ce-12.1.12-ce.0.el7.x86_64.rpm 使用: # rpm -Uvh gitlab-ce-12.1.12-ce.0.el7.x86_64   如果报错. Error executing action `run` on resource 'ruby_block[directory resource: /var/opt/gitlab/git-data/repositories]'   解决方法: sudo chmod 2770 /var/opt/gitlab/git-data/repositories   4.启动并查看gitlab版本信息 # gitlab-ctl reconfigure # gitlab-ctl restart # head -1 /opt/gitlab/version-manifest.txt

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/确实没有这两个文件。

?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 [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服务。

?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 自行编译的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

 

 

出处:https://www.cnblogs.com/kevingrace/p/5985918.html

标签:opt,Gitlab,gitlab,rails,yum,Linux,ctl,root
From: https://www.cnblogs.com/mq0036/p/17188139.html

相关文章

  • Linux下查看某个进程占用的CPU、内存
    1、用top命令指定固定的PIDtop-p10997结果如下所示: 查询指定进程的PIDps-ef|grepzookeeper2、使用ps查询指定进程名或者PID的占用情况ps-aux|grepz......
  • Linux系统巡检、等保安全检查脚本
    以下shell脚本适合linux分支中的redhat、centos使用,运行脚本将结果输出到自定义的文件中,可将巡检脚本以root用户登录放在/usr/local/sbin的目录下执行。脚本只是一个检查......
  • Linux中gdal的使用
    四:Ubuntu中GDAL的使用(JavaWeb项目使用)1:整理文件,把生成的文件放置到gdal/java目录cp/home/zcx/Desktop/XQ/gdal-3.2.1/swig/java/gdal.jar/usr/local/pgsql/plugin/gd......
  • Linux-MySQL 数据备份
    MySQL数据备份是一个非常重要的工作,保证数据的安全性和可靠性。常用方法:一、使用mysqldump工具来备份MySQL数据库。该工具可以生成SQL脚本文件,包含数据库中......
  • xilinx zynmp linux 开机自启动脚本添加
    下面以linx5.4.0-xilinx-v2020.1为例说明如何添加自启动脚本。linux系统内核启动完成后会加载第一个进程init,关于init进程的介绍参考博客https://zhuanlan.zhihu.com/p/......
  • Linux备份与恢复使用技巧
    在日常的Linux系统运维中,备份和恢复是非常重要的操作,能够有效避免数据丢失和系统故障导致的影响。本文将介绍一些关于Linux系统备份和恢复的实用技巧,帮助管理员更好地管理......
  • VMware创建Linux虚拟机
    本篇记录用VMware创建Linux虚拟机,安装的是Centos7一、VMware安装:自行百度 二、Centos7镜像下载:链接:https://pan.baidu.com/s/1D-Y4H17tcgWz5cSB5MSMOg?pwd=q8jt提......
  • linux系统忘记root密码
     centOS:1、开机过程按上下箭头键,让系统不要进入到引导程序中,2、按'e'进入到编辑模式3、找到linux16开始的首行,在末尾加入'rwinit=/bin/sh'(会出现修改......
  • 熟悉Linux的操作界面及切换方法
    熟悉Linux的操作界面及切换方法TTY终端在linux默认的登录模式中,主要分为两种,一种是仅有纯文本界面(命令行界面)的登录环境,另外一种则是图形桌面的登录环境。Linux默认情况下......
  • Linux/Centos Mondo 一键部署、镜像恢复,快速部署
    一.环境准备 (1) 镜像机要能上网,因为需要从网上装所需的包,没有网络的话,需要的软件包也早下载好了,可以离线安装,离线安装比较费事,尽量有网比较好 (2) 镜像机磁盘不要用......