2024-07-12
한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina
Table of contents
1. Modify the administrator password via Gitlab command line
3. The company's development code submission process
- [root@tty01 ~]# gitlab-rails console -e production # 启动GitLab的Rails控制台
- --------------------------------------------------------------------------------
- Ruby: ruby 3.1.4p223 (2023-03-30 revision 957bb7cb81) [x86_64-linux]
- GitLab: 16.11.5-jh (3a067aedcc3) EE
- GitLab Shell: 14.35.0
- PostgreSQL: 14.11
- ------------------------------------------------------------[ booted in 50.69s ]
- Loading production environment (Rails 7.0.8.1)
- irb(main):001:0> user = User.where(id: 1).first # id为1的是超级管理员
- => #<User id:1 @root>
- irb(main):002:0> user.password = 'Qq111111' # 密码必须至少8个字符
- => "Qq111111"
- irb(main):003:0> user.save! # 如没有问题 返回true
- => true
- irb(main):004:0> exit # 退出
- gitlab-ctl start # 启动所有 gitlab 组件;
- gitlab-ctl stop # 停止所有 gitlab 组件;
- gitlab-ctl restart # 重启所有 gitlab 组件;
- gitlab-ctl status # 查看服务状态;
- gitlab-ctl reconfigure # 启动服务;
- vim /etc/gitlab/gitlab.rb # 修改默认的配置文件;
- gitlab-ctl tail # 查看日志;
Project managers (PMs) create tasks in GitLab and assign them to developers:
After the developer receives the task, he uses git clone to pull the code base locally:
git clone <仓库地址>
Developers create development branches and carry out development:
dev
: git checkout -b dev
dev
Code development and modification are performed on branches.After the developer completes the development, submit it to the local warehouse:
git add . git commit -m "完成任务描述"
Developers apply for a branch merge request on the GitLab interface:
git push origin dev
master
ormain
)。PM checks the submission and code modification status on GitLab, and after confirming that everything is correct, confirms to merge the developer's branch into the main branch:
dev
Merge branch intomaster
Branch.The developer confirms the development is complete by clicking Mark done on GitLab and closes the Issue.:
close #1
(in#1
is the Issue number), so that when the Merge Request is merged, the related Issue will be automatically closed.
Check the system version and software version
- [root@tty01 ~]# cat /etc/redhat-release
- Rocky Linux release 9.4 (Blue Onyx)
- [root@tty01 ~]# cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
- 16.11.5-jh
Open the /etc/gitlab/gitlab.rb configuration file and view a configuration item related to backup:
- [root@tty01 ~]# vim /etc/gitlab/gitlab.rb #启用下述两个配置项
- gitlab_rails['manage_backup_path'] = true #指定GitLab是否应该自动管理备份路径
- gitlab_rails['backup_path'] = "/var/opt/gitlab/backups" #指定GitLab备份文件的存储路径
This item defines the default backup file path. You can modify this configuration and execute gitlab-ctl reconfigure or gitlab-ctl restart Restart the service to take effect.
- [root@tty01 ~]# gitlab-ctl reconfigure
- 或
- [root@tty01 ~]# gitlab-ctl restart
Execute the backup command to back up
[root@tty01 ~]# gitlab-rake gitlab:backup:create
After executing the command, there will be a warning prompt:gitlab.rb
andgitlab-secrets.json
The files contain sensitive data and are not included in this backup. When restoring the backup, you will need to back up these files manually.
Of course, these can also be combined with planned tasks.
Check whether the files in the backup directory exist normally.
- [root@tty01 ~]# ls /var/opt/gitlab/backups/
- 1720624341_2024_07_10_16.11.5-jh_gitlab_backup.tar
Set the backup retention period to prevent daily backups. There is definitely a risk of the directory being full. Open the /etc/gitlab/gitlab.rb configuration file and find the following configuration:
- [root@tty01 ~]# vim /etc/gitlab/gitlab.rb # 启用下述两个配置项
- gitlab_rails['backup_keep_time'] = 604800 # 设置备份文件过期时间,604800秒等于7天
The configuration time is in seconds. If you want to increase or decrease it, you can configure it directly here and restart the service through gitlab-ctl restart to take effect.
After the backup is completed, a tarball with today's date will be generated in the backup directory.
Log in as an administrative user and delete the library project
You need to stop the data connection service before restoring:
- [root@tty01 ~]# gitlab-ctl stop unicorn
- [root@tty01 ~]# gitlab-ctl stop sidekiq
If it is a newly built host, there is generally no need to stop the data connection operation. In theory, it is also OK to not stop these two services. Stopping these two services is to ensure data consistency. Generally, the backup files in the old server's /data/gitlab/backups directory are copied to the new server's /data/gitlab/backups for restoration. Here, the experimental environment is restored on this machine.
Note: 600 permissions cannot be restored. The experimental environment can be changed to 777, and the production environment is recommended to change the owner and group
After executing the command, wait for a while..., then enter yes twice to complete the recovery.
- [root@tty01 ~]# cd /var/opt/gitlab/backups/ #进入数据备份目录
- [root@tty01 backups]# gitlab-rake gitlab:backup:restore BACKUP=1720624341_2024_07_10_16.11.5-jh
Note the file name after BACKUP=. In newer versions, you cannot use the full name. _gitlab_backup.tarh will be added automatically, so you cannot write the dot after the file name.
After the recovery is complete, restart all services, or just start the two data connection services that were shut down earlier.
- [root@tty01 backups]# gitlab-ctl restart
- 或
- [root@tty01 backups]# gitlab-ctl start unicorn
- [root@tty01 backups]# gitlab-ctl start sidekiq
Note: When restoring gitlab through backup files, the gitlab versions of the two hosts must be consistent, otherwise a version mismatch will be prompted
At this time, refresh or log in again to see the deleted data
Please change it to your email address, mail service provider, authorization code, port and other information
- [root@tty01 ~]# vim /etc/gitlab/gitlab.rb #找到并替换邮箱配置,更改你的邮箱进行测试
- gitlab_rails['smtp_enable'] = true
- gitlab_rails['smtp_address'] = "smtp.163.com"
- gitlab_rails['smtp_port'] = 465
- gitlab_rails['smtp_user_name'] = "[email protected]"
- gitlab_rails['smtp_password'] = "UWYNCPQOBQFCDLIW"
- gitlab_rails['smtp_domain'] = "smtp.163.com"
- gitlab_rails['smtp_authentication'] = "login"
- gitlab_rails['smtp_enable_starttls_auto'] = false
- gitlab_rails['smtp_tls'] = true
- gitlab_rails['smtp_pool'] = false
- gitlab_rails['gitlab_email_from'] = '[email protected]'
After setting, save and exit, then reload the configuration.
[root@tty01 ~]# gitlab-ctl reconfigure #重新配置 GitLab 服务
Log in to the web page and log in as a random user. Previously, we used a random email format. Now we change it to our real email to test our email configuration.
After you click Save, a pop-up window will pop up asking you to go to your mailbox and click Confirm to verify.
When I come to the mailbox, I can see that the sender is a QQ mailbox I filled in the configuration, and a verification is sent to the mailbox changed by the user.
Clicking Verify will redirect to a new page where you can see that the user has successfully changed their email address.