1. 程式人生 > 其它 >|NO.Z.00372|——————————|CloudNative|——|KuberNetes&CI/CD.V10|-----------------------------------------------------------|Jenkins.v09|Gitlab安裝配置.v01|

|NO.Z.00372|——————————|CloudNative|——|KuberNetes&CI/CD.V10|-----------------------------------------------------------|Jenkins.v09|Gitlab安裝配置.v01|



[CloudNative:KuberNetes&CI/CD.V10]                                                                    [Applications.KuberNetes] [|Jenkins|Gitlab安裝配置|jenkins下gitlab配置|]








一、Gitlab Server安裝
### --- Gitlab Server安裝
~~~     實際生產環境中,gitlab應建議是一臺單獨的伺服器

### --- 基礎依賴環境配置:關閉防火牆、SELinux、開啟郵件服務、依賴包
~~~     gitlab-ce 10.x.x以後的版本需要依賴policycoreutils-python
~~~     # 安裝依賴包

centos7:
[root@k8s-gitlab ~]# yum install -y curl openssh-server openssh-clients postfix cronie policycoreutils-python
centos8:
[root@k8s-gitlab ~]# yum install -y curl openssh-server openssh-clients postfix cronie  policycoreutils-python-utils
### --- 
啟動Postfix

[root@k8s-gitlab ~]# systemctl start  postfix
[root@k8s-gitlab ~]# systemctl enable postfix
二、安裝gitlab
### --- 獲取gitlab安裝包或者配置yum源

~~~     # yum源下載地址:
~~~     Gitlab 下載地址:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/
~~~                     https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el8/
~~~     # 方案一:直接下載rpm包

[root@k8s-gitlab ~]# wget -c https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-13.0.3-ce.0.el7.x86_64.rpm
~~~     # 方案二:配置清華源地址

[root@k8s-gitlab ~]# cat /etc/yum.repos.d/gitlab-ce.repo 
[gitlab-ce]
name=gitlab-ce
baseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7
repo_gpgcheck=0
gpgcheck=0
enabled=1
gpgkey=https://packages.gitlab.com/gpg.key 
~~~     # 方案三:配置清華源地址

[root@k8s-gitlab ~]# curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
~~~     # 修改為清華源地址

[root@k8s-gitlab ~]# 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
gpgkey=https://packages.gitlab.com/gpg.key 
### --- 安裝gitlab

[root@k8s-gitlab ~]# yum -y install gitlab-ce-13.0.3
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : gitlab-ce-13.0.3-ce.0.el7.x86_64                                                                                                                                             1/1 
It looks like GitLab has not been configured yet; skipping the upgrade script.
       *.                  *.
      ***                 ***
     *****               *****
    .******             *******
    ********            ********
   ,,,,,,,,,***********,,,,,,,,,
  ,,,,,,,,,,,*********,,,,,,,,,,,
  .,,,,,,,,,,,*******,,,,,,,,,,,,
      ,,,,,,,,,*****,,,,,,,,,.
         ,,,,,,,****,,,,,,
            .,,,***,,,,
                ,*,.
     _______ __  __          __
    / ____(_) /_/ /   ____ _/ /_
   / / __/ / __/ /   / __ `/ __ \
  / /_/ / / /_/ /___/ /_/ / /_/ /
  \____/_/\__/_____/\__,_/_.___/
  
Thank you for installing GitLab!
### --- 注:

[root@k8s-gitlab ~]# yum -y install gitlab-ce        # 自動安裝最新版
[root@k8s-gitlab ~]# yum -y install gitlab-ce-x.x.x  # 安裝指定版本Gitlab
三、檢視gitlab版本
[root@k8s-gitlab ~]#  head -1 /opt/gitlab/version-manifest.txt 
gitlab-ce 13.0.3

四、gitlab安裝後配置
### --- Gitlab 配置登入域名
~~~     # 設定登入連結:沒有域名,可以設定為本機IP地址

[root@k8s-gitlab ~]# vim /etc/gitlab/gitlab.rb
external_url 'http://gitlab.test.com'
~~~     # 檢視繫結監聽的域名或IP

[root@k8s-gitlab ~]# grep "^external_url" /etc/gitlab/gitlab.rb
external_url 'http://gitlab.test.com'      
~~~     # 配置hosts檔案

192.168.1.16 gitlab.test.com
### --- 配置語言環境:gitlab要求語言環境為英文環境,必須切換,切換方法如下:
~~~     # 配置gitlab語言環境
~~~     方案一:注意:可以先嚐試以下方案:語言環境問題:如果碰到之後的解決方案如下,需要重新登入

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

[root@k8s-gitlab ~]# yum install langpacks-zh_CN langpacks-en langpacks-en_GB -y
[root@k8s-gitlab ~]# 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@k8s-gitlab ~]# source /etc/profile.d/locale.sh
### --- 重新載入配置檔案並初始化

~~~     # econfigure過載配置檔案並初始化
~~~     它會幫我們啟動很多服務,可以根據自己的需求來停止
~~~     可以使用gitlab-ctl來重啟或者停止對應服務
[root@k8s-gitlab ~]# gitlab-ctl reconfigure
Starting Chef Client, version 14.14.29
.....
    - execute sysctl -e --system
Recipe: gitlab::gitlab-workhorse
  * runit_service[gitlab-workhorse] action restart (up to date)
Recipe: monitoring::node-exporter
  * runit_service[node-exporter] action restart (up to date)
Recipe: monitoring::gitlab-exporter
  * runit_service[gitlab-exporter] action restart (up to date)
Recipe: monitoring::redis-exporter
  * runit_service[redis-exporter] action restart (up to date)
Recipe: monitoring::prometheus
  * runit_service[prometheus] action restart (up to date)
  * execute[reload prometheus] action run
    - execute /opt/gitlab/bin/gitlab-ctl hup prometheus
Recipe: monitoring::alertmanager
  * runit_service[alertmanager] action restart (up to date)
Recipe: monitoring::postgres-exporter
  * runit_service[postgres-exporter] action restart (up to date)
Recipe: monitoring::grafana
  * runit_service[grafana] action restart (up to date)
Running handlers:
Running handlers complete
Chef Client finished, 542/1469 resources updated in 12 minutes 17 seconds
gitlab Reconfigured! 
[root@k8s-gitlab ~]# gitlab-ctl restart                                             //可以使用該命令重啟所有的服務
[root@k8s-gitlab ~]# gitlab-ctl stop gitlab-exporter
ok: down: gitlab-exporter: 0s, normally up
[root@k8s-gitlab ~]# gitlab-ctl stop grafana
ok: down: grafana: 0s, normally up
[root@k8s-gitlab ~]# gitlab-ctl stop prometheus
ok: down: prometheus: 0s, normally up 
### --- 啟動 Gitlab 服務

[root@k8s-gitlab ~]# 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
[root@k8s-node02 ~]# lsof -i:80
COMMAND   PID       USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
nginx   97334       root    7u  IPv4 413896      0t0  TCP *:http (LISTEN)
nginx   97335 gitlab-www    7u  IPv4 413896      0t0  TCP *:http (LISTEN)
nginx   97336 gitlab-www    7u  IPv4 413896      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)