zoukankan      html  css  js  c++  java
  • gitlab

    环境准备

    节点 192.168.56.11

    [root@linux-node1 ~]# cat /etc/redhat-release
    CentOS Linux release 7.2.1511 (Core)
    [root@linux-node1 ~]# uname -r
    3.10.0-327.el7.x86_64

    下载epel源

    [root@linux-node1 ~]#wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
    [root@linux-node1 ~]#wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

    关闭 NetworkManger 防火墙

    [root@linux-node1 ~]# systemctl stop firewalld.service
    [root@linux-node1 ~]# systemctl disable firewalld.service
    [root@linux-node1 ~]# systemctl disable NetworkManager

    关闭SElinux 并确认关闭状态
    [root@linux-node1 ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
    [root@linux-node1 ~]# grep SELINUX=disabled /etc/selinux/config
    SELINUX=disabled
    [root@linux-node1 ~]# setenforce 0
    setenforce: SELinux is disabled

    安装

    192.168.56.11
    [root@linux-node1 ~]# yum install curl policycoreutils openssh-server openssh-clients postfix -y
    [root@linux-node1 ~]# curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
    [root@linux-node1 ~]# yum install -y gitlab-ce
    [root@linux-node1 ~]# systemctl start postfix.service
    [root@linux-node1 ~]# systemctl status postfix.service

    由于网络原因可以使用清华的镜像源安装

    [root@linux-node1 ~]# 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@linux-node1 ~]# yum makecache
    [root@linux-node1 ~]# yum install -y gitlab-ce

    安装git 客户端
    [root@linux-node1 ~]# yum install git -y

    配置并启动gitlab-ce
    [root@linux-node1 ~]#gitlab-ctl reconfigure
    耐心等待

    gitlab常用命令:

    [root@linux-node1 ~]# gitlab-ctl status 状态
    [root@linux-node1 ~]# gitlab-ctl stop 停止
    [root@linux-node1 ~]# gitlab-ctl start 开始
    [root@linux-node1 ~]# gitlab-ctl restart 重启
    [root@linux-node1 ~]# gitlab-ctl reconfigure 重载配置文件

    提示:保证80端口不被占用
    [root@linux-node1 ~]# lsof -i:80
    COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
    nginx 112906 root 7u IPv4 1591432 0t0 TCP *:http (LISTEN)
    nginx 112907 gitlab-www 7u IPv4 1591432 0t0 TCP *:http (LISTEN)

    浏览器输入:192.168.56.11

    页面提示我们需要配置至少8位密码(设置密码123456789)默认用户名为root

    以管理员身份登陆
    第一步:关闭自动注册,内部使用,运维分配用户

    提示save 在最下面,记得点保存

    现在查看首页没有注册页面了

    第二步:创建一个用户和一个项目
    提示:gitlab 有项目跟组的概念,我们创建一个组,才可以创建一个项目。因为gitlab的路径上首先是IP地址,其次是组

    创建完成之后提示我们可以创建一个key对它进行管理

    我们点击上面的readme 随便写点东西测试一下

    我们要做免密钥验证
    配置keys

    [root@linux-node1 ~]# cat .ssh/id_rsa.pub
    ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDvUSHBbrnOcNzeTKSJRe49zbhke3PJRGwq0/zHt7qKygLAe6tkDx8Nra+2Onj27klMhtilEJx9SQ0MAU+xvCbayS1U8cax0gHEXJj4Qw5IrZNmZNADESzx4+inMixdnna+F8D+4gwXAKPXKnMEP+Rx/XTTyLcpQRXvE1Kqz9vMuZiQJz+G7aI8UUGTSg+gUdHQRuF+dDpv7X6lXwc4/FXroYmkti1Uo6/w6byq7K8e6fnGJV+xd5T7vTzxdKOtiTSBmSm4sGXj0E4x23VrGSZWNnPeTQaV9TWirsrgT8b9tfeeOSWXqMYYvHl0HeY7GgaldSvQOWYpZl9zoBLqVCJ5 root@linux-node1.example.com
    [root@linux-node1 ~]#

    添加完之后我们就可以拉取代码了

    [root@linux-node1 git]# git clone git@gitlab.example.com:web/web_test.git
    Cloning into 'web_test'...
    The authenticity of host 'gitlab.example.com (192.168.56.11)' can't be established.
    ECDSA key fingerprint is SHA256:DTGoyWgHF1Q29DUyp52OD785cbE3dvt2CV1qj1nwIv0.
    ECDSA key fingerprint is MD5:e4:08:e7:40:37:c9:22:e7:cf:71:f2:95:ce:57:f9:a4.
    Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added 'gitlab.example.com,192.168.56.11' (ECDSA) to the list of known hosts.
    remote: Counting objects: 3, done.
    remote: Total 3 (delta 0), reused 0 (delta 0)
    Receiving objects: 100% (3/3), done.
    [root@linux-node1 git]# ll
    total 0
    drwxr-xr-x 3 root root 33 Feb 7 17:58 web_test
    [root@linux-node1 git]# cd web_test/
    [root@linux-node1 web_test]# ll
    total 4
    -rw-r--r-- 1 root root 16 Feb 7 17:55 README.md
    [root@linux-node1 web_test]# cat README.md
    my name is mumu

    模拟开发写代码提交

    [root@linux-node1 web_test]# echo "hello-world" >> index.html
    [root@linux-node1 web_test]# ll
    total 8
    -rw-r--r-- 1 root root 12 Feb 7 18:02 index.html
    -rw-r--r-- 1 root root 16 Feb 7 17:55 README.md
    [root@linux-node1 web_test]# git add index.html
    [root@linux-node1 web_test]# git commit -m "add index.html"
    [master 8a58194] add index.html
    Committer: root root@linux-node1.example.com
    Your name and email address were configured automatically based
    on your username and hostname. Please check that they are accurate.
    You can suppress this message by setting them explicitly:

    git config --global user.name "Your Name"
    git config --global user.email you@example.com
    

    After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author
    

    1 file changed, 1 insertion(+)
    create mode 100644 index.html

    需要身份验证:
    [root@linux-node1 web_test]# git config --global user.name "xu"
    [root@linux-node1 web_test]# git config --global user.email xu@example.com
    [root@linux-node1 web_test]# git commit -m "add index.html"
    On branch master
    Your branch is ahead of 'origin/master' by 1 commit.
    (use "git push" to publish your local commits)

    nothing to commit, working directory clean

    git push 命令用于将本地分支的更新,推送到远程主机。
    [root@linux-node1 web_test]# git push
    warning: push.default is unset; its implicit value is changing in
    Git 2.0 from 'matching' to 'simple'. To squelch this message
    and maintain the current behavior after the default changes, use:

    git config --global push.default matching

    To squelch this message and adopt the new behavior now, use:

    git config --global push.default simple

    See 'git help config' and search for 'push.default' for further information.
    (the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
    'current' instead of 'simple' if you sometimes use older versions of Git)

    Counting objects: 4, done.
    Compressing objects: 100% (2/2), done.
    Writing objects: 100% (3/3), 292 bytes | 0 bytes/s, done.
    Total 3 (delta 0), reused 0 (delta 0)
    To git@gitlab.example.com:web/web_test.git
    28fb1c8..8a58194 master -> master

    gitlab配置文件放在/etc/gtilab/gitlab.rb,可以修改配置文件,让它使用IP进行访问
    编辑配置文件
    [root@linux-node1 web_test]# vim /etc/gitlab/gitlab.rb
    external_url 'http://192.168.56.11'
    修改完要重载配置才会生效
    [root@linux-node1 web_test]# gitlab-ctl reconfigure

    从新登陆查看

  • 相关阅读:
    poj 4005 Moles
    牛客 2C 圈圈
    牛客 2B 树 (组合计数)
    AC日记——校门外的树(增强版) 洛谷 P1276
    AC日记——寻找道路 洛谷 P2296
    AC日记——挤牛奶 洛谷 P1204
    AC日记——最大数 洛谷 P1198 [JSOI2008]
    AC日记——中位数 洛谷 P1168
    AC日记——校门外的树 洛谷 P1047
    AC日记——约瑟夫问题 codevs 1282
  • 原文地址:https://www.cnblogs.com/fengmeng1030/p/8427432.html
Copyright © 2011-2022 走看看