同步系統時間服務器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