gitlab-ce安装笔记

安装:

quick install

curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash

执行以上命令之后,就可以用apt安装了。

sudo apt install gitlab-ce

安装之后会有提示修改external_url:

alpha@mascot:~/workspace/gitlab$ sudo apt install gitlab-ce 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  linux-headers-5.4.0-104 linux-headers-5.4.0-104-generic linux-image-5.4.0-104-generic linux-modules-5.4.0-104-generic linux-modules-extra-5.4.0-104-generic
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
  gitlab-ce
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 1,247 MB of archives.
After this operation, 3,286 MB of additional disk space will be used.
Get:1 https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu focal/main amd64 gitlab-ce amd64 15.9.2-ce.0 [1,247 MB]
Fetched 1,247 MB in 1min 37s (12.8 MB/s)                                                                                                                                                     
Selecting previously unselected package gitlab-ce.
(Reading database ... 159036 files and directories currently installed.)
Preparing to unpack .../gitlab-ce_15.9.2-ce.0_amd64.deb ...
Unpacking gitlab-ce (15.9.2-ce.0) ...
Setting up gitlab-ce (15.9.2-ce.0) ...
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

For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md

Help us improve the installation experience, let us know how we did with a 1 minute survey:
https://gitlab.fra1.qualtrics.com/jfe/form/SV_6kVqZANThUQ1bZb?installation=omnibus&release=15-9
 

根据提示打开/etc/gitlab/gitlab.rb修改external_url即可:

external_url 'http://0.0.0.0:9981'

修改完成之后执行:

sudo gitlab-ctl reconfigure

这个过程配置了很多东西,花的时间有点长,成功之后会提示重置root密码(这个是GItLab系统的root用户,不是Ubuntu系统的root用户):

......

    - execute /opt/gitlab/bin/gitlab-ctl hup prometheus
[2023-03-04T22:33:43+08:00] INFO: env_dir[/opt/gitlab/etc/alertmanager/env] sending restart action to runit_service[alertmanager] (delayed)
Recipe: monitoring::alertmanager
  * runit_service[alertmanager] action restart (up to date)
[2023-03-04T22:33:44+08:00] INFO: env_dir[/opt/gitlab/etc/postgres-exporter/env] sending restart action to runit_service[postgres-exporter] (delayed)
Recipe: monitoring::postgres-exporter
  * runit_service[postgres-exporter] action restart (up to date)
[2023-03-04T22:33:44+08:00] INFO: Cinc Client Run complete in 193.323360192 seconds

Running handlers:
[2023-03-04T22:33:44+08:00] INFO: Running report handlers
Running handlers complete
[2023-03-04T22:33:44+08:00] INFO: Report handlers complete
Infra Phase complete, 573/1539 resources updated in 03 minutes 15 seconds

Notes:
Default admin account has been configured with following details:
Username: root
Password: You didn't opt-in to print initial root password to STDOUT.
Password stored to /etc/gitlab/initial_root_password. This file will be cleaned up in first reconfigure run after 24 hours.

NOTE: Because these credentials might be present in your log files in plain text, it is highly recommended to reset the password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.

gitlab Reconfigured!
 

按照提示重置root密码:

alpha@mascot:~/workspace/gitlab$ sudo gitlab-rake "gitlab:password:reset"
Enter username: root
Enter password: 
Confirm password: 
Password successfully updated for user with username root.
 

按照参考文章的介绍,这个时候就可以访问GitLab了。

但我的访问会502出错:

502

Whoops, GitLab is taking too much time to respond.


Try refreshing the page, or going back and attempting the action again.

Please contact your GitLab administrator if this problem persists.

网上的文章说是系统内存太小了。

用sudo gitlab-ctl status命令查看(gitlab-ctl --help可以查看更多命令):

alpha@mascot:~/workspace/gitlab$ sudo gitlab-ctl status
run: alertmanager: (pid 42577) 2107s; run: log: (pid 39330) 3276s
run: gitaly: (pid 42588) 2106s; run: log: (pid 38653) 3395s
run: gitlab-exporter: (pid 42602) 2106s; run: log: (pid 39233) 3294s
run: gitlab-kas: (pid 42604) 2106s; run: log: (pid 38930) 3381s
run: gitlab-workhorse: (pid 42614) 2105s; run: log: (pid 39116) 3314s
run: logrotate: (pid 42623) 2105s; run: log: (pid 38587) 3405s
run: nginx: (pid 42629) 2104s; run: log: (pid 39166) 3308s
run: node-exporter: (pid 42635) 2104s; run: log: (pid 39217) 3300s
run: postgres-exporter: (pid 42641) 2103s; run: log: (pid 39360) 3272s
run: postgresql: (pid 42648) 2103s; run: log: (pid 38793) 3389s
run: prometheus: (pid 42662) 2103s; run: log: (pid 39279) 3282s
run: puma: (pid 45016) 1s; run: log: (pid 39047) 3324s
run: redis: (pid 42676) 2102s; run: log: (pid 38610) 3399s
run: redis-exporter: (pid 42682) 2101s; run: log: (pid 39248) 3290s
run: sidekiq: (pid 42764) 2101s; run: log: (pid 39075) 3320s
 

看起来各个模块都正常启动了。

检查gitlab:

alpha@mascot:~/workspace/gitlab$ sudo gitlab-rake gitlab:check SANITIZE=true --trace
** Invoke gitlab:check (first_time)
** Invoke gitlab_environment (first_time)
** Execute gitlab_environment
** Invoke environment (first_time)
** Execute environment
** Execute gitlab:check
Checking GitLab subtasks ...

Checking GitLab Shell ...

GitLab Shell: ... GitLab Shell version >= 14.17.0 ? ... OK (14.17.0)
Running /opt/gitlab/embedded/service/gitlab-shell/bin/check
Internal API available: FAILED - Internal API unreachable
gitlab-shell self-check failed
  Try fixing it:
  Make sure GitLab is running;
  Check the gitlab-shell configuration file:
  sudo -u git -H editor /opt/gitlab/embedded/service/gitlab-shell/config.yml
  Please fix the error above and rerun the checks.

Checking GitLab Shell ... Finished

Checking Gitaly ...

Gitaly: ... default ... OK

Checking Gitaly ... Finished

Checking Sidekiq ...

Sidekiq: ... Running? ... yes
Number of Sidekiq processes (cluster/worker) ... 1/1

Checking Sidekiq ... Finished

Checking Incoming Email ...

Incoming Email: ... Reply by email is disabled in config/gitlab.yml

Checking Incoming Email ... Finished

Checking LDAP ...

LDAP: ... LDAP is disabled in config/gitlab.yml

Checking LDAP ... Finished

Checking GitLab App ...

Database config exists? ... yes
All migrations up? ... yes
Database contains orphaned GroupMembers? ... no
GitLab config exists? ... yes
GitLab config up to date? ... yes
Cable config exists? ... yes
Resque config exists? ... yes
Log directory writable? ... yes
Tmp directory writable? ... yes
Uploads directory exists? ... yes
Uploads directory has correct permissions? ... yes
Uploads directory tmp has correct permissions? ... skipped (no tmp uploads folder yet)
Systemd unit files or init script exist? ... skipped (omnibus-gitlab has neither init script nor systemd units)
Systemd unit files or init script up-to-date? ... skipped (omnibus-gitlab has neither init script nor systemd units)
Projects have namespace: ... 
2/1 ... yes
Redis version >= 6.0.0? ... yes
Ruby version >= 2.7.2 ? ... yes (2.7.7)
Git user has default SSH configuration? ... yes
Active users: ... 1
Is authorized keys file accessible? ... yes
GitLab configured to store new projects in hashed storage? ... yes
All projects are in hashed storage? ... yes

Checking GitLab App ... Finished


Checking GitLab subtasks ... Finished
 

实际是8080端口被占用。

修改:sudo vim /etc/gitlab/gitlab.rb

puma['port'] = 8864

修改puma['port'] 为一个不使用的端口,问题解决。

可以用external_url配置的地址访问了,登录root用户,用前面重置root密码时设置的密码登录。

可以注册新的用户,新用户需要root批准才能生效。登录root用户,进入Admin批准用户即可。

在GitHub的用户创建一个Token,就可以从GitHub导入仓库。

GitLab只能从指定的位置导入项目,不能从gitee导入仓库。

参考:

GitLab Installation instructions

GitLab Reset a user’s password

Gitlab 仓库搭建(详细版)_gitlab搭建_~407的博客-CSDN博客在ubuntu上部署gitlab详细步骤-CSDN博客gitlab访问错误Whoops, GitLab is taking too much time to respond_gblfy的博客-CSDN博客GItlab:Internal API available: FAILED - Internal API error 502_gitlab internal_xiaozhidepikaqiu的博客-CSDN博客在ubuntu上部署gitlab详细步骤-CSDN博客

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Docker可以用来轻松地在容器中运行GitLab CE(Community Edition),这是一个开源的Git服务,提供了代码托管、持续集成/持续部署等功能。下面是使用Docker安装GitLab CE的基本步骤: 1. **安装Docker**: 首先确保你的系统上已经安装了Docker。如果你的系统是Linux,可以使用包管理器如apt或yum;如果是Windows或Mac,可以从Docker官网下载并安装。 2. **获取GitLab CE镜像**: 使用Docker Hub上的官方镜像,你可以运行`docker pull gitlab/gitlab-ce`来下载最新的GitLab CE镜像。 3. **运行GitLab容器**: 创建一个Docker运行命令,指定所需的端口映射和数据卷,以保存配置和数据。例如: ``` docker run -d \ --name gitlab \ -p 80:80 -p 443:443 -p 2222:22 \ --restart always \ -v /path/to/data:/var/opt/gitlab \ -v /path/to/config:/etc/gitlab \ gitlab/gitlab-ce ``` 这里 `-d` 表示后台运行,`-p` 映射端口,`--restart always` 确保容器重启时继续运行,`-v` 挂载主机目录到容器中的路径。 4. **设置环境**: 容器启动后,可能需要访问GitLab Web界面进行初始化设置,包括数据库连接信息、邮件服务器配置等。首次启动时,可能还需要完成一些基础的配置步骤。 5. **安全和认证**: 为了保护GitLab,确保配置了适当的安全措施,包括HTTPS(通常映射的443端口)和密码策略。 6. **监控和日志**: 为持久监控和问题排查,你可能需要查看Docker容器的日志和使用第三方工具对GitLab进行性能监控。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值