真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

gitlab遷移實(shí)踐

因辦公室環(huán)境網(wǎng)絡(luò)調(diào)整,近期計(jì)劃將gitlab從內(nèi)網(wǎng)機(jī)房遷移至公有云。遷移過(guò)程做了一下簡(jiǎn)單的記錄,希望對(duì)各位同行有所幫助。

創(chuàng)新互聯(lián)專注于新絳網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗(yàn)。 熱誠(chéng)為您提供新絳營(yíng)銷型網(wǎng)站建設(shè),新絳網(wǎng)站制作、新絳網(wǎng)頁(yè)設(shè)計(jì)、新絳網(wǎng)站官網(wǎng)定制、小程序定制開(kāi)發(fā)服務(wù),打造新絳網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供新絳網(wǎng)站排名全網(wǎng)營(yíng)銷落地服務(wù)。

服務(wù)器Acentos6.910.1.2.10gitlab-ce-8.16.0-ce.0.el6.x86_64
新服務(wù)器B centos6.9 192.168.100.10 gitlab-ce-8.16.0-ce.0.el6.x86_64

一、遷移基本思路
1、采購(gòu)公有云服務(wù)器,自帶公網(wǎng)IP、加入onlyyou安全組。
2、安全組開(kāi)放80端口(所有辦公網(wǎng)出口、v隧p道n(公))、9000端口(所有辦公網(wǎng)出口、v隧p道n(公)、以及Jks、其他測(cè)試服公網(wǎng)IP)。
3、搭建同版本Git服務(wù)。
4、發(fā)布公告,暫停git服務(wù)
5、將完整備份導(dǎo)入新Git。
6、利用iptables映射9000端口至3303(iptables -t nat -A PREROUTING -p tcp --dport 9000 -j REDIRECT --to-ports 3303)。(注:9000為之前frp的遠(yuǎn)程端口,3303為服務(wù)器B的ssh端口)
7、DNS解析(git.bd.com):刪除辦公網(wǎng)DNS的解析記錄,修改公網(wǎng)DNS解析記錄至服務(wù)器B公網(wǎng)IP。

二、操作步驟
2.1、備份
1.備份服務(wù)器A中的git數(shù)據(jù),具體備份操作命令
[root@serverA ~]# gitlab-rake gitlab:backup:create STRATEGY=copy
備份文件在/var/opt/gitlab/backups/下,假設(shè)備好的文件為1568659149_2019_03_17_10.6.4_gitlab_backup.tar
注:在備份期間需禁止對(duì)gitlab進(jìn)行任何操作

2.2、新服務(wù)器搭建gitlab

    為了備份可用,新服務(wù)器上使用跟原服務(wù)器相同的版本
    如果舊服務(wù)器已是最新版,可以在新服務(wù)器直接使用yum安裝.
    如果安裝最新版本,采用以下方式安裝即可
    `[root@serverB ~]#  yum install gitlab-ce`

    本人采用的是指定的相同的版本來(lái)進(jìn)行安裝的

    1.因不是最新版本,需要從https://packages.gitlab.com/gitlab/gitlab-ce上下載所需的版本,此處因?yàn)榘惭b系統(tǒng)為centos6,所以下載el6版本
    或者使用服務(wù)器A中的yum源文件
    `[root@serverB ~]# cat /etc/yum.repos.d/gitlab_gitlab-ce.repo`
    [gitlab_gitlab-ce]
    name=gitlab_gitlab-ce
    baseurl=https://packages.gitlab.com/gitlab/gitlab-ce/el/6/$basearch
    repo_gpgcheck=1
    gpgcheck=0
    enabled=1
    gpgkey=https://packages.gitlab.com/gpg.key
    sslverify=1
    sslcacert=/etc/pki/tls/certs/ca-bundle.crt

    [gitlab_gitlab-ce-source]
    name=gitlab_gitlab-ce-source
    baseurl=https://packages.gitlab.com/gitlab/gitlab-ce/el/6/SRPMS
    repo_gpgcheck=1
    gpgcheck=0
    enabled=1
    gpgkey=https://packages.gitlab.com/gpg.key
    sslverify=1
    sslcacert=/etc/pki/tls/certs/ca-bundle.crt

    2.安裝git
    [root@serverB ~]#  `yum -y install git`

    3.安裝gitlib
    [root@serverB ~]#  ```
    EXTERNAL_URL="http://gitlab.example.com" yum install -y gitlab-ce-10.6.4-ce.0.el6.x86_64
    ```

    4、修改配置
    安裝好后,修改/etc/gitlab/gitlab.rb
    external_url 'http://gitlab.example.com'
    其上所有的http://gitlab.example.com改成自己要使用的gitlab地址

    在/var/opt/gitlab/nginx/conf/gitlab-http.conf 中修改所需端口
    在/var/opt/gitlab/nginx/conf/nginx.conf 中增加
     include /var/opt/gitlab/nginx/conf/custom.conf;

    端口是為了跟原來(lái)的環(huán)境保持一致,比如原來(lái)的是54444,這里也修改成一樣的即可
    custom.conf  是自己定義的白名單,比如:
    allow 110.110.110.110;
    deny  all;
    server {
            server_name default;
            listen *:80;
            location / {
                    proxy_pass http://127.0.0.1:54444;
            }
    }

    重新配置升效

    [root@serverB ~]# gitlab-ctl reconfigure

2.3、拷貝備份
將備份從服務(wù)器A拷到新服務(wù)器B的/var/opt/gitlab/backups/下,此步從服務(wù)器A上操作

    [root@serverA ~]# scp /var/opt/gitlab/backups/1568659149_2019_03_17_10.6.4_gitlab_backup.tar root@192.168.100.10:/var/opt/gitlab/backups/
    修改備份文件權(quán)限,以免恢復(fù)備份時(shí)出現(xiàn)權(quán)限不足的情況

    [root@serverB ~]# chown git:git 1568659149_2019_03_17_10.6.4_gitlab_backup.tar
    [root@serverB ~]# chmod 777 1568659149_2019_03_17_10.6.4_gitlab_backup.tar

2.4、恢復(fù)備份
此步參考官方文檔https://docs.gitlab.com/ce/raketasks/backup_restore.html#restore-for-omnibus-installations
1.停止數(shù)據(jù)相服務(wù)

    [root@serverB ~]# gitlab-ctl stop unicorn
    [root@serverB ~]# gitlab-ctl stop sidekiq
    [root@serverB ~]# gitlab-ctl status

    2.恢復(fù)備份
    此處命令結(jié)尾使用的是上面拷貝過(guò)來(lái)的文件名,但不是全名,取其_gitlab之前的名稱即可
    最開(kāi)始的時(shí)候,會(huì)提示輸入yes,直接輸入即可
    [root@serverB ~]# gitlab-rake gitlab:backup:restore BACKUP=1568659149_2019_03_17_10.6.4
    Unpacking backup ... done
    Before restoring the database, we will remove all existing
    tables to avoid future upgrade problems. Be aware that if you have
    custom tables in the GitLab database these tables and all data will be
    removed.

    ```
    **Do you want to continue (yes/no)? yes**
    ```
    Removing all tables. Press `Ctrl-C` within 5 seconds to abort
    Cleaning the database ... 
    done
    Restoring database ... 
    Restoring PostgreSQL database gitlabhq_production ... SET
    SET
    SET
    SET
    .......

    Put GitLab hooks in repositories dirs [DONE]
    done
    Restoring uploads ... 
    done
    Restoring builds ... 
    done
    Restoring artifacts ... 
    done
    Restoring pages ... 
    done
    Restoring lfs objects ... 
    done
    This will rebuild an authorized_keys file.
    You will lose any data stored in authorized_keys file.

    **Do you want to continue (yes/no)? no  ##這里如果保留舊的權(quán)限,輸入no
    **Quitting...

    3.重置服務(wù)

    [root@serverB ~]# gitlab-ctl restart
    [root@serverB ~]# gitlab-rake gitlab:check SANITIZE=true

三、郵件功能確認(rèn)
關(guān)于gitlab是否可以正常發(fā)送郵件,需要做好確認(rèn)。
舊環(huán)境中,serverA中的配置使用的是25端口,但是公有云服務(wù)器默認(rèn)是屏蔽25端口的,發(fā)送郵件就會(huì)出現(xiàn)如下報(bào)錯(cuò)。

最初配置為:
[root@serverB ~]# grep -v "#" /etc/gitlab/gitlab.rb | grep -v "^$"
external_url 'http://git.bd.com'
nginx['listen_port'] = 54444
gitlab_rails['time_zone'] = 'Asia/Shanghai'
gitlab_rails['gitlab_shell_ssh_port'] = 9000
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.exmail.qq.com"
gitlab_rails['smtp_port'] = 25
gitlab_rails['smtp_user_name'] = "git@bd.com"
gitlab_rails['smtp_password'] = "88888888"
gitlab_rails['smtp_domain'] = "exmail.qq.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['gitlab_email_from'] = 'git@bd.com'
user["git_user_email"] = "git@bd.com"
nginx['custom_nginx_config'] = "include /var/opt/gitlab/nginx/conf/custom.conf;"
gitlab_ci['backup_path'] = "/gitlab_backup"
[root@serverB ~]#

測(cè)試發(fā)送郵件功能
[root@serverB ~]# gitlab-rails console
Loading production environment (Rails 4.2.10)
irb(main):001:0> Notify.test_email("ch@bd.com","title","gitlab").deliver_now

Notify#test_email: processed outbound mail in 180.0ms

Sent mail to ch@bd.com (1885.3ms)
Date: Thu, 19 Sep 2019 19:05:27 +0800
From: GitLab
Reply-To: GitLab
To: ch@bd.com
Message-ID: <5d8360f7d0fae_79823fbf26cdb1b033298@serverB.mail>
Subject: title
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
Auto-Submitted: auto-generated
X-Auto-Response-Suppress: All


gitlab

Net::OpenTimeout: execution expired
from /opt/gitlab/embedded/lib/ruby/2.3.0/net/smtp.rb:542:in initialize'
from /opt/gitlab/embedded/lib/ruby/2.3.0/net/smtp.rb:542:in
open'
from /opt/gitlab/embedded/lib/ruby/2.3.0/net/smtp.rb:542:in tcp_socket'
from /opt/gitlab/embedded/lib/ruby/2.3.0/net/smtp.rb:552:in
block in do_start'
from /opt/gitlab/embedded/lib/ruby/2.3.0/timeout.rb:101:in timeout'
from /opt/gitlab/embedded/lib/ruby/2.3.0/net/smtp.rb:551:in
do_start'
from /opt/gitlab/embedded/lib/ruby/2.3.0/net/smtp.rb:521:in start'
from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/mail-2.7.0/lib/mail/network/delivery_methods/smtp.rb:109:in
start_smtp_session'
from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/mail-2.7.0/lib/mail/network/delivery_methods/smtp.rb:100:in deliver!'
from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/mail-2.7.0/lib/mail/message.rb:2160:in
do_delivery'
from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/mail-2.7.0/lib/mail/message.rb:260:in block in deliver'
from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/actionmailer-4.2.10/lib/action_mailer/base.rb:543:in
block in deliver_mail'
from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/activesupport-4.2.10/lib/active_support/notifications.rb:164:in block in instrument'
from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/activesupport-4.2.10/lib/active_support/notifications/instrumenter.rb:20:in
instrument'
from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/activesupport-4.2.10/lib/active_support/notifications.rb:164:in instrument'
from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/actionmailer-4.2.10/lib/action_mailer/base.rb:541:in
deliver_mail'
from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/mail-2.7.0/lib/mail/message.rb:260:in deliver'
from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/actionmailer-4.2.10/lib/action_mailer/message_delivery.rb:85:in
deliver_now'
from (irb):1
from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/railties-4.2.10/lib/rails/commands/console.rb:110:in start'
from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/railties-4.2.10/lib/rails/commands/console.rb:9:in
start'
from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:68:in console'
from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:39:in
run_command!'
from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/railties-4.2.10/lib/rails/commands.rb:17:in <top (required)>'
from bin/rails:9:in
require'
from bin/rails:9:in `

'

經(jīng)過(guò)排查分析,25端口已經(jīng)被統(tǒng)一關(guān)閉,需要使用安全傳輸層協(xié)議進(jìn)行發(fā)送郵件。

修改配置為
[root@serverB ~]# grep -v "#" /etc/gitlab/gitlab.rb | grep -v "^$"
external_url 'http://git.bd.com'
nginx['listen_port'] = 54444
gitlab_rails['time_zone'] = 'Asia/Shanghai'
gitlab_rails['gitlab_shell_ssh_port'] = 9000
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.exmail.qq.com"
gitlab_rails['smtp_tls'] = true
gitlab_rails['smtp_port'] = 465

gitlab_rails['smtp_user_name'] = "git@bd.com"
gitlab_rails['smtp_password'] = "88888888"
gitlab_rails['smtp_domain'] = "exmail.qq.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['gitlab_email_from'] = 'git@bd.com'
user["git_user_email"] = "git@bd.com"
nginx['custom_nginx_config'] = "include /var/opt/gitlab/nginx/conf/custom.conf;"
gitlab_ci['backup_path'] = "/gitlab_backup"
[root@serverB ~]#

修改后執(zhí)行g(shù)itlab-ctl reconfigure

確認(rèn)可以發(fā)送郵件:
[root@serverB ~]# gitlab-rails console
Loading production environment (Rails 4.2.10)
irb(main):001:0> Notify.test_email("ch@bd.com","title","gitlab").deliver_now

Notify#test_email: processed outbound mail in 180.0ms

Sent mail to ch@bd.com (1885.3ms)
Date: Thu, 19 Sep 2019 19:05:27 +0800
From: GitLab
Reply-To: GitLab
To: ch@bd.com
Message-ID: <5d8360f7d0fae_79823fbf26cdb1b033298@serverB.mail>
Subject: title
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
Auto-Submitted: auto-generated
X-Auto-Response-Suppress: All


gitlab

=> #, >, >, , >, , , , , , >
irb(main):002:0

若發(fā)送不成功請(qǐng)看下是否配置user['git_user_email'],若以上都配置了請(qǐng)查看云服務(wù)器安全組有沒(méi)有開(kāi)放465端口。

四、驗(yàn)證方法:
辦公網(wǎng)環(huán)境驗(yàn)證ssh協(xié)議命令行操作及Web頁(yè)面打開(kāi)情況。 ##通過(guò)
辦公網(wǎng)v隧p道n環(huán)境驗(yàn)證ssh協(xié)議命令行操作及Web頁(yè)面打開(kāi)情況。 ##通過(guò)
公網(wǎng)環(huán)境驗(yàn)證ssh協(xié)議命令行操作及Web頁(yè)面禁止訪問(wèn)和打開(kāi)情況。 ##通過(guò),公網(wǎng)禁止訪問(wèn)
公網(wǎng)v隧p道n環(huán)境驗(yàn)證ssh協(xié)議命令行操作及Web頁(yè)面打開(kāi)情況。 ##通過(guò)


分享題目:gitlab遷移實(shí)踐
當(dāng)前地址:http://weahome.cn/article/piodce.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部