下面是文章正文,希望能帮到您
GitLab 是一个用于仓库管理系统的开源项目,使用Git作为代码管理工具,并在此基础上搭建起来的Web服务。如今,它变得更加强大。GitLab is the most comprehensive AI-powered DevSecOps Platform.
系统准备:
# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
## 软件包版本
# rpm -qa | grep gitlab
gitlab-ce-16.0.2-ce.0.el7.x86_64
这里面有ee版本和ce版本的区别
https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh
这里只研究ce(社区版)的
https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh
安装前的系统检查以及配置脚本,这种方式针对可以访问公网地址可以通过脚本链接处理一些必要依赖等:
script.rpm.sh
# vi script.rpm.sh
#!/bin/bash
unknown_os ()
{
echo "Unfortunately, your operating system distribution and version are not supported by this script."
echo
echo "You can override the OS detection by setting os= and dist= prior to running this script."
echo "You can find a list of supported OSes and distributions on our website: https://packages.gitlab.com/docs#os_distro_version"
echo
echo "For example, to force CentOS 6: os=el dist=6 ./script.sh"
echo
echo "Please email [email protected] and let us know if you run into any issues."
exit 1
}
curl_check ()
{
echo "Checking for curl..."
if command -v curl > /dev/null; then
echo "Detected curl..."
else
echo "Installing curl..."
yum install -d0 -e0 -y curl
fi
}
detect_os ()
{
if [[ ( -z "${os}" ) && ( -z "${dist}" ) ]]; then
if [ -e /etc/os-release ]; then
. /etc/os-release
os=${ID}
if [ "${os}" = "poky" ]; then
dist=`echo ${VERSION_ID}`
elif [ "${os}" = "sles" ]; then
dist=`echo ${VERSION_ID}`
elif [ "${os}" = "opensuse" ]; then
dist=`echo ${VERSION_ID}`
elif [ "${os}" = "opensuse-leap" ]; then
os=opensuse
dist=`echo ${VERSION_ID}`
elif [ "${os}" = "amzn" ]; then
dist=`echo ${VERSION_ID}`
else
dist=`echo ${VERSION_ID} | awk -F '.' '{ print $1 }'`
fi
elif [ `which lsb_release 2>/dev/null` ]; then
# get major version (e.g. '5' or '6')
dist=`lsb_release -r | cut -f2 | awk -F '.' '{ print $1 }'`
# get os (e.g. 'centos', 'redhatenterpriseserver', etc)
os=`lsb_release -i | cut -f2 | awk '{ print tolower($1) }'`
elif [ -e /etc/oracle-release ]; then
dist=`cut -f5 --delimiter=' ' /etc/oracle-release | awk -F '.' '{ print $1 }'`
os='ol'
elif [ -e /etc/fedora-release ]; then
dist=`cut -f3 --delimiter=' ' /etc/fedora-release`
os='fedora'
elif [ -e /etc/redhat-release ]; then
os_hint=`cat /etc/redhat-release | awk '{ print tolower($1) }'`
if [ "${os_hint}" = "centos" ]; then
dist=`cat /etc/redhat-release | awk '{ print $3 }' | awk -F '.' '{ print $1 }'`
os='centos'
elif [ "${os_hint}" = "scientific" ]; then
dist=`cat /etc/redhat-release | awk '{ print $4 }' | awk -F '.' '{ print $1 }'`
os='scientific'
else
dist=`cat /etc/redhat-release | awk '{ print tolower($7) }' | cut -f1 --delimiter='.'`
os='redhatenterpriseserver'
fi
else
aws=`grep -q Amazon /etc/issue`
if [ "$?" = "0" ]; then
dist='6'
os='aws'
else
unknown_os
fi
fi
fi
if [[ ( -z "${os}" ) || ( -z "${dist}" ) ]]; then
unknown_os
fi
# remove whitespace from OS and dist name
os="${os// /}"
dist="${dist// /}"
echo "Detected operating system as ${os}/${dist}."
if [ "${dist}" = "8" ]; then
_skip_pygpgme=1
else
_skip_pygpgme=0
fi
}
finalize_yum_repo ()
{
if [ "$_skip_pygpgme" = 0 ]; then
echo "Installing pygpgme to verify GPG signatures..."
yum install -y pygpgme --disablerepo='gitlab_gitlab-ce'
pypgpme_check=`rpm -qa | grep -qw pygpgme`
if [ "$?" != "0" ]; then
echo
echo "WARNING: "
echo "The pygpgme package could not be installed. This means GPG verification is not possible for any RPM installed on your system. "
echo "To fix this, add a repository with pygpgme. Usualy, the EPEL repository for your system will have this. "
echo "More information: https://fedoraproject.org/wiki/EPEL#How_can_I_use_these_extra_packages.3F"
echo
# set the repo_gpgcheck option to 0
sed -i'' 's/repo_gpgcheck=1/repo_gpgcheck=0/' /etc/yum.repos.d/gitlab_gitlab-ce.repo
fi
fi
echo "Installing yum-utils..."
yum install -y yum-utils --disablerepo='gitlab_gitlab-ce'
yum_utils_check=`rpm -qa | grep -qw yum-utils`
if [ "$?" != "0" ]; then
echo
echo "WARNING: "
echo "The yum-utils package could not be installed. This means you may not be able to install source RPMs or use other yum features."
echo
fi
echo "Generating yum cache for gitlab_gitlab-ce..."
yum -q makecache -y --disablerepo='*' --enablerepo='gitlab_gitlab-ce'
echo "Generating yum cache for gitlab_gitlab-ce-source..."
yum -q makecache -y --disablerepo='*' --enablerepo='gitlab_gitlab-ce-source'
}
finalize_zypper_repo ()
{
zypper --gpg-auto-import-keys refresh gitlab_gitlab-ce
zypper --gpg-auto-import-keys refresh gitlab_gitlab-ce-source
}
main ()
{
detect_os
curl_check
yum_repo_config_url="https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/config_file.repo?os=${os}&dist=${dist}&source=script"
if [ "${os}" = "sles" ] || [ "${os}" = "opensuse" ]; then
yum_repo_path=/etc/zypp/repos.d/gitlab_gitlab-ce.repo
else
yum_repo_path=/etc/yum.repos.d/gitlab_gitlab-ce.repo
fi
echo "Downloading repository file: ${yum_repo_config_url}"
curl -sSf "${yum_repo_config_url}" > $yum_repo_path
curl_exit_code=$?
if [ "$curl_exit_code" = "22" ]; then
echo
echo
echo -n "Unable to download repo config from: "
echo "${yum_repo_config_url}"
echo
echo "This usually happens if your operating system is not supported by "
echo "packagecloud.io, or this script's OS detection failed."
echo
echo "You can override the OS detection by setting os= and dist= prior to running this script."
echo "You can find a list of supported OSes and distributions on our website: https://packages.gitlab.com/docs#os_distro_version"
echo
echo "For example, to force CentOS 6: os=el dist=6 ./script.sh"
echo
echo "If you are running a supported OS, please email [email protected] and report this."
[ -e $yum_repo_path ] && rm $yum_repo_path
exit 1
elif [ "$curl_exit_code" = "35" -o "$curl_exit_code" = "60" ]; then
echo
echo "curl is unable to connect to packagecloud.io over TLS when running: "
echo " curl ${yum_repo_config_url}"
echo
echo "This is usually due to one of two things:"
echo
echo " 1.) Missing CA root certificates (make sure the ca-certificates package is installed)"
echo " 2.) An old version of libssl. Try upgrading libssl on your system to a more recent version"
echo
echo "Contact [email protected] with information about your system for help."
[ -e $yum_repo_path ] && rm $yum_repo_path
exit 1
elif [ "$curl_exit_code" -gt "0" ]; then
echo
echo "Unable to run: "
echo " curl ${yum_repo_config_url}"
echo
echo "Double check your curl installation and try again."
[ -e $yum_repo_path ] && rm $yum_repo_path
exit 1
else
echo "done."
fi
if [ "${os}" = "sles" ] || [ "${os}" = "opensuse" ]; then
finalize_zypper_repo
else
finalize_yum_repo
fi
echo
echo "The repository is setup! You can now install packages."
}
main
YUM 网络安装
## 查看本地源
# yum list | grep gitlab
gitlab-ce.x86_64 16.0.2-ce.0.el7 @gitlab_gitlab-ce
gitlab-ce.x86_64 16.0.3-ce.0.el7 gitlab_gitlab-ce
## yum安装
# yum -y install gitlab-ce.x86_64
GitLab rpm包本地:
https://packages.gitlab.com/gitlab/gitlab-ce/packages/scientific/7/gitlab-ce-16.0.2-ce.0.el7.x86_64.rpm
# ls
gitlab-ce-16.0.2-ce.0.el7.x86_64.rpm
# yum -y install ./gitlab-ce-16.0.2-ce.0.el7.x86_64.rpm
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: ftp.sjtu.edu.cn
* updates: mirrors.ustc.edu.cn
正在解决依赖关系
--> 正在检查事务
---> 软件包 gitlab-ce.x86_64.0.16.0.2-ce.0.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
=====================================================================================================================================================================================================================================
Package 架构 版本 源 大小
=====================================================================================================================================================================================================================================
正在安装:
gitlab-ce x86_64 16.0.2-ce.0.el7 gitlab_gitlab-ce 1.2 G
事务概要
=====================================================================================================================================================================================================================================
安装 1 软件包
总下载量:1.2 G
安装大小:2.6 G
Downloading packages:
警告:/var/cache/yum/x86_64/7/gitlab_gitlab-ce/packages/gitlab-ce-16.0.2-ce.0.el7.x86_64.rpm: 头V4 RSA/SHA1 Signature, 密钥 ID f27eab47: NOKEY====================================================-] 9.3 MB/s | 1.2 GB 00:00:00 ETA
gitlab-ce-16.0.2-ce.0.el7.x86_64.rpm 的公钥尚未安装
gitlab-ce-16.0.2-ce.0.el7.x86_64.rpm | 1.2 GB 00:02:08
从 https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey 检索密钥
导入 GPG key 0x51312F3F:
用户ID : "GitLab B.V. (package repository signing key) "
指纹 : f640 3f65 44a3 8863 daa0 b6e0 3f01 618a 5131 2f3f
来自 : https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey
从 https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey/gitlab-gitlab-ce-3D645A26AB9FBD22.pub.gpg 检索密钥
导入 GPG key 0xF27EAB47:
用户ID : "GitLab, Inc. "
指纹 : dbef 8977 4ddb 9eb3 7d9f c3a0 3cfc f9ba f27e ab47
来自 : https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey/gitlab-gitlab-ce-3D645A26AB9FBD22.pub.gpg
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : gitlab-ce-16.0.2-ce.0.el7.x86_64 1/1
It looks like GitLab has not been configured yet; skipping the upgrade script.
*. *.
*** ***
***** *****
.****** *******
******** ********
,,,,,,,,,***********,,,,,,,,,
,,,,,,,,,,,*********,,,,,,,,,,,
.,,,,,,,,,,,*******,,,,,,,,,,,,
,,,,,,,,,*****,,,,,,,,,.
,,,,,,,****,,,,,,
.,,,***,,,,
,*,.
_______ __ __ __
/ ____(_) /_/ / ____ _/ /_
/ / __/ / __/ / / __ `/ __ \
/ /_/ / / /_/ /___/ /_/ / /_/ /
\____/_/\__/_____/\__,_/_.___/
Thank you for installing GitLab!
GitLab was unable to detect a valid hostname for your instance.
Please configure a URL for your GitLab instance by setting `external_url`
configuration in /etc/gitlab/gitlab.rb file.
Then, you can start your GitLab instance by running the following command:
sudo gitlab-ctl reconfigure
For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
Help us improve the installation experience, let us know how we did with a 1 minute survey:
https://gitlab.fra1.qualtrics.com/jfe/form/SV_6kVqZANThUQ1bZb?installation=omnibus&release=16-0
验证中 : gitlab-ce-16.0.2-ce.0.el7.x86_64 1/1
已安装:
gitlab-ce.x86_64 0:16.0.2-ce.0.el7
完毕!
配置
# vi /etc/gitlab/gitlab.rb
external_url 'http://10.2.6.155' #修改为自己的服务器IP地址或者域名
启动
# 重新加载配置
gitlab-ctl reconfigure
# 执行启动
gitlab-ctl restart
登陆地址:
http://10.2.6.155
GitLab环境准备是第一步。接下来主要就是基于自己工作的角色去有针对性的学习!关注企业级的应用,如集成LDAP。基于不同的用户角色针对性实验。研发人员需要关注代码提交、分支管理等的常用操作并理解其具体含义以及操作的风险等!管理员需要保障服务的正常运行,权限管理、文件备份、CI/CD、安全等操作。