同步系统时间服务器html
ntpdate cn.ntp.org.cn
安装依赖包:java
[root@baolin ~]# yum install epel-release -y [root@baolin ~]# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker -y
编译安装高版本gitpython
wget https://github.com/git/git/archive/v2.7.4.zip unzip v2.7.4.zip cd git-2.7.4/ make prefix=/usr/local/git all make prefix=/usr/local/git install rm -fr /usr/bin/git ln -s /usr/local/git/bin/git /usr/bin/git git --version
在commit后能够对当次提交作一个tag版本nginx
[root@baolin git_test]# git tag -a v1.0 -m "注释内容" [root@baolin git_test]# git tag v1.0 # -d 删除指定标签 [root@baolin git_test]# git tag -d v1.0 Deleted tag 'v1.0' (was 07032f1)
把本地版本tag推送到线上git
[root@baolin git_test]# git push origin --tags
删除本地版本tag -dgithub
[root@baolin git_test]# git tag -d v1.0 Deleted tag 'v1.0' (was 13db2c6)
推送的空的同名版本到线上,达到删除线上版本的目标:redis
[root@baolin git_test]# git push origin :refs/tags/v1.0
经过tag获取指定版本的代码sql
[root@baolin git_test]# git fetch origin tag v1.0
1.安装依赖关系shell
[root@baolin git_test]# yum install curl policycoreutils openssh-server openssh-clients policycoreutils-python -y [root@baolin git_test]# systemctl enable sshd [root@baolin git_test]# systemctl start sshd [root@baolin git_test]# systemctl enable postfix [root@baolin git_test]# systemctl start postfix
2.下载安装数据库
地址:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/ [root@baolin git_test]# wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-10.6.6-ce.0.el7.x86_64.rpm [root@baolin git_test]# rpm -ivh gitlab-ce-10.6.6-ce.0.el7.x86_64.rpm
3.修改配置文件并启动
[root@baolin git_test]# vim /etc/gitlab/gitlab.rb #external_url 'http://gitlab.example.com' # 访问地址,若是用域名访问,此处应该使用域名地址 external_url 'http://192.8.21.100' # 自动化组件安装(并启动) [root@baolin git_test]# gitlab-ctl reconfigure # 组件日志所在目录 [root@baolin gitlab]# pwd /var/log/gitlab
4.Gitlab经常使用管理命令
# 查看 各组件状态 gitlab-ctl status # 启动 gitlab-ctl start # 关闭 gitlab-ctl stop # 重启 gitlab-ctl restart # 查看nginx 日志 gitlab-ctl tail nginx # 备份命令 gitlab-rake gitlab:backup:create
5.Gitlab 经常使用组件
- nginx:静态Web服务器 - gitlab-shell:用于处理Git命令和修改authorized keys列表 - gitlab-workhorse:轻量级的反向代理服务器 - logrotate:日志文件管理工具 - postgresql:数据库 - redis:缓存数据库 - sidekiq:用于在后台执行队列任务(异步执行) - unicorn:GitLab Rails 应用是托管在这个服务器上的
6.目录结构
- /var/opt/gitlab/git-data/repositories/ :库默认存储目录 - /opt/gitlab :应用代码和相应的依赖程序 - gitlab-ctl reconfigure : 命令编译后的应用数据和配置文件,不须要认为的修改配置 - /etc/gitlab :配置文件目录 - /var/log/gitlab :此目录下存放了gitlab各个组件产生的日志 - /var/opt/gitlab/backups :备份文件生成的目录
变动主配置文件
- gitlab-ctl reconfigure 重置配置文件 - gitlab-ctl show-config 验证配置文件 - gitlab-ctl restart 重启gitlab服务 - gitlab-rails console 进入控制台
修改后须要:gitlab-ctl reconfigure 更新配置 并 执行 gitlab-ctl restart 重启服务
1.配置备份路径
# 须要有git 用户权限 [root@baolin app1]# vim /etc/gitlab/gitlab.rb gitlab_rails['backup_path'] = "/var/opt/gitlab/backups"
2.配置备份保存时间
# 默认保存时间 7 天,此处为 30天 gitlab_rails['backup_keep_time'] = 2592000
3.备份当前现有gitlab数据
[root@baolin app1]# gitlab-rake gitlab:backup:create # 查看备份数据 [root@baolin app1]# ll -sh /var/opt/gitlab/backups 80K -rw------- 1 git git 80K Jun 6 16:38 1528274316_2018_06_06_10.6.6_gitlab_backup.tar
4.添加备份的计划任务
0 2 * * * /usr/bin/gitlab-rake gitlab:backup:create
5.恢复数据
# 关闭 unicorn 和 sidekiq 服务 [root@baolin app1]# gitlab-ctl stop unicorn [root@baolin app1]# gitlab-ctl stop sidekiq # 切换至 备份文件所在目录 [root@baolin backups]# cd /var/opt/gitlab/backups [root@baolin backups]# pwd /var/opt/gitlab/backups # 执行恢复文件 文件名为 "时间戳加时间段" 名称 [root@baolin backups]# gitlab-rake gitlab:backup:restore BACKUP=1528274316_2018_06_06_10.6.6 # 重启服务 【30秒等待】 [root@baolin backups]# gitlab-ctl restart
6.只备份版本库
# 版本库路径 [root@baolin repositories]# pwd /var/opt/gitlab/git-data/repositories # 手动打包代码库 [root@baolin repositories]# ls java [root@baolin repositories]# tar zcf /data/git_bak.tar.gz ./
1.参考邮件配置:
https://docs.gitlab.com.cn/omnibus/settings/smtp.html#qq-exmail
2.邮件验证:gitlab-rails console
#配置完成后能够用Rails控制台验证邮件是否能发送成功。 在GitLab服务器上,执行 gitlab-rails console 进入控制台。 而后在控制台提示符后输入下面的命令 发送一封测试邮件: irb(main):003:0> Notify.test_email('destination_email@address.com', 'Message Subject', 'Message Body').deliver_now # 示例 Notify.test_email('收件人邮箱', '邮件标题', '邮件正文').deliver_now
查看当前数据任务
http://192.8.21.100/admin/background_jobs