Maintenance Rake tasks

原文:https://docs.gitlab.com/ee/administration/raketasks/maintenance.html

Maintenance Rake tasks

GitLab 提供 Rake 任务进行常规维护.

Gather GitLab and system information

该命令收集有关您的 GitLab 安装及其运行系统的信息. 这些在寻求帮助或报告问题时可能很有用.

全部安装

sudo gitlab-rake gitlab:env:info 

源安装

bundle exec rake gitlab:env:info RAILS_ENV=production 

输出示例:

System information
System:           Debian 7.8
Current User:     git
Using RVM:        no
Ruby Version:     2.1.5p273
Gem Version:      2.4.3
Bundler Version:  1.7.6
Rake Version:     10.3.2
Redis Version:    3.2.5
Sidekiq Version:  2.17.8

GitLab information
Version:          7.7.1
Revision:         41ab9e1
Directory:        /home/git/gitlab
DB Adapter:       postgresql
URL:              https://gitlab.example.com
HTTP Clone URL:   https://gitlab.example.com/some-project.git
SSH Clone URL:    git@gitlab.example.com:some-project.git
Using LDAP:       no
Using Omniauth:   no

GitLab Shell
Version:          2.4.1
Repositories:     /home/git/repositories/
Hooks:            /home/git/gitlab-shell/hooks/
Git:              /usr/bin/git 

Show GitLab license information

在 GitLab Starter 12.6 中引入 .

该命令显示有关您的GitLab 许可证以及使用了多少个席位的信息. 它仅在 GitLab Enterprise 安装中可用:许可证无法安装到 GitLab Community Edition 中.

当通过支持人员举票或以编程方式检查许可证参数时,这些选项可能很有用.

全部安装

sudo gitlab-rake gitlab:license:info 

源安装

bundle exec rake gitlab:license:info RAILS_ENV=production 

输出示例:

Today's Date: 2020-02-29
Current User Count: 30
Max Historical Count: 30
Max Users in License: 40
License valid from: 2019-11-29 to 2020-11-28
Email associated with license: user@example.com 

Check GitLab configuration

gitlab:check Rake 任务运行以下 Rake 任务:

  • gitlab:gitlab_shell:check
  • gitlab:gitaly:check
  • gitlab:sidekiq:check
  • gitlab:app:check

它将检查是否已根据安装指南设置了每个组件,并针对发现的问题提出了修复建议. 此命令必须从您的应用程序服务器运行,并且在Gitaly 之类的组件服务器上将无法正常运行.

您还可以查看我们的故障排除指南,以了解:

要运行gitlab:check ,请运行:

全部安装

sudo gitlab-rake gitlab:check 

源安装

bundle exec rake gitlab:check RAILS_ENV=production 

注意:gitlab:check使用SANITIZE=true gitlab:check是否要从输出中省略项目名称.

输出示例:

Checking Environment ...

Git configured for git user? ... yes
Has python2? ... yes
python2 is supported version? ... yes

Checking Environment ... Finished

Checking GitLab Shell ...

GitLab Shell version? ... OK (1.2.0)
Repo base directory exists? ... yes
Repo base directory is a symlink? ... no
Repo base owned by git:git? ... yes
Repo base access is drwxrws---? ... yes
post-receive hook up-to-date? ... yes
post-receive hooks in repos are links: ... yes

Checking GitLab Shell ... Finished

Checking Sidekiq ...

Running? ... yes

Checking Sidekiq ... Finished

Checking GitLab ...

Database config exists? ... yes
Database is SQLite ... no
All migrations up? ... yes
GitLab config exists? ... yes
GitLab config outdated? ... no
Log directory writable? ... yes
Tmp directory writable? ... yes
Init script exists? ... yes
Init script up-to-date? ... yes
Redis version >= 2.0.0? ... yes

Checking GitLab ... Finished 

Rebuild authorized_keys file

在某些情况下,有必要重建authorized_keys文件. 为此,请运行:

全部安装

sudo gitlab-rake gitlab:shell:setup 

源安装

cd /home/git/gitlab
sudo -u git -H bundle exec rake gitlab:shell:setup RAILS_ENV=production 

输出示例:

This will rebuild an authorized_keys file.
You will lose any data stored in authorized_keys file.
Do you want to continue (yes/no)? yes 

Clear Redis cache

如果出于某种原因,仪表板显示了错误的信息,则可能需要清除 Redis 的缓存. 为此,请运行:

全部安装

sudo gitlab-rake cache:clear 

源安装

cd /home/git/gitlab
sudo -u git -H bundle exec rake cache:clear RAILS_ENV=production 

Precompile the assets

有时,在版本升级期间,您可能会遇到一些错误的 CSS 或缺少某些图标的情况. 在这种情况下,请尝试再次重新编译资产.

这仅适用于源安装,不适用于 Omnibus 软件包.

源安装

cd /home/git/gitlab
sudo -u git -H bundle exec rake gitlab:assets:compile RAILS_ENV=production 

对于多功能版本,未优化的资产(JavaScript,CSS)在上游 GitLab 发行时被冻结. 多功能版本包括这些资产的优化版本. 除非在安装软件包之后在生产机器上修改 JavaScript / CSS 代码,否则应该没有理由在生产机器上重做rake gitlab:assets:compile . 如果您怀疑资产已损坏,则应重新安装 omnibus 软件包.

Check TCP connectivity to a remote site

有时您需要知道您的 GitLab 安装是否可以连接到另一台机器上的 TCP 服务-也许是 PostgreSQL 或 HTTPS 服务器. 包含一个 Rake 任务可以帮助您:

全部安装

sudo gitlab-rake gitlab:tcp_check[example.com,80] 

源安装

cd /home/git/gitlab
sudo -u git -H bundle exec rake gitlab:tcp_check[example.com,80] RAILS_ENV=production 

Clear exclusive lease (DANGER)

GitLab 使用共享锁机制: ExclusiveLease防止共享资源中的同时操作. 一个示例是在存储库上运行定期垃圾收集.

在非常特殊的情况下,如果不释放锁定,则由专有租赁锁定的操作可能会失败. 如果您不能等待它过期,可以运行此任务以手动清除它.

要清除所有专有租赁:

危险:请勿在 GitLab 或 Sidekiq 运行时运行它

sudo gitlab-rake gitlab:exclusive_lease:clear 

要指定租约type或租约type + id ,请指定范围:

# to clear all leases for repository garbage collection:
sudo gitlab-rake gitlab:exclusive_lease:clear[project_housekeeping:*]

# to clear a lease for repository garbage collection in a specific project: (id=4)
sudo gitlab-rake gitlab:exclusive_lease:clear[project_housekeeping:4] 

Display status of database migrations

请参阅升级文档 ,以了解在升级 GitLab 时如何检查迁移是否完成.

要检查特定迁移的状态,可以使用以下 Rake 任务:

sudo gitlab-rake db:migrate:status 

这将为每个迁移 ID 输出一个Statusupdown的表.

database: gitlabhq_production

 Status   Migration ID    Migration Name
--------------------------------------------------
   up     migration_id    migration_name 

Run incomplete database migrations

数据库迁移可能会停留在不完整的状态. 也就是说,它们在sudo gitlab-rake db:migrate:status命令的输出中将处于down状态.

要完成这些迁移,请使用以下 Rake 任务:

sudo gitlab-rake db:migrate 

命令完成后,运行sudo gitlab-rake db:migrate:status来检查是否所有迁移都已完成(具有up状态).

Import common metrics

有时,您可能需要重新导入为"指标"仪表板提供动力的通用指标.

这可能是由于更新现有指标或作为故障排除措施的结果 .

要重新导入指标,可以运行:

sudo gitlab-rake metrics:setup_common_metrics 
Copyright © 温玉 2021 | 浙ICP备2020032454号 all right reserved,powered by Gitbook该文件修订时间: 2021-03-27 13:48:25

results matching ""

    No results matching ""