先决条件
硬件要求
CPU - 最低4核,最多支持500个用户。
内存 - 最低4GB,最多支持500个用户。
存储 - 如果有足够的CPU和内存,Gitlab的速度主要受硬盘寻道时间的限制,推荐使用7200转以上机械盘或者固态硬盘。可以使用NFS,但不建议使用网络文件系统,因为会影响性能。
软件要求
PostgreSQL - PostgreSQL是唯一受支持的数据库,Gitlab 12.1删除了对Mysql的支持。PostgreSQL与 Omnibus GitLab 包捆绑在一起,也可以使用外部PostgreSQL数据库。
Redis - Gitlab 13.0以及更高版本,需要Redis 5.0以上版本。建议是用Redis 6.0以上版本,因为这是 从 GitLab 13.9 开始的Omnibus GitLab软件包附带的。Redis 存储所有用户会话和后台任务队列。Redis 的存储需求很小,每个用户大约 25kB。
Prometheus - 默认启用,以对Gitlab进行监控。在默认配置下,进程大约需要消耗200MB内存。
Gitlab Runner - 如果使用Gitlab的CI功能,建议降Gitlab Runner分开部署。因为Gitlab Runner会消耗大量内存。
安装gitlab-15.3.2(Omnibus)
什么是Omnibus Gitlab?
Omnibus GitLab 是 Chef 的 Omnibus 项目的定制分支,它使用 Chef 组件来执行在用户计算机中配置 GitLab 的任务。
Gitlab本身拥有众多组件,这些组件的确实或者配置不正确,都会导致Gitlab无法正常运行。所以具有捆绑依赖项的软件包(Omnibus Gitlab)可以减少安装时候的工作量。
下载安装包
gitlab/gitlab-ce - Packages · packages.gitlab.com
安装
rpm -ivh gitlab-ce-15.3.2-ce.0.el7.x86_64.rpm
初始密码位置:/etc/gitlab/initial_root_password
此密码只保留24小时,尽快登陆root账号修改密码。
修改配置文件
#访问gitlab的ip:端口,也可以是域名
external_url 'http://${ip}:${port}'
#gitlab 文件备份位置
gitlab_rails['backup_path'] = "${backup_file_path}"
#gitlab数据目录
git_data_dirs({
"default" => {
"path" => "${git_data_dir}"
}
})
#postgresql 数据目录
postgresql['dir'] = "${postgresql_data_path}"
#postgresql 日志目录
postgresql['log_directory'] = "${postgresql_log_path}"
#gitlab-psql 用户家目录
postgresql['home'] = "${postgresql_user_home_path}"
#prometheus 日志目录
prometheus['log_directory'] = '${prometheus_log_path}'
#prometheus 规则目录
prometheus['rules_files'] = ['${prometheus_rules_path}']
#prometheus 监听地址
prometheus['listen_address'] = '0.0.0.0:9090'
生效配置文件
gitlab-ctl reconfigure
访问gitlab修改初始密码