Github版本管理以及git使用
1.git客户端编译安装
同步系统时间服务器
ntpdate cn.ntp.org.cn
安装依赖包:
[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
编译安装高版本git
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版本
[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推送到线上
[root@baolin git_test]# git push origin --tags
删除本地版本tag -d
[root@baolin git_test]# git tag -d v1.0
Deleted tag 'v1.0' (was 13db2c6)
推送的空的同名版本到线上,达到删除线上版本的目标:
[root@baolin git_test]# git push origin :refs/tags/v1.0
通过tag获取指定版本的代码
[root@baolin git_test]# git fetch origin tag v1.0
2.安装gitlab版本厂库
1.安装依赖关系
[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 进入控制台
3.页面配置gitlab组权限
- 登录Gitlab 用户root
- 创建 Groups 组
- 创建 Users 用户
- 创建 Projects 项目
- 将用 user 户加入到 projects 中,并设置权限
- 添加用户 key 用于免秘钥 下载代码
- Deploy key 只能下载代码不能上传代码,一般给Jenkins使用
4.gitlab的备份与恢复【全量包括用户关系】
修改后需要: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
5.性能监控
查看当前数据任务
http://192.8.21.100/admin/background_jobs
Github版本管理以及git使用的更多相关文章
- linux系统下使用流行的版本管理工具 Git
前几天被版本管理困扰了好久,主要是因为 没法回到之前的版本,新版本又出了问题真的很尴尬. 终于决定使用目前网上很火的版本管理工具-------Git 历史啥的就不说了,说些有用的. 我用的是oschi ...
- Studio之版本管理工具Git (图文教程)
目前业界主流的版本管理工具主要是 svn/git.svn是1种集中式的代码管理工具,而git是1种散布式的代码管理工具,广受极客的爱好.而基于git的github更是全宇宙码农的提高逼格,深究技术的必 ...
- 版本管理工具Git(1)带你认识git
简介 本篇将带领大家认识,git.github,让大家对git有基本的认识:下面将持续更新几篇文章来介绍git,见git导航: 下一篇中将讲解git的安装及使用: Git系列导航 版本管理工具Git( ...
- 版本管理工具Git(2)git的安装及使用
下载安装git 官方下载地址:https://git-scm.com/download/win 这里以windows为例,选择正确的版本: 验证是否安装成功,右键菜单中会出现如下菜单: Git工作流程 ...
- 版本管理工具Git(一)简要介绍
版本管理工具不但可以备份而且还能记录版本,也就是同一个东西不同时期的状态同时可以跟踪追溯.版本管理工具由CVS.SVN.Git.GitHub. 最早的版本管理工具CVS,因为多人开发项目导致工作很难协 ...
- 版本管理工具Git(2)git的使用
上一篇带大家认识了Git,在本篇中将讲解Git的安装及使用: Git系列导航 版本管理工具Git(1)带你认识git 版本管理工具Git(2)git的安装及使用 版本管理工具Git(3)VS下如何使用 ...
- 版本管理工具Git(3)VS2013下如何使用git
Git系列导航 版本管理工具Git(1)带你认识git 版本管理工具Git(2)git的安装及使用 版本管理工具Git(3)VS下如何使用git VS下创建项目 vs中新建项目MyGitTest201 ...
- 码农的好助手:版本管理工具git的使用
一.什么是github? GitHub 是一个面向开源及私有软件项目的托管平台,因为只支持 Git 作为唯一的版本库格式进行托管,故名 GitHub. GitHub 于 2008 年 4 月 10 日 ...
- git学习笔记04-将本地仓库添加到GitHub远程仓库-git比svn先进的地方
第1步:创建SSH Key.在用户主目录下,看看有没有.ssh目录,如果有,再看看这个目录下有没有id_rsa和id_rsa.pub这两个文件,如果已经有了,可直接跳到下一步. 如果没有,打开Shel ...
随机推荐
- Debian9 使用 Docker 安装 gitlab完整过程
一. 安装Docker CE (参考 官网指南) 1. 卸载老版本 sudo apt-get remove docker docker-engine docker.io 2. Update the ...
- 【Shell】30分钟关闭Tcpdump,开启Tcpdump、检测目录大小终止任务
场景 按照一定时间规律运行Tcpdump 思路 编程思路细化思考 查看文件个数 file_count_results=`ls -al "C:\\Users\\Windows32\\Deskt ...
- Python运维开发基础04-语法基础【转】
上节作业回顾(讲解+温习90分钟) #!/usr/bin/env python3 # -*- coding:utf-8 -*- # author:Mr.chen # 仅用列表+循环实现“简单的购物车程 ...
- C++学习day1
1. 有符号整数 对于有符号整数,最高位为0表示正数,为1表示负数 负数的绝对值为除最高位外,其余取反再加1 int 字节数:4,取值范围:-232~232-1 最大值为232-1 最小值即为 000 ...
- npm 安装 sass-loader 失败的解决办法
You got to add python to your PATH variable. One thing you can do is Edit your Path variable now and ...
- 用函数SendARP()获取局域网计算机的MAC地址
sendARP 31 说明对方没有开机,我们的函数检测不到它, 1784 说明的给函数的最后一个参数的值是0,或你的给的值与你给的缓存区大小不符合. 如果返回31不在线,则最后一个参数指针指向的值赋值 ...
- PHP JSON 数据解析代码
作者: 字体:[增加减小] 类型:转载 PHP解析JSON 数据代码,与大多数流行的 Web 服务如 twitter .人人网通过开放 API 来提供数据一样,它总是能够知道如何解析 API 数据 ...
- 浏览器开启桌面通知Web Notification
本文主要描述如何开启各个浏览器的桌面通知功能 一.谷歌浏览器(chrome) 点击地址栏前面的图标
- Nginx和apache服务器中php运行方式
PHP5的CGI方式的一大优势是内置了FastCGI的支持,只需指明绑定的地址和端口参数便可以以FastCGI的方式运行,如下: php-cgi -b 127.0.0.1:9000 配置Nginx的P ...
- TCP与UDP区别小结
TCP(Transmission Control Protocol):传输控制协议 UDP(User Datagram Protocol):用户数据报协议 主要从连接性(Connectiv ...