文档中心 | IMDC 创达睿通
  • 导读
  • 应用中心
    • 开发运维
      • TeamCity快速入门
      • Rainbond快速入门
      • FASTPANEL快速入门
      • Cockpit快速入门
      • Django快速入门
      • WinAllServer 全能快速入门
      • XAMPP快速入门
      • phpStudy快速入门
      • WAMP快速入门
      • WampServer快速入门
      • Web 应用环境
      • code-server快速入门
      • WDCP快速入门
      • Gogs快速入门
      • Zabbix快速入门
      • AWX快速入门
      • Portainer快速入门
      • BT宝塔 快速入门
      • Webmin快速入门
      • Gitlab快速入门
      • Jenkins快速入门
    • 客户成功
      • nopCommerce快速入门
      • Prestashop快速入门
      • OpenCart快速入门
      • Magento快速入门
    • 内容管理
      • DiscuzQ快速入门
      • Typo3快速入门
      • XWiki快速入门
      • Sakai快速入门
      • Discuz快速入门
      • Mediawiki快速入门
      • Canvas快速入门
      • Moodle快速入门
      • WordPress快速入门
      • Ghost快速入门
      • Joomla快速入门
      • Drupal快速入门
    • 企业管理
      • EspoCRM快速入门
      • Dolibarr快速入门
      • ONLYOFFICE Workspace快速入门
      • VtigerCRM快速入门
      • ERPNext快速入门
      • SuiteCRM快速入门
      • Odoo快速入门
    • 人工智能
      • OpenCV快速入门
      • TensorFlow快速入门
    • 设计与创作
      • APITable快速入门
      • APEX快速入门
      • Mingdao 明道快速入门
      • Scratch快速入门
      • Budibase快速入门
    • 数据与分析
      • Matomo快速入门
      • Akeneo快速入门
      • Elastic Stack快速入门
      • Graylog快速入门
      • Grafana快速入门
      • Metabase快速入门
      • Superset快速入门
      • Knowage快速入门
    • 协作与生产力
      • Pydio Cells快速入门
      • KodBox快速入门
      • iRedMail快速入门
      • Mattermost快速入门
      • Zentao 禅道 快速入门
      • Seafile快速入门
      • Redmine快速入门
      • OwnCloud快速入门
      • Alfresco快速入门
      • Nextcloud快速入门
    • 云原生架构
      • SRS快速入门
      • MinIO快速入门
      • Parse Server快速入门
      • ONLYOFFICE Docs快速入门
      • HAProxy快速入门
      • Kafka快速入门
      • Rocket快速入门
      • RabbitMQ快速入门
      • ActiveMQ快速入门
    • 云数据库
      • Oracle Database快速入门
      • SQLite快速入门
      • Neo4j快速入门
      • Memcached快速入门
      • Redis快速入门
      • CouchDB快速入门
      • MongoDB快速入门
      • RethinkDB快速入门
      • PostgreSQL快速入门
      • CloudBeaver快速入门
      • MySQL/MariaDB快速入门
      • SQL Server快速入门
    • 云桌面
      • 原生桌面
  • 购买与支持
    • IT 服务台
  • 用户指南
    • 云服务指南
      • Azure指南
      • AWS指南
    • 词汇表
  • 联系我们
由 GitBook 提供支持
在本页
  • 准备​
  • GitLab 初始化向导​
  • GitLab 使用入门​
  • GitLab 常用操作​
  • GitLab 参数​
  1. 应用中心
  2. 开发运维

Gitlab快速入门

GitLab 是一个完整的 DevOps 平台软件。 使用 GitLab,您可以获得开箱即用的完整 CI/CD 工具链。极狐 GitLab 是本地化的版本,基于 GitLab EE 和极狐 GitLab 在国内独立运营的 JH 代码仓库构建,产品的企业级订阅许可证、源代码管理、支付系统等均在中国境内管理,受中国法律保护。

上一页Webmin快速入门下一页Jenkins快速入门

最后更新于1年前

部署 创达睿通 提供的 GitLab 或 极狐 GitLab 之后,请参考下面的步骤快速入门。

准备

  1. 在云控制台获取您的 服务器公网IP地址

  2. 在云控制台安全组中,确保 Inbound(入)规则 下的 TCP:80 端口已经开启

  3. 在服务器中查看 GitLab 的 默认管理员账号和密码

  4. 若想用域名访问 GitLab,务必先完成 域名五步设置 过程

  1. 本地电脑浏览器访问:http://域名 或 *http://服务器公网IP*,进入初始化页面

一般服务器启动后需要1到2分钟才能显示 Gitlab 页面,如果 GitLab 页面还无法显示的情况下强制重启服务器会导致重新生成新密码,导致密码无法登陆

  1. 输入账号密码,进入 GitLab 控制台

  2. 进入管理设置面板(Admin Area)

  3. 语言设置:【User Settings】>【Preferences】,设置自己喜欢的语言(包含中文)

  4. SSH key 设置:【User Settings】>【SSH key】

  5. 如果你部署的是 GitLab-EE(企业版),通过:【管理中心】>【许可证】导入后,试用或启用企业版

如果您安装了 创达睿通 提供的 GitLab 和其他 DevOps 的组合应用,请提前获取 端口和账号密码 ,并完成它们的初始化过程。

若碰到问题,请第一时刻联系 技术支持。也可以先参考下面列出的问题定位或 FAQ 尝试快速解决问题:

GitLab能打开,但总是出现 502 错误?

参阅:联系 技术支持

GitLab 每次启动需等1分钟才能使用?

参阅:联系 技术支持

下面介绍 Gitlab 在团队管理、权限管理、代码管理等方面的应用。

  1. 项目管理:管理员新建项目,并进行项目初始化、添加开发分支 dev ,不对开发人员开放主分支 master

    创建 cdrt-Site1 项目

    初始化项目,添加自述文件 README.md 和 index.html 页面,并提交

    新建开发分支 dev

  2. 成员管理:团队成员在登录页面注册账号,管理员在后台激活用户,并在项目成员中邀请用户,配置权限。用户须激活后才能登录系统。

    成员注册

    管理员激活注册用户

    管理员邀请用户加入项目组,分配权限

  3. 代码管理: 项目成员负责index.html页面开发, 通过 git clone 项目到本地 ,在vs code 开发。 打开 Git Base 工具,通过 git clone 将项目克隆本地

    在 vs code 中打开项目,编辑index.html

    编辑完成,提交本地代码到服务器。开发账号登录 gitlab ,查看更新并创建合并请求

    管理员登录 gitlab 合并请求

在初始化之前的 准备 环节,如果您已经完成 域名五步设置,GitLab 可以域名访问,但是 GitLab 仓库的网址还不是用户自己的域名。

  1. 通过 SSH 或 SFTP 登录云服务器

  2. external_url "http://gitlab.example.com" # 改为自定义域名
    ...
  3. 保存配置文件,重启下面的服务

    sudo gitlab-ctl reconfigure
  1. 通过 SFTP 连接服务器,修改 GitLab 配置文件:/etc/gitlab/gitlab.rb

    gitlab_rails['smtp_enable'] = true
    gitlab_rails['smtp_address'] = "smtp.exmail.qq.com"
    gitlab_rails['smtp_port'] = 465
    gitlab_rails['smtp_user_name'] = "xxxx@xx.com"
    gitlab_rails['smtp_password'] = "password"
    gitlab_rails['smtp_authentication'] = "login"
    gitlab_rails['smtp_enable_starttls_auto'] = true
    gitlab_rails['smtp_tls'] = true
    gitlab_rails['gitlab_email_from'] = 'xxxx@xx.com'
  2. 重启服务后生效

    sudo gitlab-ctl reconfigure
  1. 使用 SSH 登陆 GitLab 服务器

  2. 输入 gitlab-rails console 命令,根据提示完成后续步骤

    
    $ gitlab-rails console     //进入控制台命令
    --------------------------------------------------------------------------------
     Ruby:         ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
     GitLab:       13.8.4 (9fb9cbf50c3) FOSS
     GitLab Shell: 13.15.1
     PostgreSQL:   12.5
    --------------------------------------------------------------------------------
    
    Loading production environment (Rails 6.0.3.4)
    irb(main):001:0>
    irb(main):002:0> user = User.find_by_username 'root'  //找到用户,默认管理员用户名为 root
    => #<User id:1 @root>
    irb(main):003:0> user.password='cdrt'   //修改密码
    => "cdrt"
    irb(main):004:0> user.password_confirmation='cdrt'  //二次确认密码
    => "cdrt"
    irb(main):006:0>  user.save! //保存更改
    Enqueued ActionMailer::MailDeliveryJob (Job ID: 3f4ac447-9869-412a-9b5a-988c06cf          eaa2) to Sidekiq(mailers) with arguments: "DeviseMailer", "password_change_by_ad          min", "deliver_now", {:args=>[#<GlobalID:0x00007fb7e5337990 @uri=#<URI::GID gid:          //gitlab/User/1>>]}
    => true
    irb(main):007:0>
    

下面是一个简化的架构图,可用于了解 GitLab 的组件架构。

-nginx:静态web服务器。 -gitlab-shell:用于处理Git命令和修改authorized keys列表。 -gitlab-workhorse: 轻量级的反向代理服务器。 -logrotate:日志文件管理工具。 -postgresql:数据库。 -redis:缓存数据库。 -sidekiq:用于在后台执行队列任务(异步执行)。 -unicorn:An HTTP server for Rack applications,GitLab Rails应用是托管在这个服务器上面的。

通过运行 docker ps,查看 GitLab 运行时所有的服务组件:

CONTAINER ID   IMAGE                         COMMAND                  CREATED       STATUS                 PORTS                                                                               NAMES
c5b22639c668   gitlab/gitlab-ce:latest       "/assets/wrapper"        2 hours ago   Up 2 hours (healthy)   443/tcp, 0.0.0.0:23->22/tcp, :::23->22/tcp, 0.0.0.0:9001->80/tcp, :::9001->80/tcp   gitlab
49995b282a20   gitlab/gitlab-runner:latest   "/usr/bin/dumb-init …"   2 hours ago   Up 2 hours                                                                                                 gitlab-runner

GitLab 安装目录: /data/apps/gitlab GitLab 数据目录: /data/apps/gitlab/data/gitlab_data GitLab 日志目录: /data/apps/gitlab/data/gitlab_logs GitLab 配置文件: /data/apps/gitlab/data/gitlab_config/gitlab.rb

除 80, 443 等常见端口需开启之外,以下端口可能会用到:

暂无特殊端口

docker exec -i gitlab head -n+1 /opt/gitlab/version-manifest.txt
sudo docker start | stop | restart | stats gitlab
sudo docker start | stop | restart | stats gitlab-runner

GitLab 提供了命令行工具 gitlab-ctl 用于全面管理和配置 GitLab

$ docker exec -it gitlab gitlab-ctl -h

I don't know that command.
omnibus-ctl: command (subcommand)
check-config
  Check if there are any configuration in gitlab.rb that is removed in specified version
deploy-page
  Put up the deploy page
diff-config
  Compare the user configuration with package available configuration
get-redis-master
  Get connection details to Redis master
prometheus-upgrade
  Upgrade the Prometheus data to the latest supported version
remove-accounts
  Delete *all* users and groups used by this package
reset-grafana
  Reset Grafana instance to its initial state by removing the data directory
set-grafana-password
  Reset admin password for Grafana
upgrade
  Run migrations after a package upgrade
upgrade-check
  Check if the upgrade is acceptable
General Commands:
  cleanse
    Delete *all* gitlab data, and start from scratch.
  help
    Print this help message.
  reconfigure
    Reconfigure the application.
  show-config
    Show the configuration that would be generated by reconfigure.
  uninstall
    Kill all processes and uninstall the process supervisor (data will be preserved).
Service Management Commands:
  graceful-kill
    Attempt a graceful stop, then SIGKILL the entire process group.
  hup
    Send the services a HUP.
  int
    Send the services an INT.
  kill
    Send the services a KILL.
  once
    Start the services if they are down. Do not restart them if they stop.
  restart
    Stop the services if they are running, then start them again.
  service-list
    List all the services (enabled services appear with a *.)
  start
    Start services if they are down, and restart them if they stop.
  status
    Show the status of all the services.
  stop
    Stop the services, and do not restart them.
  tail
    Watch the service logs of all enabled services.
  term
    Send the services a TERM.
  usr1
    Send the services a USR1.
  usr2
    Send the services a USR2.
Gitlab Geo Commands:
  geo
    Interact with Geo
  geo-replication-pause
    Replication Process
  geo-replication-resume
    Replication Process
  promote-db
    Promote secondary PostgreSQL database
  promote-to-primary-node
    Promote to primary node
  promotion-preflight-checks
    Run preflight checks for promotion to primary node
  replicate-geo-database
    Replicate Geo database
  set-geo-primary-node
    Make this node the Geo primary
Pgbouncer Commands:
  pgb-console
    Connect to the pgbouncer console
  pgb-kill
    Send the "resume" command to pgbouncer
  pgb-notify
    Notify pgbouncer of an update to its database
  pgb-resume
    Send the "resume" command to pgbouncer
  pgb-suspend
    Send the "suspend" command to pgbouncer
Database Commands:
  get-postgresql-primary
    Get connection details to the PostgreSQL primary
  patroni
    Interact with Patroni
  pg-password-md5
    Generate MD5 Hash of user password in PostgreSQL format
  pg-upgrade
    Upgrade the PostgreSQL DB to the latest supported version
  revert-pg-upgrade
    Run this to revert to the previous version of the database
  set-replication-password
    Set database replication password
  write-pgpass
    Write a pgpass file for the specified user
Consul Commands:
  consul
    Interact with the gitlab-consul cluster
Container Registry Commands:
  registry-garbage-collect
    Run Container Registry garbage collection.
Let's Encrypt Commands:
  renew-le-certs
    Renew the existing Let's Encrypt certificates
Gitaly Commands:
  praefect
    Interact with Gitaly cluster
Backup Commands:
  backup-etc
    Backup GitLab configuration [options]
curl "https://gitlab.example.com/api/v4/projects"

GitLab 初始化向导

详细步骤

GitLab 仓库地址

需要了解更多 GitLab 的使用,请参考官方文档:

组合应用

出现问题?

GitLab 使用入门

gitlab
gitlab

GitLab 常用操作

设置 GitLab 仓库地址

因此,还需要参考下面的步骤:

修改 GitLab 配置文件,将 external_url 项的值 修改为你的域名

设置 GitLab 仓库的 HTTPS

GitLab 仓库的 HTTPS 不等同于 GitLab 自身的 HTTPS,前置还需额外设置:

配置 SMTP

参考 GitLab 官方提供的 ,准备好 SMTP 参数

重置管理员密码

忘记管理员密码时,请参考如下方案重置密码():

极狐 Gitlab 设置中文

GitLab 参数

GitLab 应用中包含 Docker, Portainer 等组件,可通过 查看路径、服务、端口等参数。

GitLab 包含数十种组件(),通过容器内路径 /opt/gitlab/version-manifest.txt 查看所有组件名称和版本

路径

端口

版本

服务

命令行

API

GitLab 提供 方式,包括:REST API, SCIM API, GraphQL API

​
​
设置
GitLab Documentation
​
​
​
​
​
设置 GitLab 仓库地址
http://gitlab.example.com
​
Enabling HTTPS
​
SMTP Setting 范例
​
方案来源
​
​
通用参数表
查看
​
​
​
​
​
​
多种 API
​