Gitlab Server 部署

1、环境配置

关闭防火墙、SELinux

开启邮件服务

systemctl start  postfix
systemctl enable postfix
#ps:不开去邮箱可以不期待,不是必须操作

  

2、部署 Gitlab

1、安装 gitlab 依赖包

centos7:
 ~]# yum install -y curl openssh-server openssh-clients postfix cronie policycoreutils-python
# gitlab-ce 10.x.x以后的版本需要依赖policycoreutils-python

centos8:
 ~]# yum install -y curl openssh-server openssh-clients postfix cronie  policycoreutils-python-utils

  

2、添加官方源

~]# curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash

因为官方源太慢,可以使用国内清华yum源,配置如下

~]# vim /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

 

3、安装 Gitlab

 ~]# yum -y install gitlab-ce                    # 自动安装最新版
 ~]# yum -y install gitlab-ce-x.x.x	     # 安装指定版本Gitlab

4、配置 Gitlab

1、查看Gitlab版本
]# head -1 /opt/gitlab/version-manifest.txt
gitlab-ce 13.8.4
[root@node1 gitlab]# pwd
/opt/gitlab
[root@node1 gitlab]# ll
总用量 2580
drwxr-xr-x  2 root root     153 2月  14 21:02 bin
-rw-r--r--  1 root root  192450 2月  11 18:36 dependency_licenses.json
drwxr-xr-x 14 root root     168 2月  14 21:02 embedded
drwxr-xr-x  2 root root      32 2月  14 21:02 etc
drwxr-xr-x  2 root root       6 2月  11 18:37 init
-rw-r--r--  1 root root 2391185 2月  11 18:36 LICENSE
drwxr-xr-x  2 root root     306 2月  14 21:02 licenses
drwxr-xr-x  2 root root    8192 2月  14 21:02 LICENSES
drwxr-xr-x  2 root root       6 2月  11 18:37 service
drwxr-xr-x  2 root root       6 2月  11 18:37 sv
-rw-r--r--  1 root root   31942 2月  11 18:37 version-manifest.json
-rw-r--r--  1 root root   12135 2月  11 18:37 version-manifest.txt      #依赖包位置
2、Gitlab 配置登录链接
#设置登录链接
[root@qfedu.com ~]# vim /etc/gitlab/gitlab.rb
***
## GitLab URL
##! URL on which GitLab will be reachable.
##! For more details on configuring external_url see:
##! https://docs.gitlab.com/omnibus/settings/configuration.html#configuring-the-external-url-for-gitlab
# 没有域名,可以设置为本机IP地址

32 external_url 'http://192.168.1.1'    #也可以加端口

***

 [root@node1 gitlab]# grep "^external_url" /etc/gitlab/gitlab.rb
 external_url 'http://192.168.1.1'  #绑定监听的域名或IP

3、初始化 Gitlab

第一次使用配置时间较长

 ~]# gitlab-ctl reconfigure   
......

  Running handlers:
  Running handlers complete
  Chef Infra Client finished, 578/1549 resources updated in 02 minutes 57 seconds

  Notes:
  It seems you haven't specified an initial root password while configuring the GitLab instance.
  On your first visit to your GitLab instance, you will be presented with a screen to set a
  password for the default admin account with username `root`.

  gitlab Reconfigured!

  

4、启动 Gitlab 服务
[root@node1 gitlab]# gitlab-ctl start
ok: run: alertmanager: (pid 14192) 65s
ok: run: gitaly: (pid 14079) 67s
ok: run: gitlab-exporter: (pid 14089) 67s
ok: run: gitlab-workhorse: (pid 14049) 68s
ok: run: grafana: (pid 14211) 64s
ok: run: logrotate: (pid 13583) 153s
ok: run: nginx: (pid 13560) 160s
ok: run: node-exporter: (pid 14064) 68s
ok: run: postgres-exporter: (pid 14203) 64s
ok: run: postgresql: (pid 13272) 215s
ok: run: prometheus: (pid 14174) 66s
ok: run: puma: (pid 13459) 178s
ok: run: redis: (pid 13101) 227s
ok: run: redis-exporter: (pid 14091) 66s
ok: run: sidekiq: (pid 13487) 172s

  

  [root@node1 gitlab]# lsof -i:80  #查看git
  COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
  nginx 13560 root 7u IPv4 64606 0t0 TCP *:http (LISTEN)
  nginx 13561 gitlab-www 7u IPv4 64606 0t0 TCP *:http (LISTEN)
  nginx 13562 gitlab-www 7u IPv4 64606 0t0 TCP *:http (LISTEN)
  nginx 13563 gitlab-www 7u IPv4 64606 0t0 TCP *:http (LISTEN)
  nginx 13564 gitlab-www 7u IPv4 64606 0t0 TCP *:http (LISTEN)

5、Gitlab 的使用

在浏览器中输入 http://192.168.1.1,然后 change password: ,并使用root用户登录 即可 (后续动作根据提示操作)

 

 

 

5.1、Gitlab 命令行修改密码

~]# gitlab-rails console production
irb(main):001:0>user = User.where(id: 1).first      # id为1的是超级管理员
irb(main):002:0>user.password = 'yourpassword'      # 密码必须至少8个字符
irb(main):003:0>user.save!                          # 如没有问题 返回true
exit                                                 # 退出

5.2、Gitlab服务管理

~]# gitlab-ctl start                      # 启动所有 gitlab 组件;
~]# gitlab-ctl stop                       # 停止所有 gitlab 组件;
~]# gitlab-ctl restart                    # 重启所有 gitlab 组件;
~]# gitlab-ctl status                     # 查看服务状态;
~]# gitlab-ctl reconfigure                # 初始化服务;
~]# vim /etc/gitlab/gitlab.rb             # 修改默认的配置文件;
~]# gitlab-ctl tail                       # 查看日志;

 

内容来源于网络如有侵权请私信删除

文章来源: 博客园

原文链接: https://www.cnblogs.com/lin-strive/p/14402923.html

你还没有登录,请先登录注册
  • 还没有人评论,欢迎说说您的想法!