gitlab部署
注意!!!在部署之前要确保环境为纯洁环境,内存尽量给多一些
[root@129-master ~]# cd /etc/yum.repos.d/
[root@129-master yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
[root@129-master yum.repos.d]# sed -i 's|^#baseurl=https://download.example/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel*
[root@129-master yum.repos.d]# sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel*
# 安装依赖包
yum -y install curl openssh-server openssh-clients postfix cronie perl
# 启动postfix服务并设置开机自启
[root@129-master ~]# systemctl restart postfix
[root@129-master ~]# systemctl enable postfix
Created symlink /etc/systemd/system/multi-user.target.wants/postfix.service → /usr/lib/systemd/system/postfix.service.
下载gitlab的rpm包
[root@129-master ~]# cd /usr/src/
[root@129-master src]# ls
debug kernels
[root@129-master src]# wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-15.3.3-ce.0.el7.x86_64.rpm
此时安装会发现需要一个依赖包 policycoreutils-python
wget https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/Packages/policycoreutils-python-2.5-34.el7.x86_64.rpm
[root@129-master src]# ls
debug gitlab-ce-15.3.3-ce.0.el7.x86_64.rpm kernels policycoreutils-python-2.5-34.el7.x86_64.rpm
rpm -ivh gitlab-ce-15.3.3-ce.0.el7.x86_64.rpm --nodeps
修改配置文件
[root@129-master ~]# vim /etc/gitlab/gitlab.rb
external_url 'http://192.168.253.133' //将此处设为gitlab的服务器ip地址亦或域名
重载配置文件并重启gitlab
[root@129-master ]# gitlab-ctl start
[root@129-master ]# gitlab-ctl reconfigure
ok: run: alertmanager: (pid 27635) 0s
ok: run: gitaly: (pid 27645) 0s
ok: run: gitlab-exporter: (pid 27661) 0s
ok: run: gitlab-kas: (pid 27663) 0s
ok: run: gitlab-workhorse: (pid 27677) 1s
ok: run: logrotate: (pid 27688) 0s
ok: run: nginx: (pid 27694) 1s
ok: run: node-exporter: (pid 27702) 0s
ok: run: postgres-exporter: (pid 27712) 1s
ok: run: postgresql: (pid 27731) 0s
ok: run: prometheus: (pid 27733) 1s
ok: run: puma: (pid 27832) 0s
ok: run: redis: (pid 27837) 1s
ok: run: redis-exporter: (pid 27843) 0s
ok: run: sidekiq: (pid 27853) 0s
查看当前的gitlab版本
[root@129-master src]# head -1 /opt/gitlab/version-manifest.txt
gitlab-ce 15.3.3
破解管理员密码
[root@localhost ~]# gitlab-rails console -e production
--------------------------------------------------------------------------------
Ruby: ruby 2.7.5p203 (2021-11-24 revision f69aeb8314) [x86_64-linux]
GitLab: 15.3.3 (c629a47f87f) FOSS
GitLab Shell: 14.10.0
PostgreSQL: 13.6
------------------------------------------------------------[ booted in 24.80s ]
Loading production environment (Rails 6.1.6.1)
irb(main):001:0> user = User.where(id:1).first
=> #<User id:1 @root>
irb(main):002:0> user.password = 'renweiwei'
=> "renweiwei"
irb(main):003:0> user.password_confirmation = 'renweiwei'
=> "renweiwei"
irb(main):004:0> user.save!
=> true
irb(main):005:0> exit
关闭防火墙和selinux
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost ~]# setenforce 0
[root@localhost ~]# sed -ri 's/^(SELINUX=).*/\1disabled/g' /etc/sysconfig/selinux