Gitlab

Gitlab
Noahgitlab 基础
一.gitlab 概念
1.gitlab 是什么?
GitLab 是一个用于仓库管理系统的开源项目,使用 Git 作为代码管理工具,并在此基础上搭建起来的 Web 服务。 2.官网:https://about.gitlab.com/
二.gitlab 安装 1.下载 gitlab 安装包 2.安装 3.修改配置 4.启动
5.GitLab 常用组件 #清华大学软件包地址
https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/ #下载
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-14.1.0-
ce.0.el7.x86_64.rpm
#ce 为社区版,ee 为企业版
yum -y install gitlab-ce-14.1.0-ce.0.el7.x86_64.rpm
vim /etc/gitlab/gitlab.rb
external_url ‘http://192.168.0.118‘
gitlab-ctl reconfigure #访问
http://ip #用户名:root 密码:cat /etc/gitlab/initial_root_password
#gitlab 默认端口为 80,为了防止端口重复可以修改端口
#1.修改/etc/gitlab/gitlab.rb 文件,如果有如下参数直接修改,如果没有就新增
nginx[‘listen_port’] = 8088
external_url ‘http://192.168.0.118:9006‘
#2.修改默认的 gitlab nginx 的 web 服务 80 端 /var/opt/gitlab/nginx/conf/gitlab-http.conf
server { ## HTTPS server
listen *:8088;
#3.重新初始化并重启
gitlab-ctl reconfigure
gitlab-ctl restart
6.GitLab 服务参数
7.GitLab 常用命令 8.关闭 GitLab 组件
由于 GitLab 核心功能是代码托管,避免资源浪费,有些额外的组件是不需 要的,可以考虑关闭掉
三、docker 部署
nginx #静态 Web 服务器
gitlab-shell #用于处理 Git 命令
gitlab-workhorse #轻量级的反向代理服务器
logrotate #日志文件管理工具
postgresql #数据库
redis #缓存数据库
sidekiq #用于在后台执行队列任务(异步执行)
unicorn #GitLab Rails 应用是托管在这个服务器上面的
常用参数如下:
/opt/gitlab #应用代码和相应的依赖程序
/etc/gitlab #配置文件目录
/etc/gitlab/gitlab.rb #gitlab 配置文件
/var/log/gitlab #gitlab 各个组件产生的日志
/var/opt/gitlab/git-data/repositories #库默认存储目录
/var/opt/gitlab/backups/ #备份文件生成的目录
/var/opt/gitlab/gitlab-rails/etc/unicorn.rb #unicorn 配置文件
/var/opt/gitlab/nginx/conf/gitlab-http.conf #nginx 配置文件
gitlab-ctl start #启动全部服务(也可指定单个服务)
gitlab-ctl restart #重启全部服务(也可指定单个服务)
gitlab-ctl stop #停止全部服务(也可指定单个服务)
gitlab-ctl reconfigure #使配置文件生效(修改主配置文件后使用)
gitlab-ctl show-config #验证配置文件
gitlab-ctl uninstall #卸载 gitlab(保留数据)
gitlab-ctl cleanse #删除所有数据,从新开始
gitlab-ctl tail #查看服务的日志 #修改 gitlab 配置文件,关闭不需要的组件
vim /etc/gitlab/gitlab.rb
#…该配置所在行数仅供参考,不同版本,有所差异,可搜索关键字查询
1801 prometheus[‘enable’] = false
1802 prometheus[‘monitor_kubernetes’] = false
1879 alertmanager[‘enable’] = false
1902 node_exporter[‘enable’] = false
1921 redis_exporter[‘enable’] = false
1939 postgres_exporter[‘enable’] = false
1970 gitlab_exporter[‘enable’] = false
1984 prometheus_monitoring[‘enable’] = false
1991 grafana[‘enable’] = false #重新配置 GitLab
version: ‘3.7’
services:
gitlab:
image: ‘gitlab/gitlab-ce:14.1.0-ce.0’
container_name: gitlab
restart: always
ports:
- ‘8085:80’
- ‘8443:443’
- ‘8022:22’
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url ‘http://192.168.134.119‘
volumes: - ‘/usr/local/gitlab/etc:/etc/gitlab’
- ‘/usr/local/gitlab/log:/var/log/gitlab’
- ‘/usr/local/gitlab/data:/var/opt/gitlab






