Centos 7 搭建 Gitlab 服务器

Last login: Mon Mar 30 13:22:46 on ttys000
xxxs-MacBook-Pro:~ kenny$ ifconfig
lo0: flags=8049<up,loopback,running,multicast> mtu 16384
	options=1203<rxcsum,txcsum,txstatus,sw_timestamp>
	inet 127.0.0.1 netmask 0xff000000 
	inet6 ::1 prefixlen 128 
	。
    。
    。
	options=3<rxcsum,txcsum>
	ether 00:1c:42:00:00:09 
	inet 10.37.129.2 netmask 0xffffff00 broadcast 10.37.129.255
	media: autoselect
	status: active
xxxs-MacBook-Pro:~ kenny$ ifconfig | grep 192
xxxs-MacBook-Pro:~ kenny$ ifconfig | grep 10
gif0: flags=8010<pointopoint,multicast> mtu 1280
	media: autoselect (100baseTX )
	inet 10.66.105.48 netmask 0xfffff800 broadcast 10.66.111.255
		maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200
	inet 10.211.55.2 netmask 0xffffff00 broadcast 10.211.55.255
	inet 10.37.129.2 netmask 0xffffff00 broadcast 10.37.129.255
xxxs-MacBook-Pro:~ kenny$ ping 10.211.55.3
PING 10.211.55.3 (10.211.55.3): 56 data bytes
64 bytes from 10.211.55.3: icmp_seq=0 ttl=64 time=0.291 ms
64 bytes from 10.211.55.3: icmp_seq=1 ttl=64 time=0.306 ms
64 bytes from 10.211.55.3: icmp_seq=2 ttl=64 time=0.440 ms
^C
--- 10.211.55.3 ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.291/0.346/0.440/0.067 ms
xxxs-MacBook-Pro:~ kenny$ ssh -l kenny 10.211.55.3
The authenticity of host '10.211.55.3 (10.211.55.3)' can't be established.
ECDSA key fingerprint is SHA256:3u3go1kEgAKFyUXQf+Bv9MmyCop4dUUgyuDSH0EJw3I.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.211.55.3' (ECDSA) to the list of known hosts.
kenny@10.211.55.3's password: 
Last login: Mon Apr 20 15:42:30 2020
[kenny@localhost ~]$ ls
Desktop  Documents  Downloads  fontconfig  hhhha.txt  Music  Pictures  Public  Templates  Videos
[kenny@localhost ~]$ ls
Desktop  Documents  Downloads  fontconfig  hhhha.txt  Music  Pictures  Public  Templates  Videos
[kenny@localhost ~]$ ls
Desktop  Documents  Downloads  fontconfig  hhhha.txt  Music  Pictures  Public  Templates  Videos
[kenny@localhost ~]$ mkdir android && cd android
[kenny@localhost android]$ wget https://dl.google.com/android/repository/tools_r26.1.1-linux.zip
--2020-04-20 16:06:33--  https://dl.google.com/android/repository/tools_r26.1.1-linux.zip
正在解析主机 dl.google.com (dl.google.com)... 203.208.39.225, 203.208.39.230, 203.208.39.238, ...
正在连接 dl.google.com (dl.google.com)|203.208.39.225|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 404 Not Found
2020-04-20 16:06:34 错误 404:Not Found。

[kenny@localhost android]$ ls
[kenny@localhost android]$ apt -get --quiet update --yes
bash: apt: 未找到命令...
[kenny@localhost android]$ ping www.baidu.com
PING www.a.shifen.com (180.101.49.12) 56(84) bytes of data.
64 bytes from 180.101.49.12 (180.101.49.12): icmp_seq=1 ttl=128 time=10.8 ms
64 bytes from 180.101.49.12 (180.101.49.12): icmp_seq=2 ttl=128 time=16.7 ms
64 bytes from 180.101.49.12 (180.101.49.12): icmp_seq=3 ttl=128 time=17.3 ms
^C
--- www.a.shifen.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2004ms
rtt min/avg/max/mdev = 10.877/14.993/17.396/2.924 ms
[kenny@localhost android]$ sudo yum install -y curl policycoreutils-python openssh-server

我们信任您已经从系统管理员那里了解了日常注意事项。
总结起来无外乎这三点:

    #1) 尊重别人的隐私。
    #2) 输入前要先考虑(后果和风险)。
    #3) 权力越大,责任越大。

[sudo] kenny 的密码:
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.njupt.edu.cn
 * updates: mirrors.ustc.edu.cn
软件包 policycoreutils-python-2.5-33.el7.x86_64 已安装并且是最新版本
软件包 openssh-server-7.4p1-21.el7.x86_64 已安装并且是最新版本
正在解决依赖关系
--> 正在检查事务
---> 软件包 curl.x86_64.0.7.29.0-54.el7 将被 升级
---> 软件包 curl.x86_64.0.7.29.0-54.el7_7.2 将被 更新
--> 正在处理依赖关系 libcurl = 7.29.0-54.el7_7.2,它被软件包 curl-7.29.0-54.el7_7.2.x86_64 需要
--> 正在检查事务
---> 软件包 libcurl.x86_64.0.7.29.0-54.el7 将被 升级
---> 软件包 libcurl.x86_64.0.7.29.0-54.el7_7.2 将被 更新
--> 解决依赖关系完成

依赖关系解决

============================================================================================================================================================================================================================================================================================================================================================================
 Package                                                                                架构                                                                                  版本                                                                                             源                                                                                      大小
============================================================================================================================================================================================================================================================================================================================================================================
正在更新:
 curl                                                                                   x86_64                                                                                7.29.0-54.el7_7.2                                                                                updates                                                                                270 k
为依赖而更新:
 libcurl                                                                                x86_64                                                                                7.29.0-54.el7_7.2                                                                                updates                                                                                223 k

事务概要
============================================================================================================================================================================================================================================================================================================================================================================
升级  1 软件包 (+1 依赖软件包)

总计:493 k
Downloading packages:
警告:/var/cache/yum/x86_64/7/updates/packages/curl-7.29.0-54.el7_7.2.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 检索密钥
导入 GPG key 0xF4A80EB5:
 用户ID     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
 指纹       : 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 软件包     : centos-release-7-7.1908.0.el7.centos.x86_64 (@anaconda)
 来自       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在更新    : libcurl-7.29.0-54.el7_7.2.x86_64                                                                                                                                                                                                                                                                                                                        1/4 
  正在更新    : curl-7.29.0-54.el7_7.2.x86_64                                                                                                                                                                                                                                                                                                                           2/4 
  清理        : curl-7.29.0-54.el7.x86_64                                                                                                                                                                                                                                                                                                                               3/4 
  清理        : libcurl-7.29.0-54.el7.x86_64                                                                                                                                                                                                                                                                                                                            4/4 
  验证中      : curl-7.29.0-54.el7_7.2.x86_64                                                                                                                                                                                                                                                                                                                           1/4 
  验证中      : libcurl-7.29.0-54.el7_7.2.x86_64                                                                                                                                                                                                                                                                                                                        2/4 
  验证中      : libcurl-7.29.0-54.el7.x86_64                                                                                                                                                                                                                                                                                                                            3/4 
  验证中      : curl-7.29.0-54.el7.x86_64                                                                                                                                                                                                                                                                                                                               4/4 

更新完毕:
  curl.x86_64 0:7.29.0-54.el7_7.2                                                                                                                                                                                                                                                                                                                                           

作为依赖被升级:
  libcurl.x86_64 0:7.29.0-54.el7_7.2                                                                                                                                                                                                                                                                                                                                        

完毕!
[kenny@localhost android]$ sudo systemctl enable sshd
[kenny@localhost android]$ sudo systemctl start sshd
[kenny@localhost android]$ sudo firewall-cmd --permanent --add-service=http
success
[kenny@localhost android]$ sudo systemctl reload firewalld
[kenny@localhost android]$ cd ..
[kenny@localhost ~]$ ls
android  Desktop  Documents  Downloads  fontconfig  hhhha.txt  Music  Pictures  Public  Templates  Videos
[kenny@localhost ~]$ sudo yum install postfix
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.njupt.edu.cn
 * updates: mirrors.ustc.edu.cn
软件包 2:postfix-2.10.1-7.el7.x86_64 已安装并且是最新版本
无须任何处理
[kenny@localhost ~]$ sudo systemctl enable postfix
[kenny@localhost ~]$ sudo systemctl start postfix
[kenny@localhost ~]$ sudo yum install wget
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.njupt.edu.cn
 * updates: mirrors.ustc.edu.cn
软件包 wget-1.14-18.el7_6.1.x86_64 已安装并且是最新版本
无须任何处理
[kenny@localhost ~]$ wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-11.9.9-ce.0.el7.x86_64.rpm
--2020-04-20 16:46:43--  https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-11.9.9-ce.0.el7.x86_64.rpm
正在解析主机 mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)... 101.6.8.193
正在连接 mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)|101.6.8.193|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:569226236 (543M) [application/x-redhat-package-manager]
正在保存至: “gitlab-ce-11.9.9-ce.0.el7.x86_64.rpm”

 0% [=>                                              ] 5,070,497    177KB/s 剩余 37m 33s^C                                                                                                                                                                                                                                                                                                                 ] 12,811,545  3.76KB/s 用时 6m 8s  

2020-04-20 17:22:52 (15.2 KB/s) - 在 12811545/569226236 字节处发生读取错误 (Connection reset by peer)。[kenny@localhost ~]$ ls
android  Desktop  Documents  Downloads  fontconfig  gitlab-ce-11.9.9-ce.0.el7.x86_64.rpm  hhhha.txt  Music  Pictures  Public  Templates  Videos
[kenny@localhost ~]$ rpm -i gitlab-ce-11.9.9-ce.0.el7.x86_64.rpm
警告:gitlab-ce-11.9.9-ce.0.el7.x86_64.rpm: 头V4 RSA/SHA1 Signature, 密钥 ID f27eab47: NOKEY
错误:can't create 事务 lock on /var/lib/rpm/.rpm.lock (权限不够)
[kenny@localhost ~]$ sudo rpm -i gitlab-ce-11.9.9-ce.0.el7.x86_64.rpm
[sudo] kenny 的密码:
警告:gitlab-ce-11.9.9-ce.0.el7.x86_64.rpm: 头V4 RSA/SHA1 Signature, 密钥 ID f27eab47: NOKEY
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

[kenny@localhost ~]$ vi /etc/gitlab/gitlab.rb
</security@centos.org></pointopoint,multicast></rxcsum,txcsum></rxcsum,txcsum,txstatus,sw_timestamp></up,loopback,running,multicast>

找到 external_url 这个属性,把地址改为虚拟机 ip 并指定端口号:

[kenny@localhost ~]$ su
密码:
[root@localhost kenny]# cd /etc
[root@localhost etc]# ls
abrt                   auto.smb                   chromium      dbus-1                      environment   gcrypt       grub.d       ipa            latrace.d       logrotate.d               mtools.conf        ntp.conf        pcp.env         pulse       redhat-release    securetty          ssl                 target               virt-who.d
adjtime                avahi                      chrony.conf   dconf                       ethertypes    gdbinit      gshadow      iproute2       ld.so.cache     lsm                       multipath          numad.conf      pinforc         purple      request-key.conf  security           sssd                tcsd.conf            wgetrc
aliases                bash_completion.d          chrony.keys   default                     exports       gdbinit.d    gshadow-     ipsec.conf     ld.so.conf      lvm                       my.cnf             oddjob          pkcs11          python      request-key.d     selinux            statetab            terminfo             wpa_supplicant
aliases.db             bashrc                     cifs-utils    depmod.d                    exports.d     gdm          gss          ipsec.d        ld.so.conf.d    machine-id                my.cnf.d           oddjobd.conf    pki             qemu-ga     resolv.conf       services           statetab.d          tmpfiles.d           X11
alternatives           binfmt.d                   cron.d        dhcp                        favicon.png   geoclue      gssproxy     ipsec.secrets  libaudit.conf   magic                     nanorc             oddjobd.conf.d  plymouth        qemu-kvm    rhsm              sestatus.conf      subgid              trusted-key.key      xdg
anacrontab             bluetooth                  cron.daily    DIR_COLORS                  fcoe          GeoIP.conf   host.conf    iscsi          libblockdev     mailcap                   ndctl              openldap        pm              radvd.conf  rpc               setroubleshoot     subuid              tuned                xinetd.d
asound.conf            brltty                     cron.deny     DIR_COLORS.256color         festival      ghostscript  hostname     issue          libibverbs.d    mail.rc                   netconfig          opt             pnm2ppa.conf    rc0.d       rpm               setuptool.d        sudo.conf           udev                 xml
at.deny                brltty.conf                cron.hourly   DIR_COLORS.lightbgcolor     filesystems   gimp         hosts        issue.net      libnl           makedumpfile.conf.sample  NetworkManager     os-release      polkit-1        rc1.d       rsyncd.conf       sgml               sudoers             udisks2              yum
audisp                 centos-release             cron.monthly  dleyna-server-service.conf  firewalld     gitlab       hosts.allow  java           libpaper.d      man_db.conf               networks           PackageKit      popt.d          rc2.d       rsyslog.conf      shadow             sudoers.d           unbound              yum.conf
audit                  centos-release-upstream    crontab       dnsmasq.conf                flatpak       glvnd        hosts.deny   jvm            libreport       maven                     nfs.conf           pam.d           postfix         rc3.d       rsyslog.d         shadow-            sudo-ldap.conf      updatedb.conf        yum.repos.d
autofs.conf            certmonger                 cron.weekly   dnsmasq.d                   fonts         gnupg        hp           jvm-commmon    libuser.conf    mime.types                nfsmount.conf      papersize       ppp             rc4.d       rwtab             shells             sysconfig           UPower
autofs_ldap_auth.conf  cgconfig.conf              crypttab      dracut.conf                 fprintd.conf  GREP_COLORS  idmapd.conf  kdump.conf     libvirt         mke2fs.conf               nscd.conf          passwd          prelink.conf.d  rc5.d       rwtab.d           skel               sysctl.conf         usb_modeswitch.conf
auto.master            cgconfig.d                 csh.cshrc     dracut.conf.d               fstab         groff        ImageMagick  kernel         locale.conf     modprobe.d                nslcd.conf         passwd-         printcap        rc6.d       samba             smartmontools      sysctl.d            vconsole.conf
auto.master.d          cgrules.conf               csh.login     e2fsck.conf                 fuse.conf     group        init.d       krb5.conf      localtime       modules-load.d            nsswitch.conf      pbm2ppa.conf    profile         rc.d        sane.d            sos.conf           systemd             vimrc
auto.misc              cgsnapshot_blacklist.conf  cups          egl                         fwupd         group-       inittab      krb5.conf.d    login.defs      motd                      nsswitch.conf.bak  pcp             profile.d       rc.local    sasl2             speech-dispatcher  system-release      virc
auto.net               chkconfig.d                cupshelpers   enscript.cfg                gconf         grub2.cfg    inputrc      ksmtuned.conf  logrotate.conf  mtab                      ntp                pcp.conf        protocols       rdma        scl               ssh                system-release-cpe  virt-who.conf
[root@localhost etc]# cd gitlab/
[root@localhost gitlab]# ls
gitlab.rb
[root@localhost gitlab]# vi gitlab.rb 
[root@localhost gitlab]# gitlab-ctl reconfigure
Starting Chef Client, version 13.6.4
resolving cookbooks for run list: ["gitlab"]
Synchronizing Cookbooks:
  - gitlab (0.0.1)
  - package (0.1.0)
  - postgresql (0.1.0)
  - redis (0.1.0)
  - registry (0.1.0)
  - mattermost (0.1.0)
  - consul (0.1.0)
  - gitaly (0.1.0)
  - letsencrypt (0.1.0)
  - nginx (0.1.0)
  - runit (4.3.0)
  - acme (3.1.0)
  - crond (0.1.0)
  - compat_resource (12.19.1)
。
。
。
Recipe: <dynamically defined="" resource="">
  * service[alertmanager] action restart
    - restart service service[alertmanager]
  * service[postgres-exporter] action restart
    - restart service service[postgres-exporter]

Running handlers:
Running handlers complete
Chef Client finished, 475/1268 resources updated in 02 minutes 43 seconds
gitlab Reconfigured!

虽然 gitlab 指定了使用 8888 端口,但是这时候防火墙并没有开放这个端口,所以需要在防火墙配置一下。

[root@localhost gitlab]# firewall-cmd --list-ports

[root@localhost gitlab]# firewal-cmd --zone=public --add-port=8888/tcp --permanent
bash: firewal-cmd: 未找到命令...
[root@localhost gitlab]# firewall-cmd --zone=public --add-port=8888/tcp --permanent
success
[root@localhost gitlab]# firewall-cmd --reload
success
[root@localhost gitlab]# firewall-cmd --list-ports
8888/tcp
[root@localhost gitlab]# packet_write_wait: Connection to 10.211.55.3 port 22: Broken pipe
xxxs-MacBook-Pro:~ kenny$ 
https://blog.csdn.net/Captive_Rainbow_/article/details/90375937
打赏