centOs安装gitlab-ee

1> 安装

# 关闭防火墙,查看防火墙状态,如果开启就stop关闭一下
systemctl status firewalld.service

# 清华大学开源软件镜像站 查看相关下载的地址    https://mirrors.tuna.tsinghua.edu.cn/

# 安装方式一:配置yum源
vim /etc/yum.repos.d/gitlab-ee.repo
# 拷贝以下内容,然后 :wq! 保存退出
[gitlab-ee]
name=Gitlab EE Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ee/yum/el7/
gpgcheck=0
enabled=1
# 更新本地yum缓存
yum makecache
# 安装gitlab-ee最新版(也可以指定版本)
yum install gitlab-ce


# 安装方式二:使用rpm命令安装
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ee/yum/el7/gitlab-ee-10.0.0-ee.0.el7.x86_64.rpm --no-check-certificate
# 使用rpm安装需要手动解决依赖问题
# 前置条件依赖policycoreutils-python、openssh-server设置开机自启
yum -y install policycoreutils-python openssh-server
systemctl enable sshd
systemctl start sshd
# 还缺啥安装时会有提示,缺啥安装啥就行
rpm -Uvh gitlab-ee-10.0.0-ee.0.el7.x86_64.rpm


#安装成功后加载配置并启动
gitlab-ctl reconfigure
gitlab-ctl restart

2> 修改Gitlab配置文件 gitlab.rb

vim /etc/gitlab/gitlab.rb


# 启用 smtp 服务
gitlab_rails['smtp_enable'] = true
# 配置 smtp 服务地址,这里需要填写邮件服务里面的“SMTP服务器地址”(如下是网易163邮箱的smtp服务器地址)
gitlab_rails['smtp_address'] = "smtp.163.com"
# 配置 smtp 服务的端口号(默认)
gitlab_rails['smtp_port'] = 465
# 配置发送邮件的电子邮箱名称(即刚才注册的邮箱名称)
gitlab_rails['smtp_user_name'] = "[email protected]"
# 配置发送邮件的电子邮箱授权密码,刚才在邮箱里面开启 SMTP 服务的时候弹框提示的那一串【授权密码】(切记:这里不是邮箱的登录>密码,是SMTP的授权密码)
gitlab_rails['smtp_password'] = "授权密码"
# 配置 SMTP 服务的域名,和上面的smtp服务器地址一致(如下是网易163邮箱的smtp域名)
gitlab_rails['smtp_domain'] = "smtp.163.com"
# 配置 SMTP 鉴定类别(默认 login 即可)
gitlab_rails['smtp_authentication'] = "login"
# # 开启纯文本通信协议扩展
gitlab_rails['smtp_enable_starttls_auto'] = true
# 开启 smtp_tls (传输安全)
gitlab_rails['smtp_tls'] = true

# gitlab 服务邮件发送来源邮箱(即发出邮件的发送方邮箱),填写刚才注册的邮箱即可
gitlab_rails['gitlab_email_from'] = '[email protected]'

# 修改完成后重新加载配置文件
gitlab-ctl reconfigure
# 重新启动gitlab
gitlab-ctl restart

3> 测试gitlab是否正常发送邮件

[root@localhost ~]# gitlab-rails console
--------------------------------------------------------------------------------
 Ruby:         ruby 2.7.7p221 (2022-11-24 revision 168ec2b1e5) [x86_64-linux]
 GitLab:       15.9.3-ee (d3356768b48) EE
 GitLab Shell: 14.17.0
 PostgreSQL:   13.8
------------------------------------------------------------[ booted in 31.33s ]
Loading production environment (Rails 6.1.7.2)
irb(main):001:0> Notify.test_email('[email protected]', 'title', 'body').deliver_now
Delivered mail [email protected] (738.7ms)
=> #, >, >, , >, , , , , , >
irb(main):002:0> 

4> 修改root管理员密码

[root@localhost ~]# cat /etc/gitlab/initial_root_password
# WARNING: This value is valid only in the following conditions
#          1. If provided manually (either via `GITLAB_ROOT_PASSWORD` environment variable or via `gitlab_rails['initial_root_password']` setting in `gitlab.rb`, it was provided before database was seeded for the first time (usually, the first reconfigure run).
#          2. Password hasn't been changed manually, either via UI or via command line.
#
#          If the password shown here doesn't work, you must reset the admin password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.

Password: ............................这里是初始化密码.............................................

# NOTE: This file will be automatically deleted in the first reconfigure run after 24 hours.

# 进入控制台
[root@localhost ~]# gitlab-rails console -e production
--------------------------------------------------------------------------------
 Ruby:         ruby 2.7.7p221 (2022-11-24 revision 168ec2b1e5) [x86_64-linux]
 GitLab:       15.9.3-ee (d3356768b48) EE
 GitLab Shell: 14.17.0
 PostgreSQL:   13.8
------------------------------------------------------------[ booted in 22.00s ]
Loading production environment (Rails 6.1.7.2)
irb(main):001:0> User.all #输入User.all 查看所有的用户
=> #]>
irb(main):002:0> user=User.where(id:1).first  #指定修改哪个用户密码
=> #
irb(main):003:0> user.password='xxx'    #输入密码
=> "xxx"
irb(main):004:0> user.password_confirmation='xxx'    #输入确认密码
=> "xxx"
irb(main):005:0> user.save!    #保存确定
=> true
irb(main):006:0> 

5> 性能优化

unicorn['worker_processes'] = 2                         #官方建议值为CPU核数+1(服务器只部署gitLab的情况下),可提高服务器响应速度,此参数最小值为2,设为1服务器可能卡死
unicorn['work_timeout'] = 60                            #设置超时时间
unicorn['worker_memory_limit_min'] = "200 * 1 << 20"    #减少最小内存
unicorn['worker_memory_limit_max'] = "300 * 1 << 20"    #减少最大内存
postgresql['shared_buffers'] = "128MB"                  #减少数据库缓存
postgresql['max_worker_processes'] = 6                  #减少数据库并发数
sidekiq['concurrency'] = 15                             #减少sidekiq并发数

#额外的组件比较浪费资源,可以考虑关闭。
prometheus['enable'] = false
prometheus['monitor_kubernetes'] = false
alertmanager['enable'] = false  
node_exporter['enable'] = false 
redis_exporter['enable'] = false 
postgres_exporter['enable'] = false
gitlab_exporter['probe_sidekiq'] = false
prometheus_monitoring['enable'] = false
grafana['enable'] = false  

6> 其他命令

gitlab-ctl start #启动全部服务
gitlab-ctl restart#重启全部服务
gitlab-ctl stop #停止全部服务
gitlab-ctl restart nginx #重启单个服务,如重启nginx
gitlab-ctl status #查看服务状态
gitlab-ctl reconfigure #使配置文件生效
gitlab-ctl show-config #验证配置文件
gitlab-ctl uninstall #删除gitlab(保留数据)
gitlab-ctl cleanse #删除所有数据,从新开始
gitlab-ctl tail 查看服务的日志
gitlab-ctl tail nginx  #如查看gitlab下nginx日志
gitlab-rails console  #进入控制台
gitlab-ctl help                  #查看gitlab帮助信息

你可能感兴趣的:(linux,gitlab,linux)