极狐GitLab 正式推出面向 GitLab 老旧版本(12.x、13.x、14.x、15.x 等)免费用户的专业升级服务,点击查看详情

返回列表 发布新帖

极狐Gitlab开启fast_ssh_key_lookup导致备份恢复错误解决

1051 1
发表于 2024-4-29 15:25:37 | 显示全部楼层 阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

×

如果备份的实例开启了 fast_ssh_key_lookup 功能,并关闭了 authorized_keys 文件认证:

web界面 - admin - settings - network - Performance optimization - 取消勾选 Use authorized_keys file to authenticate SSH keys

恢复的时候会报错:

...
2022-09-13 17:17:09 +0800 -- Restoring terraform states ... done
2022-09-13 17:17:09 +0800 -- Restoring packages ... 
2022-09-13 17:17:09 +0800 -- Restoring packages ... done
WARNING

The "Write to authorized_keys file" setting is disabled, which prevents
the file from being rebuilt!

It should be enabled for most GitLab installations. Large installations
may wish to disable it as part of speeding up SSH operations.

See https://docs.gitlab.com/ee/administration/operations/fast_ssh_key_lookup.html

If you did not intentionally disable this option in Admin Area > Settings,
then you may have been affected by the 9.3.0 bug in which the new setting
was disabled by default.

https://gitlab.com/gitlab-org/gitlab/issues/2738

It was reverted in 9.3.1 and fixed in 9.3.3, however, if Settings were
saved while the setting was unchecked, then it is still disabled.
Do you want to permanently enable the "Write to authorized_keys file" setting now?
Do you want to continue (yes/no)? yes
Enabling the "Write to authorized_keys file" setting...
rake aborted!
OpenSSL::Cipher::CipherError: 
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/load_balancing/connection_proxy.rb:119:in `block in write_using_load_balancer'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/load_balancing/load_balancer.rb:112:in `block in read_write'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/load_balancing/load_balancer.rb:172:in `retry_with_backoff'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/load_balancing/load_balancer.rb:110:in `read_write'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/load_balancing/connection_proxy.rb:118:in `write_using_load_balancer'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/load_balancing/connection_proxy.rb:70:in `transaction'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/load_balancing/connection_proxy.rb:119:in `block in write_using_load_balancer'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/load_balancing/load_balancer.rb:112:in `block in read_write'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/load_balancing/load_balancer.rb:172:in `retry_with_backoff'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/load_balancing/load_balancer.rb:110:in `read_write'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/load_balancing/connection_proxy.rb:118:in `write_using_load_balancer'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/load_balancing/connection_proxy.rb:70:in `transaction'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/current_settings.rb:32:in `method_missing'
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/shell.rake:106:in `ensure_write_to_authorized_keys_is_enabled'
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/shell.rake:71:in `setup'
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/shell.rake:47:in `block (3 levels) in <top (required)>'
/opt/gitlab/embedded/service/gitlab-rails/lib/backup/manager.rb:106:in `restore'
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/backup.rake:20:in `block (3 levels) in <top (required)>'
/opt/gitlab/embedded/bin/bundle:23:in `load'
/opt/gitlab/embedded/bin/bundle:23:in `<main>'
Tasks: TOP => gitlab:shell:setup
(See full trace by running task with --trace)
  • 这里失败中断了恢复过程,相比正常恢复就只是未正常恢复 authorized_keys 文件与清理恢复过程中的中间 tmp 文件

解决方法有 2 种

方法一:

  1. 直接忽略错误
  2. 删除 /var/opt/gitlab/backups/ 中残留的恢复中间 tmp 文件
  3. 继续按正常流程恢复 config 与 ssh key
  4. 配置 ssh,开启 fast_ssh_key_lookup
  5. 最后 gitlab-ctl reconfigure && gitlab-ctl restart

方法二:

  1. 备份前开启备份实例 authorized_keys 文件认证:web界面 - admin - settings - network - Performance optimization - 勾选 Use authorized_keys file to authenticate SSH keys
  2. 正常备份,然后关闭备份实例 authorized_keys 文件认证:web界面 - admin - settings - network - Performance optimization - 取消勾选 Use authorized_keys file to authenticate SSH keys
  3. 然后正常恢复数据、config 与 ssh key
  4. 配置恢复实例 ssh,开启 fast_ssh_key_lookup
  5. 恢复实例执行:gitlab-ctl reconfigure && gitlab-ctl restart
  6. 最后关闭恢复实例 authorized_keys 文件认证:web界面 - admin - settings - network - Performance optimization - 取消勾选 Use authorized_keys file to authenticate SSH keys
回复

使用道具 举报

评论1

樱空翼Lv.1 发表于 2024-4-29 16:42:50 | 显示全部楼层
学习了
回复

使用道具 举报

意见建议

Email:forum@gitlab.cn
  • 关注公众号
  • 添加专业顾问
Copyright © 2001-2025 极狐GitLab论坛 版权所有 All Rights Reserved. 鄂ICP备2021008419号-1|鄂公网安备42018502006137号
关灯 快速发帖
扫一扫添加专业顾问
返回顶部
快速回复 返回顶部 返回列表