GitLab介绍及实战

1 介绍

Gitlab是依赖于Git的远程代码仓库,类似于GitHub、Gitee,不同的是GitHub、Gitee的公网上代码仓库, Gitlab是可以私有化部署的免费远程代码仓库。

官网:The DevSecOps Platform | GitLab

2 部署GitLab

至少内存4G,否则电脑带不起来

ce社区版 和ee 企业版区别

CE 比 EE 要少一些服务,EE 需要购买额外服务(自己对自己写的代码,都特别自信,却很有bug,所有提出了code review)。

2.1 安装依赖

# yum install curl policycoreutils openssh-server openssh-client -y

2.2 启动sshd

# systemctl enable sshd
# systemctl start sshd

2.3 安装邮件服务

# yum install postfix
# systemctl enable postfix
# systemctl start postfix

2.3 下载安装gitlab-ce

# curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
# yum install gitlab-ce  -y
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

2.4 修改配置

# vim /etc/gitlab/gitlab.rb

修改:

external_url 'http://xxx.xxx.xxx.xxx'
 

2.5 配置初始化

# gitlab-ctl reconfigure

2.6 启动

# gitlab-ctl restart
# gitlab-ctl status
run: alertmanager: (pid 22039) 856606s; run: log: (pid 19890) 856919s
run: gitaly: (pid 22047) 856605s; run: log: (pid 18927) 857048s
run: gitlab-exporter: (pid 22060) 856604s; run: log: (pid 19740) 856938s
run: gitlab-kas: (pid 22119) 856594s; run: log: (pid 19161) 857031s
run: gitlab-workhorse: (pid 22128) 856594s; run: log: (pid 19588) 856958s
run: logrotate: (pid 6755) 3283s; run: log: (pid 18843) 857060s
run: nginx: (pid 22149) 856593s; run: log: (pid 19614) 856952s
run: node-exporter: (pid 22155) 856592s; run: log: (pid 19685) 856945s
run: postgres-exporter: (pid 22162) 856592s; run: log: (pid 19933) 856912s
run: postgresql: (pid 22174) 856591s; run: log: (pid 19070) 857037s
run: prometheus: (pid 22183) 856591s; run: log: (pid 19825) 856927s
run: puma: (pid 22215) 856590s; run: log: (pid 19464) 856971s
run: redis: (pid 22225) 856590s; run: log: (pid 18860) 857056s
run: redis-exporter: (pid 22232) 856589s; run: log: (pid 19781) 856931s
run: sidekiq: (pid 14241) 194627s; run: log: (pid 19533) 856963s

 2.7 查看密码

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: NMo3VK+Lm9HHhhuHVZZI6d7Uvb5cQ9S6nEZr+A4ZD78=

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

2.8 登陆

账号为:root,密码为2.7显示密码。

3 基础配置

3.1 查看版本

3.1.1 控制台查询

 3.1.2 命令行查

# gitlab-rake gitlab:env:info
System information
System:
Current User:	git
Using RVM:	no
Ruby Version:	3.0.6p216
Gem Version:	3.4.14
Bundler Version:2.4.16
Rake Version:	13.0.6
Redis Version:	7.0.12
Sidekiq Version:6.5.7
Go Version:	unknown

GitLab information
Version:	16.2.4
Revision:	deac0811459
Directory:	/opt/gitlab/embedded/service/gitlab-rails
DB Adapter:	PostgreSQL
DB Version:	13.11
URL:		http://43.140.247.205
HTTP Clone URL:	http://43.140.247.205/some-group/some-project.git
SSH Clone URL:	[email protected]:some-group/some-project.git
Using LDAP:	no
Using Omniauth:	yes
Omniauth Providers:

GitLab Shell
Version:	14.23.0
Repository storages:
- default: 	unix:/var/opt/gitlab/gitaly/gitaly.socket
GitLab Shell path:		/opt/gitlab/embedded/service/gitlab-shell

 命令行查询到的信息没有控制台信息齐全。

3.2 用户管理

 GitLab Alert Bot和GitLab Support Bot是系统用户不可修改。 

3.2.1 admin用户

3.2.1.1 admin用户详情 

3.2.1.2 编辑admin用户信息

3.2.2 新增用户

 

新建用户管理员无法设置密码,初始密码会通过邮箱发送给用户,用户首次登陆必须修改密码。

 

 

 用户详情。

3.3 中文配置 

猜你喜欢

转载自blog.csdn.net/ygq13572549874/article/details/132306733
今日推荐