GitLab 是一个用于仓库管理系统的开源项目,使用Git作为代码管理工具,并在此基础上搭建起来的Web服务。
#清华大学软件包地址
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
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核心功能是代码托管,避免资源浪费,有些额外的组件是不需 要的,可以考虑关闭掉
#修改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
评论