1 镜像下载地址
我目前使用的版本是:11.10.2
ubuntu/bionic/gitlab-ce_11.10.2-ce.0_amd64.deb - gitlab/gitlab-ce · packages.gitlab.com
版本13以后,把原始仓库路径默认都给变成了hash加密了,很难辨识出原始仓库,所以不选择13以上的版本。
2 每次服务器断电后不能启动gitlab
2.1 断电后启动gitlab报错
fail: alertmanager: runsv not running
fail: gitaly: runsv not running
fail: gitlab-monitor: runsv not running
fail: gitlab-workhorse: runsv not running
fail: logrotate: runsv not running
fail: nginx: runsv not running
fail: node-exporter: runsv not running
fail: postgres-exporter: runsv not running
fail: postgresql: runsv not running
fail: prometheus: runsv not running
fail: redis: runsv not running
fail: redis-exporter: runsv not running
fail: sidekiq: runsv not running
fail: unicorn: runsv not running
2.2 解决办法
2.2.1 参考gitlab官方文档 gitlab-runsvdir not starting
https://docs.gitlab.com/omnibus/common_installation_problems/#gitlab-runsvdir-not-starting
2.2.2 执行systemctl -t target 有dead字段
yfgitlab@ubuntu:~$systemctl -t target
................
multi-user.target loaded inactive dead start Multi-User System //执行命令以后有dead
............
2.2.3 执行systemctl list-jobs
yfgitlab@ubuntu:~$ systemctl list-jobs
JOB UNIT TYPE STATE
2 multi-user.target start waiting
1 graphical.target start waiting
139 gitlab-runsvdir.service start waiting
162 ureadahead-stop.timer start waiting
140 plymouth-quit-wait.service start running //这里有一个running,官方建议卸载,然后gitlab就能启动了
26 setvtrgb.service start waiting
129 system-getty.slice start waiting
156 systemd-update-utmp-runlevel.service start waiting
In this case, consider uninstalling Plymouth (官方文档解决办法)
执行sudo apt remove plymouth 删掉这个应用
2.2.4 执行gitaly
[sudo] password for yfgitlab:
ok: run: alertmanager: (pid 3665) 0s
timeout: run: gitaly: (pid 1461) 1005s, got TERM
ok: run: gitlab-monitor: (pid 3748) 0s
ok: run: gitlab-workhorse: (pid 3755) 1s
ok: run: logrotate: (pid 3769) 0s
ok: run: nginx: (pid 3781) 1s
ok: run: node-exporter: (pid 3795) 0s
ok: run: postgres-exporter: (pid 3804) 0s
ok: run: postgresql: (pid 3816) 1s
ok: run: prometheus: (pid 3824) 0s
ok: run: redis: (pid 3839) 1s
ok: run: redis-exporter: (pid 3844) 0s
ok: run: sidekiq: (pid 3852) 0s
ok: run: unicorn: (pid 3864) 0s
sudo gitlab-ctl stop
删除/var/opt/gitlab/gitaly/gitaly.pid 文件,然后重启gitlab
重启电脑
sudo gitlab-ctl start
3 FreeNAS使用
我的gitlab安装在了ubuntu上面,ubuntu通过nfs挂载了FreeNAS的存储盘,这样将giltlab的原始仓库保存在FreeNAS服务器上面,防止丢失。
参考官方文档挂载nfs
nfs挂载参数
#/etc/fstab中添加挂载
192.168.10.194:/mnt/storage/gitlab_nfs /mnt/gitlab_nfs nfs4 defaults,vers=4.1,hard,rsize=1048576,wsize=1048576,noatime,nofail,lookupcache=positive 0 2
nfs按上面的参数进行挂载,否则gitlab会出现读写权限的问题
4 安装前执行脚本
#!/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 Ubuntu Trusty: os=ubuntu dist=trusty ./script.sh"
echo
echo "Please email support@packagecloud.io and let us know if you run into any issues."
exit 1
}
gpg_check ()
{
echo "Checking for gpg..."
if command -v gpg > /dev/null; then
echo "Detected gpg..."
else
echo "Installing gnupg for GPG verification..."
apt-get install -y gnupg
if [ "$?" -ne "0" ]; then
echo "Unable to install GPG! Your base system has a problem; please check your default OS's package repositories because GPG should work."
echo "Repository installation aborted."
exit 1
fi
fi
}
curl_check ()
{
echo "Checking for curl..."
if command -v curl > /dev/null; then
echo "Detected curl..."
else
echo "Installing curl..."
apt-get install -q -y curl
if [ "$?" -ne "0" ]; then
echo "Unable to install curl! Your base system has a problem; please check your default OS's package repositories because curl should work."
echo "Repository installation aborted."
exit 1
fi
fi
}
install_debian_keyring ()
{
if [ "${os}" = "debian" ]; then
echo "Installing debian-archive-keyring which is needed for installing "
echo "apt-transport-https on many Debian systems."
apt-get install -y debian-archive-keyring &> /dev/null
fi
}
detect_os ()
{
if [[ ( -z "${os}" ) && ( -z "${dist}" ) ]]; then
# some systems dont have lsb-release yet have the lsb_release binary and
# vice-versa
if [ -e /etc/lsb-release ]; then
. /etc/lsb-release
if [ "${ID}" = "raspbian" ]; then
os=${ID}
dist=`cut --delimiter='.' -f1 /etc/debian_version`
else
os=${DISTRIB_ID}
dist=${DISTRIB_CODENAME}
if [ -z "$dist" ]; then
dist=${DISTRIB_RELEASE}
fi
fi
elif [ `which lsb_release 2>/dev/null` ]; then
dist=`lsb_release -c | cut -f2`
os=`lsb_release -i | cut -f2 | awk '{ print tolower($1) }'`
elif [ -e /etc/debian_version ]; then
# some Debians have jessie/sid in their /etc/debian_version
# while others have '6.0.7'
os=`cat /etc/issue | head -1 | awk '{ print tolower($1) }'`
if grep -q '/' /etc/debian_version; then
dist=`cut --delimiter='/' -f1 /etc/debian_version`
else
dist=`cut --delimiter='.' -f1 /etc/debian_version`
fi
else
unknown_os
fi
fi
if [ -z "$dist" ]; then
unknown_os
fi
# remove whitespace from OS and dist name
os="${os// /}"
dist="${dist// /}"
echo "Detected operating system as $os/$dist."
}
main ()
{
detect_os
curl_check
gpg_check
# Need to first run apt-get update so that apt-transport-https can be
# installed
echo -n "Running apt-get update... "
apt-get update &> /dev/null
echo "done."
# Install the debian-archive-keyring package on debian systems so that
# apt-transport-https can be installed next
install_debian_keyring
echo -n "Installing apt-transport-https... "
apt-get install -y apt-transport-https &> /dev/null
echo "done."
gpg_key_url="https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey"
apt_config_url="https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/config_file.list?os=${os}&dist=${dist}&source=script"
apt_source_path="/etc/apt/sources.list.d/gitlab_gitlab-ce.list"
echo -n "Installing $apt_source_path..."
# create an apt config file for this repository
curl -sSf "${apt_config_url}" > $apt_source_path
curl_exit_code=$?
if [ "$curl_exit_code" = "22" ]; then
echo
echo
echo -n "Unable to download repo config from: "
echo "${apt_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 Ubuntu Trusty: os=ubuntu dist=trusty ./script.sh"
echo
echo "If you are running a supported OS, please email support@packagecloud.io and report this."
[ -e $apt_source_path ] && rm $apt_source_path
exit 1
elif [ "$curl_exit_code" = "35" -o "$curl_exit_code" = "60" ]; then
echo "curl is unable to connect to packagecloud.io over TLS when running: "
echo " curl ${apt_config_url}"
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 support@packagecloud.io with information about your system for help."
[ -e $apt_source_path ] && rm $apt_source_path
exit 1
elif [ "$curl_exit_code" -gt "0" ]; then
echo
echo "Unable to run: "
echo " curl ${apt_config_url}"
echo
echo "Double check your curl installation and try again."
[ -e $apt_source_path ] && rm $apt_source_path
exit 1
else
echo "done."
fi
echo -n "Importing packagecloud gpg key... "
# import the gpg key
curl -L "${gpg_key_url}" 2> /dev/null | apt-key add - &>/dev/null
echo "done."
echo -n "Running apt-get update... "
# update apt on this system
apt-get update &> /dev/null
echo "done."
echo
echo "The repository is setup! You can now install packages."
}
main