gitlab配置文件详解和找回管理员密码

一 目录文件

作用

路径

配置文件须备份

/etc/gitlab/gitlab.rb

nginx配置文件

/var/opt/gitlab/nginx/conf

邮件配置备份

/etc/postfix/main.cfpostfix

二 主配置gitlab.rb文件详解

vim /etc/gitlab/gitlab.rb
external_url 'http://39.108.116.110:8090'
gitlab_rails['gitlab_shell_ssh_port'] = 52222
 gitlab_rails['rack_attack_git_basic_auth'] = {
   'enabled' => true,
   'ip_whitelist' => ["127.0.0.1","39.108.116.110"],
   'maxretry' => 300,
   'findtime' => 60,
   'bantime' => 3600
 }
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.qq.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "641205699@qq.com"
gitlab_rails['smtp_password'] = "1212520zy"
gitlab_rails['smtp_domain'] = "qq.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
unicorn['listen'] = '127.0.0.1'
unicorn['port'] = 8070
nginx['ssl_protocols'] = "TLSv1 TLSv1.1 TLSv1.2"
nginx['listen_port'] = 8090
gitlab_rails['manage_backup_path'] = true
gitlab_rails['backup_path'] = "/data/gitlab/backups"    #gitlab备份目录
gitlab_rails['backup_archive_permissions'] = 0644       #生成的备份文件权限
gitlab_rails['backup_keep_time'] = 7776000              #备份保留天数为3个月(即90天,这里是7776000秒)

三 找回管理员密码

1、登陆后台服务器,切换git用户

su - git

2、登录GitLab的Rails控制台

gitlab-rails console production

或者其他方法切换root账户

gitlab-rails console

3、使用user = User.where(id: 1).first,定位到id=1的用户,就是超级管理员

user = User.where(id: 1).first

1