GitLab部署
官网
安装包网站:https://packages.gitlab.com/gitlab/gitlab-ce
GitLab介绍
Gitlab 是一个开源的Git代码仓库系统,使用Git作为代码管理工具,并在此基础上搭建起来的web服务。GitLab由乌克兰程序员DmitriyZaporozhets和ValerySizov开发,它由Ruby写成。后来,一些部分用Go语言重写,现今并在国内外大中型互联网公司广泛使用。
GitLab 拥有与Github类似的功能,能够浏览源代码,管理缺陷和注释。可以管理团队对仓库的访问,它非常易于浏览提交过的版本并提供一个文件历史库。团队成员可以利用内置的简单聊天程序(Wall)进行交流。它还提供一个代码片段收集功能可以轻松实现代码复用,便于日后有需要的时候进行查找。
部署安装
下载gitlab的rpm包,进行安装
rpm -ivh gitlab-ce-14.6.0-ce.0.el7.x86_64.rpm
或
yum -y install gitlab-ce-14.6.0-ce.0.el7.x86_64.rpm 自动安装依赖环境
warning: /home/zzf/gitlab.rpm: Header V4 RSA/SHA1 Signature, key ID f27eab47: NOKEY Preparing... ################################# [100%] Updating / installing... 1:gitlab-ce-14.4.4-ce.0.el7 ################################# [100%] It looks like GitLab has not been configured yet; skipping the upgrade script. *. *. *** *** ***** ***** .****** ******* ******** ******** ,,,,,,,,,***********,,,,,,,,, ,,,,,,,,,,,*********,,,,,,,,,,, .,,,,,,,,,,,*******,,,,,,,,,,,, ,,,,,,,,,*****,,,,,,,,,. ,,,,,,,****,,,,,, .,,,***,,,, ,*,. _______ __ __ __ / ____(_) /_/ / ____ _/ /_ / / __/ / __/ / / __ `/ __ \ / /_/ / / /_/ /___/ /_/ / /_/ / \____/_/\__/_____/\__,_/_.___/ Thank you for installing GitLab! GitLab was unable to detect a valid hostname for your instance. Please configure a URL for your GitLab instance by setting `external_url` configuration in /etc/gitlab/gitlab.rb file. Then, you can start your GitLab instance by running the following command: sudo gitlab-ctl reconfigure For a comprehensive list of configuration options please see the Omnibus GitLab readme https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md Help us improve the installation experience, let us know how we did with a 1 minute survey: https://gitlab.fra1.qualtrics.com/jfe/form/SV_6kVqZANThUQ1bZb?installation=omnibus&release=14-4
配置文件修改
配置ip地址、端口、仓库路径
vim /etc/gitlab/gitlab.rb
external_url 'http://192.168.88.132' #本机IP地址 git_data_dirs({ "default" => { "path" => "/gitlab" #设置的仓库目录路径 } }) nginx['listen_port'] = 8801 #nginx访问端口
加载配置文件
gitlab-ctl reconfigure
gitlab控制
启动gitlab
gitlab-ctl start
ok: run: alertmanager: (pid 13938) 15s ok: run: gitaly: (pid 13965) 12s ok: run: gitlab-exporter: (pid 13913) 18s ok: run: gitlab-workhorse: (pid 13894) 19s ok: run: grafana: (pid 13952) 14s ok: run: logrotate: (pid 13023) 230s ok: run: nginx: (pid 13457) 128s ok: run: node-exporter: (pid 13904) 18s ok: run: postgres-exporter: (pid 13946) 14s ok: run: postgresql: (pid 13138) 212s ok: run: prometheus: (pid 13921) 17s ok: run: puma: (pid 13384) 151s ok: run: redis: (pid 13053) 224s ok: run: redis-exporter: (pid 13915) 17s ok: run: sidekiq: (pid 13401) 145s
关闭gitlab
gitlab-ctl stop
ok: down: alertmanager: 0s, normally up ok: down: gitaly: 0s, normally up ok: down: gitlab-exporter: 0s, normally up ok: down: gitlab-workhorse: 1s, normally up ok: down: grafana: 0s, normally up ok: down: logrotate: 1s, normally up ok: down: nginx: 0s, normally up ok: down: node-exporter: 0s, normally up ok: down: postgres-exporter: 1s, normally up ok: down: postgresql: 0s, normally up ok: down: prometheus: 1s, normally up ok: down: puma: 0s, normally up ok: down: redis: 1s, normally up ok: down: redis-exporter: 0s, normally up ok: down: sidekiq: 0s, normally up
查看gitlab状态
gitlab-ctl status
run: alertmanager: (pid 15560) 410s; run: log: (pid 15144) 475s run: gitaly: (pid 15591) 408s; run: log: (pid 14336) 590s run: gitlab-exporter: (pid 15527) 412s; run: log: (pid 14969) 493s run: gitlab-workhorse: (pid 15500) 414s; run: log: (pid 14845) 511s run: grafana: (pid 15579) 409s; run: log: (pid 15396) 431s run: logrotate: (pid 14218) 605s; run: log: (pid 14233) 604s run: nginx: (pid 14883) 506s; run: log: (pid 14897) 505s run: node-exporter: (pid 15522) 413s; run: log: (pid 14939) 499s run: postgres-exporter: (pid 15568) 409s; run: log: (pid 15234) 468s run: postgresql: (pid 14477) 582s; run: log: (pid 14494) 579s run: prometheus: (pid 15540) 412s; run: log: (pid 15053) 479s run: puma: (pid 14779) 525s; run: log: (pid 14791) 522s run: redis: (pid 14265) 599s; run: log: (pid 14291) 596s run: redis-exporter: (pid 15529) 412s; run: log: (pid 15004) 487s run: sidekiq: (pid 14803) 519s; run: log: (pid 14822) 516s
查看gitlab版本
cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
14.8.2-ee
登录gitlab
账号为root,密码在/etc/gitlab/initial_root_password中查看
docker部署Gitlab
下载docker镜像
可以指定版本,这里是gitlab-ee:14.8.2.0
]# docker pull gitlab/gitlab-ee:14.8.2-ee.0
准备配置文件
临时启动容器,将容器内gitlab配置文件/etc/gitlab/gitlab.rb复制到本地目录
]# docker run -itd --name gittest1 gitlab/gitlab-ee:14.8.2-ee.0 ]# mkdir /opt/gitlab ]# docker cp /etc/gitlab/gitlab.rb /opt/gitlab
修改配置文件,同上
准备docker compose
version: "3.8" services: gitlab-server: image: gitlab/gitlab-ee:14.8.2-ee.0 container_name: gitlab1 environment: - "TZ:Asia/Shanghai" ports: - 8801:8801 volumes: - /etc/localtime:/etc/localtime ##时区配置 - /opt/gitlab/gitlab.rb:/etc/gitlab/gitlab.rb ##gitlab配置文件 - /opt/gitlab/backups:/var/opt/gitlab/backups ##gitlab备份目录 - /opt/gitlab/data:/gitlab ##gitlab数据目录 restart: always networks: - gitnet networks: gitnet: name: gitnet
启动gitlab
]# docker compose -f gitlab-compose.yml up -d