本篇內(nèi)容介紹了“DevOps版本控制系統(tǒng)GitLab部署方法是什么”的有關(guān)知識(shí),在實(shí)際案例的操作過(guò)程中,不少人都會(huì)遇到這樣的困境,接下來(lái)就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!
創(chuàng)新互聯(lián)專注于敘州網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗(yàn)。 熱誠(chéng)為您提供敘州營(yíng)銷(xiāo)型網(wǎng)站建設(shè),敘州網(wǎng)站制作、敘州網(wǎng)頁(yè)設(shè)計(jì)、敘州網(wǎng)站官網(wǎng)定制、微信平臺(tái)小程序開(kāi)發(fā)服務(wù),打造敘州網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供敘州網(wǎng)站排名全網(wǎng)營(yíng)銷(xiāo)落地服務(wù)。
使用RPM包部署
這里使用的系統(tǒng)是CentOS8
## 下載軟件包 wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el8/gitlab-ce-13.7.0-ce.0.el8.x86_64.rpm ## 安裝 rpm -ivh gitlab-ce-13.7.0-ce.0.el8.x86_64.rpm ## 日志輸出 warning: gitlab-ce-13.7.0-ce.0.el8.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID f27eab47: NOKEY Verifying... ################################# [100%] Preparing... ################################# [100%] Updating / installing... 1:gitlab-ce-13.7.0-ce.0.el8 ################################# [100%] It looks like GitLab has not been configured yet; skipping the upgrade script. *. *. *** *** ***** ***** .****** ******* ******** ******** ,,,,,,,,,***********,,,,,,,,, ,,,,,,,,,,,*********,,,,,,,,,,, .,,,,,,,,,,,*******,,,,,,,,,,,, ,,,,,,,,,*****,,,,,,,,,. ,,,,,,,****,,,,,, .,,,***,,,, ,*,. _______ __ __ __ / ____(_) /_/ / ____ _/ /_ / / __/ / __/ / / __ `/ __ \ / /_/ / / /_/ /___/ /_/ / /_/ / \____/_/\__/_____/\__,_/_.___/ Thank you for installing GitLab! GitLab was unable to detect a valid hostname for your instance. Please configure a URL for your GitLab instance by setting `external_url` configuration in /etc/gitlab/gitlab.rb file. Then, you can start your GitLab instance by running the following command: sudo gitlab-ctl reconfigure For a comprehensive list of configuration options please see the Omnibus GitLab readme https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md Help us improve the installation experience, let us know how we did with a 1 minute survey: https://gitlab.fra1.qualtrics.com/jfe/form/SV_6kVqZANThUQ1bZb?installation=omnibus&release=13-7
配置
安裝完成后可以發(fā)現(xiàn)以下信息,需要修改gitlab.rb配置文件。
GitLab was unable to detect a valid hostname for your instance. Please configure a URL for your GitLab instance by setting external_urlconfiguration in /etc/gitlab/gitlab.rb file. Then, you can start your GitLab instance by running the following command: sudo gitlab-ctl reconfigure
編輯 /etc/gitlab/gitlab.rb 可以看到默認(rèn)的域名配置。如果是學(xué)習(xí)使用則可以繼續(xù)使用該域名,不用再做其他配置。
32 external_url 'http://gitlab.example.com'
如果是需要修改該域名,則需要這樣做:
## 修改gitlab.rb external_url 'http://gitlab.devops.com' ## 重新配置 gitlab-ctl reconfigure
服務(wù)運(yùn)行控制
## 啟動(dòng)服務(wù) gitlab-ctl start ## 重啟服務(wù) gitlab-ctl restart ## 查看狀態(tài) gitlab-ctl status ## 停止 gitlab-ctl stop
訪問(wèn)測(cè)試
由于使用的是gitlab.devops.com 這個(gè)域名,需要在DNS或者本地hosts中添加該解析記錄。
vi /etc/hosts 192.168.1.200 gitlab.devops.com
瀏覽器訪問(wèn)http://gitlab.devops.com/, 設(shè)置用戶密碼。默認(rèn)用戶root。這里設(shè)置的密碼是devops1234。
能夠正常進(jìn)入首頁(yè)即可,安裝完成。
擴(kuò)展:使用外部PG數(shù)據(jù)庫(kù)
使用docker快速啟動(dòng)PG
You are using PostgreSQL 9.6.16, but PostgreSQL >= 11 is required for this version of GitLab.
mkdir /root/gitlab/pgdata docker run --name dockerPG11 \ -e POSTGRES_PASSWORD=postgres \ -v /root/gitlab/pgdata:/var/lib/postgresql/data \ -p 54322:5432 \ -d postgres:11.5 ## 創(chuàng)建數(shù)據(jù)庫(kù) psql -U postgres -h localhost -p 54322 psql (11.5 (Debian 11.5-3.pgdg90+1)) Type "help" for help. postgres=# create role gitlab login encrypted password 'gitlab'; CREATE ROLE postgres=# create database gitlabhq_production owner=gitlab ENCODING = 'UTF8'; CREATE DATABASE postgres=# \c gitlabhq_production You are now connected to database "gitlabhq_production" as user "postgres". gitlabhq_production=# CREATE EXTENSION IF NOT EXISTS btree_gist; CREATE EXTENSION gitlabhq_production=# CREATE EXTENSION IF NOT EXISTS pg_trgm; CREATE EXTENSION postgres=# \q
使用postgres用戶創(chuàng)建 EXTENSION, btree_gist, pg_trgm。否則會(huì)遇到如下錯(cuò)誤:
STDOUT: psql:/opt/gitlab/embedded/service/gitlab-rails/db/structure.sql:9: ERROR: permission denied to create extension "btree_gist" HINT: Must be superuser to create this extension.
修改gitlab.rb配置文件
編輯/etc/gitlab/gitlab.rb
654 gitlab_rails['db_adapter'] = "postgresql" 655 gitlab_rails['db_encoding'] = "utf8" 656 # gitlab_rails['db_collation'] = nil 657 gitlab_rails['db_database'] = "gitlabhq_production" 658 gitlab_rails['db_username'] = "gitlab" 659 gitlab_rails['db_password'] = "gitlab" 660 gitlab_rails['db_host'] = "192.168.1.200" 661 gitlab_rails['db_port'] = 54322 1025 postgresql['enable'] = false ## 配置更新 gitlab-ctl reconfigure
驗(yàn)證配置生效
cat /opt/gitlab/embedded/service/gitlab-rails/config/database.yml # This file is managed by gitlab-ctl. Manual changes will be # erased! To change the contents below, edit /etc/gitlab/gitlab.rb # and run `sudo gitlab-ctl reconfigure`. production: adapter: postgresql encoding: utf8 collation: database: gitlabhq_production username: "gitlab" password: "gitlab" host: "192.168.1.200" port: 54322
“DevOps版本控制系統(tǒng)GitLab部署方法是什么”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識(shí)可以關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實(shí)用文章!