缺省安装后的一些重要信息
- 程序目录在:
/opt/gitlab
- 文件数据在:
/var/opt/gitlab
- git repo目录在:
/var/opt/gitlab/git-data
- 上传图片目录在:
/var/opt/gitlab/uploads
- 大文件、二进制文件目录在:
/var/opt/gitlab/gitlab-rails/shared/lfs-objects
- 备份文件目录在:
/var/opt/gitlab/backups
- 使用的本地模式运行的postgresql数据,会随gitlab启动时候自动运行,
socket模式没有监听端口
- 默认生成的配置文件位置:
/var/opt/gitlab/gitlab-rails/etc
- 使用本地运行的redis服务,会随gitlab启动时候自动运行
socket
- 缺省利用本地邮件,自动投递给其他服务器,如果是非互联网ip,可以修改为本地smtp方式
- 修改ssh服务的git账号入口,git账号的登录shell处理为gitlab-shell
- 自带nginx,缺省会在所有ip地址的80端口监听请求,请求会转发给ruby进程
管理
所有组件状态 |
查看版本信息
gitlab-rake gitlab:env:info RAILS_ENV=production
System information
System: CentOS 6.5
Current User: git
Using RVM: no
Ruby Version: 2.3.3p222
Gem Version: 2.6.6
Bundler Version:1.13.7
Rake Version: 10.5.0
Redis Version: 3.2.5
Git Version: 2.13.4
Sidekiq Version:5.0.0
Go Version: unknown
GitLab information
Version: 9.4.5
Revision: 140292e
Directory: /opt/gitlab/embedded/service/gitlab-rails
DB Adapter: postgresql
URL: http://gitlab.sh.45.com
HTTP Clone URL: http://gitlab.sh.45.com/some-group/some-project.git
SSH Clone URL: git@gitlab.sh.45.com:some-group/some-project.git
Using LDAP: no
Using Omniauth: no
GitLab Shell
Version: 5.3.1
Repository storage paths:
- default: /var/opt/gitlab/git-data/repositories
Hooks: /opt/gitlab/embedded/service/gitlab-shell/hooks
Git: /opt/gitlab/embedded/bin/git
数据库同步所有历史信息
gitlab-rake db:migrate:status RAILS_ENV=production
database: gitlabhq_production |
汉化
确认GitLab版本
cat /opt/gitlab/embedded/service/gitlab-rails/VERSION |
克隆代码
mkdir -p /opt/gitlab-zh |
比较汉化分支和原分支导出文件
git diff origin/9-4-stable 9-4-stable-zh > /opt/gitlab-zh/9.4.diff |
补丁
cd /opt/gitlab-zh |
备份恢复
https://docs.gitlab.com/ce/raketasks/backup_restore.html
备份
# 定时备份 |
/etc/gitlab/gitlab.rb
gitlab_rails['backup_keep_time'] = 604800 # 一周, 默认为0
恢复
首先进入备份 gitlab 的目录
,这个目录是配置文件中的gitlab_rails[‘backup_path’],默认为/var/opt/gitlab/backups
.
然后停止 unicorn 和 sidekiq ,保证数据库没有新的连接,不会有写数据情况。sudo gitlab-ctl stop unicorn
ok: down: unicorn: 0s, normally up
sudo gitlab-ctl stop sidekiq
ok: down: sidekiq: 0s, normally up
查看备份文件时间戳, 1502957534_2017_08_17_9.4.5
为备份文件的时间戳 恢复
ls /var/opt/gitlab/backups
1503395474_2017_08_22_9.4.5_gitlab_backup.tar
gitlab-rake gitlab:backup:restore BACKUP=1502957534_2017_08_17_9.4.5
数据迁移
首先需要暂停服务,避免用户在迁移期间读写数据:gitlab-ctl stop
rsync -av /var/opt/gitlab/git-data/repositories /path/to/git-data/
sudo gitlab-ctl start
sudo gitlab-ctl reconfigure
pgsql修改
极少情况下需要修改(修改最大权限示例) |
清缓存
清空redis缓存 |
大型文件、二进制文件对象相关
https://docs.gitlab.com/ce/workflow/lfs/manage_large_binaries_with_git_lfs.html
https://docs.gitlab.com/ce/workflow/lfs/lfs_administration.html
Gitaly RPC调用配置
存储服务等配置
默认情况下开启
https://docs.gitlab.com/ce/administration/gitaly/index.html/etc/default/gitlab
添加 gitaly_enabled=false
,重载配置生效
监控
白名单
/etc/gitlab/gitlab.rb
谁能访问gitlab_rails['monitoring_whitelist'] = ['127.0.0.0/8', '192.168.0.1']
Admin area ➔ Monitoring ➔ Health check (admin/health_check
)
https://gitlab.example.com/-/readiness?token=ACCESS_TOKEN |
Prometheus 监控
默认开启
监听地址为localhost
/etc/gitlab/gitlab.rb
修改配置文件禁用此服务
prometheus_monitoring['enable'] = false |
https://docs.gitlab.com/ce/administration/monitoring/prometheus/index.html
设置redis session过期
rcli() { |
# Tell Redis to expire each matched key after 600 seconds. |
CHECK
当前配置是否有问题
sudo gitlab-rake gitlab:check |
检查git仓库
dangling commit 检查是否有悬空的提交 |
https://docs.gitlab.com/ce/administration/raketasks/ldap.html#check
https://docs.gitlab.com/ce/administration/repository_checks.html、
Performance
- Housekeeping: Keep your Git repository tidy and fast.
- Operations: Keeping GitLab up and running.
- Polling: Configure how often the GitLab UI polls for updates.
- Request Profiling: Get a detailed profile on slow requests.
- Performance Bar: Get performance information for the current page
存储路径配置
https://docs.gitlab.com/ce/administration/repository_storage_paths.html
升级参考地址
http://interprism.hatenablog.com/entry/gitlab6to8
http://theterminallife.com/migrating-gitlab-to-gitlab-omnibus/