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

一、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)

 
 
 
 
 
 
 
 
 

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

 

 

posted on   yanqi_vip  阅读(36)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示