2.2
主旨
说明
系统环境
10.2.6.155
/opt/gitlab
http://10.2.6.155/
GitLab版本
gitlab-ce.x86_64 16.0.2-ce.0.el7 gitlab_gitlab-ce
初始密码查看
# cat /etc/gitlab/initial_root_password
Password: cZ8wa9fZ8ZzQev5tnLCDocFwDbgIRkfvoq5pQm2CvKs=
# NOTE: This file will be automatically deleted in the first reconfigure run after 24 hours.
企业级数据存放
1、gitlab的目录存储目录是 /var/opt/gitlab/git-data/
2、创建新存储目录
mkdir -p /data/gitlab-data
3、修改配置文件(找到 git_data_dirs 参数对应的配置)
vim /etc/gitlab/gitlab.rb
git_data_dirs({
“default” => {
“path” => “/data/git-data”
}
})
4、将旧的gitlab数据迁移到新目录
cp -ar /var/opt/gitlab/git-data/repositories /data/gitlab-data/
5、重新加载配置
gitlab-ctl reconfigure
6、启动gitlab
gitlab-ctl start
默认数据存放
# ll /var/opt/gitlab/git-data/repositories
总用量 0
drwxr-sr-x 4 git git 30 6月 7 14:10 +gitaly
drwxr-s--- 3 git git 16 6月 7 14:10 @hashed
# ll /var/opt/gitlab/postgresql/data
总用量 60
drwx------ 6 gitlab-psql root 54 6月 7 11:56 base
drwx------ 2 gitlab-psql root 4096 6月 7 12:00 global
drwx------ 2 gitlab-psql root 6 6月 7 11:55 pg_commit_ts
drwx------ 2 gitlab-psql root 6 6月 7 11:55 pg_dynshmem
-rw-r--r-- 1 gitlab-psql root 3198 6月 7 11:55 pg_hba.conf
-rw-r--r-- 1 gitlab-psql root 1789 6月 7 11:55 pg_ident.conf
drwx------ 4 gitlab-psql root 68 6月 7 11:55 pg_logical
drwx------ 4 gitlab-psql root 36 6月 7 11:55 pg_multixact
drwx------ 2 gitlab-psql root 6 6月 7 11:55 pg_notify
drwx------ 2 gitlab-psql root 6 6月 7 11:55 pg_replslot
drwx------ 2 gitlab-psql root 6 6月 7 11:55 pg_serial
drwx------ 2 gitlab-psql root 6 6月 7 11:55 pg_snapshots
drwx------ 2 gitlab-psql root 6 6月 7 11:55 pg_stat
drwx------ 2 gitlab-psql root 101 6月 7 14:15 pg_stat_tmp
drwx------ 2 gitlab-psql root 18 6月 7 11:55 pg_subtrans
drwx------ 2 gitlab-psql root 6 6月 7 11:55 pg_tblspc
drwx------ 2 gitlab-psql root 6 6月 7 11:55 pg_twophase
-rw------- 1 gitlab-psql root 3 6月 7 11:55 PG_VERSION
drwx------ 3 gitlab-psql root 220 6月 7 11:58 pg_wal
drwx------ 2 gitlab-psql root 18 6月 7 11:55 pg_xact
-rw------- 1 gitlab-psql root 88 6月 7 11:55 postgresql.auto.conf
-rw-r--r-- 1 gitlab-psql root 15193 6月 7 11:55 postgresql.conf
-rw------- 1 gitlab-psql gitlab-psql 87 6月 7 11:55 postmaster.opts
-rw------- 1 gitlab-psql gitlab-psql 111 6月 7 11:55 postmaster.pid
-rw-r--r-- 1 gitlab-psql root 4601 6月 7 11:55 runtime.conf
-r-------- 1 gitlab-psql gitlab-psql 1805 6月 7 11:55 server.crt
-r-------- 1 gitlab-psql gitlab-psql 3243 6月 7 11:55 server.key
# ll /var/opt/gitlab/gitlab-rails/uploads
总用量 0
日志查看
# tail -f /var/log/gitlab/gitlab-rails/production.log
Creating scope :in_pipelines. Overwriting existing method Ci::Build.in_pipelines.
Creating scope :without_statuses. Overwriting existing method Ci::Pipeline.without_statuses.
Creating scope :of_projects. Overwriting existing method MergeRequest.of_projects.
Creating scope :join_project. Overwriting existing method MergeRequest.join_project.
Creating scope :references_project. Overwriting existing method MergeRequest.references_project.
Creating scope :system. Overwriting existing method Note.system.
Creating scope :order_created_desc. Overwriting existing method Packages::Package.order_created_desc.
Creating scope :order_name_desc. Overwriting existing method Packages::Package.order_name_desc.
Creating scope :auth. Overwriting existing method Key.auth.
Creating scope :signing. Overwriting existing method Key.signing.
最新安装
# 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 support@packagecloud.io 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 support@packagecloud.io 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 support@packagecloud.io 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
# bash script.rpm.sh
Detected operating system as centos/7.
Checking for curl...
Detected curl...
Downloading repository file: https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/config_file.repo?os=centos&dist=7&source=script
done.
Installing pygpgme to verify GPG signatures...
已加载插件:fastestmirror
Determining fastest mirrors
* base: mirrors.aliyun.com
* extras: ftp.sjtu.edu.cn
* updates: mirrors.ustc.edu.cn
base | 3.6 kB 00:00:00
docker-ce-stable | 3.5 kB 00:00:00
extras | 2.9 kB 00:00:00
gitlab_gitlab-ce-source/signature | 862 B 00:00:00
从 https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey 检索密钥
导入 GPG key 0x51312F3F:
用户ID : "GitLab B.V. (package repository signing key) <packages@gitlab.com>"
指纹 : 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 检索密钥
gitlab_gitlab-ce-source/signature | 951 B 00:00:03 !!!
kubernetes/signature | 454 B 00:00:00
kubernetes/signature | 1.4 kB 00:00:00 !!!
updates | 2.9 kB 00:00:00
(1/3): kubernetes/primary | 131 kB 00:00:00
(2/3): docker-ce-stable/7/x86_64/primary_db | 111 kB 00:00:01
(3/3): updates/7/x86_64/primary_db | 21 MB 00:00:01
gitlab_gitlab-ce-source/primary | 175 B 00:00:02
kubernetes 968/968
软件包 pygpgme-0.3-9.el7.x86_64 已安装并且是最新版本
无须任何处理
Installing yum-utils...
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: ftp.sjtu.edu.cn
* updates: mirrors.ustc.edu.cn
软件包 yum-utils-1.1.31-54.el7_8.noarch 已安装并且是最新版本
无须任何处理
Generating yum cache for gitlab_gitlab-ce...
导入 GPG key 0x51312F3F:
用户ID : "GitLab B.V. (package repository signing key) <packages@gitlab.com>"
指纹 : f640 3f65 44a3 8863 daa0 b6e0 3f01 618a 5131 2f3f
来自 : https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey
Generating yum cache for gitlab_gitlab-ce-source...
The repository is setup! You can now install packages.
# yum list | grep gitlab
gitlab-ce.x86_64 16.0.2-ce.0.el7 gitlab_gitlab-ce
# yum -y install gitlab-ce.x86_64
已加载插件: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) <packages@gitlab.com>"
指纹 : 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. <support@gitlab.com>"
指纹 : 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' #修改这一行数据值
# gitlab-ctl reconfigure
Running handlers:
[2023-06-07T12:02:30+08:00] INFO: Running report handlers
Running handlers complete
[2023-06-07T12:02:30+08:00] INFO: Report handlers complete
Infra Phase complete, 571/1589 resources updated in 07 minutes 58 seconds
Notes:
Default admin account has been configured with following details:
Username: root
Password: You didn't opt-in to print initial root password to STDOUT.
Password stored to /etc/gitlab/initial_root_password. This file will be cleaned up in first reconfigure run after 24 hours.
NOTE: Because these credentials might be present in your log files in plain text, it is highly recommended to reset the password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.
gitlab Reconfigured!
# gitlab-ctl start
# 常用命令
gitlab-ctl start # 启动所有 gitlab 组件
gitlab-ctl stop # 停止所有 gitlab 组件
gitlab-ctl restart # 重启所有 gitlab 组件
gitlab-ctl status # 查看服务状态
gitlab-ctl reconfigure # 启动服务
vim /etc/gitlab/gitlab.rb # 修改默认的配置文件
gitlab-rake gitlab:check SANITIZE=true --trace # 检查gitlab
gitlab-ctl tail # 查看日志
http://10.2.6.155/users/sign_in
root
# cat /etc/gitlab/initial_root_password
# WARNING: This value is valid only in the following conditions
# 1. If provided manually (either via `GITLAB_ROOT_PASSWORD` environment variable or via `gitlab_rails['initial_root_password']` setting in `gitlab.rb`, it was provided before database was seeded for the first time (usually, the first reconfigure run).
# 2. Password hasn't been changed manually, either via UI or via command line.
#
# If the password shown here doesn't work, you must reset the admin password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.
Password: cZ8wa9fZ8ZzQev5tnLCDocFwDbgIRkfvoq5pQm2CvKs=
# NOTE: This file will be automatically deleted in the first reconfigure run after 24 hours.
历史事件
2023-06-07|创建说明文档