CentOS 7安装gitlab-ee企业版

青旅半醒 2022-06-05 03:21 281阅读 0赞

CentOS 7安装gitlab-ee企业版

下面提供官方安装文档:
官方文档地址:https://about.gitlab.com/installation/#centos-7
安装前:

  1. [root@localhost ~]# free -m
  2. total used free shared buff/cache available
  3. Mem: 7823 136 7486 8 200 7491
  4. Swap: 8191 0 8191

一、安装

1.安装必要的依赖项

系统开放http和ssh访问,可能有些系统没有安装防火墙使用的是其他安全组件,最后两行可以不执行

  1. sudo yum install -y curl policycoreutils-python openssh-server
  2. sudo systemctl enable sshd
  3. sudo systemctl start sshd
  4. sudo firewall-cmd --permanent --add-service=http
  5. sudo systemctl reload firewalld

安装邮件服务器,用于发送邮件通知,如果有其他的解决方案,可以不用安装,跳过此步

  1. sudo yum install postfix
  2. sudo systemctl enable postfix
  3. sudo systemctl start postfix

安装过程直接回车继续…

2.下载安装Gitlab包

  1. curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh | sudo bash

这一步可以设置EXTERNAL_URL=http://gitlab.example.com,用于安装启动后访问gitlab,这里如果使用https的话安装之后还需要做一些额外的配置

  1. sudo EXTERNAL_URL="http://gitlab.example.com" yum install -y gitlab-ee

如果不设置EXTERNAL_URL=http://gitlab.example.com,可以直接安装,安装之后在编辑访问url,直接安装使用:

  1. sudo yum install -y gitlab-ee
  2. It looks like GitLab has not been configured yet; skipping the upgrade script.
  3. *. *.
  4. *** ***
  5. ***** *****
  6. .****** *******
  7. ******** ********
  8. ,,,,,,,,,***********,,,,,,,,,
  9. ,,,,,,,,,,,*********,,,,,,,,,,,
  10. .,,,,,,,,,,,*******,,,,,,,,,,,,
  11. ,,,,,,,,,*****,,,,,,,,,.
  12. ,,,,,,,****,,,,,,
  13. .,,,***,,,,
  14. ,*,.
  15. _______ __ __ __
  16. / ____(_) /_/ / ____ _/ /_
  17. / / __/ / __/ / / __ \`/ __ \
  18. / /_/ / / /_/ /___/ /_/ / /_/ /
  19. \____/_/\__/_____/\__,_/_.___/
  20. Thank you for installing GitLab!
  21. GitLab was unable to detect a valid hostname for your instance.
  22. Please configure a URL for your GitLab instance by setting `external_url`
  23. configuration in /etc/gitlab/gitlab.rb file.
  24. Then, you can start your GitLab instance by running the following command:
  25. sudo gitlab-ctl reconfigure
  26. For a comprehensive list of configuration options please see the Omnibus GitLab readme
  27. https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
  28. D: %posttrans(gitlab-ee-10.1.3-ee.0.el7.x86_64): waitpid(5767) rc 5767 status 0
  29. D: closed db index /var/lib/rpm/Sha1header
  30. D: closed db index /var/lib/rpm/Sigmd5
  31. D: closed db index /var/lib/rpm/Installtid
  32. D: closed db index /var/lib/rpm/Dirnames
  33. D: closed db index /var/lib/rpm/Triggername
  34. D: closed db index /var/lib/rpm/Obsoletename
  35. D: closed db index /var/lib/rpm/Conflictname
  36. D: closed db index /var/lib/rpm/Providename
  37. D: closed db index /var/lib/rpm/Requirename
  38. D: closed db index /var/lib/rpm/Group
  39. D: closed db index /var/lib/rpm/Basenames
  40. D: closed db index /var/lib/rpm/Name
  41. D: closed db index /var/lib/rpm/Packages
  42. D: closed db environment /var/lib/rpm
  43. [root@localhost gitlab]#

安装完成以后修改文件/etc/gitlab/gitlab.rb,设置访问url

  1. ## GitLab URL
  2. ##! URL on which GitLab will be reachable.
  3. ##! For more details on configuring external_url see:
  4. ##! https://docs.gitlab.com/omnibus/settings/configuration.html#configuring-the-external-url-for-gitlab
  5. external_url 'http://10.10.10.10:80/gitlab'

二、启动

  1. [root@localhost gitlab]# gitlab-ctl reconfigure
  2. ....
  3. Running handlers:
  4. Running handlers complete
  5. Chef Client finished, 365/538 resources updated in 03 minutes 43 seconds
  6. gitlab Reconfigured!
  7. [root@localhost gitlab]# free
  8. total used free shared buff/cache available
  9. Mem: 8011216 1937024 3476364 88720 2597828 5694128
  10. Swap: 8388604 0 8388604

访问之后系统内存(gitlab比较耗内存啊):

  1. [root@localhost gitlab]# free
  2. total used free shared buff/cache available
  3. Mem: 8011216 3120148 2288708 88788 2602360 4510728
  4. Swap: 8388604 0 8388604

三、修改账号密码

  • 注:在第一次访问的时候会提示输入新密码,此时该密码为最初的密码,可以在页面设置新密码或者通过下面的方式重置密码
    Gitlab 修改root用户密码

使用root权限登录服务器并启动Ruby on Rails 控制台.

  1. [root@localhost ~]# gitlab-rails console production
  2. Loading production environment (Rails 4.2.8)
  3. irb(main):001:0>

回车后感觉没响应,耐心等待1分钟左右…

有多种方式可以重置密码

  1. irb(main):001:0> user = User.where(id: 1).first
  2. => #<User id:1 @root>
  3. irb(main):002:0>user.password = 'secret_pass'
  4. irb(main):002:0>user.password_confirmation = 'secret_pass'
  5. irb(main):002:0>user.save

或者

  1. irb(main):001:0> user = User.find_by(email: 'admin@local.host')
  2. => #<User id:1 @root>
  3. irb(main):002:0>user.password = 'secret_pass'
  4. irb(main):002:0>user.password_confirmation = 'secret_pass'
  5. irb(main):002:0>user.save

修改密码后可以尝试使用新密码登录

四、TortoiseGit clone push 项目

1.在用户目录下使用cmd或者git bash创建一个目录.ssh

  1. $ mkdir .ssh

2.使用ssh-keygen -C 邮箱 -t rsa生成公钥和私钥
此处邮箱为gitlab上用户的邮箱,输入命令后一路回车,使用默认配置

  1. $ ssh-keygen -C 2810010108@qq.com -t rsa
  2. Generating public/private rsa key pair.
  3. Enter file in which to save the key (/c/Users/cnlm.me/.ssh/id_rsa):
  4. Enter passphrase (empty for no passphrase):
  5. Enter same passphrase again:
  6. Your identification has been saved in /c/Users/cnlm.me/.ssh/id_rsa.
  7. Your public key has been saved in /c/Users/cnlm.me/.ssh/id_rsa.pub.
  8. The key fingerprint is:
  9. SHA256:JXOINlt4OpM92GIDCAypY97ndQcELMcjNtDE7Im9rDY 2810010108@qq.com
  10. The key's randomart image is: +---[RSA 2048]----+ |=. .*.o.. | |.o . O B o | |. . * @ O o | |o. . * @ * | |o.. . % S . | | . . = * o . | | + . . . | | E . | | . . | +----[SHA256]-----+ cnlm.me@DESKTOP-RKGQDB9 MINGW64 ~/.ssh

此时,生成了id-rsa私钥和id-rsa.pub公钥,远程需要访问gitlab下载和提交,需要将此公钥配置到gitlab对应账号下
3.配置SSH Keys

  • 登录http://ip/gitlab
  • 点击右上角头像
  • settings
  • SSH Keys
  • 在Key输入框输入id-rsa.pub公钥文件内容
  • 保存

4.TortoiseGit生成ppk私钥
由于本地使用的是TortoiseGit,因此需要生成一个.ppk的私钥

  • 在TortoiseGit安装目录bin下双击打开puttygen.exe
  • 点击load,选中id-rsa私钥
  • 点击Save private key,.ssh目录会生成一个.ppk的私钥

5.clone

  • 鼠标右键,git clone …
  • URL输入git@ip:test/pms_dev.git
  • Directory输入….\gitlab\pms_dev
  • 勾选Load Putty Key,选择文件C:\Users….ssh\ppk.ppk
  • OK
    成功将项目clone到了本地

6.push

  • 修改其中一个文件
  • 鼠标右键,Git Commit -> “master”…
  • 提交到本地仓库后直接push到远程gitlab master

发表评论

表情:
评论列表 (有 0 条评论,281人围观)

还没有评论,来说两句吧...

相关阅读