GitLab 是一个用于仓库管理系统的开源项目,使用Git作为代码管理工具,并在此基础上搭建起来的Web服务。安装方法是参考GitLab在GitHub上的Wiki页面。
安装依赖软件
yum -y install policycoreutils openssh-server openssh-clients postfix
设置postfix开机自启,并启动,postfix支持gitlab发信功能
systemctl enable postfix && systemctl start postfix
清华大学镜像站:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/
yum -y install wget wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm rpm -ivh gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm
修改gitlab配置文件指定服务器ip和自定义端口,防火墙策略自行配置
vim /etc/gitlab/gitlab.rb
修改内容:
external_url 'http://gitlab.example.com'
防火墙开放
firewall-cmd --zone=public --add-port=10001/tcp --permanent
重启防火墙
firewall-cmd --reload
查询是否添加成功
firewall-cmd --query-port=10001/tcp
使用gitlab自动配置,并安装数据库,初始化信息,(第一次使用配置时间较长)
gitlab-ctl reconfigure
启动gitlab服务
gitlab-ctl start
停止gitlab服务
gitlab-ctl stop
第一次访问,要求你设置root用户的密码
登录成功
官方安装文档:
https://about.gitlab.com/install/
Gitlab相关操作及说明
目录:
/etc/gitlab/gitlab.rb #gitlab配置文件
/opt/gitlab #gitlab的程序安装目录
/var/opt/gitlab #gitlab目录数据目录
/var/opt/gitlab/git-data #存放仓库数据
命令:
gitlab-ctl reconfigure #重新加载配置
gitlab-ctl status #查看当前gitlab所有服务运行状态
gitlab-ctl stop #停止gitlab服务
gitlab-ctl stop nginx #单独停止某个服务
gitlab-ctl tail #查看所有服务的日志
Gitlab的服务构成:
nginx: 静态web服务器
gitlab-workhorse 轻量级反向代理服务器
logrotate 日志文件管理工具
postgresql 数据库
redis 缓存数据库
sidekiq 用于在后台执行队列任务(异步执行)
[root@localhost tmp]# gitlab-ctl stop
ok: down: gitaly: 0s, normally up
ok: down: gitlab-monitor: 0s, normally up
ok: down: gitlab-workhorse: 1s, normally up
ok: down: logrotate: 0s, normally up
ok: down: nginx: 1s, normally up
ok: down: node-exporter: 0s, normally up
ok: down: postgres-exporter: 0s, normally up
ok: down: postgresql: 0s, normally up
ok: down: prometheus: 0s, normally up
ok: down: redis: 1s, normally up
ok: down: redis-exporter: 0s, normally up
ok: down: sidekiq: 0s, normally up
ok: down: unicorn: 0s, normally up