【运维系列】【ubuntu22.04】安装GitLab
一.下载安装文件
root@gitlab:~# wget https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/9/gitlab-ce-17.4.0-ce.0.el9.x86_64.rpm
二.执行安装脚本
2.1 先执行安装前的命令
root@gitlab:~# apt install -y perl-interpreter
root@gitlab:~# apt install -y openssh-server
root@gitlab:~# apt install -y policycoreutils-python-utils
2.2 再执行安装命令
root@gitlab:~# rpm -Uvh gitlab-ce-17.4.0-ce.0.el9.x86_64.rpm
如果执行出现这个问题
就换个一个命令执行,执行拉取最新的:
root@gitlab:/opt/gitlab# curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
安装gitlab-ce,这会要一些时间:
root@gitlab:/opt/gitlab# sudo apt-get install gitlab-ce
继续执行上图中的命令:
root@gitlab:/opt/gitlab# sudo gitlab-ctl reconfigure
然后检查下各个服务的状态,均为run代表没有问题
root@gitlab:/opt/gitlab# sudo gitlab-ctl status
三.验证
3.1 获取密码
使用用户名root,以及从 /etc/gitlab/initial_root_password 文件中获取的密码进行登录。
root@gitlab:/opt/gitlab# cat /etc/gitlab/initial_root_password
登录成功:
四. 日常命令
sudo gitlab-rake gitlab:check # 验证GitLab配置
sudo gitlab-rake 'gitlab:password:reset[root]' # 重置GitLab root密码
sudo gitlab-ctl status # 查看GitLab状态
sudo gitlab-ctl stop # 停止GitLab
sudo gitlab-ctl restart # 重新启动GitLab
sudo gitlab-ctl start # 启动GitLab服务
sudo systemctl list-units --type=service | grep gitlab # 确定GitLab服务的名称
sudo systemctl status gitlab-runsvdir # 查看GitLab服务的状态
sudo systemctl is-enabled gitlab-runsvdir # 检查是否设置了开机禁用GitLab服务:应该返回disabled
sudo systemctl stop gitlab-runsvdir # 停止当前运行的GitLab服务
sudo systemctl disable gitlab-runsvdir # 禁用GitLab服务:在下次启动时不会自动运行
五.卸载命令
sudo gitlab-ctl stop # Shutdown Gitlab
sudo gitlab-ctl uninstall # Remove Gitlab services
sudo gitlab-ctl cleanse # Clean any data generated by usage of the package
sudo gitlab-ctl remove-accounts # Remove any Gitlab accounts on your system
sudo dpkg -P gitlab-ce # sudo apt-get purge gitlab-ce # Remove the package
sudo rm -rf /opt/gitlab /etc/gitlab /var/opt/gitlab # Remove all Gitlab paths
sudo apt update
sudo apt-get autoremove
sudo apt-get clean