zoukankan      html  css  js  c++  java
  • 基于CentOS7.x gitlab环境搭建,卸载,汉化 --搭建篇

    gitlab环境搭建,卸载,汉化 --搭建篇

    环境搭建

    1. 安装依赖软件

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

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

      systemctl enable postfix && systemctl start postfix

    3. 下载gitlab安装包,然后安装  

      - 10.0.x版本需要大于4G内存,否则报502(解决办法创建4G的swap,并且赋600权限)
      wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm
      rpm -i gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm                                                                           chmod -R 755 /var/log/gitlab

    4. 如果报错 错误:依赖检测失败: policycoreutils-python 被 gitlab-ce-10.0.0-ce.0.el7.x86_6 则执行 yum install policycoreutils-python -y
    5. - 8.x版本直接安装
      wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-8.0.0-ce.0.el7.x86_64.rpm
      rpm -i gitlab-ce-8.0.0-ce.0.el7.x86_64.rpm

    6. 修改gitlab配置文件指定服务器ip和自定义端口

          vim /etc/gitlab/gitlab.rb

    1. 重置并启动GitLab  gitlab-ctl reconfigure(初始化)(初始化如果卡在ruby_block[supervise_redis_sleep] action run ,就执行一下sudo systemctl restart gitlab-runsvdir)
    2. 查看gitlab版本  

      head -1 /opt/gitlab/version-manifest.txt 或者 cat /opt/gitlab/embedded/service/gitlab-rails/VERSION 

    3. 设置、重置root密码(下面代码一行一行执行,初始化123456789密码,版本10.0.0不用改密码,登录会自动提示修改密码) 

      cd /opt/gitlab/bin
      gitlab-rails console production
      user=User.where(id:1).first
      user.password=123456789
      user.password_confirmation=123456789
      user.save!
      exit

     

             启动:gitlab-ctl start

             停止:gitlab-ctl stop 

       重启:gitlab-ctl restart

    https://blog.csdn.net/liuli905306022/article/details/89512896

    gitlab 修改默认的仓库存储目录及数据迁移

    Gitlab默然安装时,默认的仓库存储路径在 /var/opt/gitlab/git-data目录下,仓库存储在子目录repositories里面,可以通过修改/etc/gitlab/gitlab.rb文件中git_data_dirs参数来自定义父目录
    在这里插入图片描述
    自定义git仓库的存储路径并使其生效
    在这里插入图片描述
    注:/data/gitlab/git-data 是我新创建的存储目录,目标路径及其子路径不能为软连接

    在没有数据的情况下

     gitlab-ctl stop (停止GitLab服务,防止用户写入数据)
     gitlab-ctl reconfigure (使其修改配置生效)

    如果默认存储路劲下/var/opt/gitlab/git-data 目录下已经存在仓库数据下进行数据迁移

     gitlab-ctl stop (数据迁移前,停止服务,防止用户写入数据)
     rsync -av /var/opt/gitlab/git-data/repositories /data/gitlab/git-data/ (执行仓库数据迁移,正常情况应该有下面这个子目录)
     gitlab-ctl reconfigure ( 使其配置生效)
     gitlab-ctl start(开启服务,验证一下是否能通过web访问)

     

     

    其他教程

    下载好 gitlab 的rpm 包,我下载的是gitlab-ce-11.6.0-ce.0.el7.x86_64.rpm

    https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/

    安装 gitlab 的依赖包

    yum install curl openssh-server openssh-clients postfix cronie policycoreutils-python –y

    yum install -y patch

    启动 postfix,并且设置为开机启动(有些机子没有,自行解决)

    systemctl start postfix

    systemctl enable postfix

    安装刚下载好 gitlab 的rpm 包

    rpm -i gitlab-ce-11.6.0-ce.0.el7.x86_64.rpm

    当出现图像,则证明 gitlab 的程序安装完了

    继续安装提示执行配置 gitlab 的命令

    gitlab-ctl reconfigure

    修改 gitlab 的配置文件

    vi /etc/gitlab/gitlab.rb

    修改里面的 external_url 参数,例如机器的IP地址为47.92.82.152

    external_url='http://47.92.82.152'

    因为修改了配置文件,所以重新加载配置文件

    gitlab-ctl reconfigure

    软件安装部分就完成了,以下是web 页面配置部分

    ? web页面配置

    gitlab 默认的端口号为 80,使用浏览器访问以下地址:http:// 47.92.82.152:80

    自己在页面上输入 新的密码,该密码为 管理员密码,管理员的登陆名为 root。

    如果访问页面访问报错502,请检查如下问题

     

     

       1)权限问题:Gitlab文件需要给予读写的权限

    chmod -R 755 /var/log/gitlab

    2)端口问题:Gitlab的默认启动端口是80,8080,所以有肯能会与其他的端口产生冲突,需要修改端口号

    3)内存不足的问题:安装gitlab的时候,已经说明你的空余内存需要有4G左右的内存,所以在安装gitlab的时候,请给足内存,在安装。

    修改访问端口号:

    1)更改端口

     vi /etc/gitlab/gitlab.rb

    修改内容:

    external_url 'http:// 47.92.82.152:88'   #指定访问端口,默认是80

    nginx['listen_port'] = 88

    nginx['listen_https'] = false

    unicorn['port'] = 8001  # 为unicorn worker的工作端口,默认为8080,如果你的8080端口被占用的,这一项需要更改

    2)改nginx端口

    vi /var/opt/gitlab/nginx/conf/gitlab-http.conf   

    查找如下内容并修改:

    server {

    listen *:88;

    server_name 47.92.82.152

    if ($http_host = "") {

        set $http_host_with_default "47.92.82.152:88";

    }

    }

    3)修改完成后执行

    gitlab-ctl reconfigure  #重新加载配置

    gitlab-ctl restart      #重启

    打开浏览器,输入"http:/ 47.92.82.152:88",进入登录页面

     

     

    配置gitlab 用户注册时的邮箱通知信息(自行配置)

     修改 /etc/gitlab/gitlab.rb 配置文件,该邮箱地址是未来gitlab 向用户发送邮件时的推送邮箱

    复制代码

    gitlab_rails['smtp_enable'] = true

    gitlab_rails['smtp_address'] = "smtp.qq.com"           # 用户输入自己的smtp服务器地址,例如作者的时163 的企业服务地址

    gitlab_rails['smtp_port'] = 25                         # 用户smtp 的端口号

    gitlab_rails['smtp_user_name'] = "***@qq.com"          # 用户的邮箱地址

    gitlab_rails['smtp_password'] = "PASSWORD"             # 用户的邮箱密码

    gitlab_rails['smtp_domain'] = "qq.com"                 # 用户邮箱的域名

    gitlab_rails['smtp_authentication'] = "login"

    gitlab_rails['smtp_enable_starttls_auto'] = true

    gitlab_rails['smtp_tls'] = false

    gitlab_rails['gitlab_email_from'] = '***@qq.com'       # 用户的邮箱地址

    user['git_user_email'] = "***@qq.com"                  # 用户的邮箱地址

     

    查看gitlab 的配置

    gitlab-ctl show-config

    查看gitlab 的运行日志

    gitlab-ctl tail

    切换gitlab 仓库的数据目录

    gitlab 默认的仓库数据目录为 /var/opt/gitlab/git-data/repositories/ ,如果未来用户的数据量大了,需要更换仓库数据目录,可以通过修改 /etc/gitlab/gitlab.rb 配置进行调整。

    用户在调整gitlab 的配置之前,建议对其先停止服务。

    gitlab-ctl stop

    然后用户创建好未来要迁移的数据目录,并且将原来的数据迁移过去,由于作者的 gitlab 是通过 rpm 包安装的,所以gitlab 的系统用户为 git,用户组为 root,所以在拷贝数据后还需要修改新数据目录的用户归属,否者后面gitlab无法对该目录写入新的数据。

     

    mkdir -p /mnt/gitlab/git-data/

    mv /var/opt/gitlab/git-data/repositories/* /mnt/gitlab/git-data/repositories/

    chown -R git:root /mnt/gitlab/git-data/*

     

    然后用户就可以对 /etc/gitlab/gitlab.rb 进行调整了。

     

    /etc/gitlab/gitlab.rb 默认对数据目录的配置是注释的。

     

    用户可以新增配置信息

     

    复制代码

    git_data_dirs({

      "default" => {

         "path" => "/mnt/gitlab/git-data"

      }

    })

     

    然后对 gitlab 重新刷新配置

     

    gitlab-ctl reconfigure  #因为修改了配置文件,所以重新加载配置文件

    gitlab-ctl restart

     

    查看git路径

    whereis git

    [root@localhost etc]# whereis git

    git: /usr/bin/git /usr/share/man/man1/git.1.gz

     

    纵有白头俱老意,奈何缘浅路芊芊.
  • 相关阅读:
    Error #2044: 未处理的 NetStatusEvent:。 level=error, code=NetConnection.Call.BadVersion。
    Decode amf3 object using PHP
    Papervision3D Proximity Grid Example
    array容易混淆的几个有用的方法
    输出流实际上不写对象的值,而是对象吧自己本身写在流上
    OM Unit Selling Price 与 Price List Setup 不一致
    CoreApiHtml.sql 3< (INVItemCt115h.sql ) Note: 223702.1
    LOT NUMBER / PO / RECEIPT NO Relation.
    CoreApiHtml.sql 2< (INVItemCt115h.sql ) Note: 223702.1
    CoreApiHtml.sql 1< (INVItemCt115h.sql ) Note: 223702.1
  • 原文地址:https://www.cnblogs.com/hanby/p/14361553.html
Copyright © 2011-2022 走看看