首页 > 系统相关 >centos7系统GitLab服务器搭建(最新稳定版)

centos7系统GitLab服务器搭建(最新稳定版)

时间:2024-07-02 09:44:55浏览次数:18  
标签:0s 稳定版 gitlab ok 0.0 GitLab 00 centos7 root

1、GitLab介绍

GitLab 是一个用于仓库管理系统的开源项目,使 Git 作为代码管理工具,并在此基础上搭建起来的 Web 服务。

Gitlab 是被广泛使用的基于 git 的开源代码管理平台,基于 Ruby on Rails 构建, 主要针对软件开发过程中产生的代

码和文档进行管理,Gitlab 主要针对 group 和 project 两个维度进行代码和文档管理,其中 group 是群组,

project是工程项目,一个 group 可以管理多个 project,可以理解为一个群组中有多项软件开发任务,而一个

project 中可能包含多个 branch,意为每个项目中有多个分支,分支间相互独立,不同分支可以进行归并。

2、GitLab安装

如果某些步骤已经操作过了,则无需执行。

2.1 安装SSH依赖

yum install -y curl policycoreutils-python openssh-server

  

2.2 启动SSH服务

[root@VM-8-8-centos lighthouse]# systemctl enable sshd
[root@VM-8-8-centos lighthouse]# systemctl start sshd
# 查看启动状态
[root@VM-8-8-centos lighthouse]# systemctl status sshd
● sshd.service - OpenSSH server daemon
   Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2024-05-24 11:35:45 CST; 2h 36min ago
     Docs: man:sshd(8)
           man:sshd_config(5)
 Main PID: 1636 (sshd)
   CGroup: /system.slice/sshd.service
           └─1636 /usr/sbin/sshd -D

2.3 设置防火墙-启用IP转发功能(可直接关闭防火墙)

vim /etc/sysctl.conf
# 在文件末尾添加
net.ipv4.ip_forward = 1

2.4 安装并启动防火墙

yum install firewalld systemd -y
systemctl enable firewalld
systemctl start firewalld
systemctl status firewalld
#查看启动情况
[root@VM-8-8-centos lighthouse]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2024-05-24 14:20:56 CST; 35s ago
     Docs: man:firewalld(1)
 Main PID: 29060 (firewalld)
   CGroup: /system.slice/firewalld.service
           └─29060 /usr/bin/python2 -Es /usr/sbin/firewalld --nofork --nopid

2.5 添加HTTP服务到firewalld

[root@VM-8-8-centos lighthouse]# firewall-cmd --permanent --add-service=http
success
[root@VM-8-8-centos lighthouse]# systemctl reload firewalld

其中,pemmanent 表示永久生效,若不加 --permanent 系统下次启动后就会失效。

2.6 安装Postfix以发送邮件

yum install postfix
systemctl enable postfix
systemctl start postfix
systemctl status postfix
# 查看启动情况
[root@VM-8-8-centos lighthouse]# systemctl status postfix
● postfix.service - Postfix Mail Transport Agent
   Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2024-05-24 11:35:45 CST; 2h 50min ago
 Main PID: 1360 (master)
   CGroup: /system.slice/postfix.service
           ├─1360 /usr/libexec/postfix/master -w
           ├─1378 qmgr -l -t unix -u
           └─9367 pickup -l -t unix -u
vim /etc/postfix/main.cf
# 修改inet_protocols = all为
inet_protocols = ipv4
#重启服务
systemctl restart postfix

2.7 添加gitlab镜像

在 /etc/yum.repos.d 目录下新建 gitlab-ce.repo 文件并保存,内容如下:

[gitlab-ce]
name=Gitlab CE Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/
gpgcheck=0
enabled=1
# 重新生成缓存
yum makecache

2.8 安装GitLab

yum install -y gitlab-ce #最新稳定版

yum list gitlab-ce --showduplicates #查看yum源可安装的版本
yum install -y gitlab-ce-版本号

安装信息:

[root@VM-8-8-centos yum.repos.d]# yum install -y gitlab-ce
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package gitlab-ce.x86_64 0:17.0.1-ce.0.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

====================================================================================================================================
 Package                       Arch                       Version                               Repository                     Size
====================================================================================================================================
Installing:
 gitlab-ce                     x86_64                     17.0.1-ce.0.el7                       gitlab-ce                     918 M

Transaction Summary
====================================================================================================================================
Install  1 Package

Total download size: 918 M
Installed size: 2.5 G
Downloading packages:
gitlab-ce-17.0.1-ce.0.el7.x86_64.rpm                                                                         | 918 MB  00:01:22     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : gitlab-ce-17.0.1-ce.0.el7.x86_64                                                                                 1/1 
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=17-0

  Verifying  : gitlab-ce-17.0.1-ce.0.el7.x86_64                                                                                 1/1 

Installed:
  gitlab-ce.x86_64 0:17.0.1-ce.0.el7                                                                                                

Complete!

2.9 修改gitlab配置文件

vim  /etc/gitlab/gitlab.rb
# 指定服务器ip和自定义端口
external_url 'http://192.168.164.195:8000'
# 修改alertmanager 监听地址防止alertmanager组件无法启动

alertmanager['listen_address'] = '0.0.0.0:9093'



# 将8000端口添加到防火墙中
firewall-cmd --zone=public --add-port=8000/tcp --permanent
# 重启防火墙
systemctl reload firewalld

2.10 重置gitlab

gitlab-ctl reconfigure
# 出现下面信息代表充值成功
Notes:
Default admin account has been configured with following details:
Username: root
Password: You didn't opt-in to print initial root password to STDOUT.
Password stored to /etc/gitlab/initial_root_password. This file will be cleaned up in first reconfigure run after 24 hours.

NOTE: Because these credentials might be present in your log files in plain text, it is highly recommended to reset the password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.

[2024-05-24T16:47:38+08:00] WARN: This release of Cinc Client became end of life (EOL) on May 1st 2024. Please update to a supported release to receive new features, bug fixes, and security updates.
gitlab Reconfigured!

2.11 启动gitlab

gitlab-ctl restart
[root@VM-8-8-centos yum.repos.d]# gitlab-ctl restart
ok: run: alertmanager: (pid 11174) 0s
ok: run: gitaly: (pid 11203) 0s
ok: run: gitlab-exporter: (pid 11219) 0s
ok: run: gitlab-kas: (pid 11280) 0s
ok: run: gitlab-workhorse: (pid 11289) 0s
ok: run: logrotate: (pid 11299) 1s
ok: run: nginx: (pid 11306) 0s
ok: run: node-exporter: (pid 11312) 1s
ok: run: postgres-exporter: (pid 11319) 0s
ok: run: postgresql: (pid 11332) 0s
ok: run: prometheus: (pid 11334) 0s
ok: run: puma: (pid 11352) 0s
ok: run: redis: (pid 11361) 0s
ok: run: redis-exporter: (pid 11368) 1s
ok: run: sidekiq: (pid 11383) 0s

注意:

alertmanager报错Failed to get final advertise address: No private IP address found, and explicit IP no

修改/etc/gitlab/gitlab.rb

alertmanager['listen_address'] = '0.0.0.0:9093'

2.12 访问Gitlab页面

通过服务器ip和指定端口进行访问:

查看初始化密码:

[root@VM-8-8-centos yum.repos.d]# cat /etc/gitlab/initial_root_password 
# WARNING: This value is valid only in the following conditions
#          1. If provided manually (either via `GITLAB_ROOT_PASSWORD` environment variable or via `gitlab_rails['initial_root_password']` setting in `gitlab.rb`, it was provided before database was seeded for the first time (usually, the first reconfigure run).
#          2. Password hasn't been changed manually, either via UI or via command line.
#
#          If the password shown here doesn't work, you must reset the admin password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.

Password: PECffl07TzWOvpTiwZ/Yf8QI7IdTLqHnEbDhvyBBQAE=

# NOTE: This file will be automatically deleted in the first reconfigure run after 24 hours.

 

gitlab完全卸载

[root@sasac-169 ~]# gitlab-ctl stop
ok: down: alertmanager: 0s, normally up
ok: down: gitaly: 1s, normally up
ok: down: gitlab-exporter: 0s, normally up
ok: down: gitlab-workhorse: 0s, normally up
ok: down: grafana: 0s, 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: 1s, normally up
ok: down: postgresql: 0s, normally up
ok: down: prometheus: 0s, 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
[root@sasac-169 ~]# rpm -e gitlab-ce
[root@sasac-169 ~]# ps aux | grep gitlab
root      3142  0.0  0.0   4384   484 ?        Ss   00:48   0:00 runsvdir -P /opt/gitlab/service log: ...........................................................................................................................................................................................................................................................................................................................................................................................................
root      3150  0.0  0.0   4376   540 ?        S    00:48   0:00 svlogd -tt /var/log/gitlab/postgresql
root      3152  0.0  0.0   4376   540 ?        S    00:48   0:00 svlogd -tt /var/log/gitlab/redis
root      3155  0.0  0.0   4232   348 ?        Ss   00:48   0:00 runsv gitlab-workhorse
root      3159  0.0  0.0   4376   348 ?        S    00:48   0:00 svlogd /var/log/gitlab/sidekiq
root      3161  0.0  0.0   4376   540 ?        S    00:48   0:00 svlogd -tt /var/log/gitlab/puma
root      3163  0.0  0.0   4232   348 ?        Ss   00:48   0:00 runsv gitlab-exporter
root      3167  0.0  0.0   4376   540 ?        S    00:48   0:00 svlogd -tt /var/log/gitlab/logrotate
root      3171  0.0  0.0   4376   540 ?        S    00:48   0:00 svlogd -tt /var/log/gitlab/gitlab-exporter
root      3176  0.0  0.0   4376   544 ?        S    00:48   0:00 svlogd -tt /var/log/gitlab/alertmanager
root      3177  0.0  0.0   4376   540 ?        S    00:48   0:00 svlogd -tt /var/log/gitlab/node-exporter
root      3181  0.0  0.0   4376   544 ?        S    00:48   0:00 svlogd -tt /var/log/gitlab/postgres-exporter
root      3182  0.0  0.0   4376   544 ?        S    00:48   0:00 svlogd -tt /var/log/gitlab/grafana
root      3183  0.0  0.0   4376   344 ?        S    00:48   0:00 svlogd /var/log/gitlab/gitlab-workhorse
root      3187  0.0  0.0   4376   348 ?        S    00:48   0:00 svlogd /var/log/gitlab/gitaly
root      3190  0.0  0.0   4376   540 ?        S    00:48   0:00 svlogd -tt /var/log/gitlab/nginx
root      3197  0.0  0.0   4376   540 ?        S    00:48   0:00 svlogd -tt /var/log/gitlab/redis-exporter
root      3207  0.0  0.0   4376   544 ?        S    00:48   0:00 svlogd -tt /var/log/gitlab/prometheus
root     20014  0.0  0.0 112812   968 pts/0    S+   01:45   0:00 grep --color=auto gitlab
[root@sasac-169 ~]# kill -9 3142
[root@sasac-169 ~]# find / -name gitlab | xargs rm -rf

 

参考连接 :

https://blog.csdn.net/weidu01/article/details/139173493

https://www.cnblogs.com/sylvia-liu/p/15598085.html

标签:0s,稳定版,gitlab,ok,0.0,GitLab,00,centos7,root
From: https://www.cnblogs.com/xiaoni-fighting/p/18279284

相关文章

  • 聊聊gitlab ci如何构建以时间为版本号的docker镜像
    前言最近朋友他们部门有部分内部项目,打算用gitlabci来做项目持续集成部署,他们有个需求,构建docker镜像的时候,版本需要是以当前时间作为版本。其格式为yyyymmddhhmm一开始朋友翻阅官方文档,发现gitlabci有个变量CI_COMMIT_TIMESTAMP,可以生成时间戳,他默认生成的格式是ISO-8601。就......
  • centos7 docker 配置阿里云镜像加速
    1、安装docker1.1卸载原有dockeryumremovedockerdocker-clientdocker-client-latestdocker-commondocker-latestdocker-latest-logrotatedocker-logrotatedocker-engine1.2 部署docker依赖yuminstall-yyum-utils1.3配置阿里云镜像加速yum-config-manage......
  • Centos7 安装Rabbitmq3.9.11
    安装erlang安装依赖包yum-yinstallgccglibc-develmakencurses-developenssl-develxmltoperlwgetgtk2-develbinutils-devel下载wgethttps://github.com/erlang/otp/releases/download/OTP-24.1.7/otp_src_24.1.7.tar.gz解压tar-zxvfotp_src_24.1.7.tar......
  • CentOS7.9部署Redis
    简介本章节主要讲的是在Linux系统CentOS7.9上去完成Redis软件的安装步骤1.下载Redis安装包2.解压Redis压缩包3.yum安装gcc依赖4.跳转到Redis解压目录下5.编译安装6.启动Redis实施1.下载Redis安装包wgethttp://download.redis.io/releases/redis-4.0.6.t......
  • Centos7.9安装普罗米修斯+grafana
    一、基本概念​1、之间的关系​prometheus与grafana之间是相辅相成的关系。作为完美的分布式监控系统的Prometheus,就想布加迪威龙一样示例和动力强劲。在猛的车也少不了仪表盘来观察。于是优雅的可视化平台Grafana出现了。​简而言之Grafana作为可视化......
  • ubuntu gitlab+frp 映射 版本管理平台搭建
    环境准备站点服务器:ubuntuserver22LST,RAM4G+(不然很可能502)个人PC:Vscode,git,xshell远程工具站点服务器云服务器,实体机子均可。再次动用家里的NAS-unraid开了一台ubuntu虚拟机,虚拟机用任意linux发行最新版本均可。搭建开始上一篇文章分享了hexo博客站点的搭......
  • CentOS7 升级内核记录
    为什么要升级kernel安全性提升:新版本的kernel通常修复了旧版本中的安全漏洞。性能改进:升级可能包含对硬件支持的改进,从而提高系统性能。新功能:新版本可能引入了新的功能或改进了现有功能。更好的兼容性:新kernel可能会更好地支持最新的硬件和软件。但是,升级kernel也可能带来......
  • 虚拟机centos7,无法ping通百度
    参考:centos7虚拟机静态ip设置详细教程(超全超详细亲测有效)_centos7设置静态ip-CSDN博客一、虚拟机需要设置这个网络编辑器,网络选为NAT模式。 打开命令行,执行:vim/etc/sysconfig/network-scripts/ifcfg-ens33TYPE="Ethernet"PROXY_METHOD="none"BROWSER_ONLY="no"BOOTPR......
  • centos7禁止 SSH 登录失败超过30次的IP
    使用firewalld禁止SSH登录失败超过30次的IP概述在CentOS7中,一般默认安装了firewalld动态添加失败登录超过30次的IP地址到防火墙规则中,禁止这些IP的访问。编写和使用脚本,通过firewalld来实现;注意iptables不适用,但大差不差。步骤1.安装firewalld确保firewalld已......
  • centos7&国产uos&银河麒麟系统安装MYSQL
     1.解压  tar -zxvf mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz mv mysql-5.7.34-linux-glibc2.12-x86_64 mysql 2. 先检查是否有mysql用户组和mysql用户,没有就添加有就忽略:groupsmysql  添加用户组和用户groupaddmysql&&useradd-r-gmys......