一、gitlab相关
安装
1、安装必要的依赖项,配置SSH开机启动,系统防火墙中开放HTTP、HTTPS访问。
yum install -y curl policycoreutils-python openssh-server
systemctl enable sshd
systemctl start sshd
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
systemctl reload firewalld
2、上传gitlab-ce-15.9.2-ce.0.el7.x86_64.rpm 到root目录
3、安装gitlab-ce社区版本
rpm -ivh gitlab-ce-15.9.2-ce.0.el7.x86_64.rpm
4、修改配置
vi /etc/gitlab/gitlab.rb
说明:将external_url 'http://gitlab.example.com'地址修改成服务器的ip或域名 按ESC 输入:wq 回车保存
6、加载配置并重启gitlab
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart
密钥
1、生成
ssh-keygen -t rsa -b 2048 -C "<wwt082928@163.com>"
2、查看
cat ~/.ssh/id_rsa.pub
备份迁移
1、查看gitlab版本
gitlab-rake gitlab:env:info
2、旧服务器代码数据备份
sudo gitlab-rake gitlab:backup:create
备份文件地址: /var/opt/gitlab/backups
3、上传备份文件到新服务器并设置777权限
chmod 777 /var/opt/gitlab/backups/1678424737_2023_03_10_15.9.2_gitlab_backup.tar
4、停止unicorn和sidekiq服务
gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq
5、恢复备份数据到新服务器并覆盖
gitlab-rake gitlab:backup:restore BACKUP=1678424737_2023_03_10_15.9.2
6、重启gitlab服务
gitlab-ctl start
⚠注意:1、新旧服务器上的gitlab版本建议保持一致
2、将旧服务器上/etc/gitlab/gitlab-secrets.json文件覆盖到了新的服务器上,否则部分设置会出现500 错误
内存优化
1、修改/etc/gitlab/gitlab.rb 配置文件
puma['enable'] = true
puma['worker_timeout'] = 60
puma['worker_processes'] = 2
puma['per_worker_max_memory_mb'] = 300
sidekiq['max_concurrency'] = 15
postgresql['shared_buffers'] = "128MB"
postgresql['max_worker_processes'] = 4
2、加载配置并重启gitlab
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart
卸载
1、停止gitlab
gitlab-ctl stop
2、卸载gitlab(注意这里写的是gitlab-ce)
rpm -e gitlab-ce
3、查看gitlab进程
ps aux | grep gitlab
4、杀掉service.log进程(后缀很多…的进程)*个人建议直接重启服务器
kill -9 进程号
5、删除所有包含gitlab文件
find / -name gitlab | xargs rm -rf
修改root密码
gitlab-rails console -e production
user = User.where(id: 1).first
user.password = '你的密码'
user.password_confirmation = '你的密码'
user.save!
exit