如果需要汉化版本,请根据汉化来选择版本
汉化包下载地址:https://gitlab.com/xhang/gitlab/
1.依赖包安装
yum -y install policycoreutils-python openssh-server openssh-clients postfix wget curl
2.下载gitlab-ce并安装
# 下载安装包 https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-15.9.4-ce.0.el7.x86_64.rpm rpm -ivh gitlab-ce-15.9.4-ce.0.el7.x86_64.rpm
vim /etc/gitlab/gitlab.rb # 修改gitlab配置文件指定服务器ip和自定义端口,如果有需要可以修改数据存放路径 # 自定义IP和端口: external_url 'http://0.0.0.0:9981'
# 修改时区
gitlab_rails['time_zone'] = 'Asia/Shanghai' # 修改存储路径 # gitlab默认存储路径:/var/opt/gitlab/git-data # 修改为新路径:/db/gitlab/git-data git_data_dirs({ "default" => { "path" => "/db/gitlab/git-data", "failure_count_threshold" => "10", "failure_wait_time" => "30", "failure_reset_time" => "1800", "storage_timeout" => "30" } })
# qq发送邮件
gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.qq.com" gitlab_rails['smtp_port'] = 465 gitlab_rails['smtp_user_name'] = "xxxxx@qq.com" gitlab_rails['smtp_password'] = "xxxxxx" # qq授权码 gitlab_rails['smtp_domain'] = "qq.com" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_tls'] = true gitlab_rails['smtp_pool'] = false gitlab_rails['gitlab_email_enabled'] = true gitlab_rails['gitlab_email_from'] = 'xxx@qq.com' gitlab_rails['gitlab_email_display_name'] = 'Gitlab-Server-Admin' gitlab_rails['gitlab_email_subject_suffix'] = '9you'
# gitlab备份地址参数
gitlab_rails['backup_path'] = '/db/gitlab_backup/'
# 使用gitlab-ctl reconfigure 自动配置,并安装数据库,初始化信息 gitlab-ctl reconfigure
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-rake "gitlab:password:reset" Enter username: root Enter password: Confirm password: Password successfully updated for user with username root.
3.查看命令
# 检查状态 [root@gitlab gitlab]# gitlab-ctl status run: alertmanager: (pid 1598) 378s; run: log: (pid 16733) 3104s run: gitaly: (pid 1635) 375s; run: log: (pid 15387) 3247s run: gitlab-exporter: (pid 1591) 379s; run: log: (pid 16598) 3124s run: gitlab-kas: (pid 1571) 381s; run: log: (pid 15754) 3228s run: gitlab-workhorse: (pid 1582) 380s; run: log: (pid 16367) 3140s run: logrotate: (pid 383) 498s; run: log: (pid 15270) 3259s run: nginx: (pid 1247) 417s; run: log: (pid 16425) 3133s run: node-exporter: (pid 1275) 416s; run: log: (pid 16457) 3130s run: postgres-exporter: (pid 1626) 378s; run: log: (pid 16849) 3099s run: postgresql: (pid 461) 490s; run: log: (pid 15586) 3236s run: prometheus: (pid 1309) 411s; run: log: (pid 16676) 3110s run: puma: (pid 1146) 421s; run: log: (pid 16259) 3154s run: redis: (pid 394) 496s; run: log: (pid 15300) 3253s run: redis-exporter: (pid 1295) 412s; run: log: (pid 16622) 3116s run: sidekiq: (pid 1154) 420s; run: log: (pid 16292) 3146s # 检查问题 [root@gitlab gitlab]# gitlab-rake gitlab:check SANITIZE=true --trace # 记得注意端口,如果没问题,访问出现502的问题就再刷新下
# 测试邮件发送 [root@gitlab gitlab]# gitlab-rails console -------------------------------------------------------------------------------- Ruby: ruby 2.7.7p221 (2022-11-24 revision 168ec2b1e5) [x86_64-linux] GitLab: 15.9.4 (d6192c2ab77) FOSS GitLab Shell: 14.17.0 PostgreSQL: 13.8 ------------------------------------------------------------[ booted in 30.42s ] Loading production environment (Rails 6.1.7.2) irb(main):001:0>Notify.test_email('xx@qq.com', 'Subject', 'Message Body').deliver_now # 发送成功,如果发送失败,再看下邮件配置 Delivered mail 64365f0918938_677d4880216e0@iZuf671s2u2a1ivhvekjz5Z.mail (1014.8ms) => #<Mail::Message:295840, Multipart: false, Headers: <Date: Wed, 12 Apr 2023 15:34:33 +0800>, <From: Gitlab-Server-Admin <xxx@qq.com>>, <Reply-To: Gitlab-Server-Admin <noreply@gitlab>>,
<To: xxx@qq.com>, <Message-ID: <64365f0918938_677d4880216e0@iZuf671s2u2a1ivhvekjz5Z.mail>>, <Subject: Subject>, <Mime-Version: 1.0>, <Content-Type: text/html; charset=UTF-8>, <Content-Transfer-Encoding: 7bit>,
<Auto-Submitted: auto-generated>, <X-Auto-Response-Suppress: All>> # 如果失败,修改好邮件配置后重新执行 gitlab-ctl reconfigure gitlab-ctl restart
4.gitlab服务
gitlab-ctl stop --停止服务 gitlab-ctl reconfigure --启动服务 gitlab-ctl start --启动所有gitlab组件 gitlab-ctl restart 重启
5.访问页面
http://192.168.1.1:9981/
6.页面配置
(1) 设置为中文界面
(2) 添加项目组和成员
(3) 创建项目
7.项目检出,上传,修改
8.手动进行gitlab备份
mkdir /db/gitlab_backup # 备份命令,warning报警可以不管 gitlab-rake gitlab:backup:create
9.gitlab备份数据恢复
# Gitlab的恢复只能恢复到与原本备份文件相同的gitlab版本中,恢复时,需要停止数据库写入操作,但是保持gitlab时运行的 # 暂停数据写入,停止会连接数据库的服务 gitlab-ctl stop unicorn gitlab-ctl stop sidekiq gitlab-ctl stop nginx # 查看是否停止 gitlab-ctl status | grep down # 进行数据恢复,整个恢复过程基本时删表、创建表 ll /db/gitlab_backup/1667474494_2022_07_11_12.0.3_gitlab_backup.tar # 恢复命令,只需要填写备份文件的时间戳信息即可 gitlab-rake gitlab:backup:restore BACKUP=1667474494_2022_07_11_12.0.3 # 中间点yes,结束提示 Restore task is donw # 最后一步重新读取配置,确认gitlab可以访问 gitlab-ctl reconfigure gitlab-ctl restart # 将关闭的服务全部重新启动 # 验证数据