千家信息网

gitlab安装与简单配置

发表于:2024-11-28 作者:千家信息网编辑
千家信息网最后更新 2024年11月28日,1、官网安装文档:https://about.gitlab.com/downloads/#centos7sudo yum install curl policycoreutils openssh-se
千家信息网最后更新 2024年11月28日gitlab安装与简单配置

1、官网安装文档:https://about.gitlab.com/downloads/#centos7

sudo yum install curl policycoreutils openssh-server openssh-clientssudo systemctl enable sshdsudo systemctl start sshdsudo yum install postfixsudo systemctl enable postfixsudo systemctl start postfixsudo firewall-cmd --permanent --add-service=httpsudo systemctl reload firewalld


2、配置官网镜像源

curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bashsudo yum install gitlab-ce


由于国内特殊网络,使用官网镜像源较慢,在次提供国内镜像源

清华大学镜像源:https://mirror.tuna.tsinghua.edu.cn/help/gitlab-ce/

RHEL/CentOS 用户

新建 /etc/yum.repos.d/gitlab-ce.repo,内容为

[gitlab-ce]name=Gitlab CE Repositorybaseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/gpgcheck=0enabled=1

再执行

sudo yum makecachesudo yum install gitlab-ce

安装完成后目录结构如下

[root@docker gitlab]# tree /opt/gitlab/ -L 1/opt/gitlab/├── bin├── dependency_licenses.json├── embedded├── etc├── init├── LICENSE├── LICENSES├── service├── sv├── var├── version-manifest.json└── version-manifest.txt8 directories, 4 files[root@docker gitlab]# tree /etc/gitlab/ -L 1/etc/gitlab/├── gitlab.rb├── gitlab-secrets.json└── trusted-certs

主要集成了如下服务

# tree /opt/gitlab/sv/ -L 1/opt/gitlab/sv/├── gitaly├── gitlab-monitor├── gitlab-workhorse├── logrotate├── nginx├── node-exporter├── postgres-exporter├── postgresql├── prometheus├── redis├── redis-exporter├── sidekiq└── unicorn


3、配置gitlab地址

# cat /etc/gitlab/gitlab.rb |grep ^external_urlexternal_url 'http://192.168.99.101'

默认url地址是http://{hostname}


4、重载配置并启动

gitlab-ctl reconfigure

启动时确保80、8060、8080、9090、9100、9121、9168、9187这些端口没有占用,否则启动失败


5、查看启动状态

# gitlab-ctl statusrun: gitaly: (pid 5435) 2522s; run: log: (pid 4150) 3071srun: gitlab-monitor: (pid 5441) 2522s; run: log: (pid 4585) 3023srun: gitlab-workhorse: (pid 5445) 2522s; run: log: (pid 4203) 3065srun: logrotate: (pid 5456) 2521s; run: log: (pid 4305) 3053srun: nginx: (pid 5737) 2439s; run: log: (pid 4264) 3059srun: node-exporter: (pid 5471) 2520s; run: log: (pid 4415) 3041srun: postgres-exporter: (pid 5478) 2520s; run: log: (pid 4514) 3029srun: postgresql: (pid 5487) 2519s; run: log: (pid 3858) 3170srun: prometheus: (pid 5490) 2519s; run: log: (pid 4372) 3047srun: redis: (pid 5497) 2518s; run: log: (pid 3744) 3181srun: redis-exporter: (pid 5502) 2518s; run: log: (pid 4449) 3035srun: sidekiq: (pid 5804) 2371s; run: log: (pid 4104) 3077srun: unicorn: (pid 5540) 2515s; run: log: (pid 4049) 3083s


6、gitlab启动、停止、重启等操作

[root@docker gitlab]# gitlab-ctl stopok: down: gitaly: 0s, normally upok: down: gitlab-monitor: 0s, normally upok: down: gitlab-workhorse: 1s, normally upok: down: logrotate: 0s, normally upok: down: nginx: 1s, normally upok: down: node-exporter: 0s, normally upok: down: postgres-exporter: 0s, normally upok: down: postgresql: 0s, normally upok: down: prometheus: 0s, normally upok: down: redis: 1s, normally upok: down: redis-exporter: 0s, normally upok: down: sidekiq: 0s, normally upok: down: unicorn: 0s, normally up[root@docker gitlab]# gitlab-ctl startok: run: gitaly: (pid 14482) 0sok: run: gitlab-monitor: (pid 14488) 1sok: run: gitlab-workhorse: (pid 14491) 0sok: run: logrotate: (pid 14500) 0sok: run: nginx: (pid 14506) 1sok: run: node-exporter: (pid 14514) 0sok: run: postgres-exporter: (pid 14520) 1sok: run: postgresql: (pid 14526) 0sok: run: prometheus: (pid 14534) 1sok: run: redis: (pid 14544) 0sok: run: redis-exporter: (pid 14548) 0sok: run: sidekiq: (pid 14559) 1sok: run: unicorn: (pid 14562) 0s[root@docker gitlab]# gitlab-ctl statusrun: gitaly: (pid 14482) 12s; run: log: (pid 4150) 3982srun: gitlab-monitor: (pid 14488) 12s; run: log: (pid 4585) 3934srun: gitlab-workhorse: (pid 14491) 11s; run: log: (pid 4203) 3976srun: logrotate: (pid 14500) 11s; run: log: (pid 4305) 3964srun: nginx: (pid 14506) 11s; run: log: (pid 4264) 3970srun: node-exporter: (pid 14514) 10s; run: log: (pid 4415) 3952srun: postgres-exporter: (pid 14520) 10s; run: log: (pid 4514) 3940srun: postgresql: (pid 14526) 9s; run: log: (pid 3858) 4081srun: prometheus: (pid 14534) 9s; run: log: (pid 4372) 3958srun: redis: (pid 14544) 8s; run: log: (pid 3744) 4092srun: redis-exporter: (pid 14548) 8s; run: log: (pid 4449) 3946srun: sidekiq: (pid 14559) 8s; run: log: (pid 4104) 3988srun: unicorn: (pid 14562) 7s; run: log: (pid 4049) 3994s[root@docker gitlab]# gitlab-ctl restartok: run: gitaly: (pid 14624) 0sok: run: gitlab-monitor: (pid 14630) 0sok: run: gitlab-workhorse: (pid 14633) 1sok: run: logrotate: (pid 14645) 0sok: run: nginx: (pid 14651) 1sok: run: node-exporter: (pid 14659) 0sok: run: postgres-exporter: (pid 14665) 1sok: run: postgresql: (pid 14674) 0sok: run: prometheus: (pid 14684) 0sok: run: redis: (pid 14695) 1sok: run: redis-exporter: (pid 14699) 0sok: run: sidekiq: (pid 14705) 1sok: run: unicorn: (pid 14710) 0s[root@docker gitlab]#


0