经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » 软件/图像 » Git » 查看文章
部署gitlab-01
来源:cnblogs  作者:林奋斗的成长之路  时间:2021/2/18 15:07:52  对本文有异议

Gitlab Server 部署

1、环境配置

关闭防火墙、SELinux

开启邮件服务

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

  

2、部署 Gitlab

1、安装 gitlab 依赖包

  1. centos7:
  2. ~]# yum install -y curl openssh-server openssh-clients postfix cronie policycoreutils-python
  3. # gitlab-ce 10.x.x以后的版本需要依赖policycoreutils-python
  4.  
  5. centos8:
  6. ~]# yum install -y curl openssh-server openssh-clients postfix cronie policycoreutils-python-utils

  

2、添加官方源

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

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

  1. ~]# vim /etc/yum.repos.d/gitlab-ce.repo
  2. [gitlab-ce]
  3. name=Gitlab CE Repository
  4. baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/
  5. gpgcheck=0
  6. enabled=1

 

3、安装 Gitlab

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

4、配置 Gitlab

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

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

  1. ***

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

3、初始化 Gitlab

第一次使用配置时间较长

  1. ~]# 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 服务
  1. [root@node1 gitlab]# gitlab-ctl start
  2. ok: run: alertmanager: (pid 14192) 65s
  3. ok: run: gitaly: (pid 14079) 67s
  4. ok: run: gitlab-exporter: (pid 14089) 67s
  5. ok: run: gitlab-workhorse: (pid 14049) 68s
  6. ok: run: grafana: (pid 14211) 64s
  7. ok: run: logrotate: (pid 13583) 153s
  8. ok: run: nginx: (pid 13560) 160s
  9. ok: run: node-exporter: (pid 14064) 68s
  10. ok: run: postgres-exporter: (pid 14203) 64s
  11. ok: run: postgresql: (pid 13272) 215s
  12. ok: run: prometheus: (pid 14174) 66s
  13. ok: run: puma: (pid 13459) 178s
  14. ok: run: redis: (pid 13101) 227s
  15. ok: run: redis-exporter: (pid 14091) 66s
  16. 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 命令行修改密码

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

5.2、Gitlab服务管理

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

 

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

 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号