gitlab服務器安裝

一、示例主機信息:linux

hostname:vm0.lansgg.comnginx

ip        :    192.168.85.128git

Os        : centos 6.5 x64vim

gitlab版本:  gitlab-ce-8.7.0-ce.0.el6.x86_64.rpmcentos

Ps : 關閉 iptables selinuxbash

二、系統依賴軟件安裝ssh

root@vm0 ~]# yum install curl openssh-server openssh-clients  cronie –y

三、安裝gitlabcurl

[root@vm0 ~]# rpm -vhi gitlab-ce-8.7.0-ce.0.el6.x86_64.rpm 
Preparing...                ########################################### [100%]
   1:gitlab-ce              ########################################### [100%]
gitlab: Thank you for installing GitLab!
gitlab: To configure and start GitLab, RUN THE FOLLOWING COMMAND:

sudo gitlab-ctl reconfigure

gitlab: GitLab should be reachable at http://vm0.lansgg.com
gitlab: Otherwise configure GitLab for your system by editing /etc/gitlab/gitlab.rb file
gitlab: And running reconfigure again.
gitlab: 
gitlab: For a comprehensive list of configuration options please see the Omnibus GitLab readme
gitlab: https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
gitlab: 
It looks like GitLab has not been configured yet; skipping the upgrade script.
[root@vm0 ~]#

3.一、初始化
ide

[root@vm0 ~]# gitlab-ctl reconfigure

到此安裝成功:gitlab

地址:http://192.168.85.128/

默認用戶名是 root , 密碼是 5iveL!fe

登錄後會提示修改當前管理員密碼

四、設置https

建立ssl證書目錄

[root@vm0 ~]# mkdir -p /etc/gitlab/ssl
[root@vm0 ~]# cd /etc/gitlab/ssl/
[root@vm0 ssl]# ll
總用量 8
-rw-r--r--. 1 root root 1444 9月   7 16:16 vm0.lansgg.com.crt
-rw-r--r--. 1 root root 1704 9月   7 16:16 vm0.lansgg.com.key
[root@vm0 ssl]#

4.一、修改git配置項中的ssl證書文件地址     #/etc/gitlab/gitlab.rb(#大約是477行)

11 external_url '
472  nginx['enable'] = true
473  nginx['client_max_body_size'] = '250m'
474  nginx['redirect_http_to_https'] = false
475 # nginx['redirect_http_to_https_port'] = 80
476  nginx['ssl_client_certificate'] = "/etc/gitlab/ssl/vm0.lansgg.com.crt"
477  nginx['ssl_certificate'] = "/etc/gitlab/ssl/vm0.lansgg.com.crt"

wKioL1fPzhOS90LRAABeko6ArO4912.jpg-wh_50

4.二、修改nginx配置文件

38 server {
 39   listen *:443;
 40   ssl on;
 41   ssl_certificate /etc/gitlab/ssl/vm0.lansgg.com.crt;
 42   ssl_certificate_key /etc/gitlab/ssl/vm0.lansgg.com.key;

wKiom1fPzqGwCYj2AAAps_98CtY988.jpg-wh_50

4.三、配置http跳轉https

[root@vm0 ssl]# vim /var/opt/gitlab/nginx/conf/index.conf            ###新建
server {
    listen *:80;
    server_name www.abc.com;
  
    rewrite ^(.*)$  https://$host$1 permanent;
}

wKiom1fPzwyz__gqAAAnVI1TsZQ705.jpg-wh_50

4.四、修改配置文件載入index.conf

配置文件地址:/var/opt/gitlab/nginx/conf/nginx.conf,在其中加入如下內容

include/var/opt/gitlab/nginx/conf/index.conf;
include/var/opt/gitlab/nginx/conf/gitlab-http.conf;

4.五、重啓服務

以上操做所有完成以後, 使用gitlab-ctl restart來重啓全部服務, 便可使用HTTPS訪問GitLab了.

https://192.168.85.128 

https://vm0.lansgg.com


五、gitlab的備份與還原

5.一、gitlab的備份

使用Gitlab一鍵安裝包安裝Gitlab很是簡單, 一樣的備份恢復與遷移也很是簡單. 使用一條命令便可建立完整的Gitlab備份:

[root@vm0 ssl]# gitlab-rake gitlab:backup:create

使用以上命令會在/var/opt/gitlab/backups目錄下建立一個名稱相似爲:

1467362634_gitlab_backup.tar 的壓縮包, 這個壓縮包就是Gitlab整個的完整部分, 其中開頭的  1473237111  是備份建立的日期.

wKiom1fP0Lfyt1blAAB4iUGQjJE645.jpg-wh_50

Gitlab 修改備份文件默認目錄

[root@vm0 etc]# vim /var/opt/gitlab/gitlab-rails/etc/gitlab.yml

wKiom1fP0TKjQ8G4AABixakT-_U893.jpg-wh_50

Gitlab 自動備份

也能夠經過crontab使用備份命令實現自動備份:

0 2 * * */opt/gitlab/bin/gitlab-rake gitlab:backup:create

5.二、gitlab的還原


中止相關服務

[root@vm0 etc]# gitlab-ctl stop unicorn
[root@vm0 etc]# gitlab-ctl stop sidekiq


從備份文件中恢復

以20160630 的備份文件 1467225280_gitlab_backup.tar爲例 )

將恢復文件 1467225280_gitlab_backup.tar 放到gitlab的備份目錄

[root@slvae4 gitback]# cp 1467225280_gitlab_backup.tar/var/opt/gitlab/backups/

 

按照編號進行恢復

[root@slvae4 gitback]# gitlab-rake gitlab:backup:restoreBACKUP=1467225280


從新啓動

[root@vm0 etc]# gitlab-ctl restart


解決方案

1、按照上述恢復 gitlab後,放你訪問git地址時,可能會出現 500 錯誤;以下:

wKiom1fP0ifBTLtKAAB6vu3u9TM032.jpg-wh_50

查看日誌信息以下:

wKiom1fP0l6CRvxJAAB5D1ujIeA751.jpg-wh_50

初步覺得,由於使用ssl訪問時加解密的問題;查了資料,嘗試如下步驟:

The temporary solutions are:

  1. Copy the old     db_key_base from the old instance to the new one.

  2. Delete     imported project data that is no longer required by projects. Something     like this may work:


執行命令:gitlab-rails runner "Project.where.not(import_url: nil).each { |p| p.import_data.destroyif p.import_data }"


wKioL1fP0o-h4MTpAABLzrqfCQ8125.jpg-wh_50

相關文章
相關標籤/搜索