0.Gitlab安装

1.安装和配置必要的依赖关系
在CentOS7,下面的命令将在系统防火墙打开HTTP和SSH访问。

yum install curl openssh-server postfix
systemctl enable sshd postfix
systemctl start sshd postfix
firewall-cmd --permanent --add-service=http
systemctl reload firewalld

2.添加gitlab包服务器安装包

curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
yum install gitlab-ce

3.配置并启动

gitlab-ctl reconfigure
gitlab-ctl status
gitlab-ctl stop
gitlab-ctl start

4.浏览到主机名和登录Browse to the hostname and login

Username: root
Password: 5iveL!fe

5.更多操作系统的安装方式,点击下方链接即可
CentOS6
CentOS7
Ubuntu14
Ubuntu12

1.Gitlab备份

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

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.cf     #postfix 邮件配置备份

1.1Gitlab备份目录

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

gitlab_rails['backup_path'] = "/var/opt/gitlab/backups"

/var/opt/gitlab/backups修改为你想存放备份的目录即可, 修改完成之后使用gitlab-ctl reconfigure命令重载配置文件即可.

1.2Gitlab自动备份

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

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

2.Gitlab恢复

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

# 停止相关数据连接服务
gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq # 从1481598919编号备份中恢复
gitlab-rake gitlab:backup:restore BACKUP=1481598919 # 启动Gitlab
sudo gitlab-ctl start

3.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配置文件目录须迁移

[root@linux-node1 ~]# gitlab-ctl stop unicorn
ok: down: unicorn: 0s, normally up
[root@linux-node1 ~]# gitlab-ctl stop sidekiq
ok: down: sidekiq: 0s, normally up
[root@linux-node1 ~]# chmod 777 /var/opt/gitlab/backups/1481598919_gitlab_backup.tar
[root@linux-node1 ~]# gitlab-rake gitlab:backup:restore BACKUP=1481598919

4.gitlab升级

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-8.12.13-ce.0.el7.x86_64 或者上官网下载最新版本 gitlab对应软件包 [gitlab官网](https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/7/gitlab-ce-8.12.13-ce.0.el7.x86_64.rpm)
使用 rpm -Uvh gitlab-ce-8.12.13-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
gitlab-ce 8.7.3

5.gitlab更改默认Nginx

更换gitlab自带Nginx,使用自行编译Nginx来管理gitlab服务。

编辑gitlab配置文件禁用自带Nignx服务器

vi /etc/gitlab/gitlab.rb
...
#设置nginx为false,关闭自带Nginx
nginx['enable'] = false
...

检查默认nginx配置文件,并迁移至新Nginx服务

/var/opt/gitlab/nginx/conf/nginx.conf          #nginx配置文件,包含gitlab-http.conf文件
/var/opt/gitlab/nginx/conf/gitlab-http.conf #gitlab核心nginx配置文件

重启 nginx、gitlab服务

$ sudo gitlab-ctl reconfigure
$ sudo service nginx restart

访问报502。原因是nginx用户无法访问gitlab用户的socket文件。 重启gitlab需要重新授权

chmod -R o+x /var/opt/gitlab/gitlab-rails

Git系列七之备份迁移 升级 恢复管理的更多相关文章

  1. Gitlab备份、迁移、恢复和升级

    Gitlab备份.迁移.恢复和升级 自建的Gitlab服务器常常会因为使用时间的增长,其空间容量等硬件需求都需要升级,或者迁移至更高配置的服务器上.备份.迁移.恢复.升级过程如下 1.gitlab备份 ...

  2. gitlab备份迁移与升级

    升级计划: https://docs.gitlab.com/ee/update/index.html#upgrade-paths 1. 安装gitlab(和源版本必须保持一致) wget https: ...

  3. maven私库nexus2.3.0-04迁移升级到nexus-3.16.1-02(异机迁移备份)

    环境信息: nexus2.3.0-04安装在32位Windows server 2003系统上 安装位置信息如下: 仓库迁移 Nexus的构件仓库都保存在sonatype-work目录中,nexus2 ...

  4. centos7 搭建svn服务器&客户端的访问&备份迁移

    当今用于版本控制的软件程序主要的有svn和git,其它软件咱不熟悉,今天记录下搭建svn服务器和svn客户端使用: 使用环境:虚拟机为centos7系统,svn服务器安装在centos7系统平台上,s ...

  5. ArcGIS Server 服务迁移、恢复

    服务迁移与恢复 如果服务可以迁移,那么备份迁移所需文件,即可恢复原服务,所以"服务的迁移与恢复"."服务的备份"问题可以汇总为一个问题"怎样迁移服务. ...

  6. Wix打包系列 (六)制作升级和补丁包

    原文:Wix打包系列 (六)制作升级和补丁包 前面我们已经知道怎么制作一个完整安装包了,但我们的软件往往不能一次性就满足客户的需要,当客户需要我们给软件进行升级的时候,我们应该怎么做呢? 在这之前,我 ...

  7. mongodb数据库备份迁移 windows -> linux

    mongodb数据库备份迁移 windows -> linux cd 到本机mongodb的安装目录 如: C:\Program Files\MongoDB\Server\3.4\bin 可以发 ...

  8. maven私库nexus2.11.4迁移升级到nexus3.12.0

    nexus简介 nexus是一个强大的maven仓库管理器,它极大的简化了本地内部仓库的维护和外部仓库的访问. nexus是一套开箱即用的系统不需要数据库,它使用文件系统加Lucene来组织数据 .n ...

  9. Git系列②之部署企业级开源仓库gitlab服务器

    Git系列②之部署企业级开源仓库gitlab服务器 上一篇我们介绍了github的常见使用方法,下面开始部署本地开源仓库gitlab GitLab 是一个用于仓库管理系统的开源项目. 1.安装配置gi ...

随机推荐

  1. SQL Server T—SQL 视图 事务

    一 视图 视图是存储在数据库中的查询的SQL 语句, 视图是从一个或多个表或视图中导出的表,是一张虚表,只能对视图进行查询,不能增.删.改. 对视图进行修改要在相应的基本表中进行修改,修改会自动的反应 ...

  2. EWS 邮件提醒

    摘要 之前做的邮件提醒的项目,最近需要优化,由于使用了队列,但即时性不是特别好,有队列,就会出现先后的问题,最近调研了exchange 流通知的模式,所以想使用流通知模式和原先的拉取邮件的方法结合,在 ...

  3. PCA算法学习(Matlab实现)

    PCA(主成分分析)算法,主要用于数据降维,保留了数据集中对方差贡献最大的若干个特征来达到简化数据集的目的. 实现数据降维的步骤: 1.将原始数据中的每一个样本用向量表示,把所有样本组合起来构成一个矩 ...

  4. 【原】DjianGo Windows7下的安装

    安装DjianGo前必须安装Python环境,由于已经装过,这里不再贴出安装Python的步骤,我的Python版本是3.2. 1.下载django https://github.com/django ...

  5. Collection集合的带All功能的测试

    public class Demo4_CollectionAll { public static void main(String[] args) { // Demo1(); // Demo2(); ...

  6. SourceTree这是一个无效的源路径

    工具->选项:修改一般下面的SSH客户端为OpenSSH

  7. layui实现复选框全选,反选

    html <div class="layui-input-inline"> <input type="checkbox" class=&quo ...

  8. 【代码笔记】iOS-自定义loading

    一,效果图. 二,工程图. 三, 代码. ViewController.h #import <UIKit/UIKit.h> //loading #import "GPLoadin ...

  9. 【代码笔记】iOS-使用MD5加密

    一,代码. - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, ...

  10. 【java】一些零碎的知识点

    java注释文档 一些常用的javadoc标签 常用javadoc标签 @see: other-class 引用other-class 生成的html文档会有一个See Alse 作为超链接的只是条目 ...