在以前的文章中,我记录过GITLAB在CENTOS7.4上的安装过程:

不过,当时的文档所描述的安装方式的弊端很明显:

  1. 安装GITLAB的服务器需要联网
  2. GITLAB的软件包需要在线下载
  3. 安装GITLAB之前,需要配置很多周边的工具,诸如:POSTFIX等等

本文,会介绍如何离线安装GITLAB。


GITLAB官方网站上,截止(2019年8月14日)最新的安装包:
https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/7/gitlab-ce-12.1.6-ce.0.el7.x86_64.rpm


下载完成后,上传服务器:

[root@gitlab ~]# cd /software/gitlab/
[root@gitlab gitlab]# ls
gitlab.rpm
[root@gitlab gitlab]# 
[root@gitlab gitlab]# du -sh *
641M    gitlab.rpm
[root@gitlab gitlab]# 

然后,直接使用命令【rpm】安装:

[root@gitlab gitlab]# rpm -ivh gitlab.rpm 
warning: gitlab.rpm: Header V4 RSA/SHA1 Signature, key ID f27eab47: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:gitlab-ce-12.1.6-ce.0.el7        ################################# [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

[root@gitlab gitlab]# 

可以看到,已经成功安装了。

下面做安装后的检查:

[root@gitlab gitlab]# rpm -qa | grep gitlab
gitlab-ce-12.1.6-ce.0.el7.x86_64
[root@gitlab gitlab]# 
[root@gitlab gitlab]# rpm -ql gitlab-ce | head -n 40
/opt
/opt/gitlab
/opt/gitlab/LICENSE
/opt/gitlab/LICENSES
/opt/gitlab/LICENSES/alertmanager-LICENSE
/opt/gitlab/LICENSES/awesome_print-LICENSE
/opt/gitlab/LICENSES/bzip2-LICENSE
/opt/gitlab/LICENSES/cacerts-LICENSE
/opt/gitlab/LICENSES/chef-acme-LICENSE
/opt/gitlab/LICENSES/chef-gem-LICENSE
/opt/gitlab/LICENSES/chef-zero-LICENSE
/opt/gitlab/LICENSES/compat_resource-LICENSE
/opt/gitlab/LICENSES/config_guess-LICENSE
/opt/gitlab/LICENSES/curl-COPYING
/opt/gitlab/LICENSES/exiftool-LICENSE.txt
/opt/gitlab/LICENSES/git-COPYING
/opt/gitlab/LICENSES/gitaly-LICENSE
/opt/gitlab/LICENSES/gitlab-config-template-LICENSE
/opt/gitlab/LICENSES/gitlab-cookbooks-LICENSE
/opt/gitlab/LICENSES/gitlab-ctl-LICENSE
/opt/gitlab/LICENSES/gitlab-healthcheck-LICENSE
/opt/gitlab/LICENSES/gitlab-monitor-LICENSE
/opt/gitlab/LICENSES/gitlab-psql-LICENSE
/opt/gitlab/LICENSES/gitlab-rails-LICENSE
/opt/gitlab/LICENSES/gitlab-rails-gitlab-gem-licenses
/opt/gitlab/LICENSES/gitlab-scripts-LICENSE
/opt/gitlab/LICENSES/gitlab-selinux-LICENSE
/opt/gitlab/LICENSES/gitlab-shell-LICENSE
/opt/gitlab/LICENSES/gitlab-workhorse-LICENSE
/opt/gitlab/LICENSES/gnupg-COPYING.LGPL3
/opt/gitlab/LICENSES/go-crond-LICENSE
/opt/gitlab/LICENSES/go_dep-github.com_jessevdk_go-flags-v1.4.0-LICENSE
/opt/gitlab/LICENSES/go_dep-github.com_robfig_cron-v1-LICENSE
/opt/gitlab/LICENSES/gpgme-COPYING.LESSER
/opt/gitlab/LICENSES/grafana-LICENSE
/opt/gitlab/LICENSES/graphicsmagick-Copyright.txt
/opt/gitlab/LICENSES/jemalloc-COPYING
/opt/gitlab/LICENSES/krb5-NOTICE
/opt/gitlab/LICENSES/libassuan-COPYING.LIB
/opt/gitlab/LICENSES/libedit-COPYING
[root@gitlab gitlab]# 

查看GITLAB的目录:

[root@gitlab gitlab]# ls -ltr /opt
total 4
drwxr-xr-x. 2 root root    6 Mar 26  2015 rh
drwxr-xr-x  9 root root 4096 Aug 14 18:59 gitlab
[root@gitlab gitlab]# 
[root@gitlab gitlab]# ls -ltr /opt/gitlab/
total 2856
-rw-r--r--  1 root root 2685691 Aug 13 01:25 LICENSE
-rw-r--r--  1 root root  160400 Aug 13 01:25 dependency_licenses.json
-rw-r--r--  1 root root   12137 Aug 13 01:26 version-manifest.txt
-rw-r--r--  1 root root   26430 Aug 13 01:26 version-manifest.json
drwxr-xr-x  2 root root       6 Aug 13 01:26 sv
drwxr-xr-x  2 root root       6 Aug 13 01:26 service
drwxr-xr-x  2 root root       6 Aug 13 01:26 init
drwxr-xr-x  2 root root   24576 Aug 14 18:58 LICENSES
drwxr-xr-x  2 root root     108 Aug 14 18:58 bin
drwxr-xr-x  2 root root      32 Aug 14 18:59 etc
drwxr-xr-x 16 root root    4096 Aug 14 18:59 embedded
[root@gitlab gitlab]# 

配置并运行GITLAB:
命令:【gitlab-ctl reconfigure】
文件:【/etc/gitlab/gitlab.rb】

[root@gitlab gitlab]# pwd
/etc/gitlab
[root@gitlab gitlab]# 
[root@gitlab gitlab]# ls -ltr
total 92
-rw------- 1 root root 92447 Aug 14 18:59 gitlab.rb
[root@gitlab gitlab]# 
[root@gitlab gitlab]# cp gitlab.rb gitlab.rb_old_orig_20190814
[root@gitlab gitlab]# 
[root@gitlab gitlab]# ls -ltr
total 184
-rw------- 1 root root 92447 Aug 14 18:59 gitlab.rb
-rw------- 1 root root 92447 Aug 14 19:15 gitlab.rb_old_orig_20190814
[root@gitlab gitlab]# 
[root@gitlab gitlab]# vi gitlab.rb
[root@gitlab gitlab]# 
[root@gitlab gitlab]# cat gitlab.rb | grep -v "^#" | grep external_url
external_url 'http://gitlab.adamhuan.com:9062'
[root@gitlab gitlab]# 
[root@gitlab gitlab]# gitlab-ctl reconfigure

(过多的输出,...)

Recipe: gitlab::gitlab-rails
  * execute[clear the gitlab-rails cache] action run
    - execute /opt/gitlab/bin/gitlab-rake cache:clear
Recipe: <Dynamically Defined Resource>
  * service[gitaly] action restart
    - restart service service[gitaly]
Recipe: gitaly::enable
  * runit_service[gitaly] action hup
    - send hup to runit_service[gitaly]
Recipe: <Dynamically Defined Resource>
  * service[gitlab-workhorse] action restart
    - restart service service[gitlab-workhorse]
  * service[node-exporter] action restart
    - restart service service[node-exporter]
  * service[gitlab-monitor] action restart
    - restart service service[gitlab-monitor]
  * service[redis-exporter] action restart
    - restart service service[redis-exporter]
  * service[prometheus] action restart
    - restart service service[prometheus]
Recipe: monitoring::prometheus
  * execute[reload prometheus] action run
    - execute /opt/gitlab/bin/gitlab-ctl hup prometheus
Recipe: <Dynamically Defined Resource>
  * service[alertmanager] action restart
    - restart service service[alertmanager]
  * service[postgres-exporter] action restart
    - restart service service[postgres-exporter]
  * service[grafana] action restart
    - restart service service[grafana]

Running handlers:
Running handlers complete
Chef Client finished, 510/1328 resources updated in 03 minutes 38 seconds
gitlab Reconfigured!
[root@gitlab gitlab]# 

可以看到,【reconfigure】执行完成。

以上过程中,GITLAB是有日志输出的:
GITLAB的日志路径:【/var/log/gitlab】

[root@gitlab ~]# ls -ltr /var/log/gitlab/                           
total 4
drwxr-xr-x 2 root              root         28 Aug 14 19:17 reconfigure
drwx------ 2 git               root         30 Aug 14 19:18 gitlab-shell
drwx------ 2 gitlab-redis      root         47 Aug 14 19:18 redis
drwx------ 2 git               root         47 Aug 14 19:18 gitaly
drwx------ 2 gitlab-psql       root         47 Aug 14 19:18 postgresql
drwx------ 2 git               root         99 Aug 14 19:18 unicorn
drwx------ 2 git               root         47 Aug 14 19:19 sidekiq
drwx------ 2 git               root         47 Aug 14 19:19 gitlab-workhorse
drwxr-x--- 2 root              gitlab-www  131 Aug 14 19:19 nginx
drwx------ 2 root              root         47 Aug 14 19:19 logrotate
drwx------ 2 gitlab-prometheus root         47 Aug 14 19:19 node-exporter
drwx------ 2 git               root         47 Aug 14 19:19 gitlab-monitor
drwx------ 2 gitlab-redis      root         47 Aug 14 19:19 redis-exporter
drwx------ 2 gitlab-prometheus root         47 Aug 14 19:19 prometheus
drwx------ 2 gitlab-prometheus root         47 Aug 14 19:19 alertmanager
drwx------ 2 gitlab-psql       root         47 Aug 14 19:20 postgres-exporter
drwx------ 2 git               root       4096 Aug 14 19:20 gitlab-rails
drwx------ 2 gitlab-prometheus root         47 Aug 14 19:21 grafana
[root@gitlab ~]# 

【reconfigure】结束后,GITLAB就在运行了:

[root@gitlab gitlab]# ps -ef | grep gitlab
avahi      692     1  0 18:55 ?        00:00:00 avahi-daemon: running [gitlab.local]
root      2071  1400  0 19:24 pts/0    00:00:00 grep --color=auto gitlab
root      2371     1  0 19:18 ?        00:00:00 runsvdir -P /opt/gitlab/service log: ...........................................................................................................................................................................................................................................................................................................................................................................................................
gitlab-+  2388  2386  0 19:18 ?        00:00:01 /opt/gitlab/embedded/bin/redis-server 127.0.0.1:0
root      2398  2386  0 19:18 ?        00:00:00 svlogd -tt /var/log/gitlab/redis
root      2429  2400  0 19:18 ?        00:00:00 svlogd /var/log/gitlab/gitaly
gitlab-+  2539  2537  0 19:18 ?        00:00:00 /opt/gitlab/embedded/bin/postgres -D /var/opt/gitlab/postgresql/data
gitlab-+  2541  2539  0 19:18 ?        00:00:00 postgres: checkpointer process   
gitlab-+  2542  2539  0 19:18 ?        00:00:00 postgres: writer process   
gitlab-+  2543  2539  0 19:18 ?        00:00:00 postgres: wal writer process   
gitlab-+  2544  2539  0 19:18 ?        00:00:00 postgres: autovacuum launcher process   
gitlab-+  2545  2539  0 19:18 ?        00:00:00 postgres: stats collector process   
gitlab-+  2546  2539  0 19:18 ?        00:00:00 postgres: bgworker: logical replication launcher   
root      2592  2537  0 19:18 ?        00:00:00 svlogd -tt /var/log/gitlab/postgresql
git       2716  2714  0 19:18 ?        00:00:00 /bin/bash /opt/gitlab/embedded/bin/gitlab-unicorn-wrapper
git       2731     1  8 19:18 ?        00:00:27 unicorn master -D -E production -c /var/opt/gitlab/gitlab-rails/etc/unicorn.rb /opt/gitlab/embedded/service/gitlab-rails/config.ru
root      2745  2714  0 19:19 ?        00:00:00 svlogd -tt /var/log/gitlab/unicorn
git       2755  2753 11 19:19 ?        00:00:35 sidekiq 5.2.7 gitlab-rails [0 of 25 busy]
root      2769  2753  0 19:19 ?        00:00:00 svlogd /var/log/gitlab/sidekiq
root      2775  2371  0 19:19 ?        00:00:00 runsv gitlab-workhorse
root      2792  2775  0 19:19 ?        00:00:00 svlogd /var/log/gitlab/gitlab-workhorse
root      2803  2801  0 19:19 ?        00:00:00 nginx: master process /opt/gitlab/embedded/sbin/nginx -p /var/opt/gitlab/nginx
gitlab-+  2805  2803  0 19:19 ?        00:00:00 nginx: worker process
gitlab-+  2806  2803  0 19:19 ?        00:00:00 nginx: cache manager process
root      2814  2801  0 19:19 ?        00:00:00 svlogd -tt /var/log/gitlab/nginx
root      2820  2818  0 19:19 ?        00:00:00 /bin/sh /opt/gitlab/embedded/bin/gitlab-logrotate-wrapper
root      2830  2818  0 19:19 ?        00:00:00 svlogd -tt /var/log/gitlab/logrotate
root      2861  2849  0 19:19 ?        00:00:00 svlogd -tt /var/log/gitlab/node-exporter
root      2869  2371  0 19:19 ?        00:00:00 runsv gitlab-monitor
root      2877  2869  0 19:19 ?        00:00:00 svlogd -tt /var/log/gitlab/gitlab-monitor
root      2905  2895  0 19:19 ?        00:00:00 svlogd -tt /var/log/gitlab/redis-exporter
root      2923  2911  0 19:19 ?        00:00:00 svlogd -tt /var/log/gitlab/prometheus
root      2955  2929  0 19:19 ?        00:00:00 svlogd -tt /var/log/gitlab/alertmanager
git       2993  2731  0 19:20 ?        00:00:00 unicorn worker[0] -D -E production -c /var/opt/gitlab/gitlab-rails/etc/unicorn.rb /opt/gitlab/embedded/service/gitlab-rails/config.ru
git       2994  2731  0 19:20 ?        00:00:00 unicorn worker[1] -D -E production -c /var/opt/gitlab/gitlab-rails/etc/unicorn.rb /opt/gitlab/embedded/service/gitlab-rails/config.ru
root      3015  3001  0 19:20 ?        00:00:00 svlogd -tt /var/log/gitlab/postgres-exporter
gitlab-+  3034  2539  0 19:20 ?        00:00:00 postgres: gitlab gitlabhq_production [local] idle
gitlab-+  3068  2539  0 19:20 ?        00:00:00 postgres: gitlab gitlabhq_production [local] idle
gitlab-+  3172  2539  0 19:20 ?        00:00:00 postgres: gitlab gitlabhq_production [local] idle
gitlab-+  3173  2539  0 19:20 ?        00:00:00 postgres: gitlab gitlabhq_production [local] idle
root      5176  3198  0 19:21 ?        00:00:00 svlogd -tt /var/log/gitlab/grafana
git       7944  2400  0 19:21 ?        00:00:00 /opt/gitlab/embedded/bin/gitaly-wrapper /opt/gitlab/embedded/bin/gitaly /var/opt/gitlab/gitaly/config.toml
git       7961  7944  0 19:21 ?        00:00:00 /opt/gitlab/embedded/bin/gitaly /var/opt/gitlab/gitaly/config.toml
git       8058  2775  0 19:21 ?        00:00:00 /opt/gitlab/embedded/bin/gitlab-workhorse -listenNetwork unix -listenUmask 0 -listenAddr /var/opt/gitlab/gitlab-workhorse/socket -authBackend http://localhost:8080 -authSocket /var/opt/gitlab/gitlab-rails/sockets/gitlab.socket -documentRoot /opt/gitlab/embedded/service/gitlab-rails/public -pprofListenAddr  -prometheusListenAddr localhost:9229 -secretPath /opt/gitlab/embedded/service/gitlab-rails/.gitlab_workhorse_secret -logFormat json -config config.toml
git       8133  7961  1 19:21 ?        00:00:01 ruby /opt/gitlab/embedded/service/gitaly-ruby/bin/gitaly-ruby 7961 /tmp/gitaly-ruby106656683/socket.0
git       8137  7961  1 19:21 ?        00:00:01 ruby /opt/gitlab/embedded/service/gitaly-ruby/bin/gitaly-ruby 7961 /tmp/gitaly-ruby106656683/socket.1
gitlab-+  8145  2849  0 19:21 ?        00:00:00 /opt/gitlab/embedded/bin/node_exporter --web.listen-address=localhost:9100 --collector.mountstats --collector.runit --collector.runit.servicedir=/opt/gitlab/sv --collector.textfile.directory=/var/opt/gitla/node-exporter/textfile_collector
git       8171  2869  0 19:21 ?        00:00:01 puma 3.12.0 (tcp://localhost:9168) [gitlab-monitor]
gitlab-+  8184  2895  0 19:21 ?        00:00:00 /opt/gitlab/embedded/bin/redis_exporter --web.listen-address=localhost:9121 --redis.addr=unix:///var/opt/gitlab/redis/redis.socket
gitlab-+  8199  2911  1 19:21 ?        00:00:02 /opt/gitlab/embedded/bin/prometheus --web.listen-address=localhost:9090 --storage.tsdb.path=/var/opt/gitlab/prometheus/data --config.file=/var/opt/gitlab/prometheus/prometheus.yml
gitlab-+  8261  2929  0 19:21 ?        00:00:00 /opt/gitlab/embedded/bin/alertmanager --web.listen-address=localhost:9093 --storage.path=/var/opt/gitlab/alertmanager/data --config.file=/var/opt/gitlab/alertmanager/alertmanager.yml
gitlab-+  8473  3001  0 19:21 ?        00:00:00 /opt/gitlab/embedded/bin/postgres_exporter --web.listen-address=localhost:9187 --extend.query-path=/var/opt/gitlab/postgres-exporter/queries.yaml
gitlab-+  8478  2539  0 19:21 ?        00:00:00 postgres: gitlab-psql postgres [local] idle
gitlab-+  8930  3198  0 19:21 ?        00:00:00 /opt/gitlab/embedded/bin/grafana-server -config /var/opt/gitlab/grafana/grafana.ini
gitlab-+ 24414  2539  0 19:21 ?        00:00:00 postgres: gitlab gitlabhq_production [local] idle
gitlab-+ 24438  2539  0 19:21 ?        00:00:00 postgres: gitlab gitlabhq_production [local] idle
gitlab-+ 24461  2539  0 19:21 ?        00:00:00 postgres: gitlab gitlabhq_production [local] idle
[root@gitlab gitlab]# 
[root@gitlab gitlab]# netstat -tupln | grep 9062
tcp        0      0 0.0.0.0:9062            0.0.0.0:*               LISTEN      2803/nginx: master  
[root@gitlab gitlab]# 
[root@gitlab gitlab]# netstat -tupln | grep gitlab
tcp        0      0 127.0.0.1:9229          0.0.0.0:*               LISTEN      8058/gitlab-workhor 
[root@gitlab gitlab]# 

接下来,用浏览器访问GITLAB:
http://gitlab.adamhuan.com:9062

这样,GITLAB就安装完成了。


终了,…

说点什么

avatar

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据

  Subscribe  
提醒
隐藏
变装