GitLab安装指南

登录账户,输入密码

Last login: Thu Dec  6 08:59:16 on console
w1:~ jiaguoshang$ ssh [email protected]
[email protected]'s password:
Last login: Wed Dec  5 18:02:02 2018 from gateway
ABRT 已检测到 '1' 个问题。预了解详细信息请执行:abrt-cli list --since 1544004122
[root@localhost ~]#

1、配置yum源
vim /etc/yum.repos.d/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
需要点击i键进入文本编辑状态,点击 esc键退出编辑状态,输入:wq回车退出编辑并保存,输入:w!回车强制退出编辑并放弃保存。
2、更新本地yum缓存
sudo yum makecache

[root@localhost ~]# sudo yum makecache
已加载插件:fastestmirror, langpacks
base                                                     | 3.6 kB     00:00
extras                                                   | 3.4 kB     00:00
gitlab-ce                                                | 2.9 kB     00:00
updates                                                  | 3.4 kB     00:00
(1/8): extras/7/x86_64/other_db                            | 106 kB   00:00
(2/8): extras/7/x86_64/prestodelta                         |  33 kB   00:00
(3/8): updates/7/x86_64/filelists_db                       | 1.3 MB   00:00
(4/8): gitlab-ce/7/primary_db                              | 2.5 MB   00:01
(5/8): updates/7/x86_64/prestodelta                        | 173 kB   00:00
(6/8): updates/7/x86_64/other_db                           | 182 kB   00:00
(7/8): updates/7/x86_64/primary_db                         | 1.3 MB   00:03
(8/8): gitlab-ce/7/filelists_db                            | 202 MB   00:21
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.163.com
元数据缓存已建立

3、下载最新的汉化包
由于汉化版本都低于英文版本,为了不产生不必要的麻烦就要先下载汉化包,查看汉化包的版本号,根据汉化包的版本号来安装制定版本的GitLab。若你安装的版本是最新的比汉化包高太多,那么你汉化时需要忽略数百到上千次的文件。并且还要执行sudo touch /etc/gitlab/skip-auto-migrations然后才能刷新配置。我想你不会选择这种傻方法吧?

git clone https://gitlab.com/xhang/gitlab.git

下载完毕,切换到你下载的汉化包目录(gitlab),查看汉化包的版本号(vim VERSION)。
在这里插入图片描述
在这里插入图片描述
4、安装指定版本GitLab社区版
(sudo yum install gitlab-ce #自动安装最新版)
sudo yum install gitlab-ce-x.x.x #安装指定版本

[root@localhost gitlab]# sudo yum install gitlab-ce-11.4.8
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.cn99.com
 * extras: mirrors.163.com
 * updates: mirrors.163.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 gitlab-ce.x86_64.0.11.4.7-ce.0.el7 将被 升级
---> 软件包 gitlab-ce.x86_64.0.11.4.8-ce.0.el7 将被 更新
--> 解决依赖关系完成

依赖关系解决

=================================================================================================================================================
 Package                          架构                          版本                                      源                                大小
=================================================================================================================================================
正在更新:
 gitlab-ce                        x86_64                        11.4.8-ce.0.el7                           gitlab-ce                        435 M

事务概要
=================================================================================================================================================
升级  1 软件包

总下载量:435 M
Is this ok [y/d/N]: y
Downloading packages:
No Presto metadata available for gitlab-ce
gitlab-ce-11.4.8-ce.0.el7.x86_64.rpm                      60% [=============================                   ] 9.7 MB/s | 265 MB  00:00:17 ETA

安装成功会有这些标志:

 Recipe: gitlab::gitlab-workhorse
  * service[gitlab-workhorse] action restart
    - restart service service[gitlab-workhorse]
Recipe: gitaly::enable
  * service[gitaly] action restart
    - restart service service[gitaly]

Running handlers:
Running handlers complete
Chef Client finished, 14/561 resources updated in 01 minutes 35 seconds
gitlab Reconfigured!
Checking for an omnibus managed postgresql: OK
Checking for a newer version of PostgreSQL to install
No new version of PostgreSQL installed, nothing to upgrade to
Ensuring PostgreSQL is updated: OK
Restarting previously running GitLab services

     _______ __  __          __
    / ____(_) /_/ /   ____ _/ /_
   / / __/ / __/ /   / __ `/ __ \
  / /_/ / / /_/ /___/ /_/ / /_/ /
  \____/_/\__/_____/\__,_/_.___/


Upgrade complete! If your GitLab server is misbehaving try running
  sudo gitlab-ctl restart
before anything else.
If you need to roll back to the previous version you can use the database
backup made during the upgrade (scroll up for the filename).

  验证中      : gitlab-ce-11.4.8-ce.0.el7.x86_64                                                                                             1/1

已安装:
  gitlab-ce.x86_64 0:11.4.8-ce.0.el7

完毕!
您在 /var/spool/mail/root 中有新邮件
GitLab常用命令
sudo gitlab-ctl start    # 启动所有 gitlab 组件;
sudo gitlab-ctl stop        # 停止所有 gitlab 组件;
sudo gitlab-ctl restart        # 重启所有 gitlab 组件;
sudo gitlab-ctl status        # 查看服务状态;
sudo gitlab-ctl reconfigure        # 启动服务;
sudo vim /etc/gitlab/gitlab.rb        # 修改默认的配置文件;
gitlab-rake gitlab:check SANITIZE=true --trace    # 检查gitlab;
sudo gitlab-ctl tail        # 查看日志;

5、修改服务地址
sudo vim /etc/gitlab/gitlab.rb
在这里插入图片描述
注意:要修改这个红框的地址。若你的服务器是装再局域网上,那么要配置这个局域网服务器的本机地址加上端口号。若你是装再公网云上,那么你可以配置域名了。不配置正确地址这个地址你不能上传和下载项目的。这个配置最关键,要多检查。
6、刷新配置,启动服务看GitLab主页是否能够使用。
注意:服务器启动成功,需要等待2分钟才能打开主页。

sudo gitlab-ctl reconfigure
sudo gitlab-ctl start

在这里插入图片描述
在这里插入图片描述
看到这个网页说明你的GitLab基本安装成功。
在这里插入图片描述
看到这个说明很可能服务器再重启中,等两分钟后再刷新页面。当然也可能是你的服务器配置错误或配置文件有冲突。若是后者需要你修改配置或执行忽略配置冲突命令(sudo touch /etc/gitlab/skip-auto-migrations)后重新刷新配置。
若出现Unable to round-trip http request to upstream: dial tcp 192.163.1.156:8888: i/o timeout或包网络超时链接超时错误。那么很可能是你服务器服务配置错误,服务器端口被占用或端口被禁用。
ping IP地址(ping 192.168.1.156),ctrl+c键可以停止。
w1:~ jiaguoshang$ ping 192.168.1.156
PING 192.168.1.156 (192.168.1.156): 56 data bytes
64 bytes from 192.168.1.156: icmp_seq=0 ttl=62 time=3.490 ms
64 bytes from 192.168.1.156: icmp_seq=1 ttl=62 time=2.554 ms
64 bytes from 192.168.1.156: icmp_seq=7 ttl=62 time=8.155 ms
^C
— 192.168.1.156 ping statistics —
8 packets transmitted, 8 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 2.253/39.847/284.912/92.659 ms
使用ssh判断

ssh是linux的标准配置并且最常用,可以用来判断端口吗?

用法: ssh -v -p port username@ip

-v 调试模式(会打印日志).

-p 指定端口

username可以随意
端口和ip可用的情况:


w1:~ jiaguoshang$ ssh -v -p 8888 [email protected]
OpenSSH_7.6p1, LibreSSL 2.6.2
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 48: Applying options for *
debug1: Connecting to 192.168.1.156 port 8888.
debug1: Connection established.
debug1: identity file /Users/jiaguoshang/.ssh/id_rsa type 0
debug1: key_load_public: No such file or directory
debug1: identity file /Users/jiaguoshang/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/jiaguoshang/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/jiaguoshang/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/jiaguoshang/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/jiaguoshang/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/jiaguoshang/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/jiaguoshang/.ssh/id_ed25519-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.6
debug1: ssh_exchange_identification: HTTP/1.1 400 Bad Request


debug1: ssh_exchange_identification: Server: nginx


debug1: ssh_exchange_identification: Date: Thu, 06 Dec 2018 03:24:33 GMT


debug1: ssh_exchange_identification: Content-Type: text/html


debug1: ssh_exchange_identification: Content-Length: 166


debug1: ssh_exchange_identification: Connection: close


debug1: ssh_exchange_identification: 


debug1: ssh_exchange_identification: <html>


debug1: ssh_exchange_identification: <head><title>400 Bad Request</title></head>


debug1: ssh_exchange_identification: <body bgcolor="white">


debug1: ssh_exchange_identification: <center><h1>400 Bad Request</h1></center>


debug1: ssh_exchange_identification: <hr><center>nginx</center>


debug1: ssh_exchange_identification: </body>


debug1: ssh_exchange_identification: </html>


ssh_exchange_identification: Connection closed by remote host
w1:~ jiaguoshang$ 

端口不可用的情况:


w1:~ jiaguoshang$ ssh -v -p 888 [email protected]
OpenSSH_7.6p1, LibreSSL 2.6.2
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 48: Applying options for *
debug1: Connecting to 192.168.1.156 port 888.
ssh: connect to host 192.168.1.156 port 888: Connection refused

因为我就遇到过端口没有开通的情况,我折腾了大半天。
若出现端口被禁用可以使用firewall-cmd --zone=public --list-ports查看开发端口列表。使用firewall-cmd --permanent --zone=public --add-port=8888/tcp开发防火墙的端口。

[root@localhost ~]# uname -a
Linux localhost.localdomain 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: active (running) since 二 2018-12-04 14:03:05 CST; 1 day 21h ago
     Docs: man:firewalld(1)
 Main PID: 46502 (firewalld)
   CGroup: /system.slice/firewalld.service
           └─46502 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid

12月 04 14:03:06 localhost.localdomain firewalld[46502]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -w --table filter --del...ailed:
12月 04 14:03:06 localhost.localdomain firewalld[46502]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -w --table filter --del...ailed:
12月 04 14:03:06 localhost.localdomain firewalld[46502]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -w --table filter --del...ailed:
12月 04 14:03:06 localhost.localdomain firewalld[46502]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -w --table filter --del...ailed:
12月 04 14:03:06 localhost.localdomain firewalld[46502]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -w --table filter --del...ailed:
12月 04 14:03:06 localhost.localdomain firewalld[46502]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -w --table filter --del...ailed:
12月 04 14:03:06 localhost.localdomain firewalld[46502]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -w --table filter --del...ailed:
12月 04 14:03:06 localhost.localdomain firewalld[46502]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -w --table filter --del...ailed:
12月 04 14:03:06 localhost.localdomain firewalld[46502]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -w --table filter --del...ailed:
12月 04 14:03:06 localhost.localdomain firewalld[46502]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -w --table filter --del...ailed:
Hint: Some lines were ellipsized, use -l to show in full.
[root@localhost ~]# uname -a
[root@localhost ~]# firewall-cmd --zone=public --list-ports
8888/tcp

7、修改root的密码。

[root@localhost ~]# gitlab-rails console production
-------------------------------------------------------------------------------------
 GitLab:       11.4.8 (bdfeff3)
 GitLab Shell: 8.3.3
 postgresql:   9.6.8
-------------------------------------------------------------------------------------
Loading production environment (Rails 4.2.10)
irb(main):001:0> user = User.where(id: 1).first
=> #<User id:1 @root>
irb(main):002:0> user.password=12345678
=> 12345678
irb(main):003:0> user.password_confirmation=12345678
=> 12345678
irb(main):004:0> user.save!
Enqueued ActionMailer::DeliveryJob (Job ID: d9b1f1f7-1256-48ff-b18a-c07d9c98e504) to Sidekiq(mailers) with arguments: "DeviseMailer", "password_change", "deliver_now", gid://gitlab/User/1
=> true
irb(main):005:0> quit

注意: User.where(id: 1).中的1代码用户列表的序号,1永远都是超级管理员root用户。若大于1就是非超级管理员账户,但是至少这个用户存在才能设置成功。
你会发现要求的成员或命令批量加入的成员,使用的局域网IP服务器,无法打开从邮箱里点击重置密码链接:http://192.163.1.156:8888/users/password/edit?reset_password_token=tZ1opLbXrgS4Txz6Fx8g 。没有办法我是使用的上面命令重置普通成员账户的初始密码,全数字类型。然后让成员账户登录里面修改密码的。
在这里插入图片描述
在这里插入图片描述

8、禁用注册功能。
在这里插入图片描述
把邮箱注册的默认选择勾选去掉
9、制作ssh登录用证书。
在这里插入图片描述
由于内容太多,关于汉化和删除后重装GitLab的内容在其它文章叙述了。

猜你喜欢

转载自blog.csdn.net/jia12216/article/details/84848046
今日推荐