gitlab服务器安装

1、示例主机信息:

hostname:vm0.lansgg.com

ip        :    192.168.85.128

Os        : centos 6.5 x64

gitlab版本:  gitlab-ce-8.7.0-ce.0.el6.x86_64.rpm

Ps : 关闭 iptables selinux

2、系统依赖软件安装

[email protected] ~]# yum install curl openssh-server openssh-clients  cronie –y

3、安装gitlab

[[email protected] ~]# rpm -vhi gitlab-ce-8.7.0-ce.0.el6.x86_64.rpm 
Preparing...                ########################################### [100%]
   1:gitlab-ce              ########################################### [100%]
gitlab: Thank you for installing GitLab!
gitlab: To configure and start GitLab, RUN THE FOLLOWING COMMAND:

sudo gitlab-ctl reconfigure

gitlab: GitLab should be reachable at http://vm0.lansgg.com
gitlab: Otherwise configure GitLab for your system by editing /etc/gitlab/gitlab.rb file
gitlab: And running reconfigure again.
gitlab: 
gitlab: For a comprehensive list of configuration options please see the Omnibus GitLab readme
gitlab: https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
gitlab: 
It looks like GitLab has not been configured yet; skipping the upgrade script.
[[email protected] ~]#

3.1、初始化

[[email protected] ~]# gitlab-ctl reconfigure

到此安装成功:

地址:http://192.168.85.128/

默认用户名是 root , 密码是 5iveL!fe

登陆后会提示修改当前管理员密码

4、设置https

创建ssl证书目录

[[email protected] ~]# mkdir -p /etc/gitlab/ssl
[[email protected] ~]# cd /etc/gitlab/ssl/
[[email protected] ssl]# ll
总用量 8
-rw-r--r--. 1 root root 1444 9月   7 16:16 vm0.lansgg.com.crt
-rw-r--r--. 1 root root 1704 9月   7 16:16 vm0.lansgg.com.key
[[email protected] ssl]#

4.1、修改git配置项中的ssl证书文件地址     #/etc/gitlab/gitlab.rb(#大约是477行)

11 external_url ‘
472  nginx[‘enable‘] = true
473  nginx[‘client_max_body_size‘] = ‘250m‘
474  nginx[‘redirect_http_to_https‘] = false
475 # nginx[‘redirect_http_to_https_port‘] = 80
476  nginx[‘ssl_client_certificate‘] = "/etc/gitlab/ssl/vm0.lansgg.com.crt"
477  nginx[‘ssl_certificate‘] = "/etc/gitlab/ssl/vm0.lansgg.com.crt"

4.2、修改nginx配置文件

38 server {
 39   listen *:443;
 40   ssl on;
 41   ssl_certificate /etc/gitlab/ssl/vm0.lansgg.com.crt;
 42   ssl_certificate_key /etc/gitlab/ssl/vm0.lansgg.com.key;

4.3、配置http跳转https

[[email protected] ssl]# vim /var/opt/gitlab/nginx/conf/index.conf            ###新建
server {
    listen *:80;
    server_name www.abc.com;
  
    rewrite ^(.*)$  https://$host$1 permanent;
}

4.4、修改配置文件载入index.conf

配置文件地址:/var/opt/gitlab/nginx/conf/nginx.conf,在其中加入以下内容

include/var/opt/gitlab/nginx/conf/index.conf;
include/var/opt/gitlab/nginx/conf/gitlab-http.conf;

4.5、重启服务

以上操作全部完成之后, 使用gitlab-ctl restart来重启所有服务, 即可使用HTTPS访问GitLab了.

https://192.168.85.128

https://vm0.lansgg.com

5、gitlab的备份与还原

5.1、gitlab的备份

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

[[email protected] ssl]# gitlab-rake gitlab:backup:create

使用以上命令会在/var/opt/gitlab/backups目录下创建一个名称类似为:

1467362634_gitlab_backup.tar 的压缩包, 这个压缩包就是Gitlab整个的完整部分, 其中开头的  1473237111  是备份创建的日期.

Gitlab 修改备份文件默认目录

[[email protected] etc]# vim /var/opt/gitlab/gitlab-rails/etc/gitlab.yml

Gitlab 自动备份

也可以通过crontab使用备份命令实现自动备份:

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

5.2、gitlab的还原

停止相关服务

[[email protected] etc]# gitlab-ctl stop unicorn
[[email protected] etc]# gitlab-ctl stop sidekiq

从备份文件中恢复

以20160630 的备份文件 1467225280_gitlab_backup.tar为例 )

将恢复文件 1467225280_gitlab_backup.tar 放到gitlab的备份目录

[[email protected] gitback]# cp 1467225280_gitlab_backup.tar/var/opt/gitlab/backups/

按照编号进行恢复

[[email protected] gitback]# gitlab-rake gitlab:backup:restoreBACKUP=1467225280

重新启动

[[email protected] etc]# gitlab-ctl restart


解决方案

1、按照上述恢复 gitlab后,放你访问git地址时,可能会出现 500 错误;如下:

查看日志信息如下:

初步以为,因为使用ssl访问时加解密的问题;查了资料,尝试以下步骤:

The temporary solutions are:

  1. Copy the old     db_key_base from the old instance to the new one.
  2. Delete     imported project data that is no longer required by projects. Something     like this may work:

执行命令:gitlab-rails runner "Project.where.not(import_url: nil).each { |p| p.import_data.destroyif p.import_data }"

时间: 2024-08-17 21:08:10

gitlab服务器安装的相关文章

Gitlab Pipeline+Supervisor 实战Python项目CI/CD

一.背景 谈到到CI/CD,我们不禁会想到Gitlab + Jenkins + Docker等一些列优秀的工具,Jenkins以其丰富的插件及灵活配置已经非常好的满足我们日常工作中的CI/CD需求,通常的做法为Gitlab配置webhook,开发人员通过push代码或merge request可以触发执行一些列的测试部署上线工作,打通了开发到部署到整个生命周期,完成持续集成持续构建.在Gitlab 也是具有一套CI/CD到框架,通过简单的注册Gitlab Runner,根据业务测试部署需求撰写

一键安装Gitlab后的备份、迁移与恢复

1.Gitlab创建备份 #gitlab-rake gitlab:backup:create 使用以上命令会在/var/opt/gitlab/backups目录下创建一个名称类似为1393513186_gitlab_backup.tar的压缩包, 这个压缩包就是Gitlab整个的完整部分, 其中开头的1393513186是备份创建的日期. 2.Gitlab恢复 # 停止相关数据连接服务 gitlab-ctl stop unicorn gitlab-ctl stop sidekiq   # 从13

GitLab备份的创建与恢复

使用Gitlab一键安装包安装Gitlab非常简单, 同样的备份恢复与迁移也非常简单. 使用一条命令即可创建完整的Gitlab备份: gitlab-rake gitlab:backup:create使用以上命令会在/var/opt/gitlab/backups目录下创建一个名称类似为1393513186_gitlab_backup.tar的压缩包, 这个压缩包就是Gitlab整个的完整部分, 其中开头的1393513186是备份创建的日期. Gitlab 修改备份文件默认目录 你也可以通过修改/

Gitlab企业代码管理服务安装及相关配置

1.安装过程 登陆www.gitlab.cc网站,根据你的系统,选择不同的安装 演示的过程是在Centos6上的配置 A.yum install curl openssh-server postfix cronie(邮箱配置另行说明,如果使用postfix,请下载安装,如使用第三方的企业邮箱,则无需安装) B.curl http://packages.gitlab.cc/install/gitlab-ce/script.rpm.sh | sudo bash C.yum install gitla

gitlab部署迁移升级

一.gitlab部署 1.参考网站 https://about.gitlab.com/downloads/#centos6 2.部署步骤: 2.1. Install and configure the necessary dependencies sudo yum install curl openssh-server openssh-clients postfix cronie sudo service postfix start sudo chkconfig postfix on sudo 

bitnami gitlab 安装

/************************************************************************************** * bitnami gitlab 安装 * 说明: * 最近再弄git服务器,但感觉缺少Web界面实在是觉得有点欠缺什么,于是找到gitlab看一下 * 运行效果,目前这种安装方法不太适合服务器安装. * * 2016-8-15 深圳 南山平山村 曾剑锋 **********************************

gitlab代码仓库管理

一.gitlab安装 1.下载rpm的地址 https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/6/gitlab-ce-8.15.3-ce.0.el6.x86_64.rpm 官网:https://about.gitlab.com/downloads/#centos6 2.开始安装 yum install curl openssh-server openssh-clients postfix cronie -y cd /home/zha

Gitlab维护记录

目前互联网公司主流的代码仓库统是gitlab,类似github的实现,维护gitlab已经有两年多的时间, 下面说一下维护过程中的注意点,以及如何维护更好. 分别是搭建,首先得搭建起来,不然怎么玩,其次是备份.备份.备份,谁也不能保证服务器会不会 突然之间Down掉,为了保险起见,建议所有重要的业务一定要有备份.当然,仅仅有备份还是不够的, 为什么呢?因为你还要做恢复演练测试,假如你的备份数据恢复不了,你备份有个毛用,和没备份是没有 区别的,所以还要验证你备份的数据能否恢复系统.再说一下,备份数

使用Gitlab一键安装包后的日常备份恢复与迁移

Gitlab 创建备份 使用Gitlab一键安装包安装Gitlab非常简单, 同样的备份恢复与迁移也非常简单. 使用一条命令即可创建完整的Gitlab备份: gitlab-rake gitlab:backup:create 使用以上命令会在/var/opt/gitlab/backups目录下创建一个名称类似为1393513186_gitlab_backup.tar的压缩包, 这个压缩包就是Gitlab整个的完整部分, 其中开头的1393513186是备份创建的日期. Gitlab 修改备份文件默