Linux下GitLab的快速安装以及备份
源码安装 GitLab 步骤繁琐:需要安装依赖包,Mysql,Redis,Postfix,Ruby,Nginx……安装完毕还得一个个手动配置这些软件,容易出错
一、安装
在Ubuntu 14上
修改/etc/apt/sources.list.d/gitlab-ce.list,添加以下行
deb https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/debian jessie main
开始安装:
# 安装依赖包
sudo apt-get install curl openssh-server ca-certificates postfix
# 安装 GitLab 社区版
apt-get install gitlab-ce
# 初始化,初始化完自动启动 GitLab
sudo gitlab-ctl reconfigure
在 CentOS 6上
新建 /etc/yum.repos.d/gitlab-ce.repo,添加以下内容
[gitlab-ce]
name=gitlab-ce
baseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6
repo_gpgcheck=0
gpgcheck=0
enabled=1
gpgkey=https://packages.gitlab.com/gpg.key
在 Centos7/REHL7 上
[gitlab-ce]
name=gitlab-ce
baseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7
repo_gpgcheck=0 gpgcheck=0 enabled=1 gpgkey=https://packages.gitlab.com/gpg.key
安装步骤:
# 安装依赖包
yum install curl openssh-server openssh-clients postfix cronie
# 启动 postfix 邮件服务
service postfix start
# 检查 postfix
chkconfig postfix on
# 安装 GitLab 社区版
yum install gitlab-ce
# 初始化 GitLab
gitlab-ctl reconfigure
登录访问
添加访问的 host,修改/etc/gitlab/gitlab.rb的external_url
external_url 'http://git.test.com'
每次修改/etc/gitlab/gitlab.rb,都要运行以下命令,让配置生效
gitlab-ctl reconfigure
在浏览器打开网址http://git.test.com,登陆。默认管理员:
用户名: root
密码: 5iveL!fe
二、安装中文语言包(汉化)
以下汉化步骤参考此篇文章,首先确认当前安装版本
cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
当前安装版本是8.5.7,因此中文补丁需要打8.5版本。
克隆 GitLab 源码仓库:
# 克隆 GitLab.com 仓库
git clone https://gitlab.com/larryli/gitlab.git
#或 Gitcafe.com 镜像,速度更快
git clone https://gitcafe.com/larryli/gitlab.git
git clone https://git.coding.net/larryli/gitlab.git
运行汉化补丁:
# 8.5 版本的汉化补丁(8-5-stable是英文稳定版,8-5-zh是中文版,两个 diff 结果便是汉化补丁)
git diff origin/8-5-stable..8-5-zh > /tmp/8.5.diff
# 停止 gitlab
gitlab-ctl stop
# 应用汉化补丁
cd /opt/gitlab/embedded/service/gitlab-rails
git apply /tmp/8.5.diff
# 启动gitlab
gitlab-ctl start
至此,汉化完毕
gitlab 8.8版本
git diff origin/8-8-stable origin/8-8-zh > /tmp/8.8.diff
三、备份
配置文件含密码等敏感信息,不要和数据备份文件放在一起。
sh -c 'umask 0077; tar -cf $(date "+etc-gitlab-%s.tar") -C /etc/gitlab'
默认数据备份目录是/var/opt/gitlab/backups,手动创建备份文件:
# Omnibus 方式安装使用以下命令备份
gitlab-rake gitlab:backup:create
日常备份,添加 crontab,运行crontab -e
# 每天2点执行备份
0 2 * * * /opt/gitlab/bin/gitlab-rake gitlab:backup:create CRON=1
如要修改备份周期和目录,在/etc/gitlab/gitlab.rb中修改以下两个选项
# 设置备份周期为7天 - 604800秒
gitlab_rails['backup_keep_time'] = 604800
# 备份目录
gitlab_rails['backup_path'] = '/mnt/backups'
恢复之前,确保备份文件所安装 GitLab 和当前要恢复的 GitLab 版本一致。首先,恢复配置文件:
mv /etc/gitlab /etc/gitlab.$(date +%s)
# 将下面配置备份文件的时间戳改为你所备份的文件的时间戳
tar -xf etc-gitlab-1399948539.tar -C /
恢复数据文件
# 将数据备份文件拷贝至备份目录
cp 1393513186_gitlab_backup.tar /var/opt/gitlab/backups/ # 停止连接数据库的进程
gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq # 恢复1393513186这个备份文件,将覆盖GitLab数据库!
gitlab-rake gitlab:backup:restore BACKUP=1393513186 # 启动 GitLab
gitlab-ctl start # 检查 GitLab
gitlab-rake gitlab:check SANITIZE=true
四、持续集成(GitLab-CI)
GitLab 从 8.0 之后就集成了GitLab-CI,所以不需要再另外安装 CI。但需要安装Runner
1.添加 Runner 安装源
# For Debian/Ubuntu
curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-ci-multi-runner/script.deb.sh | sudo bash # For CentOS
curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-ci-multi-runner/script.rpm.sh | sudo bash
安装gitlab-ci-multi-runner
# For Debian/Ubuntu
apt-get install gitlab-ci-multi-runner # For CentOS
yum install gitlab-ci-multi-runner
2.注册 Runner
获取Token:以管理员身份登录GitLab,进入管理区域,点击侧边栏的Runner,如下图,“注册授权码”后的字符串便是Token。
sudo gitlab-ci-multi-runner register Running in system-mode. Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/ci):
http://git.home.com/ci
Please enter the gitlab-ci token for this runner:
xxxx # 输入Token
Please enter the gitlab-ci description for this runner:
[xxy-web-test-02]: test-runner # 输入runner的名称
Please enter the gitlab-ci tags for this runner (comma separated):
test,php # 输入runner的标签,以区分不同的runner,标签间逗号分隔
Registering runner... succeeded runner=YDPz2or3
Please enter the executor: ssh, shell, parallels, docker, docker-ssh, virtualbox:
shell
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
注册完成便可在上图中查看你所注册的Runner。至此,所有安装完毕,Runner的构建,后续补充。
centos添加gitlab-ce.repo后,需要执行sudo yum makecache
参考文章
http://serverfault.com/questions/683196/502-gitlab-is-not-responding-after-change-username
http://skyao.github.io/2015/02/16/git-gitlab-setup/
https://gitlab.com/gitlab-org/omnibus-gitlab/issues/148
http://blog.csdn.net/wangxicoding/article/details/43738137
http://stackoverflow.com/questions/27816046/gitlab-is-not-responding-502-on-ubuntu-14-04-after-starting-server
http://www.cnblogs.com/jasondan/p/4056669.html
http://www.open-open.com/lib/view/open1399684894447.html
http://www.jianshu.com/p/7a0d6917e009
https://xuanwo.org/2016/04/13/gitlab-install-intro/
Linux下GitLab的快速安装以及备份的更多相关文章
- ElasticSearch概述及Linux下的单机ElasticSearch安装
原文链接:http://blog.csdn.net/w12345_ww/article/details/52182264 这两天在项目中要涉及到ElasticSearch的使用,就上网去搜索了一些这方 ...
- Linux下apache+phppgadmin+postgresql安装配置
Linux下apache+phppgadmin+postgresql安装配置 操作系统:CentOS 安装包:httpd(首选yum), php(包括php以及php-pgsql,php-mbstri ...
- Linux下的网络远程安装
Linux下的网络远程安装 1.用RHEL6.5光盘安装第一台服务器 2.在第一台服务器上配置YUM服务器 先创建一个挂载 #mount #umount /dev/cdrom #mkdir /mnt/ ...
- Linux下指定版本编译安装LAMP
说明: 操作系统:CentOS 6.5 64位 需求: 编译安装LAMP运行环境 各软件版本如下: MySQL:mysql-5.1.73 Apache:httpd-2.2.31 PHP:php-5.2 ...
- 【转】Linux下XenServer管理工具安装
转载文章 - Linux下XenServer管理工具安装 Xen-Server 6.5 虚拟机安装Linux系统 vmware安装ubuntu12.04嵌套安装xen server(实现嵌套虚拟化) ...
- linux下.run文件的安装与卸载
linux下.run文件的安装与卸载 .run文件的安装很简单,只需要为该文件增加可执行属性,即可执行安装 以 virtualbox 的安装文件 virtualbox-3.1.6-59338-Li ...
- Linux下rar unrar的安装
Linux下rar unrar的安装: 以3.8.0版本为例,如果是64位平台,执行以下命令,也可以去官方网站:)下载最新版: wget http://www.rarlab.com/rar/rarli ...
- 【转】Linux下Android ADB驱动安装详解
原文网址:http://blog.csdn.net/zhenwenxian/article/details/5901350 Linux下Android ADB驱动安装详解 概述 最近由于内置的合作商比 ...
- Linux下的Oracle 11gr2安装完成的的自启动操作。
Linux下的Oracle在安装结束后是处于运行状态的.重启机器后,Oracle不会像在Windows下那样将Oracle添加到Windows服务,在linux下需要手动启动Orcle服务 以orac ...
随机推荐
- XE7 iOS 取得系统字型名称
系统字型名称在每个平台的取得方式不尽相同,以下示范如何在 iOS 取得系统内所有字型的名称: uses // 加入下面二个 uses 文件 iOSapi.UIKit, iOSapi.Foundatio ...
- UVALive 4987---Evacuation Plan(区间DP)
题目链接 https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_ ...
- 2016读书List
2016年读书书单. 1. <华尔街漫步> + <战胜华尔街>+ <华尔街之狼> 2. <野蛮大陆> 3. <第三帝国的最后十四天> 4. ...
- Java基础学习总结--对象容器
目录: ArrayList 顺序泛型容器 HashSet 集合容器 HashMap<Key,Value>容器 要用Java实现记事本的功能.首先列出记事本所需功能: 可以添加记录(字符串) ...
- 12款响应式的 jQuery 旋转木马(传送带)插件
在企业网站,作品集网站,电子商务网站或任何其他类型的网站内容显示图片可以使用 jQuery 旋转木马(传送带)插件来实现. jQuery 旋转木马插件允许开发人员以水平或垂直的方式显示内容,视频和图像 ...
- 2013年最新流行的响应式 WordPress 主题【下篇】
在这篇文章中,我们收集了一些在2013年发布的最好的免费的响应式 WordPress 主题.这些主题包括高级功能,如自定义模板.自定义窗口小部件.自定义菜单主题选项等.让我们来看看下面的清单,并希望你 ...
- Unsplash.it - 实用的图片占位符,支持个性化设置
Unsplash.it 是一个使用漂亮的图像作为占位符的工具.只要把你的图像尺寸(宽与高)放到网址后面的参数中,你会得到一个占位符.你可以很容易地得到一个随机图像或者是一个模糊图像.也支持获取灰度图像 ...
- CORS(跨域资源共享)
前言:上一篇文章在写如何使用JSONP实现跨域请求的时候,偶然间提到CORS,即Cross-Origin Resource Sharing(跨域资源共享).虽然前些天也看了一下CORS相关的文章,但是 ...
- Web前端面试笔试题总结
最近一段时间要毕业了,忙着找工作,见过不少笔试面试题,自己总结了一些加上网上找的一些整合了一下.答案暂时都东拼西凑出来了,但是还是先不发出来,一方面是答案并不是唯一的并且自己的答案不能保证对,另一方面 ...
- SharePoint 2013 数据库中手动更新用户信息
在SharePoint的使用过程中,尤其是Windows认证的情况下,而且没有配置用户配置文件服务,经常会出现如果更新AD中的用户信息(包括名字.显示名.邮件等),SharePoint这边站点并不会更 ...