使用RPM包部署
这里使用的系统是CentOS8, 清华源:mirrors.tuna.tsinghua.edu.cn/gitlab-ce/
##下载软件包
wgethttps://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el8/gitlab-ce-13.7.0-ce.0.el8.x86_64.rpm
##安装
rpm-ivhgitlab-ce-13.7.0-ce.0.el8.x86_64.rpm
##日志输出
warning:gitlab-ce-13.7.0-ce.0.el8.x86_64.rpm:HeaderV4RSA/SHA256Signature,keyIDf27eab47:NOKEY
Verifying…#################################[100%]
Preparing…#################################[100%]
Updating/installing…
1:gitlab-ce-13.7.0-ce.0.el8#################################[100%]
ItlookslikeGitLabhasnotbeenconfiguredyet;skippingtheupgradescript.
*.*.
******
**********
.*************
****************
,,,,,,,,,***********,,,,,,,,,
,,,,,,,,,,,*********,,,,,,,,,,,
.,,,,,,,,,,,*******,,,,,,,,,,,,
,,,,,,,,,*****,,,,,,,,,.
,,,,,,,****,,,,,,
.,,,***,,,,
,*,.
_____________
/____(_)/_//_____//_
//__//__///__`/__
//_////_//___//_///_//
____/_/__/_____/__,_/_.___/
ThankyouforinstallingGitLab!
GitLabwasunabletodetectavalidhostnameforyourinstance.
PleaseconfigureaURLforyourGitLabinstancebysetting`external_url`
configurationin/etc/gitlab/gitlab.rbfile.
Then,youcanstartyourGitLabinstancebyrunningthefollowingcommand:
sudogitlab-ctlreconfigure
ForacomprehensivelistofconfigurationoptionspleaseseetheOmnibusGitLabreadme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
Helpusimprovetheinstallationexperience,letusknowhowwedidwitha1minutesurvey:
https://gitlab.fra1.qualtrics.com/jfe/form/SV_6kVqZANThUQ1bZb?installation=omnibus&release=13-7
配置
安装完成后可以发现以下信息,需要修改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 可以看到默认的域名配置。如果是学习使用则可以继续使用该域名,不用再做其他配置。
32external_url'http://gitlab.example.com'
如果是需要修改该域名,则需要这样做:
##修改gitlab.rb
external_url'http://gitlab.devops.com'
##重新配置
gitlab-ctlreconfigure
服务运行控制
##启动服务
gitlab-ctlstart
##重启服务
gitlab-ctlrestart
##查看状态
gitlab-ctlstatus
##停止
gitlab-ctlstop
访问测试
由于使用的是gitlab.devops.com 这个域名,需要在dns或者本地hosts中添加该解析记录。
vi/etc/hosts
192.168.1.200gitlab.devops.com
浏览器访问http://gitlab.devops.com/, 设置用户密码。默认用户root。这里设置的密码是devops1234。
能够正常进入首页即可,安装完成。
扩展:使用外部PG数据库
使用docker快速启动PG
- You are using PostgreSQL 9.6.16, but PostgreSQL >= 11 is required for this version of GitLab.
 
mkdir/root/gitlab/pgdata
dockerrun–namedockerPG11
-ePOSTGRES_PASSWORD=postgres
-v/root/gitlab/pgdata:/var/lib/postgresql/data
-p54322:5432
-dpostgres:11.5
##创建数据库
psql-Upostgres-hlocalhost-p54322
psql(11.5(Debian11.5-3.pgdg90+1))
Type"help"forhelp.
postgres=#createrolegitlabloginencryptedpassword'gitlab';
CREATEROLE
postgres=#createdatabasegitlabhq_productionowner=gitlabENCODING='UTF8';
CREATEDATABASE
postgres=#cgitlabhq_production
Youarenowconnectedtodatabase"gitlabhq_production"asuser"postgres".
gitlabhq_production=#CREATEEXTENSIONIFNOTEXISTSbtree_gist;
CREATEEXTENSION
gitlabhq_production=#CREATEEXTENSIONIFNOTEXISTSpg_trgm;
CREATEEXTENSION
postgres=#q
使用postgres用户创建 EXTENSION, btree_gist, pg_trgm。否则会遇到如下错误:
- 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
654gitlab_rails['db_adapter']="postgresql"
655gitlab_rails['db_encoding']="utf8"
656#gitlab_rails['db_collation']=nil
657gitlab_rails['db_database']="gitlabhq_production"
658gitlab_rails['db_username']="gitlab"
659gitlab_rails['db_password']="gitlab"
660gitlab_rails['db_host']="192.168.1.200"
661gitlab_rails['db_port']=54322
1025postgresql['enable']=false
##配置更新
gitlab-ctlreconfigure
验证配置生效
cat/opt/gitlab/embedded/service/gitlab-rails/config/database.yml
#Thisfileismanagedbygitlab-ctl.Manualchangeswillbe
#erased!Tochangethecontentsbelow,edit/etc/gitlab/gitlab.rb
#andrun`sudogitlab-ctlreconfigure`.
production:
adapter:postgresql
encoding:utf8
collation:
database:gitlabhq_production
username:"gitlab"
password:"gitlab"
host:"192.168.1.200"
port:54322
原文地址:https://mp.weixin.qq.com/s/O9OTQSXFMjXBpipdiNZF5g
        



    		
            	
        
        