• centos7.6安装部署gitlab服务器


    #centos7.6安装部署gitlab服务器

    1.安装依赖软件:

    yum -y install policycoreutils openssh-server openssh-clients postfix

    2.设置postfix开机自启,并启动,postfix支持gitlab发信功能:

    systemctl enable postfix && systemctl start postfix

    如果启动失败:
    编辑/etc/postfix/main.cf文件 inet_interfaces = localhost 修改为 inet_interfaces = all
    vim /etc/postfix/main.cf

    
    inet_interfaces = all
    
    
    • 1
    • 2
    • 3

    再次启动即可:
    systemctl start postfix

    3. 通过yum 命令安装:

    我安装的版本是14.8.2-ce.0.el7

    使用国内的源:
    vim /etc/yum.repos.d/gitlab_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
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    yum install gitlab-ce

    4.配置gitlab域名和内置nginx使用的端口:

    vim /etc/gitlab/gitlab.rb

    external_url 'http://osgitlab.q1oa.com'   
    
    nginx['listen_port'] = 8080		#默认是80端口
    puma['port'] = 8081				#默认是8080,一定不能和nginx端口冲突
    puma['worker_processes'] = 10    #根据机器配置进行设置,我的是docker,我写的是2
    
    postgresql['max_worker_processes'] = 4 #根据机器配置进行设置,我的是docker,配置很低,配置为4
    postgresql['shared_buffers'] = "128MB"   #根据机器配置进行设置,配置文件中推荐是总内存的1/4
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    域名根据实际情况填写,外网需要找运维增加对https支持;

    5.重新编译并启动gitlab

    gitlab-ctl reconfigure
    gitlab-ctl restart

    提示“ok: run:”表示启动成功

    6.初始化管理员密码:

    gitlab-rails console -e production
    一定不要少了参数-e,进入控制台后,按提示输入以下命令:

    irb(main):001:0> u=User.where(id:1).first
    => #
    irb(main):003:0> u.password='12345678'
    => 12345678
    irb(main):004:0> u.password_confirmation='12345678'
    => 12345678
    irb(main):005:0> u.save!
    Enqueued ActionMailer::DeliveryJob (Job ID: 15c3c8de-e839-4874-8104-d72dbe224756) to Sidekiq(mailers) with arguments: "DeviseMailer", "password_change", "deliver_now", #>
    => true
    irb(main):006:0> quit
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

    其中的u.password='12345678’即为设置管理员密码

    7.访问 GitLab页面

    http://osgitlab.q1oa.com:8080/users/sign_in

    进入系统:
    设置中文界面:
    setting->Perferences-> language :选择简体中文,重新登录即可

    8.让运维加上https证书,支持https协议,方便go mod访问

    内置nginx配置文件地址:/var/opt/gitlab/nginx/conf/gitlab-http.conf

    9.常用命令:

    1. 修改配置后的编译初始化:gitlab-ctl reconfigure
    2. 启动:gitlab-ctl start
    3. 停止:gitlab-ctl stop
    4. 重启:gitlab-ctl restart
    5. 开机自启动: systemctl enable gitlab-runsvdir.service
    6. 禁止开机自启动: systemctl disable gitlab-runsvdir.service
    7. 实时查看gitlab所有日志:gitlab-ctl tail
    8. 拉取某个指定的日志文件:gitlab-ctl tail nginx/gitlab_error.log

    10. 安装repo,管理多个git

    1、升级python2-到Python3.x

    yum -y groupinstall "Development tools"
    yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
    yum install libffi-devel -y
    
    • 1
    • 2
    • 3
    1. 下载Python3.7
    cd #回到用户目录
    wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
    tar -xvJf  Python-3.7.0.tar.xz
    
    
    • 1
    • 2
    • 3
    • 4
    1. 编译安装
    mkdir /usr/local/python3 #创建编译安装目录
    cd Python-3.7.0
    ./configure --prefix=/usr/local/python3
    make && make install
    
    • 1
    • 2
    • 3
    • 4
    1. 创建软连接
    ln -s /usr/local/python3/bin/python3 /usr/local/bin/python3
    ln -s /usr/local/python3/bin/pip3 /usr/local/bin/pip3
    
    
    • 1
    • 2
    • 3

    2、升级git到git2.x

    1. 安装git 仓库, 安装高版本 git
    yum remove git
    
    rpm -ivh http://opensource.wandisco.com/centos/7/git/x86_64/wandisco-git-release-7-1.noarch.rpm
    
    yum install git -y
    
    • 1
    • 2
    • 3
    • 4
    • 5

    3、安装repo:

    1. 安装repo工具
    curl https://storage.googleapis.com/git-repo-downloads/repo > /bin/repo   
    
    sudo chmod a+x /bin/repo   
    
    • 1
    • 2
    • 3
    1. repo运行环境安装
    repo init
    
    • 1
    1. gitlab中创建manifests项目,并在项目中新建文件gitlab.xml:
    
    
      
      
      
      
      
      
      
      
      
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    把项目拉到本地:
    git clone https://skygitlab.q1oa.com/huanghq/manifest
    4. 初始化:

    repo init -u https://skygitlab.q1oa.com/huanghq/manifest.git -b dev -m gitlab.xml
    
    
    • 1
    • 2
    1. 下载代码
    repo sync
    
    • 1
    1. 查看当前分支
    repo forall -p -c git branch -vv
    
    • 1
    1. 所有仓库切换到dev分支
    repo start dev --all
    
    • 1
    1. 其中的一个仓库切换到dev分支
    repo start dev battle
    
    • 1
  • 相关阅读:
    mysql 索引使用教程
    Flink SQL: RESET Statements
    SSM框架学习——MyBatis
    apache 基线安全加固操作
    数据分析常用指标解析及其适用场景
    第五章 Docker 自定义镜像
    用CSS的@property 定义变量
    Vue的组件传值方式
    Kubernetes-基础(Namespace,Pod,Lable,Deployment,Service)
    React key究竟有什么作用?深入源码不背概念,五个问题刷新你对于key的认知
  • 原文地址:https://blog.csdn.net/hhq163/article/details/126013649