首页 > 编程知识 正文

gitlab硬件配置,gitlab linux安装

时间:2023-05-06 14:47:41 阅读:239297 作者:4652

一、安装 1.配置yum源 vim /etc/yum.repos.d/gitlab-ce.repo

复制以下内容:

[gitlab-ce]name=Gitlab CE Repositorybaseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/gpgcheck=0enabled=1 2.更新本地yum缓存 yum makecache 3.安装GitLab社区版 yum install gitlab-ce #自动安装最新版本 4.更改默认端口配置(默认为80端口) sudo vim /etc/gitlab/gitlab.rb

修改如下:

external_url 'http://ip:26100'nginx['listen_https'] = falsenginx['listen_port'] = 26100nignx['listen_address'] = ['*'] sudo vim /var/opt/gitlab/nginx/conf/gitlab-http.conf

修改如下:

server {listen *:26100;server_name ipif ($http_host = ""){set $http_host_with_default "ip:26100";}} 5.开放端口 sudo firewall-cmd --add-port=26100/tcp --permanent 6.重新加载防火墙 sudo firewall-cmd --reload 7.修改配置后重新加载配置文件 sudo gitlab-ctl reconfigure 8.重启gitlab sudo gitlab-ctl restart

注:如无需修改端口,可省略步骤4-7。

二、邮件配置 1.修改配置文件 sudo vim /etc/gitlab/gitlab.rb

新增以下内容:

gitlab_rails['smtp_enable'] = truegitlab_rails['smtp_address'] = "mail.midea.com"gitlab_rails['smtp_port'] = 994gitlab_rails['smtp_user_name'] = "发信邮箱"gitlab_rails['smtp_password'] = "发信邮箱密码"gitlab_rails['smtp_domain'] = "xxx.com"gitlab_rails['smtp_authentication'] = "login"gitlab_rails['smtp_enable_starttls_auto'] = truegitlab_rails['smtp_tls'] = trueuser['git_user_email'] = "发信邮箱"gitlab_rails['gitlab_email_from'] = '发信邮箱' 2.修改配置后重新加载配置文件 sudo gitlab-ctl reconfigure 3.测试邮件配置是否生效 [azureuser@devops ~]$ sudo gitlab-rails console--------------------------------------------------------------------------------Ruby: ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]GitLab: 13.7.1 (c97c8073a0e) FOSSGitLab Shell: 13.14.0PostgreSQL: 12.4--------------------------------------------------------------------------------Loading production environment (Rails 6.0.3.3)irb(main):001:0> Notify.test_email('xxxx@midea.com','test','test').deliver_nowNotify#test_email: processed outbound mail in 1.4msDelivered mail 5ff2cb5082e2b_e45eb53d484754@devops.mail (673.8ms)Date: Mon, 04 Jan 2021 08:01:20 +0000From: GitLab <xxx@midea.com>Reply-To: GitLab <noreply@ip>To: xxxx@midea.comMessage-ID: <5ff2cb5082e2b_e45eb53d484754@devops.mail>Subject: testMime-Version: 1.0Content-Type: text/html;charset=UTF-8Content-Transfer-Encoding: 7bitAuto-Submitted: auto-generatedX-Auto-Response-Suppress: All<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"><html><body><p>test</p></body></html>=> #<Mail::Message:199260, Multipart: false, Headers: <Date: Mon, 04 Jan 2021 08:01:20 +0000>, <From: GitLab <xxx@midea.com>>, <Reply-To: GitLab <noreply@ip>>, <To: xxxx@midea.com>, <Message-ID: <5ff2cb5082e2b_e45eb53d484754@devops.mail>>, <Subject: test>, <Mime-Version: 1.0>, <Content-Type: text/html; charset=UTF-8>, <Content-Transfer-Encoding: 7bit>, <Auto-Submitted: auto-generated>, <X-Auto-Response-Suppress: All>>出现以上信息说明配置成功。 三、修改超级管理员root的密码 1.进入gitlab-rails控制台 sudo gitlab-rails console 2.查找切换账号 u=User.where(id:1).first 3.修改密码 u.password='更改后的密码' 4.再次确认密码 u.password_confirmation='更改后的密码' 5.保存 u.save!

至此,可使用新密码gitlab首页进行登陆。
注:保存命令后的"!"一定要加!

四、性能调优 sudo vim /etc/gitlab/gitlab.rb

新增以下内容并保存退出:

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并发数 sudo gitlab-ctl reconfigure sudo gitlab-ctl restart 五、其他gitlab命令 gitlab-ctl help #查看gitlab帮助信息gitlab-ctl show-config #查看gitlab配置信息gitlab-ctl status #查看gitlab状态gitlab-ctl reconfigure #重新加载配置gitlab-ctl tail #查看所有日志

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。