部署gitlab-01

Gitlab Server 部署

一、环境配置

关闭防火墙、SELinuxhtml

开启邮件服务node

systemctl start  postfix
systemctl enable postfix
#ps:不开去邮箱能够不期待,不是必须操做

  

二、部署 Gitlab

一、安装 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

  

二、添加官方源

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

由于官方源太慢,可使用国内清华yum源,配置以下python

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

 

三、安装 Gitlab

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

四、配置 Gitlab

一、查看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      #依赖包位置
二、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'    #也能够加端口nginx

***

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

三、初始化 Gitlab

第一次使用配置时间较长redis

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

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

  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`.json

  gitlab Reconfigured!vim

  

四、启动 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)centos

五、Gitlab 的使用

在浏览器中输入 http://192.168.1.1,而后 change password: ,并使用root用户登陆 便可 (后续动做根据提示操做)

 

 

 

5.一、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.二、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                       # 查看日志;
相关文章
相关标签/搜索