gitlab常用操作
【摘要】 安装安装docker准备docker-compose.yml文件web: image: 'gitlab/gitlab-ce:11.0.3-ce.0' restart: always hostname: 'gitlab.example.com' environment: GITLAB_OMNIBUS_CONFIG: | external_url 'http://5.25...
安装
准备docker-compose.yml文件
web: image: 'gitlab/gitlab-ce:11.0.3-ce.0' restart: always hostname: 'gitlab.example.com' environment: GITLAB_OMNIBUS_CONFIG: | external_url 'http://5.25.24.16:6100' gitlab_rails['gitlab_shell_ssh_port'] = 6101 gitlab_rails['gitlab_email_from'] = 'pro@szfangle.com' gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.szfangle.com" gitlab_rails['smtp_port'] = 25 gitlab_rails['smtp_user_name'] = "pro@szfangle.com" gitlab_rails['smtp_password'] = "123456" gitlab_rails['smtp_domain'] = "smtp.szfangle.com" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_tls'] = false ports: - '6100:6100' - '6101:22' volumes: - '/srv/gitlab/config:/etc/gitlab' - '/srv/gitlab/logs:/var/log/gitlab' - '/srv/gitlab/data:/var/opt/gitlab'
启动
docker-compose up -d
手动备份
sudo gitlab-rake gitlab:backup:create
默认备份文件在目录/var/opt/gitlab/backups/
下
还原
假设备份文件包名为
1531608284_2018_07_15_11.0.3_gitlab_backup.tar
拷贝备份文件到
/var/opt/gitlab/backups/
目录下,如果是docker安装,可拷贝到挂在点上还原文件
export time_stamp=1531608284_2018_07_15_11.0.3 sudo gitlab-ctl stop unicorn sudo gitlab-ctl stop sidekiq chown git:git ${time_stamp}_gitlab_backup.tar sudo gitlab-ctl start sudo gitlab-rake gitlab:check SANITIZE=truesudo gitlab-rake gitlab:backup:restore BACKUP=${time_stamp}
如果是docker安装,可使用
docker exec -it xxxxxx bash
进入容器,执行相关命令;
升级gitlab
备份 (可选),备份好的数据保存在目录
/var/opt/gitlab/backups
下
sudo gitlab-rake gitlab:backup:create STRATEGY=copy
升级
sudo yum install -y gitlab-ce #社区版运行该命令# sudo yum install -y gitlab-ee #企业版运行该命令
配置邮箱
这里邮箱是我们公司邮箱配置,更多配置说明见官网vim /etc/gitlab/gitlab.rb
### GitLab email server settingsgitlab_rails['gitlab_email_from'] = 'pro@szfangle.com'gitlab_rails['smtp_enable'] = truegitlab_rails['smtp_address'] = "smtp.szfangle.com"gitlab_rails['smtp_port'] = 25 gitlab_rails['smtp_user_name'] = "pro@szfangle.com"gitlab_rails['smtp_password'] = "PASWORD"gitlab_rails['smtp_domain'] = "smtp.szfangle.com"gitlab_rails['smtp_authentication'] = "login"gitlab_rails['smtp_enable_starttls_auto'] = truegitlab_rails['smtp_tls'] = false
设置外网端口
修改配置文件
/etc/gitlab/gitlab.rb
修改如下:
# external_url "http://gitlab.example.com"external_url 'http://10.200.80.255:8081'nginx['listen_port'] = 8081
重置配置
sudo gitlab-ctl reconfigure sudo gitlab-ctl restart
自动备份
安装软件
apt-get -y install crontabs
准备文件 /var/opt/gitlab/auto_backup.sh
#!/bin/bashcd /srv/ tar -czf gitlab_$(date +"%Y%m%d").tar.gz gitlab find "/srv/" -name "*.tar.gz" -ctime +31 -type f -exec rm -rf {} \;
chmod +x /var/opt/gitlab/auto_backup.sh
crontab -e
配置每周日1点备份
* 1 * * 0 /srv/backup.sh
【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)