1. 程式人生 > 其它 >|NO.Z.00011|——————————|^^ 部署 ^^|——|CI/CD&GitLab部署 .V01|----------------------------------------------------|GitLab.Server部署|初始化|

|NO.Z.00011|——————————|^^ 部署 ^^|——|CI/CD&GitLab部署 .V01|----------------------------------------------------|GitLab.Server部署|初始化|



[CloudNative:CI/CD&GitLab部署.V01]                                                                    [Applications.CloudNative] [|CI/CD|分散式版本控制系統|**3節點**|Jenkins|Git|——|Gitlab語言環境|Gitlab初始化|] [https|smtp|Gitlab取消使用者自動註冊|ssh|gitlab資料備份|定時備份|gitlab資料恢復|gitlab管理k8s叢集|]








一、基礎環境配置
### --- 基礎環境配置
~~~     關閉防火牆、selinux
~~~     開啟postfix服務
~~~     開啟Postfix服務並設定開機自啟動

[root@server11 ~]# systemctl start  postfix
[root@server11 ~]# systemctl enable postfix
### --- 安裝gitlab依賴包
~~~     gitlab-ce 10.x.x以後的版本需要依賴policycoreutils-python
~~~     centos7:

[root@server11 ~]# yum install -y curl openssh-server openssh-clients postfix cronie policycoreutils-python
~~~     centos8:

[root@server11 ~]# yum install -y curl openssh-server openssh-clients postfix cronie  policycoreutils-python-utils
二、部署gitlab server
### --- 新增gitlab.repo源

[root@server11 ~]# curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
 [root@server11 ~]# ll /etc/yum.repos.d/
-rw-r--r--  1 root root  773 Mar 28 12:29 gitlab_gitlab-ce.repo
### --- 更改為清華repo源

[root@server11 ~]# vim /etc/yum.repos.d/gitlab_gitlab-ce.repo 
[gitlab-ce]
name=Gitlab CE Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/
gpgcheck=0
enabled=1
### --- 安裝gitlab

[root@server11 ~]# yum -y install gitlab-ce          # 自動安裝最新版
[root@server11 ~]# yum -y install gitlab-ce-x.x.x    # 安裝指定版本Gitlab
### --- 檢視gitlab版本

[root@server11 ~]# head -1 /opt/gitlab/version-manifest.txt 
gitlab-ce 13.10.0

三、gitlab配置
### --- 配置gitlab登入連線
~~~     設定登入連結

[root@server11 ~]# vim /etc/gitlab/gitlab.rb
~~~     沒有域名,可以設定為本機IP地址

external_url 'http://10.10.10.11'
[root@server11 ~]# grep "^external_url" /etc/gitlab/gitlab.rb
external_url 'http://10.10.10.11'               # 繫結監聽的域名或IP
~~~     配置語言環境:gitlab要求語言環境為英文環境,必須切換,
~~~     語言環境問題:如果碰到之後的解決方案如下,需要重新登入

[root@server11 ~]#  echo "export LC_ALL=en_US.UTF-8"  >>  /etc/profile
### --- 如果上面的方案不可以,再使用下面的方案:   

[root@server11 ~]# yum install langpacks-zh_CN langpacks-en langpacks-en_GB -y
[root@server11 ~]# cat > /etc/profile.d/locale.sh<<-EOF
>  export LANG=en_US.UTF-8
>  export LANGUAGE=en_US.UTF-8
>  export LC_COLLATE=C
>  export LC_CTYPE=en_US.UTF-8
> EOF
### --- 使配置檔案生效
~~~     退出終端重新登陸

[root@server11 ~]# source /etc/profile.d/locale.sh
四、gitlab初始化
### --- gitlab初始化
~~~     第一次初始化時間有點長

[root@server11 ~]# gitlab-ctl reconfigure 
.....
### --- 啟動gitlab服務

[root@server11 ~]# gitlab-ctl start
ok: run: alertmanager: (pid 21206) 89s
ok: run: gitaly: (pid 21172) 93s
ok: run: gitlab-exporter: (pid 21171) 93s
ok: run: gitlab-workhorse: (pid 21143) 94s
ok: run: grafana: (pid 21299) 88s
ok: run: logrotate: (pid 20574) 263s
ok: run: nginx: (pid 20551) 274s
ok: run: node-exporter: (pid 21152) 94s
ok: run: postgres-exporter: (pid 21216) 89s
ok: run: postgresql: (pid 20262) 374s
ok: run: prometheus: (pid 21188) 92s
ok: run: puma: (pid 20471) 297s
ok: run: redis: (pid 20092) 392s
ok: run: redis-exporter: (pid 21182) 92s
ok: run: sidekiq: (pid 20496) 291s
### --- 檢視gitlab服務是否啟動

[root@server11 ~]# lsof -i:80
COMMAND   PID       USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
nginx   20551       root    7u  IPv4 122587      0t0  TCP *:http (LISTEN)
nginx   20552 gitlab-www    7u  IPv4 122587      0t0  TCP *:http (LISTEN)
nginx   20553 gitlab-www    7u  IPv4 122587      0t0  TCP *:http (LISTEN)








===============================END===============================


Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart                                                                                                                                                    ——W.S.Landor



來自為知筆記(Wiz)