Install gitlab
https://about.gitlab.com/installation/#centos-7
1. Install and configure the necessary dependencies
On CentOS 7 (and RedHat/Oracle/Scientific Linux 7), the commands below will also open HTTP and SSH access in the system firewall.
系统环境 CentOS 7 ,搭建sshd服务及配置防火墙允许访问
1 |
|
Next, install Postfix to send notification emails. If you want to use another solution to send emails please skip this step and configure an external SMTP server after GitLab has been installed.
下一步,安装postfix邮件服务(推荐方式),也可自行安装STMP或其他邮件服务
1 |
|
During Postfix installation a configuration screen may appear. Select ‘Internet Site’ and press enter. Use your server’s external DNS for ‘mail name’ and press enter. If additional screens appear, continue to press enter to accept the defaults.
postfix安装过程中 此处省略500字
安装postfix后可能启动失败,需修改配置文件 /etc/postfix/main.cf
1 |
|
2. Add the GitLab package repository and install the package
Add the GitLab package repository.
增加gitlab repository,此处官方只给出了gitlab-ee版本,我们自行搭建gitlab-ce版本,自己修改就好。
1 |
|
Next, install the GitLab package. Change http://git.weiresearch.com
to the URL at which you want to access your GitLab instance. Installation will automatically configure and start GitLab at that URL. HTTPS requires additional configuration after installation.
下一步,安装gitlab的package,配置访问url:http://git.weiresearch.com
,如果需要https访问,需要更多配置,此处不列举。
同样逻辑,官方给出gitlab-ee版本的安装,我们自己修改为gitlab-ce版本
1 |
|
3. Browse to the hostname and login
On your first visit, you’ll be redirected to a password reset screen. Provide the password for the initial administrator account and you will be redirected back to the login screen. Use the default account’s username root to login. 第一次登陆会跳转到重设密码界面,重置默认root账号密码。
GitLab官方配置说明:https://docs.gitlab.com/omnibus/README.html#installation-and-configuration-using-omnibus-package
4. Set up your communication preferences
官方重要说明,需详细阅读
Visit our email subscription preference center to let us know when to communicate with you. We have an explicit email opt-in policy so you have complete control over what and how often we send you emails.
Twice a month, we send out the GitLab news you need to know, including new features, integrations, docs, and behind the scenes stories from our dev teams. For critical security updates related to bugs and system performance, sign up for our dedicated security newsletter.
5. 运行配置
配置 /etc/gitlab/gitlab.rb
1 |
|
配置 nginx /etc/nginx/conf.d/gitlab.conf
1 |
|
修改/etc/gitlab/gitlab.rb
后,需重新配置gitlab并重启
1 |
|
配置crontab每天自动执行备份
1 |
|
系统迁移
- 新服务器安装gitlab最新版本并配置 参看 gitlab安装
- 需更旧服务器gitlab服务为最新版本,并备份数据
1
2
3/opt/gitlab/bin/gitlab-rake gitlab:backup:create yum install gitlab-ce -y /opt/gitlab/bin/gitlab-rake gitlab:backup:create
- 传输备份文件至新服务器
1
scp 1528278263_2018_06_06_10.8.3_gitlab_backup.tar root@10.81.50.104:/alidata1/backups/gitlab
- 新服务器上执行数据恢复
1
2cd /alidata1/backups/gitlab gitlab-rake gitlab:backup:restore BACKUP=1528278263_2018_06_06_10.8.3
- 迁移完成
数据恢复
进入gitlab备份目录/alidata1/service-data/gitlab
,选择需要恢复的版本
备份命令:gitlab-rake gitlab:backup:restore BACKUP=1528275060_2018_06_06_10.8.3
BACKUP=
备份文件前缀,包含 时间戳_日期_版本号
1 |
|
系统升级 Updating GitLab installed with the Omnibus GitLab package
https://docs.gitlab.com/omnibus/update/README.html#updating-using-the-official-repositories
Backup
1 |
|
Updating using the official repositories
If you have installed Omnibus GitLab Community Edition or Enterprise Edition, then the official GitLab repository should have already been set up for you.
如果安装的是官方 gitlab-ce 或gitlab-ee,已设定官方的gitlab repository
To update to a newer GitLab version, all you have to do is:
执行以下代码:如果安装的是gitlab-ee,自行替换下列命令。
1 |
|
邮箱配置
如果使用阿里云服务器搭建gitlab,邮箱使用腾讯企业邮箱,需在阿里云控制台申请25端口解封
- 登录阿里云控制台
- 鼠标指向右上角用户头像 -> 点击弹出
安全管控
业务申请
栏中 -> 点击25端口解封
- 增加 25端口解封申请,填写对应ip及相关信息,提交审核。
Hook配置
gitlab默认禁止本地请求,当jenkins服务和gitlab处在同一服务器时会出现异常
1 |
|
处理方式:
- 管理员账号点击上方扳手图标,进入
Admin area
->Settings
->Outbound requests
- 勾选
Allow requests to the local network from hooks and services
- Save changes 保存